Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/part/UMLInitDiagramFileAction.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/part/UMLInitDiagramFileAction.java96
1 files changed, 96 insertions, 0 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/part/UMLInitDiagramFileAction.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/part/UMLInitDiagramFileAction.java
new file mode 100644
index 00000000000..6f300b56903
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/part/UMLInitDiagramFileAction.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2012 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
+ */
+package org.eclipse.papyrus.uml.diagram.timing.part;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.uml.diagram.timing.edit.parts.TimingDiagramEditPart;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * @generated
+ */
+@SuppressWarnings("all")
+// disable warnings on generated code
+public class UMLInitDiagramFileAction implements IObjectActionDelegate {
+
+ /**
+ * @generated
+ */
+ private IWorkbenchPart targetPart;
+
+ /**
+ * @generated
+ */
+ private URI domainModelURI;
+
+ /**
+ * @generated
+ */
+ public void setActivePart(final IAction action, final IWorkbenchPart targetPart) {
+ this.targetPart = targetPart;
+ }
+
+ /**
+ * @generated
+ */
+ public void selectionChanged(final IAction action, final ISelection selection) {
+ this.domainModelURI = null;
+ action.setEnabled(false);
+ if(selection instanceof IStructuredSelection == false || selection.isEmpty()) {
+ return;
+ }
+ final IFile file = (IFile)((IStructuredSelection)selection).getFirstElement();
+ this.domainModelURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
+ action.setEnabled(true);
+ }
+
+ /**
+ * @generated
+ */
+ private Shell getShell() {
+ return this.targetPart.getSite().getShell();
+ }
+
+ /**
+ * @generated
+ */
+ public void run(final IAction action) {
+ final TransactionalEditingDomain editingDomain = WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain();
+ final ResourceSet resourceSet = editingDomain.getResourceSet();
+ EObject diagramRoot = null;
+ try {
+ final Resource resource = resourceSet.getResource(this.domainModelURI, true);
+ diagramRoot = resource.getContents().get(0);
+ } catch (final WrappedException ex) {
+ UMLDiagramEditorPlugin.getInstance().logError("Unable to load resource: " + this.domainModelURI, ex); //$NON-NLS-1$
+ }
+ if(diagramRoot == null) {
+ MessageDialog.openError(getShell(), Messages.InitDiagramFile_ResourceErrorDialogTitle, Messages.InitDiagramFile_ResourceErrorDialogMessage);
+ return;
+ }
+ final Wizard wizard = new UMLNewDiagramFileWizard(this.domainModelURI, diagramRoot, editingDomain);
+ wizard.setWindowTitle(NLS.bind(Messages.InitDiagramFile_WizardTitle, TimingDiagramEditPart.MODEL_ID));
+ UMLDiagramEditorUtil.runWizard(getShell(), wizard, "InitDiagramFile"); //$NON-NLS-1$
+ }
+}

Back to the top