Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/listener/DoubleClickListener.java')
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/listener/DoubleClickListener.java244
1 files changed, 122 insertions, 122 deletions
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/listener/DoubleClickListener.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/listener/DoubleClickListener.java
index e08f794eb21..3b2f5c0b1c4 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/listener/DoubleClickListener.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/listener/DoubleClickListener.java
@@ -1,122 +1,122 @@
-/*****************************************************************************
- * Copyright (c) 2010, 2014 CEA LIST, Christian W. Damus, 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Christian W. Damus - bug 450235
- *
- *****************************************************************************/
-package org.eclipse.papyrus.views.modelexplorer.listener;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.views.modelexplorer.Activator;
-import org.eclipse.papyrus.views.modelexplorer.Messages;
-
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-
-/**
- * this class is a listener in charge to manage double on element of the model explorer
- *
- */
-public class DoubleClickListener implements IDoubleClickListener {
-
- private final Supplier<ServicesRegistry> servicesRegistry;
-
- /**
- * Initializes me with a fixed service registry.
- *
- * @param servicesRegistry a service registry
- *
- * @deprecated The editor that the Model Explorer views can change dynamically, replacing its service registry. Use the {@link #DoubleClickListener(Supplier)} constructor instead to account for the variability of the registry.
- */
- @Deprecated
- public DoubleClickListener(ServicesRegistry servicesRegistry) {
- this(Suppliers.ofInstance(servicesRegistry));
- }
-
- /**
- * Initializes me with a variable service registry.
- *
- * @param servicesRegistrySupplier a supplier of a dynamically variable service registry
- */
- public DoubleClickListener(Supplier<ServicesRegistry> servicesRegistrySupplier) {
- this.servicesRegistry = servicesRegistrySupplier;
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
- *
- */
- public void doubleClick(DoubleClickEvent event) {
- ISelection selection = event.getSelection();
- final IPageManager pageManager;
- // get the page Manager
- try {
- pageManager = ServiceUtils.getInstance().getIPageManager(servicesRegistry.get());
- } catch (Exception e) {
- Activator.log.error(Messages.DoubleClickListener_Error_NoLoadManagerToOpen, e);
- return;
- }
-
- if (pageManager != null) {
- if (selection instanceof IStructuredSelection) {
- Iterator<?> iter = ((IStructuredSelection) selection).iterator();
- final List<EObject> pagesToOpen = new LinkedList<EObject>();
- EObject pageToSelect = null;
- while (iter.hasNext()) {
- Object currentObject = iter.next();
- EObject diag = EMFHelper.getEObject(currentObject);
-
- if (isPage(diag, pageManager)) {
- // Note that Diagram migration is triggered by the Diagram Editor.
- // Try to open the diagram, even if it is currently invalid. The editor might be able to repair it
- if (pageManager.isOpen(diag)) {
- pageToSelect = diag;
- } else {
- pagesToOpen.add(diag);
- }
- }
- }
-
- if (!pagesToOpen.isEmpty()) {
- for (EObject page : pagesToOpen) {
- pageManager.openPage(page);
- }
- } else if (pageToSelect != null) {
- pageManager.selectPage(pageToSelect);
- }
- }
-
- }
- }
-
- protected boolean isPage(EObject element, IPageManager pageManager) {
- if (pageManager.allPages().contains(element)) {
- return true;
- }
-
- Object openable = Platform.getAdapterManager().getAdapter(element, IOpenable.class);
- return openable instanceof IOpenable;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 CEA LIST, Christian W. Damus, 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 450235
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.views.modelexplorer.listener;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.views.modelexplorer.Activator;
+import org.eclipse.papyrus.views.modelexplorer.Messages;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+
+/**
+ * this class is a listener in charge to manage double on element of the model explorer
+ *
+ */
+public class DoubleClickListener implements IDoubleClickListener {
+
+ private final Supplier<ServicesRegistry> servicesRegistry;
+
+ /**
+ * Initializes me with a fixed service registry.
+ *
+ * @param servicesRegistry a service registry
+ *
+ * @deprecated The editor that the Model Explorer views can change dynamically, replacing its service registry. Use the {@link #DoubleClickListener(Supplier)} constructor instead to account for the variability of the registry.
+ */
+ @Deprecated
+ public DoubleClickListener(ServicesRegistry servicesRegistry) {
+ this(Suppliers.ofInstance(servicesRegistry));
+ }
+
+ /**
+ * Initializes me with a variable service registry.
+ *
+ * @param servicesRegistrySupplier a supplier of a dynamically variable service registry
+ */
+ public DoubleClickListener(Supplier<ServicesRegistry> servicesRegistrySupplier) {
+ this.servicesRegistry = servicesRegistrySupplier;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+ *
+ */
+ public void doubleClick(DoubleClickEvent event) {
+ ISelection selection = event.getSelection();
+ final IPageManager pageManager;
+ // get the page Manager
+ try {
+ pageManager = ServiceUtils.getInstance().getIPageManager(servicesRegistry.get());
+ } catch (Exception e) {
+ Activator.log.error(Messages.DoubleClickListener_Error_NoLoadManagerToOpen, e);
+ return;
+ }
+
+ if (pageManager != null) {
+ if (selection instanceof IStructuredSelection) {
+ Iterator<?> iter = ((IStructuredSelection) selection).iterator();
+ final List<EObject> pagesToOpen = new LinkedList<EObject>();
+ EObject pageToSelect = null;
+ while (iter.hasNext()) {
+ Object currentObject = iter.next();
+ EObject diag = EMFHelper.getEObject(currentObject);
+
+ if (isPage(diag, pageManager)) {
+ // Note that Diagram migration is triggered by the Diagram Editor.
+ // Try to open the diagram, even if it is currently invalid. The editor might be able to repair it
+ if (pageManager.isOpen(diag)) {
+ pageToSelect = diag;
+ } else {
+ pagesToOpen.add(diag);
+ }
+ }
+ }
+
+ if (!pagesToOpen.isEmpty()) {
+ for (EObject page : pagesToOpen) {
+ pageManager.openPage(page);
+ }
+ } else if (pageToSelect != null) {
+ pageManager.selectPage(pageToSelect);
+ }
+ }
+
+ }
+ }
+
+ protected boolean isPage(EObject element, IPageManager pageManager) {
+ if (pageManager.allPages().contains(element)) {
+ return true;
+ }
+
+ Object openable = Platform.getAdapterManager().getAdapter(element, IOpenable.class);
+ return openable instanceof IOpenable;
+ }
+}

Back to the top