diff options
author | Thomas Schindl | 2010-07-05 12:41:40 +0000 |
---|---|---|
committer | Thomas Schindl | 2010-07-05 12:41:40 +0000 |
commit | f1103828ef5c74f8f0a2e134146e0da2607e9069 (patch) | |
tree | 9fe7d5338afdb8ddd57df3a539fd9426d546348e /bundles | |
parent | 34d8e49223fe2759dda74efc03b21dd25cf282a1 (diff) | |
download | org.eclipse.e4.tools-intermediate_rc2.tar.gz org.eclipse.e4.tools-intermediate_rc2.tar.xz org.eclipse.e4.tools-intermediate_rc2.zip |
Bug 304584 - [Tooling] Implement Workbench-Model-Toolingintermediate_rc2
* moving wizards to new bundle
Diffstat (limited to 'bundles')
22 files changed, 3 insertions, 1614 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/.jetproperties b/bundles/org.eclipse.e4.tools.emf.editor3x/.jetproperties deleted file mode 100644 index 2907c83a..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/.jetproperties +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<jet-settings> - <template-container>templates</template-container> <source-container>src</source-container> -</jet-settings> diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/.project b/bundles/org.eclipse.e4.tools.emf.editor3x/.project index 827d8507..6682b79a 100644 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/.project +++ b/bundles/org.eclipse.e4.tools.emf.editor3x/.project @@ -6,11 +6,6 @@ </projects> <buildSpec> <buildCommand> - <name>org.eclipse.emf.codegen.JETBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> @@ -32,7 +27,6 @@ </buildCommand> </buildSpec> <natures> - <nature>org.eclipse.emf.codegen.jet.IJETNature</nature> <nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> </natures> diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF index 98b9f37f..33eead93 100644 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF @@ -25,11 +25,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.6.0", org.eclipse.e4.ui.services;bundle-version="0.9.1", org.eclipse.e4.tools.compat;bundle-version="1.0.0", org.eclipse.e4.tools.services;bundle-version="1.0.0", - org.eclipse.core.databinding;bundle-version="1.3.100", - org.eclipse.core.databinding.beans;bundle-version="1.2.100", - org.eclipse.core.databinding.property;bundle-version="1.3.0", - org.eclipse.jface.databinding;bundle-version="1.4.0", + org.eclipse.e4.tools;bundle-version="0.9.0", org.eclipse.jdt.ui;bundle-version="3.6.0" Service-Component: OSGI-INF/pdecontributionprovider.xml, OSGI-INF/xmiresourcecontextfunction.xml, OSGI-INF/projectfunction.xml Bundle-ActivationPolicy: lazy -Export-Package: org.eclipse.e4.tools.emf.editor3x.wizard;x-internal:=true diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/Part.gif b/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/Part.gif Binary files differdeleted file mode 100644 index 610f5844..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/Part.gif +++ /dev/null diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/class_obj.gif b/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/class_obj.gif Binary files differdeleted file mode 100644 index e4c2a836..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/class_obj.gif +++ /dev/null diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/plugin.png b/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/plugin.png Binary files differdeleted file mode 100644 index 6187b15a..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/plugin.png +++ /dev/null diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/wizban/newclass_wiz.png b/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/wizban/newclass_wiz.png Binary files differdeleted file mode 100644 index cc123864..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/wizban/newclass_wiz.png +++ /dev/null diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml b/bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml index 90d3c0c5..a6d28c8a 100644 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml +++ b/bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml @@ -13,46 +13,6 @@ </editor> </extension> <extension - point="org.eclipse.ui.newWizards"> - <category - id="org.eclipse.e4" - name="e4 Tooling"> - </category> - <wizard - canFinishEarly="false" - category="org.eclipse.e4" - class="org.eclipse.e4.tools.emf.editor3x.wizard.NewApplicationModelWizard" - hasPages="true" - icon="icons/full/obj16/application_view_tile.png" - id="org.eclipse.e4.tools.emf.editor3x.newappmodel" - name="New Application Model"> - </wizard> - - <wizard - canFinishEarly="false" - category="org.eclipse.e4" - class="org.eclipse.e4.tools.emf.editor3x.wizard.NewContributionModelWizard" - hasPages="true" - icon="icons/full/obj16/plugin.png" - id="org.eclipse.e4.tools.emf.editor3x.newmodelcontribution" - name="New Model Fragment"> - </wizard> - <wizard - category="org.eclipse.e4" - class="org.eclipse.e4.tools.emf.editor3x.wizard.NewHandlerClassWizard" - icon="icons/full/obj16/class_obj.gif" - id="org.eclipse.e4.tools.emf.editor3x.newhandler" - name="New Handler Class"> - </wizard> - <wizard - category="org.eclipse.e4" - class="org.eclipse.e4.tools.emf.editor3x.wizard.NewPartClassWizard" - icon="icons/full/obj16/Part.gif" - id="org.eclipse.e4.tools.emf.editor3x.newpart" - name="New Part Class"> - </wizard> - </extension> - <extension point="org.eclipse.e4.tools.emf.ui.editors"> <contributionClassCreator class="org.eclipse.e4.tools.emf.editor3x.extension.HandlerContributionEditor"> diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java index 51a76aaa..b2bc2a31 100644 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java @@ -16,7 +16,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.FileLocator; -import org.eclipse.e4.tools.emf.editor3x.wizard.NewHandlerClassWizard; +import org.eclipse.e4.internal.tools.wizards.classes.NewHandlerClassWizard; import org.eclipse.e4.tools.emf.ui.common.IContributionClassCreator; import org.eclipse.e4.ui.model.application.MContribution; import org.eclipse.e4.ui.model.application.commands.MHandler; diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/PartContributionEditor.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/PartContributionEditor.java index aad80a11..65195eac 100644 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/PartContributionEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/PartContributionEditor.java @@ -13,7 +13,7 @@ package org.eclipse.e4.tools.emf.editor3x.extension; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.e4.tools.emf.editor3x.wizard.NewPartClassWizard; +import org.eclipse.e4.internal.tools.wizards.classes.NewPartClassWizard; import org.eclipse.e4.tools.emf.ui.common.IContributionClassCreator; import org.eclipse.e4.ui.model.application.MContribution; import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl; diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/templates/HandlerTemplate.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/templates/HandlerTemplate.java deleted file mode 100644 index e969a093..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/templates/HandlerTemplate.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.eclipse.e4.tools.emf.editor3x.templates; - -import org.eclipse.e4.tools.emf.editor3x.wizard.NewHandlerClassWizard.HandlerClass; - -public class HandlerTemplate -{ - protected static String nl; - public static synchronized HandlerTemplate create(String lineSeparator) - { - nl = lineSeparator; - HandlerTemplate result = new HandlerTemplate(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = " " + NL + "package "; - protected final String TEXT_2 = ";" + NL + "" + NL + "import org.eclipse.e4.core.di.annotations.Execute;"; - protected final String TEXT_3 = NL + "import org.eclipse.e4.core.di.annotations.CanExecute;"; - protected final String TEXT_4 = NL + NL + "public class "; - protected final String TEXT_5 = " {" + NL + "\t@Execute" + NL + "\tpublic void "; - protected final String TEXT_6 = "() {" + NL + "\t\t//TODO Your code goes here" + NL + "\t}" + NL + "\t"; - protected final String TEXT_7 = NL + "\t" + NL + "\t@CanExecute" + NL + "\tpublic boolean "; - protected final String TEXT_8 = "() {" + NL + "\t\t//TODO Your code goes here" + NL + "\t}" + NL + "\t"; - protected final String TEXT_9 = "\t" + NL + "}"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - HandlerClass domainClass = (HandlerClass)argument; - stringBuffer.append(TEXT_1); - stringBuffer.append( domainClass.getPackageFragment().getElementName() ); - stringBuffer.append(TEXT_2); - if( domainClass.isUseCanExecute() ) { - stringBuffer.append(TEXT_3); - } - stringBuffer.append(TEXT_4); - stringBuffer.append( domainClass.getName() ); - stringBuffer.append(TEXT_5); - stringBuffer.append( domainClass.getExecuteMethodName() ); - stringBuffer.append(TEXT_6); - if( domainClass.isUseCanExecute() ) { - stringBuffer.append(TEXT_7); - stringBuffer.append( domainClass.getCanExecuteMethodName() ); - stringBuffer.append(TEXT_8); - } - stringBuffer.append(TEXT_9); - return stringBuffer.toString(); - } -} diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/templates/PartTemplate.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/templates/PartTemplate.java deleted file mode 100644 index 3bcf8475..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/templates/PartTemplate.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.eclipse.e4.tools.emf.editor3x.templates; - -import org.eclipse.e4.tools.emf.editor3x.wizard.NewPartClassWizard.PartClass; - -public class PartTemplate -{ - protected static String nl; - public static synchronized PartTemplate create(String lineSeparator) - { - nl = lineSeparator; - PartTemplate result = new PartTemplate(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = " " + NL + "package "; - protected final String TEXT_2 = ";" + NL + "" + NL + "import javax.inject.Inject;"; - protected final String TEXT_3 = NL + "import javax.annotation.PostConstruct;"; - protected final String TEXT_4 = NL + "import javax.annotation.PreDestroy;"; - protected final String TEXT_5 = NL + "import org.eclipse.e4.ui.di.Focus;"; - protected final String TEXT_6 = NL + "import org.eclipse.e4.ui.di.Persist;"; - protected final String TEXT_7 = NL + NL + "public class "; - protected final String TEXT_8 = " {" + NL + "\t@Inject" + NL + "\tpublic "; - protected final String TEXT_9 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t"; - protected final String TEXT_10 = NL + "\t@PostConstruct" + NL + "\tpublic void "; - protected final String TEXT_11 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t"; - protected final String TEXT_12 = NL + "\t"; - protected final String TEXT_13 = NL + "\t@PreDestroy" + NL + "\tpublic void "; - protected final String TEXT_14 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t"; - protected final String TEXT_15 = NL + "\t"; - protected final String TEXT_16 = NL + "\t@Focus" + NL + "\tpublic void "; - protected final String TEXT_17 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t"; - protected final String TEXT_18 = NL + "\t"; - protected final String TEXT_19 = NL + "\t@Persist" + NL + "\tpublic void "; - protected final String TEXT_20 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t"; - protected final String TEXT_21 = NL + "}"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - PartClass domainClass = (PartClass)argument; - stringBuffer.append(TEXT_1); - stringBuffer.append( domainClass.getPackageFragment().getElementName() ); - stringBuffer.append(TEXT_2); - if( domainClass.isUsePostConstruct() ) { - stringBuffer.append(TEXT_3); - } - if( domainClass.isUsePredestroy() ) { - stringBuffer.append(TEXT_4); - } - if( domainClass.isUseFocus() ) { - stringBuffer.append(TEXT_5); - } - if( domainClass.isUsePersist() ) { - stringBuffer.append(TEXT_6); - } - stringBuffer.append(TEXT_7); - stringBuffer.append( domainClass.getName() ); - stringBuffer.append(TEXT_8); - stringBuffer.append( domainClass.getName() ); - stringBuffer.append(TEXT_9); - if( domainClass.isUsePostConstruct() ) { - stringBuffer.append(TEXT_10); - stringBuffer.append( domainClass.getPostConstructMethodName() ); - stringBuffer.append(TEXT_11); - } - stringBuffer.append(TEXT_12); - if( domainClass.isUsePredestroy() ) { - stringBuffer.append(TEXT_13); - stringBuffer.append( domainClass.getPreDestroyMethodName() ); - stringBuffer.append(TEXT_14); - } - stringBuffer.append(TEXT_15); - if( domainClass.isUseFocus() ) { - stringBuffer.append(TEXT_16); - stringBuffer.append( domainClass.getFocusMethodName() ); - stringBuffer.append(TEXT_17); - } - stringBuffer.append(TEXT_18); - if( domainClass.isUsePersist() ) { - stringBuffer.append(TEXT_19); - stringBuffer.append( domainClass.getPersistMethodName() ); - stringBuffer.append(TEXT_20); - } - stringBuffer.append(TEXT_21); - return stringBuffer.toString(); - } -} diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/AbstractNewClassPage.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/AbstractNewClassPage.java deleted file mode 100644 index ba0a2916..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/AbstractNewClassPage.java +++ /dev/null @@ -1,376 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 BestSolution.at 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: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - ******************************************************************************/ -package org.eclipse.e4.tools.emf.editor3x.wizard; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -import org.eclipse.core.databinding.Binding; -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.UpdateValueStrategy; -import org.eclipse.core.databinding.beans.BeanProperties; -import org.eclipse.core.databinding.conversion.Converter; -import org.eclipse.core.databinding.validation.IValidator; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaModel; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.ui.JavaPlugin; -import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; -import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator; -import org.eclipse.jdt.internal.ui.wizards.TypedViewerFilter; -import org.eclipse.jdt.ui.JavaElementComparator; -import org.eclipse.jdt.ui.JavaElementLabelProvider; -import org.eclipse.jdt.ui.StandardJavaElementContentProvider; -import org.eclipse.jface.databinding.swt.IWidgetValueProperty; -import org.eclipse.jface.databinding.swt.WidgetProperties; -import org.eclipse.jface.databinding.wizard.WizardPageSupport; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.ElementListSelectionDialog; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; - -public abstract class AbstractNewClassPage extends WizardPage { - public static class JavaClass { - protected PropertyChangeSupport support = new PropertyChangeSupport(this); - - private IPackageFragmentRoot fragmentRoot; - private IPackageFragment packageFragment; - private String name; - - public JavaClass(IPackageFragmentRoot fragmentRoot) { - this.fragmentRoot = fragmentRoot; - } - - public IPackageFragmentRoot getFragmentRoot() { - return fragmentRoot; - } - - public void setFragmentRoot(IPackageFragmentRoot fragmentRoot) { - support.firePropertyChange("fragementRoot", this.fragmentRoot, this.fragmentRoot = fragmentRoot); - } - - public IPackageFragment getPackageFragment() { - return packageFragment; - } - - public void setPackageFragment(IPackageFragment packageFragment) { - support.firePropertyChange("packageFragment", this.packageFragment, this.packageFragment = packageFragment); - } - - public String getName() { - return name; - } - - public void setName(String name) { - support.firePropertyChange("name", this.name, this.name = name); - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - support.addPropertyChangeListener(listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - support.removePropertyChangeListener(listener); - } - } - - private JavaClass clazz; - private IPackageFragmentRoot froot; - private IWorkspaceRoot fWorkspaceRoot; - - protected AbstractNewClassPage(String pageName, String title, String description, IPackageFragmentRoot froot, IWorkspaceRoot fWorkspaceRoot) { - super(pageName); - this.froot = froot; - this.fWorkspaceRoot = fWorkspaceRoot; - - setTitle(title); - setDescription(description); - } - - public void createControl(Composite parent) { - final Image img = new Image(parent.getDisplay(), getClass().getClassLoader().getResourceAsStream("/icons/full/wizban/newclass_wiz.png")); - setImageDescriptor(ImageDescriptor.createFromImage(img)); - - parent.addDisposeListener(new DisposeListener() { - - public void widgetDisposed(DisposeEvent e) { - img.dispose(); - setImageDescriptor(null); - } - }); - - parent = new Composite(parent, SWT.NULL); - parent.setLayoutData(new GridData(GridData.FILL_BOTH)); - parent.setLayout(new GridLayout(3, false)); - - clazz = createInstance(); - - DataBindingContext dbc = new DataBindingContext(); - WizardPageSupport.create(this, dbc); - - { - Label l = new Label(parent, SWT.NONE); - l.setText("Source folder"); - l.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); - - Text t = new Text(parent, SWT.BORDER); - t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - t.setEditable(false); - final Binding bd = dbc.bindValue( - WidgetProperties.text().observe(t), - BeanProperties.value("fragmentRoot").observe(clazz), - new UpdateValueStrategy(), - new UpdateValueStrategy().setConverter(new PackageFragmentRootToStringConverter()) - ); - - Button b = new Button(parent, SWT.PUSH); - b.setText("Browse ..."); - b.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - IPackageFragmentRoot root = choosePackageRoot(); - if( root != null ) { - clazz.setFragmentRoot(root); - } - bd.updateModelToTarget(); //TODO Find out why this is needed - } - }); - } - - { - Label l = new Label(parent, SWT.NONE); - l.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); - l.setText("Package"); - - Text t = new Text(parent, SWT.BORDER); - t.setEditable(false); - t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - final Binding bd = dbc.bindValue( - WidgetProperties.text().observe(t), - BeanProperties.value("packageFragment").observe(clazz), - new UpdateValueStrategy(), - new UpdateValueStrategy().setConverter(new PackageFragmentToStringConverter()) - ); - - Button b = new Button(parent, SWT.PUSH); - b.setText("Browse ..."); - b.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - IPackageFragment fragment = choosePackage(); - if( fragment != null ) { - clazz.setPackageFragment(fragment); - } - bd.updateModelToTarget(); //TODO Find out why this is needed - } - }); - } - - { - Label l = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); - l.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false, 3, 1)); - } - - { - IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - - Label l = new Label(parent, SWT.NONE); - l.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); - l.setText("Name"); - - Text t = new Text(parent, SWT.BORDER); - t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - dbc.bindValue(textProp.observe(t), BeanProperties.value("name", String.class).observe(clazz)); - - new Label(parent, SWT.NONE); - } - - { - Label l = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); - l.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false, 3, 1)); - } - - createFields(parent, dbc); - setControl(parent); - } - - private IPackageFragmentRoot choosePackageRoot() { - IJavaElement initElement= clazz.getFragmentRoot(); - Class[] acceptedClasses= new Class[] { IPackageFragmentRoot.class, IJavaProject.class }; - TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, false) { - public boolean isSelectedValid(Object element) { - try { - if (element instanceof IJavaProject) { - IJavaProject jproject= (IJavaProject)element; - IPath path= jproject.getProject().getFullPath(); - return (jproject.findPackageFragmentRoot(path) != null); - } else if (element instanceof IPackageFragmentRoot) { - return (((IPackageFragmentRoot)element).getKind() == IPackageFragmentRoot.K_SOURCE); - } - return true; - } catch (JavaModelException e) { - JavaPlugin.log(e.getStatus()); // just log, no UI in validation - } - return false; - } - }; - - acceptedClasses= new Class[] { IJavaModel.class, IPackageFragmentRoot.class, IJavaProject.class }; - ViewerFilter filter= new TypedViewerFilter(acceptedClasses) { - public boolean select(Viewer viewer, Object parent, Object element) { - if (element instanceof IPackageFragmentRoot) { - try { - return (((IPackageFragmentRoot)element).getKind() == IPackageFragmentRoot.K_SOURCE); - } catch (JavaModelException e) { - JavaPlugin.log(e.getStatus()); // just log, no UI in validation - return false; - } - } - return super.select(viewer, parent, element); - } - }; - - StandardJavaElementContentProvider provider= new StandardJavaElementContentProvider(); - ILabelProvider labelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT); - ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), labelProvider, provider); - dialog.setValidator(validator); - dialog.setComparator(new JavaElementComparator()); - dialog.setTitle(NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_title); - dialog.setMessage(NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_description); - dialog.addFilter(filter); - dialog.setInput(JavaCore.create(fWorkspaceRoot)); - dialog.setInitialSelection(initElement); - dialog.setHelpAvailable(false); - - if (dialog.open() == Window.OK) { - Object element= dialog.getFirstResult(); - if (element instanceof IJavaProject) { - IJavaProject jproject= (IJavaProject)element; - return jproject.getPackageFragmentRoot(jproject.getProject()); - } else if (element instanceof IPackageFragmentRoot) { - return (IPackageFragmentRoot)element; - } - return null; - } - return null; - } - - private IPackageFragment choosePackage() { - IJavaElement[] packages= null; - try { - if (froot != null && froot.exists()) { - packages= froot.getChildren(); - } - } catch (JavaModelException e) { - e.printStackTrace(); - } - if (packages == null) { - packages= new IJavaElement[0]; - } - - ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT)); - dialog.setIgnoreCase(false); - dialog.setTitle("Choose Package"); - dialog.setMessage("Choose a Package"); - dialog.setEmptyListMessage("You need to select a package"); - dialog.setElements(packages); - dialog.setHelpAvailable(false); - - IPackageFragment pack= clazz.getPackageFragment(); - if (pack != null) { - dialog.setInitialSelections(new Object[] { pack }); - } - - if (dialog.open() == Window.OK) { - return (IPackageFragment) dialog.getFirstResult(); - } - return null; - } - - protected abstract void createFields(Composite parent, DataBindingContext dbc); - - protected abstract JavaClass createInstance(); - - public JavaClass getClazz() { - return clazz; - } - - static class ClassnameValidator implements IValidator { - - public IStatus validate(Object value) { - String name = value.toString(); - char[] ar = name.toCharArray(); - for (char c : ar) { - if (!Character.isJavaIdentifierPart(c)) { - return new Status(IStatus.ERROR, "", "'" + c + "' is not allowed in a Class-Name"); - } - } - - if (!Character.isJavaIdentifierStart(ar[0])) { - return new Status(IStatus.ERROR, "", "'" + ar[0] + "' is not allowed as the first character of a Class-Name"); - } - - return Status.OK_STATUS; - } - } - - static class PackageFragmentRootToStringConverter extends Converter { - - public PackageFragmentRootToStringConverter() { - super(IPackageFragmentRoot.class, String.class); - } - - public Object convert(Object fromObject) { - IPackageFragmentRoot f = (IPackageFragmentRoot) fromObject; - return f.getPath().makeRelative().toString(); - } - } - - static class PackageFragmentToStringConverter extends Converter { - - public PackageFragmentToStringConverter() { - super(IPackageFragment.class, String.class); - } - - public Object convert(Object fromObject) { - System.err.println(" =======================> Converting: " + fromObject); - if( fromObject == null ) { - return ""; - } - IPackageFragment f = (IPackageFragment) fromObject; - return f.getElementName(); - } - } -} diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/AbstractNewClassWizard.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/AbstractNewClassWizard.java deleted file mode 100644 index 5ae61dcb..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/AbstractNewClassWizard.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 BestSolution.at 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: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - ******************************************************************************/ -package org.eclipse.e4.tools.emf.editor3x.wizard; - -import java.io.ByteArrayInputStream; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.e4.tools.emf.editor3x.wizard.AbstractNewClassPage.JavaClass; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; - -public abstract class AbstractNewClassWizard extends Wizard implements INewWizard { - protected IPackageFragmentRoot root; - protected IFile file; - - public void init(IWorkbench workbench, IStructuredSelection selection) { - root = getFragmentRoot(getInitialJavaElement(selection)); - System.err.println("Root: " + root); - } - - protected IJavaElement getInitialJavaElement(IStructuredSelection selection) { - IJavaElement jelem = null; - if (selection != null && !selection.isEmpty()) { - Object selectedElement = selection.getFirstElement(); - if (selectedElement instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) selectedElement; - - jelem = (IJavaElement) adaptable.getAdapter(IJavaElement.class); - if (jelem == null || !jelem.exists()) { - jelem = null; - IResource resource = (IResource) adaptable - .getAdapter(IResource.class); - if (resource != null - && resource.getType() != IResource.ROOT) { - while (jelem == null - && resource.getType() != IResource.PROJECT) { - resource = resource.getParent(); - jelem = (IJavaElement) resource - .getAdapter(IJavaElement.class); - } - if (jelem == null) { - jelem = JavaCore.create(resource); // java project - } - } - } - } - } - - return jelem; - } - - protected IPackageFragmentRoot getFragmentRoot(IJavaElement elem) { - IPackageFragmentRoot initRoot = null; - if (elem != null) { - initRoot = (IPackageFragmentRoot) elem - .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); - try { - if (initRoot == null - || initRoot.getKind() != IPackageFragmentRoot.K_SOURCE) { - IJavaProject jproject = elem.getJavaProject(); - if (jproject != null) { - initRoot = null; - if (jproject.exists()) { - IPackageFragmentRoot[] roots = jproject - .getPackageFragmentRoots(); - for (int i = 0; i < roots.length; i++) { - if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE) { - initRoot = roots[i]; - break; - } - } - } - if (initRoot == null) { - initRoot = jproject.getPackageFragmentRoot(jproject - .getResource()); - } - } - } - } catch (JavaModelException e) { - // TODO - e.printStackTrace(); - } - } - return initRoot; - } - - protected abstract String getContent(); - - public JavaClass getDomainClass() { - return ((AbstractNewClassPage) getPages()[0]).getClazz(); - } - - @Override - public boolean performFinish() { - JavaClass clazz = getDomainClass(); - String content = getContent(); - - IPackageFragment fragment = clazz.getPackageFragment(); - if (fragment != null) { - String cuName = clazz.getName() + ".java"; - IResource resource = fragment.getCompilationUnit(cuName) - .getResource(); - file = (IFile) resource; - try { - if (!file.exists()) { - file.create(new ByteArrayInputStream(content.getBytes()), - true, null); - } else { - file.setContents(new ByteArrayInputStream(content.getBytes()), - IFile.FORCE | IFile.KEEP_HISTORY, null); - } - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - return true; - - } - - public IFile getFile() { - return file; - } -} diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/BaseApplicationModelWizard.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/BaseApplicationModelWizard.java deleted file mode 100644 index 27d175bf..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/BaseApplicationModelWizard.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 BestSolution.at 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: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - ******************************************************************************/ -package org.eclipse.e4.tools.emf.editor3x.wizard; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWizard; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.ISetSelectionTarget; - -public abstract class BaseApplicationModelWizard extends Wizard implements INewWizard { - private NewModelFilePage page; - private ISelection selection; - - protected IWorkbench workbench; - - /** - * Constructor for NewApplicationModelWizard. - */ - public BaseApplicationModelWizard() { - super(); - setNeedsProgressMonitor(true); - } - - /** - * Adding the page to the wizard. - */ - - public void addPages() { - page = new NewModelFilePage(selection,getDefaultFileName()); - addPage(page); - } - - public abstract String getDefaultFileName(); - - @Override - public boolean performFinish() { - try { - // Remember the file. - // - final IFile modelFile = getModelFile(); - - // Do the work within an operation. - // - WorkspaceModifyOperation operation = - new WorkspaceModifyOperation() { - @Override - protected void execute(IProgressMonitor progressMonitor) { - try { - // Create a resource set - // - ResourceSet resourceSet = new ResourceSetImpl(); - - // Get the URI of the model file. - // - URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true); - - // Create a resource for this file. - // - Resource resource = resourceSet.createResource(fileURI); - - // Add the initial model object to the contents. - // - EObject rootObject = createInitialModel(); - if (rootObject != null) { - resource.getContents().add(rootObject); - } - - // Save the contents of the resource to the file system. - // - Map<Object, Object> options = new HashMap<Object, Object>(); - resource.save(options); - } - catch (Exception exception) { - throw new RuntimeException(exception); - } - finally { - progressMonitor.done(); - } - } - }; - - getContainer().run(false, false, operation); - - // Select the new file resource in the current view. - // - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IWorkbenchPage page = workbenchWindow.getActivePage(); - final IWorkbenchPart activePart = page.getActivePart(); - if (activePart instanceof ISetSelectionTarget) { - final ISelection targetSelection = new StructuredSelection(modelFile); - getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - ((ISetSelectionTarget)activePart).selectReveal(targetSelection); - } - }); - } - - // Open an editor on the new file. - // - try { - page.openEditor - (new FileEditorInput(modelFile), - workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId()); - } - catch (PartInitException exception) { - MessageDialog.openError(workbenchWindow.getShell(), "Could not init editor", exception.getMessage()); //$NON-NLS-1$ - return false; - } - - return true; - } - catch (Exception exception) { - MessageDialog.openError(getShell(), "Error", exception.getMessage()); - return false; - } - } - - protected abstract EObject createInitialModel(); - - private IFile getModelFile() throws CoreException { - String containerName = page.getContainerName(); - String fileName = page.getFileName(); - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IResource resource = root.findMember(new Path(containerName)); - if (!resource.exists() || !(resource instanceof IContainer)) { - throwCoreException("Container \"" + containerName - + "\" does not exist."); - } - IContainer container = (IContainer) resource; - return container.getFile(new Path(fileName)); - } - - private void throwCoreException(String message) throws CoreException { - IStatus status = new Status(IStatus.ERROR, - "org.eclipse.e4.tools.emf.editor3x", IStatus.OK, message, null); - throw new CoreException(status); - } - - /** - * We will accept the selection in the workbench to see if we can initialize - * from it. - * - * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) - */ - public void init(IWorkbench workbench, IStructuredSelection selection) { - this.workbench = workbench; - this.selection = selection; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewApplicationModelWizard.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewApplicationModelWizard.java deleted file mode 100644 index ed161a7e..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewApplicationModelWizard.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 BestSolution.at 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: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - ******************************************************************************/ -package org.eclipse.e4.tools.emf.editor3x.wizard; - -import org.eclipse.e4.ui.model.application.MApplicationFactory; -import org.eclipse.emf.ecore.EObject; - - -public class NewApplicationModelWizard extends BaseApplicationModelWizard { - - @Override - public String getDefaultFileName() { - return "Application.e4xmi"; - } - - protected EObject createInitialModel() { - return (EObject) MApplicationFactory.INSTANCE.createApplication(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewContributionModelWizard.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewContributionModelWizard.java deleted file mode 100644 index 20b95dd2..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewContributionModelWizard.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 BestSolution.at 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: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - ******************************************************************************/ -package org.eclipse.e4.tools.emf.editor3x.wizard; - -import org.eclipse.e4.ui.model.fragment.MFragmentFactory; -import org.eclipse.emf.ecore.EObject; - - -public class NewContributionModelWizard extends BaseApplicationModelWizard { - - @Override - public String getDefaultFileName() { - return "fragment.e4xmi"; - } - - protected EObject createInitialModel() { - return (EObject) MFragmentFactory.INSTANCE.createModelFragments(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewHandlerClassWizard.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewHandlerClassWizard.java deleted file mode 100644 index 2790ea7f..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewHandlerClassWizard.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 BestSolution.at 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: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - ******************************************************************************/ -package org.eclipse.e4.tools.emf.editor3x.wizard; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeanProperties; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.e4.tools.emf.editor3x.templates.HandlerTemplate; -import org.eclipse.e4.tools.emf.editor3x.wizard.AbstractNewClassPage.JavaClass; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jface.databinding.swt.IWidgetValueProperty; -import org.eclipse.jface.databinding.swt.WidgetProperties; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -public class NewHandlerClassWizard extends AbstractNewClassWizard { - @Override - protected String getContent() { - HandlerTemplate template = new HandlerTemplate(); - return template.generate(getDomainClass()); - } - - @Override - public void addPages() { - addPage(new AbstractNewClassPage("Classinformation", - "New Handler", - "Create a new handler class", root, ResourcesPlugin.getWorkspace().getRoot()) { - - @Override - protected JavaClass createInstance() { - return new HandlerClass(root); - } - - @Override - protected void createFields(Composite parent, DataBindingContext dbc) { - IWidgetValueProperty textProp = WidgetProperties - .text(SWT.Modify); - - { - Label l = new Label(parent, SWT.NONE); - l.setText("Execute Method"); - l.setLayoutData(new GridData(GridData.END, GridData.CENTER, - false, false)); - - Text t = new Text(parent, SWT.BORDER); - t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - dbc.bindValue( - textProp.observe(t), - BeanProperties.value("executeMethodName").observe( - getClazz())); - - l = new Label(parent, SWT.NONE); - } - - { - Label l = new Label(parent, SWT.NONE); - l.setText("Can-Execute Method"); - l.setLayoutData(new GridData(GridData.END, GridData.CENTER, - false, false)); - - Text t = new Text(parent, SWT.BORDER); - t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - dbc.bindValue(textProp.observe(t), - BeanProperties.value("canExecuteMethodName") - .observe(getClazz())); - dbc.bindValue( - WidgetProperties.enabled().observe(t), - BeanProperties.value("useCanExecute").observe( - getClazz())); - - Button b = new Button(parent, SWT.CHECK); - dbc.bindValue( - WidgetProperties.selection().observe(b), - BeanProperties.value("useCanExecute").observe( - getClazz())); - } - } - }); - } - - - - public static class HandlerClass extends JavaClass { - private String executeMethodName = "execute"; - private String canExecuteMethodName = "canExecute"; - private boolean useCanExecute = false; - - public HandlerClass(IPackageFragmentRoot root) { - super(root); - } - - public String getExecuteMethodName() { - return executeMethodName; - } - - public void setExecuteMethodName(String executeMethodName) { - support.firePropertyChange("executeMethodName", - this.executeMethodName, - this.executeMethodName = executeMethodName); - } - - public String getCanExecuteMethodName() { - return canExecuteMethodName; - } - - public void setCanExecuteMethodName(String canExecuteMethodName) { - support.firePropertyChange("canExecuteMethodName", - this.canExecuteMethodName, - this.canExecuteMethodName = canExecuteMethodName); - } - - public boolean isUseCanExecute() { - return useCanExecute; - } - - public void setUseCanExecute(boolean useCanExecute) { - support.firePropertyChange("useCanExecute", this.useCanExecute, - this.useCanExecute = useCanExecute); - } - } -} diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewModelFilePage.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewModelFilePage.java deleted file mode 100644 index 90154bad..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewModelFilePage.java +++ /dev/null @@ -1,199 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 BestSolution.at 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: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - ******************************************************************************/ -package org.eclipse.e4.tools.emf.editor3x.wizard; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.dialogs.IDialogPage; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.ContainerSelectionDialog; - -/** - * The "New" wizard page allows setting the container for the new file as well - * as the file name. The page will only accept file name without the extension - * OR with the extension that matches the expected one (e4xmi). - */ - -public class NewModelFilePage extends WizardPage { - private Text containerText; - - private Text fileText; - - private ISelection selection; - - private String defaultFilename; - - /** - * Constructor for SampleNewWizardPage. - * - * @param pageName - */ - public NewModelFilePage(ISelection selection, String defaultFilename) { - super("wizardPage"); - setTitle("Multi-page Editor File"); - setDescription("This wizard creates a new file with *.e4xmi extension that can be opened by a multi-page editor."); - this.selection = selection; - this.defaultFilename = defaultFilename; - } - - /** - * @see IDialogPage#createControl(Composite) - */ - public void createControl(Composite parent) { - Composite container = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - container.setLayout(layout); - layout.numColumns = 3; - layout.verticalSpacing = 9; - Label label = new Label(container, SWT.NULL); - label.setText("&Container:"); - - containerText = new Text(container, SWT.BORDER | SWT.SINGLE); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - containerText.setLayoutData(gd); - containerText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - dialogChanged(); - } - }); - - Button button = new Button(container, SWT.PUSH); - button.setText("Browse..."); - button.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleBrowse(); - } - }); - label = new Label(container, SWT.NULL); - label.setText("&File name:"); - - fileText = new Text(container, SWT.BORDER | SWT.SINGLE); - gd = new GridData(GridData.FILL_HORIZONTAL); - fileText.setLayoutData(gd); - fileText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - dialogChanged(); - } - }); - initialize(); - dialogChanged(); - setControl(container); - } - - /** - * Tests if the current workbench selection is a suitable container to use. - */ - - private void initialize() { - if (selection != null && selection.isEmpty() == false - && selection instanceof IStructuredSelection) { - IStructuredSelection ssel = (IStructuredSelection) selection; - if (ssel.size() > 1) - return; - Object obj = ssel.getFirstElement(); - if (obj instanceof IResource) { - IContainer container; - if (obj instanceof IContainer) - container = (IContainer) obj; - else - container = ((IResource) obj).getParent(); - containerText.setText(container.getFullPath().toString()); - } - } - fileText.setText(defaultFilename); - } - - /** - * Uses the standard container selection dialog to choose the new value for - * the container field. - */ - - private void handleBrowse() { - ContainerSelectionDialog dialog = new ContainerSelectionDialog( - getShell(), ResourcesPlugin.getWorkspace().getRoot(), false, - "Select new file container"); - if (dialog.open() == ContainerSelectionDialog.OK) { - Object[] result = dialog.getResult(); - if (result.length == 1) { - containerText.setText(((Path) result[0]).toString()); - } - } - } - - /** - * Ensures that both text fields are set. - */ - - private void dialogChanged() { - IResource container = ResourcesPlugin.getWorkspace().getRoot() - .findMember(new Path(getContainerName())); - String fileName = getFileName(); - - if (getContainerName().length() == 0) { - updateStatus("File container must be specified"); - return; - } - if (container == null - || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) { - updateStatus("File container must exist"); - return; - } - if (!container.isAccessible()) { - updateStatus("Project must be writable"); - return; - } - if (fileName.length() == 0) { - updateStatus("File name must be specified"); - return; - } - if (fileName.replace('\\', '/').indexOf('/', 1) > 0) { - updateStatus("File name must be valid"); - return; - } - int dotLoc = fileName.lastIndexOf('.'); - if (dotLoc != -1) { - String ext = fileName.substring(dotLoc + 1); - if (ext.equalsIgnoreCase("e4xmi") == false) { - updateStatus("File extension must be \"e4xmi\""); - return; - } - } - updateStatus(null); - } - - private void updateStatus(String message) { - setErrorMessage(message); - setPageComplete(message == null); - } - - public String getContainerName() { - return containerText.getText(); - } - - public String getFileName() { - return fileText.getText(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewPartClassWizard.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewPartClassWizard.java deleted file mode 100644 index 814d3f27..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewPartClassWizard.java +++ /dev/null @@ -1,255 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 BestSolution.at 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: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - ******************************************************************************/ -package org.eclipse.e4.tools.emf.editor3x.wizard; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.beans.BeanProperties; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.e4.tools.emf.editor3x.templates.PartTemplate; -import org.eclipse.e4.tools.emf.editor3x.wizard.AbstractNewClassPage.JavaClass; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jface.databinding.swt.IWidgetValueProperty; -import org.eclipse.jface.databinding.swt.WidgetProperties; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -public class NewPartClassWizard extends AbstractNewClassWizard { - - @Override - public void addPages() { - addPage(new AbstractNewClassPage("Classinformation", "New Part", - "Create a new part class", root, ResourcesPlugin.getWorkspace() - .getRoot()) { - - @Override - protected void createFields(Composite parent, DataBindingContext dbc) { - IWidgetValueProperty textProp = WidgetProperties - .text(SWT.Modify); - IWidgetValueProperty enabledProp = WidgetProperties.enabled(); - - { - Label l = new Label(parent, SWT.NONE); - l.setText("PostContruct Method"); - l.setLayoutData(new GridData(GridData.END, GridData.CENTER, - false, false)); - - Text t = new Text(parent, SWT.BORDER); - t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - dbc.bindValue(textProp.observe(t), - BeanProperties.value("postConstructMethodName") - .observe(getClazz())); - dbc.bindValue( - enabledProp.observe(t), - BeanProperties.value("usePostConstruct").observe( - getClazz())); - - Button b = new Button(parent, SWT.CHECK); - dbc.bindValue( - WidgetProperties.selection().observe(b), - BeanProperties.value("usePostConstruct").observe( - getClazz())); - } - - { - Label l = new Label(parent, SWT.NONE); - l.setText("Predestroy Method"); - l.setLayoutData(new GridData(GridData.END, GridData.CENTER, - false, false)); - - Text t = new Text(parent, SWT.BORDER); - t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - dbc.bindValue(textProp.observe(t), - BeanProperties.value("preDestroyMethodName") - .observe(getClazz())); - dbc.bindValue( - enabledProp.observe(t), - BeanProperties.value("usePredestroy").observe( - getClazz())); - - Button b = new Button(parent, SWT.CHECK); - dbc.bindValue( - WidgetProperties.selection().observe(b), - BeanProperties.value("usePredestroy").observe( - getClazz())); - } - - { - Label l = new Label(parent, SWT.NONE); - l.setText("Focus Method"); - l.setLayoutData(new GridData(GridData.END, GridData.CENTER, - false, false)); - - Text t = new Text(parent, SWT.BORDER); - t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - dbc.bindValue(textProp.observe(t), - BeanProperties.value("focusMethodName") - .observe(getClazz())); - dbc.bindValue( - enabledProp.observe(t), - BeanProperties.value("useFocus").observe( - getClazz())); - - Button b = new Button(parent, SWT.CHECK); - dbc.bindValue( - WidgetProperties.selection().observe(b), - BeanProperties.value("useFocus").observe( - getClazz())); - } - - { - Label l = new Label(parent, SWT.NONE); - l.setText("Persist Method"); - l.setLayoutData(new GridData(GridData.END, GridData.CENTER, - false, false)); - - Text t = new Text(parent, SWT.BORDER); - t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - dbc.bindValue(textProp.observe(t), - BeanProperties.value("persistMethodName") - .observe(getClazz())); - dbc.bindValue( - enabledProp.observe(t), - BeanProperties.value("usePersist").observe( - getClazz())); - - Button b = new Button(parent, SWT.CHECK); - dbc.bindValue( - WidgetProperties.selection().observe(b), - BeanProperties.value("usePersist").observe( - getClazz())); - } - } - - @Override - protected JavaClass createInstance() { - return new PartClass(root); - } - - }); - } - - @Override - protected String getContent() { - PartTemplate template = new PartTemplate(); - return template.generate(getDomainClass()); - } - - public static class PartClass extends JavaClass { - private PropertyChangeSupport support = new PropertyChangeSupport(this); - - private boolean usePostConstruct; - private String postConstructMethodName = "postConstruct"; - - private boolean usePredestroy; - private String preDestroyMethodName = "preDestroy"; - - private boolean useFocus = true; - private String focusMethodName = "onFocus"; - - private boolean usePersist; - private String persistMethodName = "save"; - - public PartClass(IPackageFragmentRoot fragmentRoot) { - super(fragmentRoot); - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - support.addPropertyChangeListener(listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - support.removePropertyChangeListener(listener); - } - - public boolean isUsePostConstruct() { - return usePostConstruct; - } - - public void setUsePostConstruct(boolean usePostConstruct) { - support.firePropertyChange("usePostConstruct", - this.usePostConstruct, - this.usePostConstruct = usePostConstruct); - } - - public String getPostConstructMethodName() { - return postConstructMethodName; - } - - public void setPostConstructMethodName(String postConstructMethodName) { - support.firePropertyChange("postConstructMethodName", - this.postConstructMethodName, - this.postConstructMethodName = postConstructMethodName); - } - - public boolean isUsePredestroy() { - return usePredestroy; - } - - public void setUsePredestroy(boolean usePredestroy) { - support.firePropertyChange("usePredestroy", this.usePredestroy, - this.usePredestroy = usePredestroy); - } - - public String getPreDestroyMethodName() { - return preDestroyMethodName; - } - - public void setPreDestroyMethodName(String preDestroyMethodName) { - support.firePropertyChange("preDestroyMethodName", - this.preDestroyMethodName, - this.preDestroyMethodName = preDestroyMethodName); - } - - public boolean isUseFocus() { - return useFocus; - } - - public void setUseFocus(boolean useFocus) { - support.firePropertyChange("useFocus", this.useFocus, - this.useFocus = useFocus); - } - - public String getFocusMethodName() { - return focusMethodName; - } - - public void setFocusMethodName(String focusMethodName) { - support.firePropertyChange("focusMethodName", this.focusMethodName, - this.focusMethodName = focusMethodName); - } - - public boolean isUsePersist() { - return usePersist; - } - - public void setUsePersist(boolean usePersist) { - support.firePropertyChange("usePersist", this.usePersist, - this.usePersist = usePersist); - } - - public String getPersistMethodName() { - return persistMethodName; - } - - public void setPersistMethodName(String persistMethodName) { - support.firePropertyChange("persistMethodName", - this.persistMethodName, - this.persistMethodName = persistMethodName); - } - } -} diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/templates/handler.txtjet b/bundles/org.eclipse.e4.tools.emf.editor3x/templates/handler.txtjet deleted file mode 100644 index 299c4f59..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/templates/handler.txtjet +++ /dev/null @@ -1,22 +0,0 @@ -<%@ jet package="org.eclipse.e4.tools.emf.editor3x.templates" class="HandlerTemplate" imports="org.eclipse.e4.tools.emf.editor3x.wizard.NewHandlerClassWizard.HandlerClass" %> -<% HandlerClass domainClass = (HandlerClass)argument; %> -package <%= domainClass.getPackageFragment().getElementName() %>; - -import org.eclipse.e4.core.di.annotations.Execute; -<% if( domainClass.isUseCanExecute() ) { %> -import org.eclipse.e4.core.di.annotations.CanExecute; -<% } %> - -public class <%= domainClass.getName() %> { - @Execute - public void <%= domainClass.getExecuteMethodName() %>() { - //TODO Your code goes here - } - <% if( domainClass.isUseCanExecute() ) { %> - - @CanExecute - public boolean <%= domainClass.getCanExecuteMethodName() %>() { - //TODO Your code goes here - } - <% } %> -}
\ No newline at end of file diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/templates/part.txtjet b/bundles/org.eclipse.e4.tools.emf.editor3x/templates/part.txtjet deleted file mode 100644 index a6b0b1ca..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/templates/part.txtjet +++ /dev/null @@ -1,48 +0,0 @@ -<%@ jet package="org.eclipse.e4.tools.emf.editor3x.templates" class="PartTemplate" imports="org.eclipse.e4.tools.emf.editor3x.wizard.NewPartClassWizard.PartClass" %> -<% PartClass domainClass = (PartClass)argument; %> -package <%= domainClass.getPackageFragment().getElementName() %>; - -import javax.inject.Inject; -<% if( domainClass.isUsePostConstruct() ) { %> -import javax.annotation.PostConstruct; -<% } %> -<% if( domainClass.isUsePredestroy() ) { %> -import javax.annotation.PreDestroy; -<% } %> -<% if( domainClass.isUseFocus() ) { %> -import org.eclipse.e4.ui.di.Focus; -<% } %> -<% if( domainClass.isUsePersist() ) { %> -import org.eclipse.e4.ui.di.Persist; -<% } %> - -public class <%= domainClass.getName() %> { - @Inject - public <%= domainClass.getName() %>() { - //TODO Your code here - } - <% if( domainClass.isUsePostConstruct() ) { %> - @PostConstruct - public void <%= domainClass.getPostConstructMethodName() %>() { - //TODO Your code here - } - <% } %> - <% if( domainClass.isUsePredestroy() ) { %> - @PreDestroy - public void <%= domainClass.getPreDestroyMethodName() %>() { - //TODO Your code here - } - <% } %> - <% if( domainClass.isUseFocus() ) { %> - @Focus - public void <%= domainClass.getFocusMethodName() %>() { - //TODO Your code here - } - <% } %> - <% if( domainClass.isUsePersist() ) { %> - @Persist - public void <%= domainClass.getPersistMethodName() %>() { - //TODO Your code here - } - <% } %> -}
\ No newline at end of file |