diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java index c3247f1eac32f06602096bd459635843f2422382..461e136ec5c00c1262ef610079af74eff7b9472a 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java @@ -47,12 +47,6 @@ public class YoshikoResult { this.flags = flags; } - public void dispose() { - flags.delete(); - originalGraph.dispose(); - } - - //___________SETTER GETTER_____________// /** diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ClusterView.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ClusterView.java index ea067d96f60038e5df5a8f703e66dfbed5eb16a3..2cbb3a4868bb1986b1e687b24400169a54f14ab0 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ClusterView.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ClusterView.java @@ -66,7 +66,7 @@ public class ClusterView extends JPanel { //SYMBOLIC LINKS - private YoshikoCluster cluster; + private final YoshikoCluster cluster; public ClusterView(YoshikoCluster c) throws Exception { @@ -158,4 +158,14 @@ public class ClusterView extends JPanel { }; + + //____________SETTER GETTER ________________// + + public boolean isSelected() { + return isSelected; + } + + public YoshikoCluster getCluster() { + return cluster; + } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ClusterViewList.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ClusterViewList.java index ad45bb5b992fb52a4f2004c634a8c854966955f2..1ce809d369f91f370031d655191bd0fe70e8fd41 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ClusterViewList.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ClusterViewList.java @@ -10,6 +10,7 @@ import javax.swing.Scrollable; import org.slf4j.Logger; +import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoCluster; import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger; @SuppressWarnings("serial") @@ -62,4 +63,15 @@ public class ClusterViewList extends JPanel implements Scrollable { return ret; } + public ArrayList<YoshikoCluster> getSelectedClusters() { + ArrayList<YoshikoCluster> ret = new ArrayList<YoshikoCluster>(); + ArrayList<ClusterView> cv = getClusterViews(); + for (ClusterView v : cv) { + if (v.isSelected()) { + ret.add(v.getCluster()); + } + } + return ret; + } + } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java index 139591072294167c86c8d68ce10fc91b1a42a949..09d41554c356d1f2b3ef86008dc66b80dfa9bc6a 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java @@ -78,6 +78,7 @@ NetworkAboutToBeDestroyedListener //MACRO + //TODO: (Nächstes Leben) find a good solution with Swing that scales the panel and respects layout private static final int HACKFIX_FIXED_WIDTH = 128+256; private final JTabbedPane tabbedPane; @@ -87,22 +88,31 @@ NetworkAboutToBeDestroyedListener private BasicCollapsiblePanel marker; private final JLabel invalidLabel; - private ArrayList<SolutionTab> solutionTabs; + private final ArrayList<SolutionTab> solutionTabs; private final YoshikoResult result; + private boolean isValid; + public ResultPanel(YoshikoResult result) throws Exception { this.result = result; + this.isValid = true; + //Init subcomponents invalidLabel = new JLabel(); tabbedPane = new JTabbedPane(); + + solutionTabs = new ArrayList<SolutionTab>(); for (YoshikoSolution s : result.getSolutions()) { SolutionTab tab = new SolutionTab(s); tabbedPane.add( LocalizationManager.get("solution")+" "+(s.getId()+1), tab - ); } + ); + //Save reference + solutionTabs.add(tab); + } if (result.getFlags().getIlpGenerated()) { //TODO: Move to MarkerPanel for better codestyle @@ -163,7 +173,7 @@ NetworkAboutToBeDestroyedListener .addComponent(tabbedPane,HACKFIX_FIXED_WIDTH, PREFERRED_SIZE,Short.MAX_VALUE) .addComponent(destroyButton,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE); verticalGroup - .addComponent(invalidLabel,DEFAULT_SIZE, DEFAULT_SIZE,PREFERRED_SIZE) + .addComponent(invalidLabel,DEFAULT_SIZE, PREFERRED_SIZE,Short.MAX_VALUE) .addComponent(tabbedPane,DEFAULT_SIZE, DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(destroyButton,DEFAULT_SIZE, DEFAULT_SIZE,PREFERRED_SIZE); @@ -195,13 +205,15 @@ NetworkAboutToBeDestroyedListener if (dialogResult != JOptionPane.YES_OPTION) { return; } - result.dispose(); CyCore.registrar.unregisterService(this,CytoPanelComponent.class); removeAll(); super.setVisible(false); } private void invalidateResult() { + if (isValid) { + isValid = false; + } invalidLabel.setText(LocalizationManager.get("invalidated")); invalidLabel.setForeground(Color.RED); for (SolutionTab t: solutionTabs) { diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java index 6d22d6c4a5e2709ee25bb720af394ea16a8ba675..e60fd071b2e969c7a6a0a043e22187cd0356c9eb 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java @@ -27,12 +27,14 @@ import static javax.swing.GroupLayout.PREFERRED_SIZE; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.Group; import javax.swing.JButton; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ScrollPaneConstants; @@ -56,7 +58,7 @@ public class SolutionTab extends JPanel { //SWING COMPONENTS private final JScrollPane scrollPane; - private final ClusterViewList scrollPaneContent; + private final ClusterViewList clusterViewList; private final JLabel clusterCount; private final JButton createClusterView; private final JButton createMetaGraph; @@ -82,14 +84,14 @@ public class SolutionTab extends JPanel { this.solution = s; //Declaration of Swing Components - scrollPaneContent = new ClusterViewList(); + clusterViewList = new ClusterViewList(); for (YoshikoCluster c: solution.cluster) { ClusterView clusterView = new ClusterView(c); - scrollPaneContent.add(clusterView); + clusterViewList.add(clusterView); } - scrollPane = new JScrollPane(scrollPaneContent); + scrollPane = new JScrollPane(clusterViewList); clusterCount = new JLabel(LocalizationManager.get("clusterFound")+" "+s.cluster.size()); @@ -105,9 +107,20 @@ public class SolutionTab extends JPanel { @Override public void actionPerformed(ActionEvent e) { + ArrayList<YoshikoCluster> selectedClusters = clusterViewList.getSelectedClusters(); + if (selectedClusters.isEmpty()) { + JOptionPane.showMessageDialog(null, + LocalizationManager.get("optionpane_title"), + LocalizationManager.get("noClustersSelected"), + JOptionPane.INFORMATION_MESSAGE + ); + return; + } CyCore.dialogTaskManager.execute( new TaskIterator(1, - new CreateClusterViews(solution.getClusters()) + new CreateClusterViews( + selectedClusters + ) ) ); } @@ -133,7 +146,7 @@ public class SolutionTab extends JPanel { //Layout - scrollLayout = new GroupLayout(scrollPaneContent); + scrollLayout = new GroupLayout(clusterViewList); horizontalGroup_scrollLayout = scrollLayout.createParallelGroup(); verticalGroup_scrollLayout = scrollLayout.createSequentialGroup(); @@ -144,12 +157,12 @@ public class SolutionTab extends JPanel { scrollLayout.setAutoCreateContainerGaps(true); scrollLayout.setAutoCreateGaps(true); - for (ClusterView v: scrollPaneContent.getClusterViews()) { + for (ClusterView v: clusterViewList.getClusterViews()) { horizontalGroup_scrollLayout.addComponent(v); verticalGroup_scrollLayout.addComponent(v); } - scrollPaneContent.setLayout(scrollLayout); + clusterViewList.setLayout(scrollLayout); layout = new GroupLayout(this); diff --git a/src/main/resources/YoshikoStrings.properties b/src/main/resources/YoshikoStrings.properties index e21c0726ed4017dfa8e8c81c932a482f09316e9e..75d34207e234662c01ba1b1a8cad786a651f99e1 100644 --- a/src/main/resources/YoshikoStrings.properties +++ b/src/main/resources/YoshikoStrings.properties @@ -44,6 +44,7 @@ icTooltip = This value is used to determine what the algorithm pays when inserti ilpMarker = ILP Properties incompleteResult = This run yielded no usable result! instance = Instance +invalidated = No longer valid, original graph changed! lastInstanceGap = Gap (Current Instance): libFail = Failed to load library! Make sure you got the right file. The required version for this version of the wrapper is: libraryPanel = Library @@ -55,6 +56,8 @@ noLibMessage = There is no Yoshiko Library currently loaded! You might have to s noLibTitle = Library not loaded! noMappingHint = You haven't mapped the cost value to a column in your edge table.\nYoshiko runs significantly faster and generates better solutions if you map values. nodes = Nodes +optionpane_title = Yoshiko Info +noClustersSelected = You have not selected any clusters notOptimal = Optimality not guaranteed nrSolutions = Number of Solutions: operationMode = Operation Mode