Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/org.eclipse.papyrus.infra.extendedtypes.editor/src/org/eclipse/papyrus/infra/extendedtypes/presentation/CustomExtendedtypesEditor.java')
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes.editor/src/org/eclipse/papyrus/infra/extendedtypes/presentation/CustomExtendedtypesEditor.java99
1 files changed, 99 insertions, 0 deletions
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.editor/src/org/eclipse/papyrus/infra/extendedtypes/presentation/CustomExtendedtypesEditor.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.editor/src/org/eclipse/papyrus/infra/extendedtypes/presentation/CustomExtendedtypesEditor.java
new file mode 100644
index 00000000000..8297da543d0
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.editor/src/org/eclipse/papyrus/infra/extendedtypes/presentation/CustomExtendedtypesEditor.java
@@ -0,0 +1,99 @@
+/**
+ * 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:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.infra.extendedtypes.presentation;
+
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
+import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+import org.eclipse.papyrus.infra.extendedtypes.invariantcontainerconfiguration.util.InvariantContainerConfigurationAdapterFactory;
+import org.eclipse.papyrus.infra.extendedtypes.invariantsemantictypeconfiguration.provider.CustomInvariantSemanticTypeConfigurationItemProviderAdapterFactory;
+import org.eclipse.papyrus.infra.extendedtypes.provider.CustomExtendedtypesItemProviderAdapterFactory;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory;
+
+/**
+ * Custom editor to support metamodel extensions
+ */
+public class CustomExtendedtypesEditor extends ExtendedtypesEditor {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void initializeEditingDomain() {
+ // Create an adapter factory that yields item providers.
+ //
+ adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new CustomExtendedtypesItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new CustomInvariantSemanticTypeConfigurationItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new InvariantContainerConfigurationAdapterFactory());
+ adapterFactory.addAdapterFactory(new EcoreItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new UMLItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
+
+ // Create the command stack that will notify this editor as commands are
+ // executed.
+ //
+ BasicCommandStack commandStack = new BasicCommandStack();
+
+ // Add a listener to set the most recent command's affected objects to
+ // be the selection of the viewer with focus.
+ //
+ commandStack.addCommandStackListener(new CommandStackListener() {
+ public void commandStackChanged(final EventObject event) {
+ getContainer().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+
+ // Try to select the affected objects.
+ //
+ Command mostRecentCommand = ((CommandStack) event
+ .getSource()).getMostRecentCommand();
+ if (mostRecentCommand != null) {
+ setSelectionToViewer(mostRecentCommand
+ .getAffectedObjects());
+ }
+ for (Iterator<PropertySheetPage> i = propertySheetPages
+ .iterator(); i.hasNext();) {
+ PropertySheetPage propertySheetPage = i.next();
+ if (propertySheetPage.getControl().isDisposed()) {
+ i.remove();
+ } else {
+ propertySheetPage.refresh();
+ }
+ }
+ }
+ });
+ }
+ });
+
+ // Create the editing domain with a special command stack.
+ //
+ editingDomain = new AdapterFactoryEditingDomain(adapterFactory,
+ commandStack, new HashMap<Resource, Boolean>());
+ }
+}

Back to the top