Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/actions/TogglePreviewAction.java')
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/actions/TogglePreviewAction.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/actions/TogglePreviewAction.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/actions/TogglePreviewAction.java
new file mode 100644
index 00000000000..621a14fa8f0
--- /dev/null
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/actions/TogglePreviewAction.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.customization.properties.editor.actions;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.customization.properties.Activator;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * An action to toggle the UIEditor Preview
+ *
+ * @author Camille Letavernier
+ */
+public class TogglePreviewAction extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ //System.out.println("Toggle");
+
+ event.getCommand().getState("org.eclipse.papyrus.customization.properties.previewstate"); //$NON-NLS-1$
+
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if(activePage == null) {
+ return null;
+ }
+
+ //System.out.println("ActivePage is " + activePage);
+
+ IViewReference viewReference = null;
+
+ for(IViewReference reference : activePage.getViewReferences()) {
+ if(reference.getId().equals(Activator.PREVIEW_ID)) {
+ viewReference = reference;
+ }
+ }
+
+ try {
+ if(viewReference == null) {
+ //System.out.println("Opening view");
+ activePage.showView(Activator.PREVIEW_ID);
+ } else {
+ //System.out.println("Closing view");
+ activePage.hideView((ViewPart)viewReference.getPart(false));
+ }
+ } catch (PartInitException ex) {
+ Activator.log.error(ex);
+ }
+
+ return null;
+ }
+
+
+}

Back to the top