|
@@ -5,10 +5,8 @@ import java.awt.Color;
|
|
|
import java.awt.Component;
|
|
|
import java.awt.Cursor;
|
|
|
import java.awt.Dimension;
|
|
|
-import java.awt.Font;
|
|
|
import java.awt.HeadlessException;
|
|
|
import java.awt.Image;
|
|
|
-import java.awt.Label;
|
|
|
import java.awt.Point;
|
|
|
import java.awt.Toolkit;
|
|
|
import java.awt.datatransfer.UnsupportedFlavorException;
|
|
@@ -26,7 +24,6 @@ import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Timer;
|
|
|
import java.util.TimerTask;
|
|
|
-import java.util.zip.ZipException;
|
|
|
|
|
|
import javax.swing.AbstractAction;
|
|
|
import javax.swing.ActionMap;
|
|
@@ -125,6 +122,8 @@ public class GUI<E> implements CategoryListener {
|
|
|
private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
|
|
private final JTabbedPane tabbedPane2 = new JTabbedPane(JTabbedPane.TOP);
|
|
|
private final JButton splitButton = new JButton("Split View");
|
|
|
+ private JSplitPane tempSplit;
|
|
|
+ private boolean initSplit = true;
|
|
|
|
|
|
private final JPanel panelTapped_SimMenu = new JPanel();
|
|
|
private JPopupMenu popmenuEdit = new JPopupMenu();
|
|
@@ -302,7 +301,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
initialize();
|
|
|
updateCategories(model.getCategories());
|
|
|
updCon = new UpdateController(model, controller);
|
|
|
- flexPane = new FlexiblePane();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -703,6 +701,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
} else {
|
|
|
canvas.repaint();
|
|
|
}
|
|
|
+ if (!initSplit && ((JScrollPane) tabbedPane2.getSelectedComponent()).getViewport()
|
|
|
+ .getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
+ ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent()).getViewport().getComponent(0))
|
|
|
+ .repaint();
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -759,12 +762,15 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
// Testing
|
|
|
menuBar.add(splitButton);
|
|
|
- //Split View
|
|
|
+ // Split View
|
|
|
splitButton.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
if (panelTapped_SimMenu
|
|
|
.getComponent(panelTapped_SimMenu.getComponentCount() - 1) instanceof JSplitPane) {
|
|
|
+ initSplit = true;
|
|
|
+ Component tempC = tabbedPane2.getSelectedComponent();
|
|
|
+ tabbedPane.setComponentAt(tabbedPane2.getSelectedIndex(), tempC);
|
|
|
tabbedPane2.removeAll();
|
|
|
panelTapped_SimMenu
|
|
|
.remove(panelTapped_SimMenu.getComponent(panelTapped_SimMenu.getComponentCount() - 1));
|
|
@@ -772,20 +778,76 @@ public class GUI<E> implements CategoryListener {
|
|
|
} else {
|
|
|
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
|
|
|
tabbedPane2.addTab(tabbedPane.getTitleAt(i), null);
|
|
|
+ if (i >= 4) {
|
|
|
+ //tabbedPane2.setTabComponentAt(tabbedPane.getTabCount() - 1,
|
|
|
+ // new ButtonTabComponent(tabbedPane, tabbedPane2));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (tabbedPane.getSelectedComponent() == statScrollPane) {
|
|
|
+ tabbedPane.setComponentAt(0, null);
|
|
|
+ tabbedPane2.setComponentAt(0, canvasSP);
|
|
|
+ tabbedPane2.setSelectedIndex(0);
|
|
|
+ } else {
|
|
|
+ tabbedPane.setComponentAt(1, null);
|
|
|
+ tabbedPane2.setComponentAt(1, statScrollPane);
|
|
|
+ tabbedPane2.setSelectedIndex(1);
|
|
|
}
|
|
|
- JSplitPane tempSplit = new JSplitPane();
|
|
|
+ tempSplit = new JSplitPane();
|
|
|
tempSplit.setBorder(null);
|
|
|
tempSplit.setRightComponent(tabbedPane2);
|
|
|
tempSplit.setLeftComponent(tabbedPane);
|
|
|
- tempSplit.setDividerLocation(tabbedPane.getWidth()/2);
|
|
|
+ tempSplit.setDividerLocation(tabbedPane.getWidth() / 2);
|
|
|
+ tempSplit.setResizeWeight(0.9);
|
|
|
panelTapped_SimMenu.remove(tabbedPane);
|
|
|
panelTapped_SimMenu.add(tempSplit);
|
|
|
+ initSplit = false;
|
|
|
}
|
|
|
contentPane.updateUI();
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
+ tabbedPane.addChangeListener(new ChangeListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stateChanged(ChangeEvent e) {
|
|
|
+ if (tabbedPane.getSelectedComponent() == null) {
|
|
|
+ Component tempC = tabbedPane2.getSelectedComponent();
|
|
|
+ tabbedPane2.setComponentAt(tabbedPane.getSelectedIndex(), null);
|
|
|
+ tabbedPane.setComponentAt(tabbedPane.getSelectedIndex(), tempC);
|
|
|
+ tempC = tabbedPane.getComponentAt((tabbedPane.getSelectedIndex() + 1) % (tabbedPane.getTabCount()));
|
|
|
+ tabbedPane.setComponentAt((tabbedPane.getSelectedIndex() + 1) % (tabbedPane.getTabCount()), null);
|
|
|
+ tabbedPane2.setComponentAt((tabbedPane.getSelectedIndex() + 1) % (tabbedPane.getTabCount()), tempC);
|
|
|
+ tabbedPane2.setSelectedIndex((tabbedPane.getSelectedIndex() + 1) % (tabbedPane.getTabCount()));
|
|
|
+ contentPane.updateUI();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ tabbedPane2.addChangeListener(new ChangeListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stateChanged(ChangeEvent e) {
|
|
|
+ if (tabbedPane2.getSelectedComponent() == null && !initSplit) {
|
|
|
+ Component tempC = tabbedPane.getComponentAt(tabbedPane2.getSelectedIndex());
|
|
|
+ tabbedPane.setComponentAt(tabbedPane2.getSelectedIndex(), null);
|
|
|
+ tabbedPane2.setComponentAt(tabbedPane2.getSelectedIndex(), tempC);
|
|
|
+ for (int i = 0; i < tabbedPane.getTabCount(); i++) {
|
|
|
+ if (tabbedPane2.getComponentAt(i) != null && tabbedPane2.getComponentAt(i) != tempC) {
|
|
|
+ tempC = tabbedPane2.getComponentAt(i);
|
|
|
+ tabbedPane2.setComponentAt(i, null);
|
|
|
+ tabbedPane.setComponentAt(i, tempC);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (tabbedPane.getSelectedIndex() == tabbedPane2.getSelectedIndex()) {
|
|
|
+ tabbedPane.setSelectedIndex((tabbedPane2.getSelectedIndex() + 1) % tabbedPane.getTabCount());
|
|
|
+ }
|
|
|
+ contentPane.updateUI();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
mnNewMenuOptions.add(mnLanguage);
|
|
|
canvas.setBackground(Color.WHITE);
|
|
|
canvas.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
|
|
@@ -849,7 +911,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
|
if (model.getSelectedCpsObjects().size() == 1) {
|
|
|
AbstractCpsObject tempCpsObject = updCon.getActualCps();
|
|
|
- System.out.println(tempCpsObject.getName());
|
|
|
if (tempCpsObject != null && tempCpsObject.getClass() == HolonObject.class
|
|
|
&& tempCpsObject.getId() != 0) {
|
|
|
addElementPopUp = new AddElementPopUp();
|
|
@@ -1095,7 +1156,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
yProThis = e.getY();
|
|
|
xProThis = e.getX();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -1111,14 +1171,13 @@ public class GUI<E> implements CategoryListener {
|
|
|
Point mousePos = tableProperties.getMousePosition();
|
|
|
int selValueY = (int) Math.floor(yProThis / 16);
|
|
|
int selValueX = (int) Math.floor(xProThis / (tableProperties.getWidth() / 2));
|
|
|
- if (updCon.getActualCps() != null) {
|
|
|
+ if (updCon.getActualCps() != null && selValueX != 0) {
|
|
|
temp = model.getPropertyTable().getValueAt(selValueY, selValueX);
|
|
|
if (updCon.getActualCps() instanceof HolonSwitch) {
|
|
|
btemp = model.getPropertyTable().getValueAt(mousePos.y / tableProperties.getRowHeight(),
|
|
|
mousePos.x / (tableProperties.getWidth() / 2));
|
|
|
if (mousePos.y / tableProperties.getRowHeight() == 0) {
|
|
|
updCon.getActualCps().setName(btemp.toString());
|
|
|
-
|
|
|
} else if (mousePos.y / tableProperties.getRowHeight() == 2) {
|
|
|
Boolean bbTemp = Boolean.parseBoolean(btemp.toString());
|
|
|
((HolonSwitch) updCon.getActualCps()).setManualMode(bbTemp);
|
|
@@ -1134,9 +1193,8 @@ public class GUI<E> implements CategoryListener {
|
|
|
((HolonSwitch) updCon.getActualCps()).setManualState(bTemp);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- updCon.getActualCps().setName(temp.toString());
|
|
|
- if (updCon.getActualCps() instanceof CpsUpperNode) {
|
|
|
+ } else if (updCon.getActualCps() instanceof CpsUpperNode) {
|
|
|
+ updCon.getActualCps().setName(temp.toString());
|
|
|
for (int index = 4; index < tabbedPane.getTabCount(); index++) {
|
|
|
UpperNodeCanvas unc = ((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponent(index))
|
|
|
.getViewport().getComponent(0));
|
|
@@ -1145,8 +1203,9 @@ public class GUI<E> implements CategoryListener {
|
|
|
tabbedPane.updateUI();
|
|
|
}
|
|
|
}
|
|
|
+ } else if (updCon.getActualCps() instanceof HolonObject) {
|
|
|
+ updCon.getActualCps().setName(temp.toString());
|
|
|
}
|
|
|
- // }
|
|
|
} else {
|
|
|
temp = model.getPropertyTable().getValueAt(selValueY, selValueX);
|
|
|
btemp = model.getPropertyTable().getValueAt(mousePos.y / tableProperties.getRowHeight(),
|
|
@@ -1793,12 +1852,14 @@ public class GUI<E> implements CategoryListener {
|
|
|
splitPane1.setDividerLocation(500);
|
|
|
splitPaneCanvasConsole.setDividerLocation(550);
|
|
|
splitPaneCanvasConsole.setResizeWeight(0.9);
|
|
|
-
|
|
|
+
|
|
|
splitPane.setLeftComponent(scrollPane1);
|
|
|
splitPaneCanvasConsole.setLeftComponent(panelTapped_SimMenu);
|
|
|
tabbedPane.addTab("View", canvasSP);
|
|
|
tabbedPane.addTab("Statistics", statScrollPane);
|
|
|
tabbedPane.addTab("Holon", holonCanvas);
|
|
|
+ flexPane = new FlexiblePane(controller);
|
|
|
+ controller.setFlexiblePane(flexPane);
|
|
|
tabbedPane.addTab("Flexibility", flexPane);
|
|
|
|
|
|
splitPaneCanvasConsole.setRightComponent(console);
|
|
@@ -2078,12 +2139,18 @@ public class GUI<E> implements CategoryListener {
|
|
|
* Open a new Tab with an UpperNodeCanvas
|
|
|
*/
|
|
|
private void openNewUpperNodeTab() {
|
|
|
-
|
|
|
- if (((JScrollPane) tabbedPane.getSelectedComponent()).getViewport().getComponent(0) instanceof MyCanvas) {
|
|
|
+ // is the uppernode on tabbedPane or tabbedPane2
|
|
|
+ JTabbedPane tabTemp;
|
|
|
+ if (tabbedPane.getMousePosition() != null) {
|
|
|
+ tabTemp = tabbedPane;
|
|
|
+ } else {
|
|
|
+ tabTemp = tabbedPane2;
|
|
|
+ }
|
|
|
+ if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport().getComponent(0) instanceof MyCanvas) {
|
|
|
unc = new UpperNodeCanvas(model, controller, (CpsUpperNode) temp, "");
|
|
|
} else {
|
|
|
unc = new UpperNodeCanvas(model, controller, (CpsUpperNode) temp,
|
|
|
- ((UpperNodeCanvas) ((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
|
|
|
+ ((UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
.getComponent(0)).path + " -> ");
|
|
|
}
|
|
|
unc.setShowedInformation(canvas.getShowedInformation());
|
|
@@ -2091,11 +2158,17 @@ public class GUI<E> implements CategoryListener {
|
|
|
// check if tab already open for clicked NodeOfNode
|
|
|
boolean dupl = false;
|
|
|
for (int i = 4; i < tabbedPane.getTabCount() && dupl == false; i++) {
|
|
|
- if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport().getComponent(0)).upperNode
|
|
|
- .getId() == temp.getId()) {
|
|
|
+ if (tabbedPane.getComponentAt(i) != null && ((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i))
|
|
|
+ .getViewport().getComponent(0)).upperNode.getId() == temp.getId()) {
|
|
|
dupl = true;
|
|
|
tabbedPane.setSelectedComponent(tabbedPane.getComponentAt(i));
|
|
|
}
|
|
|
+ if (!initSplit && tabbedPane2.getComponentAt(i) != null
|
|
|
+ && ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getComponentAt(i)).getViewport()
|
|
|
+ .getComponent(0)).upperNode.getId() == temp.getId()) {
|
|
|
+ dupl = true;
|
|
|
+ tabbedPane2.setSelectedComponent(tabbedPane2.getComponentAt(i));
|
|
|
+ }
|
|
|
}
|
|
|
if (!dupl) {
|
|
|
unc.setBorder(null);
|
|
@@ -2108,7 +2181,13 @@ public class GUI<E> implements CategoryListener {
|
|
|
unitGraph.empty();
|
|
|
holonEleNamesDisplayed = Languages.getLanguage()[25];
|
|
|
elementGraph.setText(holonEleNamesDisplayed);
|
|
|
- temp = ((UpperNodeCanvas) ((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
|
|
|
+ JTabbedPane tabTemp;
|
|
|
+ if (tabbedPane.getMousePosition() != null) {
|
|
|
+ tabTemp = tabbedPane;
|
|
|
+ } else {
|
|
|
+ tabTemp = tabbedPane2;
|
|
|
+ }
|
|
|
+ temp = ((UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
.getComponent(0)).tempCps;
|
|
|
if (doubleClick() && MouseEvent.BUTTON3 != e.getButton() && temp instanceof CpsUpperNode) {
|
|
|
openNewUpperNodeTab();
|
|
@@ -2122,9 +2201,32 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
JScrollPane sp = new JScrollPane(unc);
|
|
|
sp.setBorder(null);
|
|
|
- tabbedPane.add(temp.getName(), sp);
|
|
|
- tabbedPane.setSelectedComponent(sp);
|
|
|
- tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, new ButtonTabComponent(tabbedPane));
|
|
|
+ if (tabTemp == tabbedPane) {
|
|
|
+ tabbedPane.add(temp.getName(), sp);
|
|
|
+ tabbedPane.setSelectedComponent(sp);
|
|
|
+ tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1,
|
|
|
+ new ButtonTabComponent(tabbedPane, tabbedPane2));
|
|
|
+ if (!initSplit) {
|
|
|
+ tabbedPane2.add(temp.getName(), null);
|
|
|
+ // tabbedPane2.setTabComponentAt(tabbedPane2.getTabCount() -
|
|
|
+ // 1,
|
|
|
+ // new ButtonTabComponent(tabbedPane, tabbedPane2));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tabbedPane2.add(temp.getName(), sp);
|
|
|
+ Component tempC = tabbedPane2.getSelectedComponent();
|
|
|
+ tabbedPane2.setComponentAt(tabbedPane2.getSelectedIndex(), null);
|
|
|
+ tabbedPane.setComponentAt(tabbedPane2.getSelectedIndex(), tempC);
|
|
|
+ tabbedPane2.setSelectedComponent(sp);
|
|
|
+
|
|
|
+ // tabbedPane2.setTabComponentAt(tabbedPane2.getTabCount() - 1,
|
|
|
+ // new ButtonTabComponent(tabbedPane, tabbedPane2));
|
|
|
+
|
|
|
+ tabbedPane.add(temp.getName(), null);
|
|
|
+ tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1,
|
|
|
+ new ButtonTabComponent(tabbedPane, tabbedPane2));
|
|
|
+ }
|
|
|
+
|
|
|
temp = null;
|
|
|
}
|
|
|
}
|