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
This commit is contained in:
Akshat Bahety
2018-06-05 21:56:57 +05:30
parent 9b341a62b6
commit 30f63266fe
4 changed files with 62 additions and 14 deletions

View File

@ -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<File> fileListView;
private ListView<File> 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<File> 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> file = chooser.showOpenMultipleDialog(designerRoot.getMainStage());
for (File f : file) {
fileListView.getItems().add(f);
}
List<File> 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();
}

View File

@ -115,8 +115,6 @@ public class MainDesignerController implements Initializable, SettingsOwner {
@FXML
private EventLogController eventLogPanelController;
private final AuxClassPathController auxClassPathController;
// Other fields
private Stack<File> 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();
}

View File

@ -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<File> auxclasspathFiles;
private Var<ClassLoader> 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<File> getAuxclasspathFiles() {
return auxclasspathFiles;
}
public void setAuxClassPathFiles(ObservableList<File> auxclasspathFiles) {
this.auxclasspathFiles = auxclasspathFiles;
}
private void setUpToDateCompilationUnit(Node node) {
astTitleLabel.setText("Abstract Syntax Tree");
ASTTreeItem root = ASTTreeItem.getRoot(node);

View File

@ -7,7 +7,7 @@
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<VBox minWidth="-Infinity" snapToPixel="false" xmlns="http://javafx.com/javafx/9.0.1"
<VBox minWidth="-Infinity" snapToPixel="false" xmlns="http://javafx.com/javafx/8.0.121"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="net.sourceforge.pmd.util.fxdesigner.AuxClassPathController">
<children>
<TitledPane collapsible="false" prefHeight="25.0" prefWidth="647.0" text="PMD Configuration"/>
@ -53,6 +53,13 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
</VBox.margin>
</Button>
<Button fx:id="cancelButton" minWidth="-Infinity" mnemonicParsing="false" text="Cancel"
textAlignment="CENTER">
<VBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
</VBox.margin>
</Button>
</children>
</VBox>
</items>