diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf')
3 files changed, 187 insertions, 187 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf/ui/actions/GenerateDawnGenModelEMFAction.java b/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf/ui/actions/GenerateDawnGenModelEMFAction.java index 59a04b3fb6..7e1150cf63 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf/ui/actions/GenerateDawnGenModelEMFAction.java +++ b/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf/ui/actions/GenerateDawnGenModelEMFAction.java @@ -1,63 +1,63 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui.actions;
-
-import org.eclipse.emf.cdo.dawn.codegen.actions.GenerateDawnGenModelAction;
-import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.DawnFragmentGenerator;
-import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.dawnEmfGenmodel.DawnEMFGenerator;
-import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.dawnEmfGenmodel.DawnEmfGenmodelFactory;
-
-import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-
-import org.eclipse.core.resources.IFile;
-
-/**
- * @author Martin Fluegge
- */
-public class GenerateDawnGenModelEMFAction extends GenerateDawnGenModelAction
-{
- protected final String emfGenmodelFileExtension = "emf";
-
- @Override
- protected DawnFragmentGenerator getDawnFragmentGenerator(IFile genFile, ResourceSet resourceSet)
- {
- String genModelFile = genFile.getRawLocationURI().toString();
- DawnEMFGenerator dawnEMFGenerator = DawnEmfGenmodelFactory.eINSTANCE.createDawnEMFGenerator();
-
- URI emfGenModelResourceUri = URI.createURI(genModelFile);
- Resource emfGenModelResource = resourceSet.getResource(emfGenModelResourceUri, true);
-
- GenModel genModel = (GenModel)emfGenModelResource.getContents().get(0);
-
- dawnEMFGenerator.setDawnEditorClassName("Dawn" + genModel.getModelName() + "Editor");
- dawnEMFGenerator.setFragmentName(genModel.getEditorPluginID() + ".dawn");
- dawnEMFGenerator.setEmfGenModel(genModel);
- return dawnEMFGenerator;
- }
-
- @Override
- protected ResourceSet createResourceSet()
- {
- ResourceSet resourceSet = super.createResourceSet();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new XMIResourceFactoryImpl());
- return resourceSet;
- }
-
- @Override
- protected Resource getDawnFragmentModelResource(String path, String modelname, ResourceSet resourceSet)
- {
- return getResource(path, modelname, resourceSet, dawngenmodelFileExtension + "_" + emfGenmodelFileExtension);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui.actions; + +import org.eclipse.emf.cdo.dawn.codegen.actions.GenerateDawnGenModelAction; +import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.DawnFragmentGenerator; +import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.dawnEmfGenmodel.DawnEMFGenerator; +import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.dawnEmfGenmodel.DawnEmfGenmodelFactory; + +import org.eclipse.emf.codegen.ecore.genmodel.GenModel; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; + +import org.eclipse.core.resources.IFile; + +/** + * @author Martin Fluegge + */ +public class GenerateDawnGenModelEMFAction extends GenerateDawnGenModelAction +{ + protected final String emfGenmodelFileExtension = "emf"; + + @Override + protected DawnFragmentGenerator getDawnFragmentGenerator(IFile genFile, ResourceSet resourceSet) + { + String genModelFile = genFile.getRawLocationURI().toString(); + DawnEMFGenerator dawnEMFGenerator = DawnEmfGenmodelFactory.eINSTANCE.createDawnEMFGenerator(); + + URI emfGenModelResourceUri = URI.createURI(genModelFile); + Resource emfGenModelResource = resourceSet.getResource(emfGenModelResourceUri, true); + + GenModel genModel = (GenModel)emfGenModelResource.getContents().get(0); + + dawnEMFGenerator.setDawnEditorClassName("Dawn" + genModel.getModelName() + "Editor"); + dawnEMFGenerator.setFragmentName(genModel.getEditorPluginID() + ".dawn"); + dawnEMFGenerator.setEmfGenModel(genModel); + return dawnEMFGenerator; + } + + @Override + protected ResourceSet createResourceSet() + { + ResourceSet resourceSet = super.createResourceSet(); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new XMIResourceFactoryImpl()); + return resourceSet; + } + + @Override + protected Resource getDawnFragmentModelResource(String path, String modelname, ResourceSet resourceSet) + { + return getResource(path, modelname, resourceSet, dawngenmodelFileExtension + "_" + emfGenmodelFileExtension); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf/ui/actions/GenerateEMFFragmentAction.java b/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf/ui/actions/GenerateEMFFragmentAction.java index 0ed643f498..2fc03a0b7d 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf/ui/actions/GenerateEMFFragmentAction.java +++ b/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf/ui/actions/GenerateEMFFragmentAction.java @@ -1,88 +1,88 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui.actions;
-
-import org.eclipse.emf.cdo.dawn.codegen.creators.Creator;
-import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui.creators.EMFFragmentCreator;
-import org.eclipse.emf.cdo.dawn.codegen.messages.Messages;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-
-/**
- * @author Martin Fluegge
- * @since 0.3
- */
-public class GenerateEMFFragmentAction implements IObjectActionDelegate
-{
- private IResource selectedElement;
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart)
- {
- }
-
- public void run(IAction action)
- {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- try
- {
- window.run(true, true, new IRunnableWithProgress()
- {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
- {
- monitor.beginTask(Messages.GenerateEMFFragmentAction_0, 1000);
- ArrayList<Creator> creators = new ArrayList<Creator>();
- creators.add(new EMFFragmentCreator(selectedElement));
-
- for (Creator creator : creators)
- {
- SubProgressMonitor monitor2 = new SubProgressMonitor(monitor, 1000 / creators.size());
- creator.create(monitor2);
- monitor2.done();
- }
- monitor.done();
- }
- });
- }
- catch (InvocationTargetException ex)
- {
- throw new RuntimeException(ex);
- }
- catch (InterruptedException ex)
- {
- throw new RuntimeException(ex);
- }
- }
-
- public void selectionChanged(IAction action, ISelection selection)
- {
- if (selection instanceof IStructuredSelection)
- {
- Object sel = ((IStructuredSelection)selection).getFirstElement();
- if (sel instanceof IResource)
- {
- selectedElement = (IResource)sel;
- }
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui.actions; + +import org.eclipse.emf.cdo.dawn.codegen.creators.Creator; +import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui.creators.EMFFragmentCreator; +import org.eclipse.emf.cdo.dawn.codegen.messages.Messages; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; + +/** + * @author Martin Fluegge + * @since 0.3 + */ +public class GenerateEMFFragmentAction implements IObjectActionDelegate +{ + private IResource selectedElement; + + public void setActivePart(IAction action, IWorkbenchPart targetPart) + { + } + + public void run(IAction action) + { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + try + { + window.run(true, true, new IRunnableWithProgress() + { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException + { + monitor.beginTask(Messages.GenerateEMFFragmentAction_0, 1000); + ArrayList<Creator> creators = new ArrayList<Creator>(); + creators.add(new EMFFragmentCreator(selectedElement)); + + for (Creator creator : creators) + { + SubProgressMonitor monitor2 = new SubProgressMonitor(monitor, 1000 / creators.size()); + creator.create(monitor2); + monitor2.done(); + } + monitor.done(); + } + }); + } + catch (InvocationTargetException ex) + { + throw new RuntimeException(ex); + } + catch (InterruptedException ex) + { + throw new RuntimeException(ex); + } + } + + public void selectionChanged(IAction action, ISelection selection) + { + if (selection instanceof IStructuredSelection) + { + Object sel = ((IStructuredSelection)selection).getFirstElement(); + if (sel instanceof IResource) + { + selectedElement = (IResource)sel; + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf/ui/creators/EMFFragmentCreator.java b/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf/ui/creators/EMFFragmentCreator.java index 2e04d9a84c..c4fb32818a 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf/ui/creators/EMFFragmentCreator.java +++ b/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui/src/org/eclipse/emf/cdo/dawn/codegen/dawngenmodel/emf/ui/creators/EMFFragmentCreator.java @@ -1,36 +1,36 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui.creators;
-
-import org.eclipse.emf.cdo.dawn.codegen.creators.impl.AbstractFragmentCreator;
-import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.util.DawnEMFWorkflowUtil;
-
-import org.eclipse.core.resources.IResource;
-
-import java.net.URL;
-
-/**
- * @author Martin Fluegge
- * @since 1.0
- */
-public class EMFFragmentCreator extends AbstractFragmentCreator
-{
- public EMFFragmentCreator(IResource selectedElement)
- {
- super(selectedElement);
- }
-
- @Override
- protected URL getWorkflowURL()
- {
- return new DawnEMFWorkflowUtil().getWorkFlow();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui.creators; + +import org.eclipse.emf.cdo.dawn.codegen.creators.impl.AbstractFragmentCreator; +import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.util.DawnEMFWorkflowUtil; + +import org.eclipse.core.resources.IResource; + +import java.net.URL; + +/** + * @author Martin Fluegge + * @since 1.0 + */ +public class EMFFragmentCreator extends AbstractFragmentCreator +{ + public EMFFragmentCreator(IResource selectedElement) + { + super(selectedElement); + } + + @Override + protected URL getWorkflowURL() + { + return new DawnEMFWorkflowUtil().getWorkFlow(); + } +} |