Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2012-10-01 16:07:27 -0400
committerSopot Cela2012-10-01 16:07:27 -0400
commit6d2199da1ec8874389465a6390ac09b1661fbf8c (patch)
tree3aae12e0ff9346a7de3059a0994515fa384a7abb
parent297a8e03e4f1e023ba921ba7a7b2a8518be92be8 (diff)
downloadorg.eclipse.e4.tools-6d2199da1ec8874389465a6390ac09b1661fbf8c.tar.gz
org.eclipse.e4.tools-6d2199da1ec8874389465a6390ac09b1661fbf8c.tar.xz
org.eclipse.e4.tools-6d2199da1ec8874389465a6390ac09b1661fbf8c.zip
Bug 390779 - Handler/ Part / Addon Wizard does not work anymore
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java39
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewAddonClassWizard.java4
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewHandlerClassWizard.java5
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewPartClassWizard.java4
4 files changed, 35 insertions, 17 deletions
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java
index 78da3e17..689c024a 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java
@@ -145,9 +145,10 @@ public abstract class AbstractNewClassPage extends WizardPage {
parent.setLayout(new GridLayout(3, false));
clazz = createInstance();
-
+ if ((froot!=null)&&(initialString!=null)){
clazz.setPackageFragment(froot.getPackageFragment(parseInitialStringForPackage(initialString)==null?"":parseInitialStringForPackage(initialString)));
clazz.setName(parseInitialStringForClassName(initialString));
+ }
DataBindingContext dbc = new DataBindingContext();
WizardPageSupport.create(this, dbc);
@@ -162,7 +163,7 @@ public abstract class AbstractNewClassPage extends WizardPage {
final Binding bd = dbc.bindValue(
WidgetProperties.text().observe(t),
BeanProperties.value("fragmentRoot").observe(clazz),
- new UpdateValueStrategy(),
+ new UpdateValueStrategy().setBeforeSetValidator(new PFRootValidator()),
new UpdateValueStrategy().setConverter(new PackageFragmentRootToStringConverter())
);
@@ -190,10 +191,10 @@ public abstract class AbstractNewClassPage extends WizardPage {
final Binding bd = dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(t),
BeanProperties.value("packageFragment").observe(clazz),
- new UpdateValueStrategy().setConverter(new StringToPackageFragmentConverter(froot)),
+ new UpdateValueStrategy().setConverter(new StringToPackageFragmentConverter(clazz)),
new UpdateValueStrategy().setConverter(new PackageFragmentToStringConverter())
);
-
+
Button b = new Button(parent, SWT.PUSH);
b.setText("Browse ...");
b.addSelectionListener(new SelectionAdapter() {
@@ -244,8 +245,6 @@ public abstract class AbstractNewClassPage extends WizardPage {
){
return null;
}
- int bi = ioBC+"bundleclass://".length()-1;
- int ei = iSecondSlash;
int lastDot = initialString2.lastIndexOf('.');
String packageString = initialString2.substring(iSecondSlash+1, lastDot);
@@ -383,6 +382,18 @@ public abstract class AbstractNewClassPage extends WizardPage {
return JavaConventions.validateJavaTypeName(name,JavaCore.VERSION_1_3,JavaCore.VERSION_1_3);
}
}
+
+ static class PFRootValidator implements IValidator {
+
+ public IStatus validate(Object value) {
+ String name = value.toString();
+ if (name.length()==0)
+ return new Status(IStatus.ERROR,ToolsPlugin.PLUGIN_ID,"Source folder must not be empty");
+
+
+ return new Status(IStatus.OK,ToolsPlugin.PLUGIN_ID,"");
+ }
+ }
static class PackageFragmentRootToStringConverter extends Converter {
@@ -416,24 +427,20 @@ public abstract class AbstractNewClassPage extends WizardPage {
static class StringToPackageFragmentConverter extends Converter {
- private IPackageFragmentRoot proot;
+ private JavaClass clazz;
- public StringToPackageFragmentConverter(IPackageFragmentRoot froot) {
+ public StringToPackageFragmentConverter(JavaClass clazz) {
super(String.class, IPackageFragment.class);
- this.proot = froot;
+ this.clazz = clazz;
}
public Object convert(Object fromObject) {
- try {
+ if (clazz.getFragmentRoot()==null) return null;
if( fromObject == null ) {
- return proot.createPackageFragment("", true, null);
+ return clazz.getFragmentRoot().getPackageFragment("");
}
- return proot.getPackageFragment((String) fromObject);
- } catch (JavaModelException e) {
- e.printStackTrace();
- return null;
- }
+ return clazz.getFragmentRoot().getPackageFragment((String) fromObject);
}
}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewAddonClassWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewAddonClassWizard.java
index 94325ef7..d5a73559 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewAddonClassWizard.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewAddonClassWizard.java
@@ -24,6 +24,10 @@ public class NewAddonClassWizard extends AbstractNewClassWizard {
public NewAddonClassWizard(String contributionURI) {
this.initialString = contributionURI;
}
+
+ public NewAddonClassWizard() {
+ // Intentially left empty
+ }
@Override
public void addPages() {
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewHandlerClassWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewHandlerClassWizard.java
index b5b29f3e..244b498e 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewHandlerClassWizard.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewHandlerClassWizard.java
@@ -33,7 +33,10 @@ public class NewHandlerClassWizard extends AbstractNewClassWizard {
public NewHandlerClassWizard(String contributionURI) {
this.initialString = contributionURI;
-
+ }
+
+ public NewHandlerClassWizard() {
+ // Intentially left empty
}
@Override
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewPartClassWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewPartClassWizard.java
index 1f6526f4..4de0b134 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewPartClassWizard.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewPartClassWizard.java
@@ -37,6 +37,10 @@ public class NewPartClassWizard extends AbstractNewClassWizard {
public NewPartClassWizard(String contributionURI) {
this.initialString = contributionURI;
}
+
+ public NewPartClassWizard() {
+ // Intentially left empty
+ }
@Override
public void addPages() {

Back to the top