diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf/src/templates/EMFFragmentTemplate.xpt')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf/src/templates/EMFFragmentTemplate.xpt | 409 |
1 files changed, 0 insertions, 409 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf/src/templates/EMFFragmentTemplate.xpt b/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf/src/templates/EMFFragmentTemplate.xpt deleted file mode 100644 index 9e9deb6849..0000000000 --- a/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf/src/templates/EMFFragmentTemplate.xpt +++ /dev/null @@ -1,409 +0,0 @@ -«REM» - Copyright (c) 2011, 2013 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 - Christian W. Damus (CEA) - bug 399933 NPE in editor when finishing Ecore wizard - - -«ENDREM» - -«IMPORT emf» -«IMPORT genmodel» -«IMPORT ecore» -«IMPORT dawngenmodel» -«IMPORT dawnEmfGenmodel» - -«EXTENSION org::eclipse::emf::cdo::dawn::codegen::util::Utils» - -«DEFINE main FOR DawnEMFGenerator» - - «setDiagramPackage(this.emfGenModel.modelPluginID)» - - «EXPAND dawnEditor FOR this» - «EXPAND dawnWizard FOR this» - «EXPAND fragmentXML FOR this» - «EXPAND manifestMF FOR this» - «EXPAND buildPROPERTIES FOR this» - «EXPAND classpath FOR this» -«ENDDEFINE» - -«REM»############################################ Extended Editor ##################################################################«ENDREM» -«DEFINE dawnEditor FOR DawnEMFGenerator» -«FILE "src/"+getDiagramPackagePath()+"/presentation/"+this.dawnEditorClassName+".java"» -package «this.emfGenModel.modelPluginID».presentation; - -import «this.emfGenModel.modelPluginID».presentation.«this.emfGenModel.modelName»Editor; - -import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; -import org.eclipse.emf.cdo.dawn.editors.IDawnEditorSupport; -import org.eclipse.emf.cdo.dawn.emf.editors.impl.DawnEMFEditorSupport; -import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput; -import org.eclipse.emf.cdo.dawn.ui.DawnLabelProvider; -import org.eclipse.emf.cdo.dawn.ui.DawnSelectionViewerAdapterFactoryContentProvider; -import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.ResourceSet; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; - -public class «this.dawnEditorClassName» extends «this.emfGenModel.modelName»Editor implements IDawnEditor -{ - private IDawnEditorSupport dawnEditorSupport; - - public static String ID = "«this.emfGenModel.modelPluginID».presentation.«this.dawnEditorClassName»ID"; - - public «this.dawnEditorClassName»() - { - super(); - dawnEditorSupport = new DawnEMFEditorSupport(this); - } - - @Override - protected void setInput(IEditorInput input) - { - super.setInput(input); - if (input instanceof DawnEditorInput) - { - dawnEditorSupport.setView(((DawnEditorInput)input).getView()); - dawnEditorSupport.registerListeners(); - } - } - - @Override - protected void setInputWithNotify(IEditorInput input) - { - super.setInput(input); - if (input instanceof DawnEditorInput) - { - CDOResource resource = ((DawnEditorInput)input).getResource(); - URI uri = URI.createURI(((DawnEditorInput)input).getURI().toString()); - - if (resource == null || resource.cdoView() == null) - { - ResourceSet resourceSet = editingDomain.getResourceSet(); - CDOTransaction transaction = CDOConnectionUtil.instance.openCurrentTransaction(resourceSet, uri.toString()); - - resource = (CDOResource)resourceSet.getResource(uri, true); - - if (resource == null || resource.cdoView() == null) - { - resource = transaction.getOrCreateResource(uri.toString()); - } - } - - ((DawnEditorInput)input).setResource(resource); - dawnEditorSupport.setView(((DawnEditorInput)input).getView()); - dawnEditorSupport.registerListeners(); - } - } - - @Override - public void createPages() - { - super.createPages(); - - if (!(getEditorInput() instanceof DawnEditorInput)) - { - return; - } - - selectionViewer.setContentProvider(new DawnSelectionViewerAdapterFactoryContentProvider(adapterFactory, - ((DawnEditorInput)getEditorInput()).getResource())); - selectionViewer - .setLabelProvider(new DawnLabelProvider(adapterFactory, dawnEditorSupport.getView(), selectionViewer)); - parentViewer.setLabelProvider(new DawnLabelProvider(adapterFactory, dawnEditorSupport.getView(), selectionViewer)); - listViewer.setLabelProvider(new DawnLabelProvider(adapterFactory, dawnEditorSupport.getView(), selectionViewer)); - treeViewer.setLabelProvider(new DawnLabelProvider(adapterFactory, dawnEditorSupport.getView(), selectionViewer)); - tableViewer.setLabelProvider(new DawnLabelProvider(adapterFactory, dawnEditorSupport.getView(), selectionViewer)); - treeViewerWithColumns.setLabelProvider(new DawnLabelProvider(adapterFactory, dawnEditorSupport.getView(), - selectionViewer)); - - CDOResource resource = ((DawnEditorInput)getEditorInput()).getResource(); - - selectionViewer.setInput(resource.getResourceSet()); - selectionViewer.setSelection(new StructuredSelection(resource), true); - - parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory)); - } - - @Override - public void doSave(IProgressMonitor progressMonitor) - { - CDOView view = dawnEditorSupport.getView(); - if (view instanceof CDOTransaction) - { - if (view.hasConflict()) - { - MessageDialog.openError(Display.getDefault().getActiveShell(), "conflict", - "Your Resource is in conflict and cannot be committed"); - } - else - { - super.doSave(progressMonitor); - } - } - else - { - super.doSave(progressMonitor); - } - } - - public String getContributorID() - { - return null; - } - - public CDOView getView() - { - return dawnEditorSupport.getView(); - } - - public void setDirty() - { - dawnEditorSupport.setDirty(true); - } - - @Override - public void dispose() - { - try - { - super.dispose(); - } - finally - { - dawnEditorSupport.close(); - } - } - - public String getContributorId() - { - return ID; - } - - public IDawnEditorSupport getDawnEditorSupport() - { - return dawnEditorSupport; - } -} -«ENDFILE» -«ENDDEFINE» -«REM»############################################ Extended Wizard ##################################################################«ENDREM» -«DEFINE dawnWizard FOR DawnEMFGenerator» -«FILE "src/"+getDiagramPackagePath()+"/presentation/"+"Dawn"+this.emfGenModel.modelName+"ModelWizard.java"» -package «this.emfGenModel.modelPluginID».presentation; - -import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants; -import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput; -import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewResourceWizardPage; -import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -import java.util.Collections; - -public class Dawn«this.emfGenModel.modelName»ModelWizard extends «this.emfGenModel.modelName»ModelWizard implements INewWizard -{ - private DawnCreateNewResourceWizardPage newResourceCreationPage; - - private CDOView view; - - private CDOResource resource; - - public Dawn«this.emfGenModel.modelName»ModelWizard() - { - super(); - CDOConnectionUtil.instance.init(PreferenceConstants.getRepositoryName(), PreferenceConstants.getProtocol(), - PreferenceConstants.getServerName()); - CDOSession session = CDOConnectionUtil.instance.openSession(); - view = CDOConnectionUtil.instance.openView(session); - } - - @Override - public void addPages() - { - newResourceCreationPage = new DawnCreateNewResourceWizardPage("«getEMFFileName(this.emfGenModel.genPackages)»", true, view); - addPage(newResourceCreationPage); - - initialObjectCreationPage = new «this.emfGenModel.modelName»ModelWizardInitialObjectCreationPage("Whatever2"); - initialObjectCreationPage.setTitle(«this.emfGenModel.modelName»EditorPlugin.INSTANCE.getString("_UI_«this.emfGenModel.modelName»ModelWizard_label")); - initialObjectCreationPage.setDescription(«this.emfGenModel.modelName»EditorPlugin.INSTANCE - .getString("_UI_Wizard_initial_object_description")); - addPage(initialObjectCreationPage); - } - - @Override - public boolean performFinish() - { - try - { - // Do the work within an operation. - // - WorkspaceModifyOperation operation = new WorkspaceModifyOperation() - { - - @Override - protected void execute(IProgressMonitor progressMonitor) - { - try - { - ResourceSet resourceSet = new ResourceSetImpl(); - - URI resourceURI = newResourceCreationPage.getURI(); - - CDOTransaction transaction = CDOConnectionUtil.instance.openCurrentTransaction(resourceSet, - resourceURI.toString()); - - resource = transaction.getOrCreateResource(resourceURI.path()); - - EObject rootObject = createInitialModel(); - if (rootObject != null) - { - resource.getContents().add(rootObject); - } - - resource.save(Collections.EMPTY_MAP); - transaction.close(); - } - catch (Exception exception) - { - «this.emfGenModel.modelName»EditorPlugin.INSTANCE.log(exception); - throw new RuntimeException(exception); - } - finally - { - progressMonitor.done(); - } - } - }; - - getContainer().run(false, false, operation); - - openEditor(newResourceCreationPage.getURI()); - - return true; - } - catch (Exception exception) - { - «this.emfGenModel.modelName»EditorPlugin.INSTANCE.log(exception); - return false; - } - } - - private void openEditor(URI uri) - { - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IWorkbenchPage page = workbenchWindow.getActivePage(); - DawnEditorInput dawnEditorInput = new DawnEditorInput(uri); - try - { - page.openEditor(dawnEditorInput, «this.dawnEditorClassName».ID); - } - catch (PartInitException exception) - { - MessageDialog.openError(workbenchWindow.getShell(), - «this.emfGenModel.modelName»EditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage()); - throw new RuntimeException(exception); - } - } -} -«ENDFILE» -«ENDDEFINE» -«REM»########################################## fragment.xml ####################################################################«ENDREM» -«DEFINE fragmentXML FOR DawnEMFGenerator» -«FILE "fragment.xml"»<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.4"?> -<fragment> - <extension point="org.eclipse.ui.newWizards"> - <wizard - id="«this.emfGenModel.modelPluginID».presentation.Dawn«this.emfGenModel.modelName»ModelWizardID" - name="Dawn «this.emfGenModel.modelName» Model" - class="«this.emfGenModel.modelPluginID».presentation.Dawn«this.emfGenModel.modelName»ModelWizard" - category="org.eclipse.emf.cdo.dawn.ui.category.examples" - icon="platform:/plugin/«this.emfGenModel.editPluginID»/icons/full/obj16/«this.emfGenModel.modelName»ModelFile.gif"> - <description>A Dawn editor for «this.emfGenModel.modelName» models</description> - <selection class="org.eclipse.core.resources.IResource"/> - </wizard> - </extension> - - <extension point="org.eclipse.ui.editors"> - <editor - id="«this.emfGenModel.modelPluginID».presentation.«this.dawnEditorClassName»ID" - name="Dawn «this.emfGenModel.modelName» model Editor" - icon="platform:/plugin/«this.emfGenModel.editPluginID»/icons/full/obj16/«this.emfGenModel.modelName»ModelFile.gif" - extensions="«getEMFFileName(this.emfGenModel.genPackages)»" - class="«this.emfGenModel.modelPluginID».presentation.«this.dawnEditorClassName»" - contributorClass="«this.emfGenModel.modelPluginID».presentation.«this.emfGenModel.modelName»ActionBarContributor"> - </editor> - </extension> -</fragment> - -«ENDFILE» -«ENDDEFINE» -«REM»##############################################################################################################«ENDREM» -«DEFINE manifestMF FOR DawnEMFGenerator» -«FILE "META-INF/MANIFEST.MF"»Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Dawn -Bundle-SymbolicName: «this.fragmentName»;singleton:=true -Bundle-Version: 1.0.0.qualifier -Fragment-Host: «this.emfGenModel.editorPluginID» -Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Require-Bundle: org.eclipse.emf.cdo.dawn;bundle-version="[2.0.0,3.0.0)", - org.eclipse.emf.cdo.dawn.ui;bundle-version="[2.0.0,3.0.0)", - org.eclipse.emf.cdo.dawn.util;bundle-version="[2.0.0,3.0.0)", - org.eclipse.emf.cdo.ui;bundle-version="[4.0.0,5.0.0)", - org.eclipse.emf.cdo.dawn.emf;bundle-version="[2.0.0,3.0.0)" -«ENDFILE» -«ENDDEFINE» - - -«DEFINE buildPROPERTIES FOR DawnEMFGenerator» -«FILE "build.properties"»source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - fragment.xml -«ENDFILE» -«ENDDEFINE» -«REM»################################### . classpath ###########################################################################«ENDREM» - -«DEFINE classpath FOR DawnEMFGenerator» -«FILE ".classpath"»<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="src"/> - <classpathentry kind="output" path="bin"/> -</classpath> -«ENDFILE» -«ENDDEFINE» - |