diff --git a/src/main/java/ui/ActionPerformer.java b/src/main/java/ui/ActionPerformer.java index a7c463b49cb155fa942cb2496ff37f843dad3f0c..c736b98e075a7d191d2544ca1b34f1e06a19d62d 100644 --- a/src/main/java/ui/ActionPerformer.java +++ b/src/main/java/ui/ActionPerformer.java @@ -953,6 +953,8 @@ public class ActionPerformer { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ELN_INDEPENDENT_VOLTAGE_SOURCE); } else if (command.equals(mgui.actions[TGUIAction.ELN_INDEPENDENT_CURRENT_SOURCE].getActionCommand())){ mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ELN_INDEPENDENT_CURRENT_SOURCE); + } else if (command.equals(mgui.actions[TGUIAction.ELN_NODE_REF].getActionCommand())){ + mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ELN_NODE_REF); // Attack Tree Diagrams } else if (command.equals(mgui.actions[TGUIAction.ATD_BLOCK].getActionCommand())) { diff --git a/src/main/java/ui/TGComponentManager.java b/src/main/java/ui/TGComponentManager.java index 5f95fe9c2fbe1839ac0e4e773885ec0baba64dbc..80ee7c7b3b5839c8fa76087baaaac0d76ce7ff74 100644 --- a/src/main/java/ui/TGComponentManager.java +++ b/src/main/java/ui/TGComponentManager.java @@ -355,6 +355,7 @@ public class TGComponentManager { public static final int ELN_TRANSMISSION_LINE = 1617; public static final int ELN_INDEPENDENT_VOLTAGE_SOURCE = 1618; public static final int ELN_INDEPENDENT_CURRENT_SOURCE = 1619; + public static final int ELN_NODE_REF = 1620; // SMD diagram public static final int PROSMD_START_STATE = 2000; @@ -1301,6 +1302,9 @@ public class TGComponentManager { case ELN_INDEPENDENT_CURRENT_SOURCE: tgc = new ELNComponentIndependentCurrentSource(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; + case ELN_NODE_REF: + tgc = new ELNComponentNodeRef(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; // Communication patterns + SD case TMLCP_CHOICE: tgc = new TMLCPChoice(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); @@ -1719,6 +1723,8 @@ public class TGComponentManager { return ELN_INDEPENDENT_VOLTAGE_SOURCE; } else if (tgc instanceof ELNComponentIndependentCurrentSource) { return ELN_INDEPENDENT_CURRENT_SOURCE; + } else if (tgc instanceof ELNComponentNodeRef) { + return ELN_NODE_REF; // Others } else if (tgc instanceof TADDeterministicDelay) { diff --git a/src/main/java/ui/TGConnectingPointWidthHeight.java b/src/main/java/ui/TGConnectingPointWidthHeight.java index 2aa78f4151b7062f88521b0de266175b6a880d71..2aa5eab134416a667546a6080ab652674c219fb0 100755 --- a/src/main/java/ui/TGConnectingPointWidthHeight.java +++ b/src/main/java/ui/TGConnectingPointWidthHeight.java @@ -75,12 +75,4 @@ public class TGConnectingPointWidthHeight extends TGConnectingPoint{ public void setH(double _h) { h = _h; } - - public double getW() { - return w; - } - - public double getH() { - return h; - } } // Class diff --git a/src/main/java/ui/TGUIAction.java b/src/main/java/ui/TGUIAction.java index 58b8b19922ebb8c43f0d464088add4ca4a9d404c..b2197e4670f2fed309bdd4a653d0ba5d98d0315c 100644 --- a/src/main/java/ui/TGUIAction.java +++ b/src/main/java/ui/TGUIAction.java @@ -297,6 +297,7 @@ public class TGUIAction extends AbstractAction { public static final int ELN_TRANSMISSION_LINE = 490; public static final int ELN_INDEPENDENT_VOLTAGE_SOURCE = 491; public static final int ELN_INDEPENDENT_CURRENT_SOURCE = 492; + public static final int ELN_NODE_REF = 494; public static final int EBRDD_EDIT = 271; public static final int EBRDD_CONNECTOR = 272; @@ -651,7 +652,7 @@ public class TGUIAction extends AbstractAction { public static final int MOVE_ENABLED = 463; public static final int FIRST_DIAGRAM = 464; - public static final int NB_ACTION = 494; + public static final int NB_ACTION = 495; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -1131,7 +1132,8 @@ public class TGUIAction extends AbstractAction { actions[ELN_TRANSMISSION_LINE] = new TAction("eln-transmission-line", "Add a transmission line", IconManager.imgic8016, IconManager.imgic8016, "Transmission line", "Add a transmission line to the currently opened ELN Diagram", 0); actions[ELN_INDEPENDENT_VOLTAGE_SOURCE] = new TAction("eln-vsource", "Add a independent voltage source", IconManager.imgic8017, IconManager.imgic8017, "Independent voltage source", "Add a independent voltage source to the currently opened ELN Diagram", 0); actions[ELN_INDEPENDENT_CURRENT_SOURCE] = new TAction("eln-isource", "Add a independent current source", IconManager.imgic8018, IconManager.imgic8018, "Independent current source", "Add a independent current source to the currently opened ELN Diagram", 0); - + actions[ELN_NODE_REF] = new TAction("eln-node-ref", "Add a reference node", IconManager.imgic8019, IconManager.imgic8019, "Reference node", "Add a reference node to the currently opened ELN Diagram", 0); + //ProActive State Machine Diagram actions[PROSMD_EDIT] = new TAction("edit-prosmd-diagram", "Edit ProActive state machine diagram", IconManager.imgic100, IconManager.imgic101, "Edit ProActive state machine diagram", "Make it possible to edit the currently opened ProActive state machine diagram", 0); actions[PROSMD_START] = new TAction("add-prosmd-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened ProActive state machine diagram", 0); diff --git a/src/main/java/ui/eln/ELNConnector.java b/src/main/java/ui/eln/ELNConnector.java index 51c09b570b45071e4f5955d619cdabeb23f74fa1..d7fb205cc581b47e2393e3b281aa94b91079c5b0 100644 --- a/src/main/java/ui/eln/ELNConnector.java +++ b/src/main/java/ui/eln/ELNConnector.java @@ -77,9 +77,17 @@ public class ELNConnector extends TGConnector implements ScalableTGComponent { protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2) { int cz = (int) (tdp.getZoom() * c); - g.fillOval(x2 - (cz / 2), y2 - (cz / 2), cz, cz); - g.fillOval(x1 - (cz / 2), y1 - (cz / 2), cz, cz); - g.drawLine(x1, y1, x2, y2); + if (p1.getName().equals("")) { + g.fillOval(x2 - (cz / 2), y2 - (cz / 2), cz, cz); + g.drawLine(x1, y1, x2, y2); + } else if (p2.getName().equals("")) { + g.fillOval(x1 - (cz / 2), y1 - (cz / 2), cz, cz); + g.drawLine(x1, y1, x2, y2); + } else { + g.fillOval(x2 - (cz / 2), y2 - (cz / 2), cz, cz); + g.fillOval(x1 - (cz / 2), y1 - (cz / 2), cz, cz); + g.drawLine(x1, y1, x2, y2); + } } public void rescale(double scaleFactor){ @@ -102,4 +110,4 @@ public class ELNConnector extends TGConnector implements ScalableTGComponent { public int getType() { return TGComponentManager.ELN_CONNECTOR; } -} \ No newline at end of file +} diff --git a/src/main/java/ui/eln/ELNDiagramToolBar.java b/src/main/java/ui/eln/ELNDiagramToolBar.java index 3316775d3e99369c7d5a67286ba49b9a42349bd0..020f91dacda317522657f2c99ff308e026a9662b 100644 --- a/src/main/java/ui/eln/ELNDiagramToolBar.java +++ b/src/main/java/ui/eln/ELNDiagramToolBar.java @@ -67,6 +67,7 @@ public class ELNDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ELN_EDIT].setEnabled(b); mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); + mgui.actions[TGUIAction.ELN_CONNECTOR].setEnabled(b); mgui.actions[TGUIAction.ELN_RESISTOR].setEnabled(b); mgui.actions[TGUIAction.ELN_CAPACITOR].setEnabled(b); mgui.actions[TGUIAction.ELN_INDUCTOR].setEnabled(b); @@ -76,6 +77,7 @@ public class ELNDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ELN_TRANSMISSION_LINE].setEnabled(b); mgui.actions[TGUIAction.ELN_INDEPENDENT_VOLTAGE_SOURCE].setEnabled(b); mgui.actions[TGUIAction.ELN_INDEPENDENT_CURRENT_SOURCE].setEnabled(b); + mgui.actions[TGUIAction.ELN_NODE_REF].setEnabled(b); mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); @@ -122,5 +124,14 @@ public class ELNDiagramToolBar extends TToolBar { button = this.add(mgui.actions[TGUIAction.ELN_INDEPENDENT_CURRENT_SOURCE]); button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.ELN_NODE_REF]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.ELN_CONNECTOR]); + button.addMouseListener(mgui.mouseHandler); } } + diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java b/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java new file mode 100644 index 0000000000000000000000000000000000000000..58690462b61d89bf1c9a65780d98c7230cb8fac9 --- /dev/null +++ b/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java @@ -0,0 +1,436 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package ui.eln.sca_eln; + +import myutil.GraphicLib; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import ui.*; +import ui.eln.ELNConnectingPoint; +import ui.window.JDialogELNComponentNodeRef; +import ui.window.JDialogELNComponentResistor; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Class ELNComponentNodeRef Reference node to be used in ELN diagrams Creation: + * 27/06/2018 + * + * @version 1.0 27/06/2018 + * @author Irina Kit Yan LEE + */ + +public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implements ActionListener { + protected Color myColor; + protected int orientation; + private int maxFontSize = 14; + private int minFontSize = 4; + private int currentFontSize = -1; + + private int textX = 15; + private double dtextX = 0.0; + protected int decPoint = 3; + + private int position = 0; + private boolean fv = false, fh = false; + private int old; + private boolean first; + + public ELNComponentNodeRef(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, + TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + initScaling(40, 40); + + dtextX = textX * oldScaleFactor; + textX = (int) dtextX; + dtextX = dtextX - textX; + + minWidth = 1; + minHeight = 1; + + initConnectingPoint(1); + + addTGConnectingPointsComment(); + + moveable = true; + editable = true; + removable = true; + userResizable = false; + value = tdp.findELNComponentName("gnd"); + + old = width; + width = height; + height = old; + } + + public void initConnectingPoint(int nb) { + nbConnectingPoint = nb; + connectingPoint = new TGConnectingPoint[nb]; + connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 0.5, 0.0, ""); + } + + public Color getMyColor() { + return myColor; + } + + public void internalDrawing(Graphics g) { + Font f = g.getFont(); + Font fold = f; + + if (this.rescaled && !this.tdp.isScaled()) { + this.rescaled = false; + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); + f = f.deriveFont((float) maxCurrentFontSize); + + while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { + if (g.getFontMetrics().stringWidth(value) < (width - (2 * textX))) { + break; + } + maxCurrentFontSize--; + f = f.deriveFont((float) maxCurrentFontSize); + } + + if (this.currentFontSize < this.minFontSize * this.tdp.getZoom()) { + maxCurrentFontSize++; + f = f.deriveFont((float) maxCurrentFontSize); + } + g.setFont(f); + this.currentFontSize = maxCurrentFontSize; + } else { + f = f.deriveFont(this.currentFontSize); + } + + Color c = g.getColor(); + + if (position == 0) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int w = g.getFontMetrics().stringWidth(value); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(value, x + (width - w) / 2, y - height / 2); + g.setFont(f.deriveFont(Font.PLAIN)); + + if (fv == true) { + rotateBottom(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + } else { + rotateTop(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + } + } else if (position == 1) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int w = g.getFontMetrics().stringWidth(value); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(value, x + (width - w) / 2, y - height / 2); + g.setFont(f.deriveFont(Font.PLAIN)); + + if (fh == true) { + rotateLeft(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); + } else { + rotateRight(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); + } + } else if (position == 2) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int w = g.getFontMetrics().stringWidth(value); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(value, x + (width - w) / 2, y - height / 2); + g.setFont(f.deriveFont(Font.PLAIN)); + + if (fv == true) { + rotateTop(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + } else { + rotateBottom(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + } + } else if (position == 3) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int w = g.getFontMetrics().stringWidth(value); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(value, x + (width - w) / 2, y - height / 2); + g.setFont(f.deriveFont(Font.PLAIN)); + + if (fh == true) { + rotateRight(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); + } else { + rotateLeft(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); + } + } + g.setColor(c); + g.setFont(fold); + } + + private void rotateTop(Graphics g) { + int[] ptx = { x + width / 2, x + width / 2, x, x, x + width, x + width, x + width / 2 }; + int[] pty = { y, y + height / 2, y + height / 2, y + height, y + height, y + height / 2, y + height / 2 }; + g.drawPolygon(ptx, pty, 7); + g.fillPolygon(ptx, pty, 7); + } + + private void rotateBottom(Graphics g) { + int[] ptx = { x + width / 2, x + width / 2, x, x, x + width, x + width, x + width / 2 }; + int[] pty = { y + height, y + height / 2, y + height / 2, y, y, y + height / 2, y + height / 2 }; + g.drawPolygon(ptx, pty, 7); + g.fillPolygon(ptx, pty, 7); + } + + private void rotateRight(Graphics g) { + int[] ptx = { x + width, x + width / 2, x + width / 2, x, x, x + width / 2, x + width / 2 }; + int[] pty = { y + height / 2, y + height / 2, y, y, y + height, y + height, y + height / 2 }; + g.drawPolygon(ptx, pty, 7); + g.fillPolygon(ptx, pty, 7); + } + + private void rotateLeft(Graphics g) { + int[] ptx = { x, x + width / 2, x + width / 2, x + width, x + width, x + width / 2, x + width / 2 }; + int[] pty = { y + height / 2, y + height / 2, y, y, y + height, y + height, y + height / 2 }; + g.drawPolygon(ptx, pty, 7); + g.fillPolygon(ptx, pty, 7); + } + + public TGComponent isOnOnlyMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public int getType() { + return TGComponentManager.ELN_NODE_REF; + } + + public boolean editOndoubleClick(JFrame frame) { + JDialogELNComponentNodeRef jde = new JDialogELNComponentNodeRef(this); + jde.setVisible(true); + return true; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<attributes position=\"" + position); + sb.append("\" width=\"" + width); + sb.append("\" height=\"" + height); + sb.append("\" fv=\"" + fv); + sb.append("\" fh=\"" + fh); + sb.append("\" first=\"" + first + "\""); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { + try { + NodeList nli; + Node n1, n2; + Element elt; + + int position, width, height; + boolean fv, fh, first; + + for (int i = 0; i < nl.getLength(); i++) { + n1 = nl.item(i); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for (int j = 0; j < nli.getLength(); j++) { + n2 = nli.item(j); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("attributes")) { + position = Integer.parseInt(elt.getAttribute("position")); + width = Integer.parseInt(elt.getAttribute("width")); + height = Integer.parseInt(elt.getAttribute("height")); + fv = Boolean.parseBoolean(elt.getAttribute("fv")); + fh = Boolean.parseBoolean(elt.getAttribute("fh")); + first = Boolean.parseBoolean(elt.getAttribute("first")); + setPosition(position); + this.width = width; + this.height = height; + setFv(fv); + setFh(fh); + setFirst(first); + } + } + } + } + } + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { + componentMenu.addSeparator(); + + JMenuItem rotateright = new JMenuItem("Rotate right 90°"); + rotateright.addActionListener(this); + componentMenu.add(rotateright); + + JMenuItem rotateleft = new JMenuItem("Rotate left 90°"); + rotateleft.addActionListener(this); + componentMenu.add(rotateleft); + + componentMenu.addSeparator(); + + JMenuItem rotatevertically = new JMenuItem("Flip vertically"); + rotatevertically.addActionListener(this); + componentMenu.add(rotatevertically); + + JMenuItem rotatehorizontally = new JMenuItem("Flip horizontally"); + rotatehorizontally.addActionListener(this); + componentMenu.add(rotatehorizontally); + } + + public void actionPerformed(ActionEvent e) { + fv = false; + fh = false; + if (e.getActionCommand().equals("Rotate right 90°")) { + position++; + position %= 4; + first = false; + } + if (e.getActionCommand().equals("Rotate left 90°")) { + position = position + 3; + position %= 4; + first = false; + } + if (e.getActionCommand().equals("Flip vertically")) { + if (fv == false) { + fv = true; + } else { + fv = false; + } + } + if (e.getActionCommand().equals("Flip horizontally")) { + if (fh == false) { + fh = true; + } else { + fh = false; + } + } + } + + public int getDefaultConnector() { + return TGComponentManager.ELN_CONNECTOR; + } + + public int getPosition() { + return position; + } + + public void setPosition(int position) { + this.position = position; + } + + public boolean isFv() { + return fv; + } + + public void setFv(boolean fv) { + this.fv = fv; + } + + public boolean isFh() { + return fh; + } + + public void setFh(boolean fh) { + this.fh = fh; + } + + public boolean isFirst() { + return first; + } + + public void setFirst(boolean first) { + this.first = first; + } +} diff --git a/src/main/java/ui/util/IconManager.java b/src/main/java/ui/util/IconManager.java index 0cc4c9ee26a18425b2115c52735c34ead9201e8c..28b8b62f0039a37f2057861812a2e2b88753631b 100755 --- a/src/main/java/ui/util/IconManager.java +++ b/src/main/java/ui/util/IconManager.java @@ -186,7 +186,7 @@ public class IconManager { public static ImageIcon imgic8000, imgic8001, imgic8002, imgic8003, imgic8004, imgic8005, imgic8006, imgic8007, imgic8008; // ELN - public static ImageIcon imgic8010, imgic8011, imgic8012, imgic8013, imgic8014, imgic8015, imgic8016, imgic8017, imgic8018; + public static ImageIcon imgic8010, imgic8011, imgic8012, imgic8013, imgic8014, imgic8015, imgic8016, imgic8017, imgic8018, imgic8019; //private static String icon7 = "turtle_large.gif"; private static String ttoolStringIcon = "starting_logo.gif"; @@ -683,6 +683,7 @@ public class IconManager { private static String icon8016 = "elntransmissionline.gif"; private static String icon8017 = "elnvsource.gif"; private static String icon8018 = "elnisource.gif"; + private static String icon8019 = "elnground.gif" public IconManager() { @@ -1190,6 +1191,7 @@ public class IconManager { imgic8016 = getIcon(icon8016); imgic8017 = getIcon(icon8017); imgic8018 = getIcon(icon8018); + imgic8019 = getIcon(icon8019); } } // Class diff --git a/src/main/java/ui/window/JDialogELNComponentNodeRef.java b/src/main/java/ui/window/JDialogELNComponentNodeRef.java new file mode 100644 index 0000000000000000000000000000000000000000..85e4380b1eb814d8e6b8e55de794b7576caa2f5b --- /dev/null +++ b/src/main/java/ui/window/JDialogELNComponentNodeRef.java @@ -0,0 +1,179 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package ui.window; + +import ui.eln.sca_eln.ELNComponentNodeRef; +import ui.util.IconManager; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.AbstractAction; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.KeyStroke; + +/** + * Class JDialogELNComponentNodeRef + * Dialog for managing of ELN reference node + * Creation: 29/06/2018 + * @version 1.0 29/06/2018 + * @author Irina Kit Yan LEE +*/ + +@SuppressWarnings("serial") + +public class JDialogELNComponentNodeRef extends JDialog implements ActionListener { + + /** Access to ActionPerformed **/ + private JTextField nameTextField; + + /** Parameters **/ + private ELNComponentNodeRef gnd; + + /** Constructor **/ + public JDialogELNComponentNodeRef(ELNComponentNodeRef _gnd) { + /** Set JDialog **/ + setTitle("Setting the reference node"); + setLocationRelativeTo(null); + setVisible(true); + setAlwaysOnTop(true); + setResizable(false); + + /** Parameters **/ + gnd = _gnd; + + getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); + getRootPane().getActionMap().put("close", new AbstractAction() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + + dialog(); + } + + public void dialog() { + /** JPanel **/ + JPanel mainPanel = new JPanel(new BorderLayout()); + this.add(mainPanel); + + JPanel attributesMainPanel = new JPanel(new GridLayout()); + mainPanel.add(attributesMainPanel, BorderLayout.NORTH); + + // Left Side + Box box = Box.createVerticalBox(); + box.setBorder(BorderFactory.createTitledBorder("Setting reference node attributes")); + + GridBagLayout gridBag = new GridBagLayout(); + GridBagConstraints constraints = new GridBagConstraints(); + JPanel boxPanel = new JPanel(); + boxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); + boxPanel.setLayout(gridBag); + + JLabel labelName = new JLabel("nm : "); + constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(labelName, constraints); + boxPanel.add(labelName); + + nameTextField = new JTextField(gnd.getValue().toString(), 10); // name not empty + constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(nameTextField, constraints); + boxPanel.add(nameTextField); + + box.add(boxPanel); // add border to box + attributesMainPanel.add(box); // add grid to grid + + // Down Side + JPanel downPanel = new JPanel(new FlowLayout()); + + JButton saveCloseButton = new JButton("Save and close"); + saveCloseButton.setIcon(IconManager.imgic25); + saveCloseButton.setActionCommand("Save_Close"); + saveCloseButton.addActionListener(this); + saveCloseButton.setPreferredSize(new Dimension(200, 30)); + downPanel.add(saveCloseButton); + + JButton cancelButton = new JButton("Cancel"); + cancelButton.setIcon(IconManager.imgic27); + cancelButton.setActionCommand("Cancel"); + cancelButton.addActionListener(this); + cancelButton.setPreferredSize(new Dimension(200, 30)); + downPanel.add(cancelButton); + + mainPanel.add(downPanel, BorderLayout.CENTER); + pack(); + this.getRootPane().setDefaultButton(saveCloseButton); + } + + public void actionPerformed(ActionEvent e) { + if ("Save_Close".equals(e.getActionCommand())) { + gnd.setValue(new String(nameTextField.getText())); + + this.dispose(); + } + + if ("Cancel".equals(e.getActionCommand())) { + this.dispose(); + } + } +} + diff --git a/src/main/resources/ui/util/elnground.gif b/src/main/resources/ui/util/elnground.gif new file mode 100644 index 0000000000000000000000000000000000000000..0c8df1962468c06409e45128b3ca5d3d3fb6222c Binary files /dev/null and b/src/main/resources/ui/util/elnground.gif differ