Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.ui/src/org/eclipse/papyrus/qompass/designer/ui/dialogs/PortLabelProvider.java')
-rw-r--r--extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.ui/src/org/eclipse/papyrus/qompass/designer/ui/dialogs/PortLabelProvider.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.ui/src/org/eclipse/papyrus/qompass/designer/ui/dialogs/PortLabelProvider.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.ui/src/org/eclipse/papyrus/qompass/designer/ui/dialogs/PortLabelProvider.java
new file mode 100644
index 00000000000..6e61151dcaa
--- /dev/null
+++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.ui/src/org/eclipse/papyrus/qompass/designer/ui/dialogs/PortLabelProvider.java
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ansgar Radermacher ansgar.radermacher@cea.fr
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.qompass.designer.ui.dialogs;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.Port;
+
+/**
+ * A label provider for either UML or FCM ports
+ *
+ * @author ansgar
+ *
+ */
+public class PortLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ /**
+ * small helper function: simply retrieval of port (element might be either a port or an FCM port)
+ *
+ * @param element
+ * @return
+ */
+ private Port getUMLport(Object element) {
+ if(element instanceof org.eclipse.papyrus.FCM.Port) {
+ org.eclipse.papyrus.FCM.Port port = (org.eclipse.papyrus.FCM.Port)element;
+ if(port != null) {
+ return port.getBase_Port();
+ }
+ } else if(element instanceof Port) {
+ return (Port)element;
+ }
+ return null;
+ }
+
+ public String getText(Object element) {
+ Port umlPort = getUMLport(element);
+ if(umlPort != null) {
+ return umlPort.getName();
+ }
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ if(columnIndex == 0) {
+ return getText(element);
+ } else if(columnIndex == 1) {
+ Port umlPort = getUMLport(element);
+ if(umlPort != null) {
+ return umlPort.getType().getName();
+ }
+ }
+ return "";
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+};

Back to the top