Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.emf.refactor.comrel/src/comrel/figures/OutputPortFigure.java')
-rw-r--r--org.eclipse.emf.refactor.comrel/src/comrel/figures/OutputPortFigure.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/org.eclipse.emf.refactor.comrel/src/comrel/figures/OutputPortFigure.java b/org.eclipse.emf.refactor.comrel/src/comrel/figures/OutputPortFigure.java
new file mode 100644
index 0000000..c8e4a49
--- /dev/null
+++ b/org.eclipse.emf.refactor.comrel/src/comrel/figures/OutputPortFigure.java
@@ -0,0 +1,63 @@
+package comrel.figures;
+
+import org.eclipse.draw2d.Ellipse;
+import org.eclipse.draw2d.Label;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+
+import comrel.OutputPort;
+
+public abstract class OutputPortFigure extends Ellipse{
+ private OutputPort port;
+ private Label portLabel;
+
+ public OutputPort getPort() {
+ return port;
+ }
+
+
+ public void setPort(OutputPort port) {
+ this.port = port;
+ this.port.setFigure(this);
+ updateFigure();
+ }
+
+ public void setLabel(String text){
+ if(portLabel == null) {
+ portLabel = new Label();
+ portLabel.setSize(this.getMinimumSize());
+ this.removeAll();
+ FontData fd = new FontData();
+ fd.setHeight(5);
+ fd.setStyle(SWT.NORMAL);
+ Font f = new Font(null, fd);
+
+ portLabel.setFont(f);
+ this.add(portLabel);
+ }
+ portLabel.setVisible(true);
+ portLabel.setEnabled(true);
+ portLabel.setText(text);
+ }
+
+ public Label getLabel() {
+ return portLabel;
+ }
+
+
+ public void updateFigure() {
+ if (port != null) {
+ String name = port.getName();
+ Class type = port.getType();
+ String typeName = "";
+ if(name == null) {
+ name = "";
+ }
+ if (type != null) {
+ typeName = type.getSimpleName();
+ }
+ setLabel(name + ":" + typeName);
+ }
+ }
+}

Back to the top