Browse Source

Fixed graph name issue

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@475 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Mark Kattenbelt 18 years ago
parent
commit
d4a1a55d20
  1. 35
      prism/src/userinterface/properties/GUIGraphHandler.java

35
prism/src/userinterface/properties/GUIGraphHandler.java

@ -49,14 +49,14 @@ import settings.*;
*/ */
public class GUIGraphHandler extends JPanel implements MouseListener public class GUIGraphHandler extends JPanel implements MouseListener
{ {
private int counter = 0;
private boolean canDelete; private boolean canDelete;
private JTabbedPane theTabs; private JTabbedPane theTabs;
private JPopupMenu backMenu, graphMenu; private JPopupMenu backMenu, graphMenu;
private ArrayList<Graph> models;
private ArrayList<GraphOptions> options;
private java.util.List<Graph> models;
private java.util.List<GraphOptions> options;
private GUIPlugin plug; private GUIPlugin plug;
@ -125,8 +125,6 @@ public class GUIGraphHandler extends JPanel implements MouseListener
models = new ArrayList<Graph>(); models = new ArrayList<Graph>();
options = new ArrayList<GraphOptions>(); options = new ArrayList<GraphOptions>();
counter = 0;
} }
private void initComponents() private void initComponents()
@ -369,7 +367,7 @@ public class GUIGraphHandler extends JPanel implements MouseListener
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
Graph graph = models.get( Graph graph = models.get(
theTabs.getSelectedIndex()
theTabs.getSelectedIndex()
); );
if (!graph.getDisplaySettings().getBackgroundColor().equals(Color.white)) if (!graph.getDisplaySettings().getBackgroundColor().equals(Color.white))
@ -399,7 +397,6 @@ public class GUIGraphHandler extends JPanel implements MouseListener
models.remove(theTabs.getSelectedIndex()); models.remove(theTabs.getSelectedIndex());
options.remove(theTabs.getSelectedIndex()); options.remove(theTabs.getSelectedIndex());
theTabs.remove(graph); theTabs.remove(graph);
counter--;
} }
}; };
deleteGraph.putValue(Action.NAME, "Delete graph"); deleteGraph.putValue(Action.NAME, "Delete graph");
@ -550,8 +547,27 @@ public class GUIGraphHandler extends JPanel implements MouseListener
public int addGraph(Graph m) public int addGraph(Graph m)
{ {
return addGraph(m, "Graph " + (counter + 1));
String name = "";
boolean nameNew;
int counter = 1;
while (true)
{
name = "Graph " + (counter);
nameNew = true;
for(int i = 0; i < theTabs.getComponentCount(); i++)
{
if(theTabs.getTitleAt(i).equals(name))
nameNew = false;
}
if (nameNew)
return addGraph(m, name);
counter++;
}
} }
public int addGraph(Graph m, String tabName) public int addGraph(Graph m, String tabName)
@ -575,9 +591,6 @@ public class GUIGraphHandler extends JPanel implements MouseListener
// make this new tab the default selection // make this new tab the default selection
theTabs.setSelectedIndex(theTabs.indexOfComponent(m)); theTabs.setSelectedIndex(theTabs.indexOfComponent(m));
// increase the graph counter
counter++;
// return the index of the component // return the index of the component
return index; return index;
} }

Loading…
Cancel
Save