Author: scabanovich
Date: 2011-01-31 09:14:07 -0500 (Mon, 31 Jan 2011)
New Revision: 28758
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIElementWizard.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIAnnotationCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorWizardPage.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java
Log:
JBIDE-8255
https://issues.jboss.org/browse/JBIDE-8255
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanCreationWizard.java 2011-01-31
14:12:36 UTC (rev 28757)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanCreationWizard.java 2011-01-31
14:14:07 UTC (rev 28758)
@@ -11,12 +11,6 @@
package org.jboss.tools.cdi.ui.wizard;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
import org.eclipse.jdt.ui.wizards.NewClassWizardPage;
import org.jboss.tools.cdi.ui.CDIUIMessages;
@@ -25,23 +19,27 @@
* @author Viacheslav Kabanovich
*
*/
-public class NewBeanCreationWizard extends NewElementWizard {
- private NewClassWizardPage fPage;
- private boolean fOpenEditorOnFinish = true;
+public class NewBeanCreationWizard extends NewCDIElementWizard {
-
public NewBeanCreationWizard() {
setWindowTitle(CDIUIMessages.NEW_BEAN_WIZARD_TITLE);
}
+ protected void initPageFromAdapter() {
+ super.initPageFromAdapter();
+ if(adapter != null) {
+ ((NewBeanWizardPage)fPage).setAlternative(true);
+ }
+ }
/*
* @see Wizard#createPages
*/
public void addPages() {
super.addPages();
if (fPage == null) {
- fPage = new NewBeanWizardPage();
- fPage.init(getSelection());
+ fPage = new NewBeanWizardPage();
+ ((NewClassWizardPage)fPage).init(getSelection());
+ initPageFromAdapter();
}
addPage(fPage);
}
@@ -53,37 +51,4 @@
return !fPage.isEnclosingTypeSelected();
}
- /* (non-Javadoc)
- * @see
org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void finishPage(IProgressMonitor monitor) throws InterruptedException,
CoreException {
- fPage.createType(monitor); // use the full progress monitor
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizard#performFinish()
- */
- public boolean performFinish() {
- warnAboutTypeCommentDeprecation();
- boolean res= super.performFinish();
- if (res) {
- IResource resource= fPage.getModifiedResource();
- if (resource != null) {
- selectAndReveal(resource);
- if (fOpenEditorOnFinish) {
- openResource((IFile) resource);
- }
- }
- }
- return res;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#getCreatedElement()
- */
- public IJavaElement getCreatedElement() {
- return fPage.getCreatedType();
- }
-
-
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java 2011-01-31
14:12:36 UTC (rev 28757)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java 2011-01-31
14:14:07 UTC (rev 28758)
@@ -88,6 +88,8 @@
protected StatusInfo fieldNameStatus = new StatusInfo();
+ boolean isAlternativeInitialValue = false;
+
public NewBeanWizardPage() {
setTitle(CDIUIMessages.NEW_BEAN_WIZARD_PAGE_NAME);
setDescription(CDIUIMessages.NEW_BEAN_WIZARD_DESCRIPTION);
@@ -96,7 +98,7 @@
public void init(IStructuredSelection selection) {
super.init(selection);
- if (!selection.isEmpty()) {
+ if (selection != null && !selection.isEmpty()) {
Object o = selection.iterator().next();
IType type = null;
if (o instanceof IType) {
@@ -379,7 +381,7 @@
protected void createAlternativeField(Composite composite) {
String label = "Add @Alternative";
- alternative = createCheckBoxField(composite, "isAlternative", label, false);
+ alternative = createCheckBoxField(composite, "isAlternative", label,
isAlternativeInitialValue);
}
protected CheckBoxEditorWrapper createCheckBoxField(Composite composite, String name,
String label, boolean defaultValue) {
@@ -423,5 +425,12 @@
return result;
}
+ public void setAlternative(boolean value) {
+ if(alternative != null) {
+ alternative.composite.setValue(Boolean.valueOf(value));
+ } else {
+ isAlternativeInitialValue = value;
+ }
+ }
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIAnnotationCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIAnnotationCreationWizard.java 2011-01-31
14:12:36 UTC (rev 28757)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIAnnotationCreationWizard.java 2011-01-31
14:14:07 UTC (rev 28758)
@@ -10,22 +10,15 @@
******************************************************************************/
package org.jboss.tools.cdi.ui.wizard;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
import org.eclipse.jdt.ui.wizards.NewAnnotationWizardPage;
+import org.jboss.tools.common.model.ui.wizards.INewClassWizard;
/**
*
* @author Viacheslav Kabanovich
*
*/
-public abstract class NewCDIAnnotationCreationWizard extends NewElementWizard {
- protected NewAnnotationWizardPage fPage;
- protected boolean fOpenEditorOnFinish = true;
+public abstract class NewCDIAnnotationCreationWizard extends NewCDIElementWizard
implements INewClassWizard {
public NewCDIAnnotationCreationWizard() {}
@@ -33,7 +26,8 @@
super.addPages();
if (fPage == null) {
fPage = createAnnotationWizardPage();
- fPage.init(getSelection());
+ ((NewAnnotationWizardPage)fPage).init(getSelection());
+ initPageFromAdapter();
}
addPage(fPage);
@@ -41,30 +35,4 @@
protected abstract NewAnnotationWizardPage createAnnotationWizardPage();
- protected void finishPage(IProgressMonitor monitor) throws InterruptedException,
CoreException {
- fPage.createType(monitor); // use the full progress monitor
- }
-
- public IJavaElement getCreatedElement() {
- return fPage.getCreatedType();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizard#performFinish()
- */
- public boolean performFinish() {
- warnAboutTypeCommentDeprecation();
- boolean res= super.performFinish();
- if (res) {
- IResource resource= fPage.getModifiedResource();
- if (resource != null) {
- selectAndReveal(resource);
- if (fOpenEditorOnFinish) {
- openResource((IFile) resource);
- }
- }
- }
- return res;
- }
-
}
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIElementWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIElementWizard.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIElementWizard.java 2011-01-31
14:14:07 UTC (rev 28758)
@@ -0,0 +1,71 @@
+package org.jboss.tools.cdi.ui.wizard;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
+import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
+import org.jboss.tools.common.model.ui.wizards.INewClassWizard;
+import org.jboss.tools.common.model.ui.wizards.NewTypeWizardAdapter;
+
+public class NewCDIElementWizard extends NewElementWizard implements INewClassWizard {
+ protected boolean fOpenEditorOnFinish = true;
+
+ protected NewTypeWizardPage fPage;
+ protected NewTypeWizardAdapter adapter;
+
+ public NewCDIElementWizard() {}
+
+ public void setAdapter(NewTypeWizardAdapter adapter) {
+ this.adapter = adapter;
+ }
+
+ public String getQualifiedClassName() {
+ IType type = fPage.getCreatedType();
+ return type == null ? "" : type.getFullyQualifiedName();
+ }
+
+ protected void initPageFromAdapter() {
+ if(adapter != null) {
+ fPage.setPackageFragmentRoot(adapter.getPackageFragmentRoot(), true);
+ fPage.setPackageFragment(adapter.getPackageFragment(), true);
+ fPage.setTypeName(adapter.getTypeName(), true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected void finishPage(IProgressMonitor monitor) throws InterruptedException,
CoreException {
+ fPage.createType(monitor); // use the full progress monitor
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#getCreatedElement()
+ */
+ public IJavaElement getCreatedElement() {
+ return fPage.getCreatedType();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizard#performFinish()
+ */
+ public boolean performFinish() {
+ warnAboutTypeCommentDeprecation();
+ boolean res= super.performFinish();
+ if (res) {
+ IResource resource= fPage.getModifiedResource();
+ if (resource != null) {
+ selectAndReveal(resource);
+ if (fOpenEditorOnFinish) {
+ openResource((IFile) resource);
+ }
+ }
+ }
+ return res;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIElementWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorCreationWizard.java 2011-01-31
14:12:36 UTC (rev 28757)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorCreationWizard.java 2011-01-31
14:14:07 UTC (rev 28758)
@@ -11,12 +11,6 @@
package org.jboss.tools.cdi.ui.wizard;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
import org.eclipse.jdt.ui.wizards.NewClassWizardPage;
import org.jboss.tools.cdi.ui.CDIUIMessages;
@@ -25,11 +19,8 @@
* @author Viacheslav Kabanovich
*
*/
-public class NewDecoratorCreationWizard extends NewElementWizard {
- private NewClassWizardPage fPage;
- private boolean fOpenEditorOnFinish = true;
+public class NewDecoratorCreationWizard extends NewCDIElementWizard {
-
public NewDecoratorCreationWizard() {
setWindowTitle(CDIUIMessages.NEW_DECORATOR_WIZARD_TITLE);
}
@@ -41,7 +32,8 @@
super.addPages();
if (fPage == null) {
fPage = new NewDecoratorWizardPage();
- fPage.init(getSelection());
+ ((NewClassWizardPage)fPage).init(getSelection());
+ initPageFromAdapter();
}
addPage(fPage);
}
@@ -53,37 +45,4 @@
return !fPage.isEnclosingTypeSelected();
}
- /* (non-Javadoc)
- * @see
org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void finishPage(IProgressMonitor monitor) throws InterruptedException,
CoreException {
- fPage.createType(monitor); // use the full progress monitor
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizard#performFinish()
- */
- public boolean performFinish() {
- warnAboutTypeCommentDeprecation();
- boolean res= super.performFinish();
- if (res) {
- IResource resource= fPage.getModifiedResource();
- if (resource != null) {
- selectAndReveal(resource);
- if (fOpenEditorOnFinish) {
- openResource((IFile) resource);
- }
- }
- }
- return res;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#getCreatedElement()
- */
- public IJavaElement getCreatedElement() {
- return fPage.getCreatedType();
- }
-
-
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorWizardPage.java 2011-01-31
14:12:36 UTC (rev 28757)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorWizardPage.java 2011-01-31
14:14:07 UTC (rev 28758)
@@ -80,7 +80,7 @@
super.init(selection);
defaultTypeName = null;
defaultFieldName = null;
- if (!selection.isEmpty()) {
+ if (selection != null && !selection.isEmpty()) {
Object o = selection.iterator().next();
IType type = null;
if (o instanceof IType) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorCreationWizard.java 2011-01-31
14:12:36 UTC (rev 28757)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorCreationWizard.java 2011-01-31
14:14:07 UTC (rev 28758)
@@ -11,13 +11,6 @@
package org.jboss.tools.cdi.ui.wizard;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
-import org.eclipse.jdt.ui.wizards.NewClassWizardPage;
import org.jboss.tools.cdi.ui.CDIUIMessages;
/**
@@ -25,11 +18,8 @@
* @author Viacheslav Kabanovich
*
*/
-public class NewInterceptorCreationWizard extends NewElementWizard {
- private NewClassWizardPage fPage;
- private boolean fOpenEditorOnFinish = true;
-
-
+public class NewInterceptorCreationWizard extends NewCDIElementWizard {
+
public NewInterceptorCreationWizard() {
setWindowTitle(CDIUIMessages.NEW_INTERCEPTOR_WIZARD_TITLE);
}
@@ -41,7 +31,8 @@
super.addPages();
if (fPage == null) {
fPage = new NewInterceptorWizardPage();
- fPage.init(getSelection());
+ ((NewInterceptorWizardPage)fPage).init(getSelection());
+ initPageFromAdapter();
}
addPage(fPage);
}
@@ -53,37 +44,4 @@
return !fPage.isEnclosingTypeSelected();
}
- /* (non-Javadoc)
- * @see
org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void finishPage(IProgressMonitor monitor) throws InterruptedException,
CoreException {
- fPage.createType(monitor); // use the full progress monitor
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizard#performFinish()
- */
- public boolean performFinish() {
- warnAboutTypeCommentDeprecation();
- boolean res= super.performFinish();
- if (res) {
- IResource resource= fPage.getModifiedResource();
- if (resource != null) {
- selectAndReveal(resource);
- if (fOpenEditorOnFinish) {
- openResource((IFile) resource);
- }
- }
- }
- return res;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#getCreatedElement()
- */
- public IJavaElement getCreatedElement() {
- return fPage.getCreatedType();
- }
-
-
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java 2011-01-31
14:12:36 UTC (rev 28757)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java 2011-01-31
14:14:07 UTC (rev 28758)
@@ -28,4 +28,11 @@
return new NewStereotypeWizardPage();
}
+ protected void initPageFromAdapter() {
+ super.initPageFromAdapter();
+ if(adapter != null) {
+ ((NewStereotypeWizardPage)fPage).setAlternative(true);
+ }
+ }
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java 2011-01-31
14:12:36 UTC (rev 28757)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java 2011-01-31
14:14:07 UTC (rev 28758)
@@ -54,6 +54,8 @@
protected ListFieldEditor stereotypes = null;
protected ListFieldEditor interceptorBindings = null;
+ boolean isAlternativeInitialValue = false;
+
protected StatusInfo targetStatus = new StatusInfo();
public NewStereotypeWizardPage() {
@@ -138,7 +140,7 @@
protected void createAlternativeField(Composite composite) {
String label = "Add @Alternative";
- alternative = createCheckBoxField(composite, "isAlternative", label, false);
+ alternative = createCheckBoxField(composite, "isAlternative", label,
isAlternativeInitialValue);
}
protected void createNamedField(Composite composite) {
@@ -325,4 +327,12 @@
stereotypes.setValue(nvs);
}
+ public void setAlternative(boolean value) {
+ if(alternative != null) {
+ alternative.composite.setValue(Boolean.valueOf(value));
+ } else {
+ isAlternativeInitialValue = value;
+ }
+ }
+
}