Skip to content
Snippets Groups Projects
Commit 14695f4f authored by Vesa Lappalainen's avatar Vesa Lappalainen :bicyclist:
Browse files

muokkaa tuplaklikkaamalla

parent 7fce5ed3
No related branches found
No related tags found
No related merge requests found
############################## ### IntelliJ IDEA ###
## Java
##############################
.mtj.tmp/
*.class
*.jar
*.war
*.ear
*.nar
hs_err_pid*
##############################
## Maven
##############################
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
##############################
## Gradle
##############################
bin/
build/
.gradle
.gradletasknamecache
gradle-app.setting
!gradle-wrapper.jar
##############################
## IntelliJ
##############################
out/ out/
.idea/ !**/src/main/**/out/
.idea_modules/ !**/src/test/**/out/
*.iml
*.ipr
*.iws
############################## ### Eclipse ###
## Eclipse .apt_generated
############################## .classpath
.settings/ .factorypath
.project
.settings
.springBeans
.sts4-cache
bin/ bin/
tmp/ !**/src/main/**/bin/
.metadata !**/src/test/**/bin/
*.tmp
*.bak ### NetBeans ###
*.swp /nbproject/private/
*~.nib /nbbuild/
local.properties /dist/
.loadpath /nbdist/
/.nb-gradle/
############################## ### VS Code ###
## NetBeans .vscode/
##############################
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
############################## ### Mac OS ###
## OS X
##############################
.DS_Store .DS_Store
\ No newline at end of file
...@@ -8,6 +8,7 @@ import fi.jyu.mit.fxgui.ModalControllerInterface; ...@@ -8,6 +8,7 @@ import fi.jyu.mit.fxgui.ModalControllerInterface;
import fi.jyu.mit.ohj2.Mjonot; import fi.jyu.mit.ohj2.Mjonot;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.ScrollPane;
import javafx.stage.Stage; import javafx.stage.Stage;
import kerho.Jasen; import kerho.Jasen;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
...@@ -25,7 +26,8 @@ public class JasenDialogController implements ModalControllerInterface<Jasen>, I ...@@ -25,7 +26,8 @@ public class JasenDialogController implements ModalControllerInterface<Jasen>, I
@FXML private GridPane gridJasen; @FXML private GridPane gridJasen;
@FXML private Label labelVirhe; @FXML private Label labelVirhe;
@FXML
ScrollPane panelJasen;
@Override @Override
public void initialize(URL arg0, ResourceBundle arg1) { public void initialize(URL arg0, ResourceBundle arg1) {
...@@ -75,13 +77,15 @@ public class JasenDialogController implements ModalControllerInterface<Jasen>, I ...@@ -75,13 +77,15 @@ public class JasenDialogController implements ModalControllerInterface<Jasen>, I
@Override @Override
public void handleShown() { public void handleShown() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
kentta = Math.max(apujasen.ekaKentta(), Math.min(kentta, apujasen.getKenttia()-1));
edits[kentta].requestFocus();
} }
private Jasen jasenKohdalla; private Jasen jasenKohdalla;
private TextField[] edits; private TextField[] edits;
private static Jasen apujasen = new Jasen(); private static Jasen apujasen = new Jasen();
private int kentta;
/** /**
...@@ -113,7 +117,7 @@ public class JasenDialogController implements ModalControllerInterface<Jasen>, I ...@@ -113,7 +117,7 @@ public class JasenDialogController implements ModalControllerInterface<Jasen>, I
if ( edit != null ) if ( edit != null )
edit.setOnKeyReleased( e -> kasitteleMuutosJaseneen(edit)); edit.setOnKeyReleased( e -> kasitteleMuutosJaseneen(edit));
// edit.setOnKeyReleased( e -> kasitteleMuutosJaseneen((TextField)(e.getSource()))); // edit.setOnKeyReleased( e -> kasitteleMuutosJaseneen((TextField)(e.getSource())));
panelJasen.setFitToHeight(true);
} }
...@@ -128,8 +132,13 @@ public class JasenDialogController implements ModalControllerInterface<Jasen>, I ...@@ -128,8 +132,13 @@ public class JasenDialogController implements ModalControllerInterface<Jasen>, I
Node node = (Node)obj; Node node = (Node)obj;
return Mjonot.erotaInt(node.getId().substring(1),oletus); return Mjonot.erotaInt(node.getId().substring(1),oletus);
} }
private void setKentta(int kentta) {
this.kentta = kentta;
}
/** /**
* Käsitellään jäseneen tullut muutos * Käsitellään jäseneen tullut muutos
* @param edit muuttunut kenttä * @param edit muuttunut kenttä
...@@ -155,9 +164,22 @@ public class JasenDialogController implements ModalControllerInterface<Jasen>, I ...@@ -155,9 +164,22 @@ public class JasenDialogController implements ModalControllerInterface<Jasen>, I
} }
} }
public static Jasen kysyJasen(Stage modalityStage, Jasen oletus) { /*
return ModalController.showModal(KerhoGUIController.class.getResource("JasenDialogView.fxml"), "Jäsen", modalityStage, oletus); * Näyttää jäsenen tiedot ja palauttaa null jos käyttäjä painaa Cancel,
* muuten viitteen muutettuun jäseneen
* @param modalityStage mille ollaan modaalisia, null = sovellukselle
* @param oletus mitä dataan näytetään oletuksena
* @param kentta mikä kenttä saa fokuksen kun näytetään
* @return null jos painetaan Cancel, muuten täytetty tietue
*/
public static Jasen kysyJasen(Stage modalityStage, Jasen oletus, int kentta) {
return ModalController.<Jasen, JasenDialogController>showModal(
KerhoGUIController.class.getResource("JasenDialogView.fxml"),
"Jäsen",
modalityStage,
oletus,
ctrl -> ctrl.setKentta(kentta));
} }
} }
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
</VBox> </VBox>
</bottom> </bottom>
<center> <center>
<ScrollPane fitToWidth="true" pannable="true" BorderPane.alignment="CENTER"> <ScrollPane fx:id="panelJasen" fitToWidth="true" pannable="true" BorderPane.alignment="CENTER">
<content> <content>
<GridPane fx:id="gridJasen" hgap="10.0"> <GridPane fx:id="gridJasen" hgap="10.0">
<columnConstraints> <columnConstraints>
......
...@@ -29,6 +29,8 @@ import kerho.Jasen; ...@@ -29,6 +29,8 @@ import kerho.Jasen;
import kerho.Kerho; import kerho.Kerho;
import kerho.SailoException; import kerho.SailoException;
import static fxKerho.JasenDialogController.getFieldId;
/** /**
* Luokka kerhon käyttöliittymän tapahtumien hoitamiseksi. * Luokka kerhon käyttöliittymän tapahtumien hoitamiseksi.
* *
...@@ -95,7 +97,7 @@ public class KerhoGUIController implements Initializable { ...@@ -95,7 +97,7 @@ public class KerhoGUIController implements Initializable {
@FXML private void handleMuokkaaJasen() { @FXML private void handleMuokkaaJasen() {
muokkaa(); muokkaa(kentta);
} }
...@@ -136,7 +138,8 @@ public class KerhoGUIController implements Initializable { ...@@ -136,7 +138,8 @@ public class KerhoGUIController implements Initializable {
private String kerhonnimi = "kelmit"; private String kerhonnimi = "kelmit";
private Kerho kerho; private Kerho kerho;
private TextField[] edits; private TextField[] edits;
private int kentta = 0;
/** /**
* Tekee tarvittavat muut alustukset, nyt vaihdetaan GridPanen tilalle * Tekee tarvittavat muut alustukset, nyt vaihdetaan GridPanen tilalle
* yksi iso tekstikenttä, johon voidaan tulostaa jäsenten tiedot. * yksi iso tekstikenttä, johon voidaan tulostaa jäsenten tiedot.
...@@ -148,7 +151,14 @@ public class KerhoGUIController implements Initializable { ...@@ -148,7 +151,14 @@ public class KerhoGUIController implements Initializable {
chooserJasenet.clear(); chooserJasenet.clear();
chooserJasenet.addSelectionListener(e -> naytaJasen()); chooserJasenet.addSelectionListener(e -> naytaJasen());
edits = JasenDialogController.luoKentat(gridJasen); edits = JasenDialogController.luoKentat(gridJasen);
for (TextField edit: edits)
if ( edit != null ) {
edit.setEditable(false);
edit.setOnMouseClicked(e -> { if ( e.getClickCount() > 1 ) muokkaa(getFieldId(edit,kentta)); });
edit.focusedProperty().addListener((a,o,n) -> kentta = getFieldId(edit,kentta));
}
} }
...@@ -295,19 +305,20 @@ public class KerhoGUIController implements Initializable { ...@@ -295,19 +305,20 @@ public class KerhoGUIController implements Initializable {
*/ */
protected void uusiJasen() { protected void uusiJasen() {
Jasen uusi = new Jasen(); Jasen uusi = new Jasen();
uusi = JasenDialogController.kysyJasen(null, uusi, uusi.ekaKentta());
if (uusi == null) return;
uusi.rekisteroi(); uusi.rekisteroi();
uusi.vastaaAkuAnkka();
kerho.lisaa(uusi); kerho.lisaa(uusi);
hae(uusi.getTunnusNro()); hae(uusi.getTunnusNro());
} }
private void muokkaa() { private void muokkaa(int k) {
Jasen jasenKohdalla = chooserJasenet.getSelectedObject(); Jasen jasenKohdalla = chooserJasenet.getSelectedObject();
if (jasenKohdalla == null) return; if (jasenKohdalla == null) return;
try { try {
Jasen jasen = jasenKohdalla.clone(); Jasen jasen = jasenKohdalla.clone();
jasen = JasenDialogController.kysyJasen(null, jasen); jasen = JasenDialogController.kysyJasen(null, jasen, k);
if (jasen == null) return; if (jasen == null) return;
kerho.korvaaTaiLisaa(jasen); kerho.korvaaTaiLisaa(jasen);
hae(jasenKohdalla.getTunnusNro()); hae(jasenKohdalla.getTunnusNro());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment