Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2016-01-18 14:12:24 +0000
committerFlorian Noyrit2016-01-18 14:12:24 +0000
commitad0a72a237393069314cbcb9bbc41239d8b0c494 (patch)
treed86889b09e277aebd0290d1d9de318022b1273bf /plugins/developer
parent61f321dd8332cb67ea4db82277215b1582c6261f (diff)
downloadorg.eclipse.papyrus-ad0a72a237393069314cbcb9bbc41239d8b0c494.tar.gz
org.eclipse.papyrus-ad0a72a237393069314cbcb9bbc41239d8b0c494.tar.xz
org.eclipse.papyrus-ad0a72a237393069314cbcb9bbc41239d8b0c494.zip
Improve RegistredElementTypesView in developer tools for the
ElementTypesConfiguration Framework Change-Id: If27996559e93bdb038f25c5e128eb1cfe0167dd0
Diffstat (limited to 'plugins/developer')
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesDetailsContentProvider.java72
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesDetailsLabelProvider.java39
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/AdvicesComparator.java35
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/view/RegistredElementTypesView.java31
4 files changed, 157 insertions, 20 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesDetailsContentProvider.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesDetailsContentProvider.java
index 6967a5d9b2a..10a3a094a65 100644
--- a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesDetailsContentProvider.java
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesDetailsContentProvider.java
@@ -13,32 +13,55 @@
package org.eclipse.papyrus.elementtypesconfigurations.developer.providers;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
import org.eclipse.gmf.runtime.emf.type.core.SpecializationType;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
+import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.elementtypesconfigurations.developer.utils.AdvicesComparator;
-public class ElementTypesDetailsContentProvider implements IStructuredContentProvider {
+public class ElementTypesDetailsContentProvider implements ITreeContentProvider {
+ /**
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ *
+ */
@Override
public void dispose() {
// TODO Auto-generated method stub
}
+ /**
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ *
+ * @param viewer
+ * @param oldInput
+ * @param newInput
+ */
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// TODO Auto-generated method stub
}
+ /**
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
+ *
+ * @param inputElement
+ * @return
+ */
@Override
public Object[] getElements(Object inputElement) {
- ArrayList<String> result = new ArrayList<String>();
+ ArrayList<Object> result = new ArrayList<Object>();
if (inputElement instanceof IElementType) {
if (inputElement instanceof IHintedType) {
result.add("Semantic Hint: " + ((IHintedType) inputElement).getSemanticHint());
@@ -81,7 +104,50 @@ public class ElementTypesDetailsContentProvider implements IStructuredContentPro
}
result.add("Display Name: " + ((IElementType) inputElement).getDisplayName());
+ IEditHelperAdvice[] advices = ElementTypeRegistry.getInstance().getEditHelperAdvice(((IElementType) inputElement));
+ result.add(Arrays.asList(advices));
}
return result.toArray();
}
+
+ /**
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ *
+ * @param parentElement
+ * @return
+ */
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof List<?>) {
+ Collections.sort((List<IEditHelperAdvice>) parentElement, new AdvicesComparator());
+ return ((List<?>) parentElement).toArray();
+ }
+
+ return Collections.emptyList().toArray();
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ @Override
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ @Override
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length == 0 ? false : true;
+ }
+
+
}
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesDetailsLabelProvider.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesDetailsLabelProvider.java
new file mode 100644
index 00000000000..2736e4dddc8
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesDetailsLabelProvider.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.elementtypesconfigurations.developer.providers;
+
+import java.util.List;
+
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
+import org.eclipse.swt.graphics.Image;
+
+public class ElementTypesDetailsLabelProvider extends org.eclipse.jface.viewers.LabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ String result = "";
+ if (element instanceof String) {
+ result += element;
+ } else if (element instanceof List<?>) {
+ result += "Advices: ";
+ } else if (element instanceof IEditHelperAdvice) {
+ result += element;
+ }
+ return result;
+ }
+}
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/AdvicesComparator.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/AdvicesComparator.java
new file mode 100644
index 00000000000..9df1c0773d7
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/AdvicesComparator.java
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.elementtypesconfigurations.developer.utils;
+
+import java.util.Comparator;
+
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
+
+
+public class AdvicesComparator implements Comparator<IEditHelperAdvice> {
+
+ /**
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ *
+ * @param arg0
+ * @param arg1
+ * @return
+ */
+ @Override
+ public int compare(IEditHelperAdvice o1, IEditHelperAdvice o2) {
+ return o1.toString().compareTo(o2.toString());
+ }
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/view/RegistredElementTypesView.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/view/RegistredElementTypesView.java
index 2a05456768f..ab2398860cc 100644
--- a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/view/RegistredElementTypesView.java
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/view/RegistredElementTypesView.java
@@ -17,11 +17,10 @@ import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.papyrus.elementtypesconfigurations.developer.providers.ElementTypesContentProvider;
import org.eclipse.papyrus.elementtypesconfigurations.developer.providers.ElementTypesDetailsContentProvider;
+import org.eclipse.papyrus.elementtypesconfigurations.developer.providers.ElementTypesDetailsLabelProvider;
import org.eclipse.papyrus.elementtypesconfigurations.developer.providers.ElementTypesLabelProvider;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.services.edit.internal.context.TypeContext;
@@ -40,9 +39,9 @@ import org.eclipse.ui.part.ViewPart;
public class RegistredElementTypesView extends ViewPart {
IClientContext context = null;
- ListViewer listViewer = null;
+ FilteredTree detailsFilteredTree = null;
SashForm sash = null;
- FilteredTree tree = null;
+ FilteredTree elementTypesFilteredTree = null;
public RegistredElementTypesView() {
try {
@@ -62,31 +61,29 @@ public class RegistredElementTypesView extends ViewPart {
@Override
public void mouseUp(MouseEvent e) {
IElementType[] elementTypes = ElementTypeRegistry.getInstance().getElementTypes(context);
- tree.getViewer().setInput(elementTypes);
+ elementTypesFilteredTree.getViewer().setInput(elementTypes);
}
});
sash = new SashForm(parent, SWT.HORIZONTAL);
sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- tree = new FilteredTree(sash, SWT.BORDER, new PatternFilter(), true);
- tree.getViewer().setLabelProvider(new ElementTypesLabelProvider());
- tree.getViewer().setContentProvider(new ElementTypesContentProvider());
- listViewer = new ListViewer(sash);
- listViewer.setLabelProvider(new LabelProvider());
- listViewer.setContentProvider(new ElementTypesDetailsContentProvider());
-
+ elementTypesFilteredTree = new FilteredTree(sash, SWT.BORDER, new PatternFilter(), true);
+ elementTypesFilteredTree.getViewer().setLabelProvider(new ElementTypesLabelProvider());
+ elementTypesFilteredTree.getViewer().setContentProvider(new ElementTypesContentProvider());
+ detailsFilteredTree = new FilteredTree(sash, SWT.BORDER, new PatternFilter(), true);
+ detailsFilteredTree.getViewer().setLabelProvider(new ElementTypesDetailsLabelProvider());
+ detailsFilteredTree.getViewer().setContentProvider(new ElementTypesDetailsContentProvider());
IElementType[] elementTypes = ElementTypeRegistry.getInstance().getElementTypes(context);
- tree.getViewer().setInput(elementTypes);
+ elementTypesFilteredTree.getViewer().setInput(elementTypes);
- tree.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
+ elementTypesFilteredTree.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
- if (event.getSelection() instanceof IStructuredSelection)
- {
- listViewer.setInput(((IStructuredSelection) event.getSelection()).getFirstElement());
+ if (event.getSelection() instanceof IStructuredSelection) {
+ detailsFilteredTree.getViewer().setInput(((IStructuredSelection) event.getSelection()).getFirstElement());
}
}

Back to the top