From 30f63266fe3fdc93f1001c685a0a322adb38f24d Mon Sep 17 00:00:00 2001 From: Akshat Bahety Date: Tue, 5 Jun 2018 21:56:57 +0530 Subject: [PATCH] added the Cancel button the list needs to be updated in the popup to make the data flow as required working on validation and left out a couple of changes due to some reasons --- .../fxdesigner/AuxClassPathController.java | 39 ++++++++++++++----- .../fxdesigner/MainDesignerController.java | 5 +-- .../fxdesigner/SourceEditorController.java | 23 +++++++++++ .../fxml/auxclasspath-setup-popup.fxml | 9 ++++- 4 files changed, 62 insertions(+), 14 deletions(-) diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java index 741888f9b2..d6d2c916d3 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java @@ -11,11 +11,14 @@ import java.net.URL; import java.util.List; import java.util.ResourceBundle; +import org.controlsfx.validation.ValidationSupport; + import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.util.ClasspathClassLoader; import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil; import net.sourceforge.pmd.util.fxdesigner.util.beans.SettingsOwner; +import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; @@ -31,7 +34,7 @@ public class AuxClassPathController implements Initializable, SettingsOwner { private final DesignerRoot designerRoot; private ClassLoader classLoader = getClass().getClassLoader(); - + private ValidationSupport validationSupport = new ValidationSupport(); @FXML @@ -39,19 +42,31 @@ public class AuxClassPathController implements Initializable, SettingsOwner { @FXML private Button selectFilesButton; @FXML - private ListView fileListView; + private ListView fileListView = new ListView<>(); @FXML private Button moveItemUpButton; @FXML private Button moveItemDownButton; @FXML private Button setClassPathButton; + @FXML + private Button cancelButton; - public AuxClassPathController(DesignerRoot designerRoot) { + public AuxClassPathController(ObservableList auxClassPathFiles, DesignerRoot designerRoot) { this.designerRoot = designerRoot; - } + if (auxClassPathFiles != null) { + fileListView.setItems(auxClassPathFiles); + } + + try { + showAuxPathWizard(); + } catch (Exception e) { + e.printStackTrace(); + } + + } @Override public void initialize(URL location, ResourceBundle resources) { @@ -65,8 +80,11 @@ public class AuxClassPathController implements Initializable, SettingsOwner { e1.printStackTrace(); } }); + + moveItemUpButton.setOnAction(e -> moveUp()); moveItemDownButton.setOnAction(e -> moveDown()); + cancelButton.setOnAction(e -> closePopup()); } @@ -79,10 +97,8 @@ public class AuxClassPathController implements Initializable, SettingsOwner { new FileChooser.ExtensionFilter("Java EARs", "*.ear"), new FileChooser.ExtensionFilter("Java class files", "*.class") ); - List file = chooser.showOpenMultipleDialog(designerRoot.getMainStage()); - for (File f : file) { - fileListView.getItems().add(f); - } + List files = chooser.showOpenMultipleDialog(designerRoot.getMainStage()); + fileListView.getItems().addAll(files); } @@ -128,12 +144,16 @@ public class AuxClassPathController implements Initializable, SettingsOwner { } + private void setValidationSupport() { + + } + private String classPathGenerator() throws IOException { String classPath = ""; for (File f : fileListView.getItems()) { - classPath = classPath + ";" + f.getAbsolutePath(); + classPath = classPath + File.pathSeparator + f.getAbsolutePath(); } setClassPath(classPath); @@ -149,6 +169,7 @@ public class AuxClassPathController implements Initializable, SettingsOwner { if (classPath != null) { classLoader = new ClasspathClassLoader(classPath, classLoader); } + SourceEditorController.auxclasspathFiles = fileListView.getItems(); closePopup(); } diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/MainDesignerController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/MainDesignerController.java index 5cb52540f3..8d5e4a14cf 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/MainDesignerController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/MainDesignerController.java @@ -115,8 +115,6 @@ public class MainDesignerController implements Initializable, SettingsOwner { @FXML private EventLogController eventLogPanelController; - private final AuxClassPathController auxClassPathController; - // Other fields private Stack recentFiles = new LimitedSizeStack<>(5); // Properties @@ -126,7 +124,6 @@ public class MainDesignerController implements Initializable, SettingsOwner { public MainDesignerController(DesignerRoot owner) { this.designerRoot = owner; - this.auxClassPathController = new AuxClassPathController(designerRoot); } @@ -169,7 +166,7 @@ public class MainDesignerController implements Initializable, SettingsOwner { setupAuxclasspathMenuItem.setOnAction(e -> { try { - auxClassPathController.showAuxPathWizard(); + sourceEditorController.showAuxClassPathController(designerRoot); } catch (Exception e1) { e1.printStackTrace(); } diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/SourceEditorController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/SourceEditorController.java index 891ac4eb87..d583c1fab8 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/SourceEditorController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/SourceEditorController.java @@ -4,6 +4,7 @@ package net.sourceforge.pmd.util.fxdesigner; +import java.io.File; import java.net.URL; import java.time.Duration; import java.util.Collection; @@ -33,6 +34,7 @@ import net.sourceforge.pmd.util.fxdesigner.util.controls.ASTTreeCell; import net.sourceforge.pmd.util.fxdesigner.util.controls.ASTTreeItem; import net.sourceforge.pmd.util.fxdesigner.util.controls.TreeViewWrapper; +import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Label; @@ -62,6 +64,9 @@ public class SourceEditorController implements Initializable, SettingsOwner { private ASTTreeItem selectedTreeItem; private static final Duration AST_REFRESH_DELAY = Duration.ofMillis(100); + public static ObservableList auxclasspathFiles; + private Var auxclasspathClassLoader; + public SourceEditorController(DesignerRoot owner, MainDesignerController mainController) { parent = mainController; astManager = new ASTManager(owner); @@ -126,6 +131,24 @@ public class SourceEditorController implements Initializable, SettingsOwner { } + public void showAuxClassPathController(DesignerRoot root) { + AuxClassPathController auxClassPathController = new AuxClassPathController(auxclasspathFiles, root); + + + } + + + @PersistentProperty + public ObservableList getAuxclasspathFiles() { + return auxclasspathFiles; + } + + + public void setAuxClassPathFiles(ObservableList auxclasspathFiles) { + this.auxclasspathFiles = auxclasspathFiles; + } + + private void setUpToDateCompilationUnit(Node node) { astTitleLabel.setText("Abstract Syntax Tree"); ASTTreeItem root = ASTTreeItem.getRoot(node); diff --git a/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/fxml/auxclasspath-setup-popup.fxml b/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/fxml/auxclasspath-setup-popup.fxml index ddd317d8a6..f66299513c 100644 --- a/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/fxml/auxclasspath-setup-popup.fxml +++ b/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/fxml/auxclasspath-setup-popup.fxml @@ -7,7 +7,7 @@ - @@ -53,6 +53,13 @@ + +