Author: scabanovich
Date: 2010-06-07 09:51:20 -0400 (Mon, 07 Jun 2010)
New Revision: 22598
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierWizardPage.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF
trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml
Log:
https://jira.jboss.org/browse/JBIDE-6413
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF 2010-06-07 13:27:25 UTC
(rev 22597)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF 2010-06-07 13:51:20 UTC
(rev 22598)
@@ -33,4 +33,5 @@
Bundle-Vendor: %Bundle-Vendor.0
Export-Package: org.jboss.tools.cdi.ui,
org.jboss.tools.cdi.ui.ca,
- org.jboss.tools.cdi.ui.preferences
+ org.jboss.tools.cdi.ui.preferences,
+ org.jboss.tools.cdi.ui.wizard
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml 2010-06-07 13:27:25 UTC (rev
22597)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml 2010-06-07 13:51:20 UTC (rev
22598)
@@ -115,4 +115,22 @@
</menuContribution>
</extension>
+ <extension point="org.eclipse.ui.newWizards">
+ <category
+ name="CDI"
+ id="org.jboss.tools.cdi.ui">
+ </category>
+ <wizard
+ category="org.jboss.tools.cdi.ui"
+ class="org.jboss.tools.cdi.ui.wizard.NewQualifierCreationWizard"
+ icon="icons/cdi16.png"
+ id="org.jboss.tools.cdi.ui.wizard.NewQualifierCreationWizard"
+ name="Qualifier Annotation Type"
+ project="false">
+ <description>
+ Create a Qualifier Java File
+ </description>
+ </wizard>
+ </extension>
+
</plugin>
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierCreationWizard.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierCreationWizard.java 2010-06-07
13:51:20 UTC (rev 22598)
@@ -0,0 +1,54 @@
+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;
+
+public class NewQualifierCreationWizard extends NewElementWizard {
+
+ private NewAnnotationWizardPage fPage;
+ private boolean fOpenEditorOnFinish = true;
+
+ public NewQualifierCreationWizard() {}
+
+ public void addPages() {
+ super.addPages();
+ if (fPage == null) {
+ fPage= new NewQualifierWizardPage();
+ fPage.init(getSelection());
+ }
+ addPage(fPage);
+
+ }
+
+ 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;
+ }
+
+ public IJavaElement getCreatedElement() {
+ return fPage.getCreatedType();
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierCreationWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierWizardPage.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierWizardPage.java 2010-06-07
13:51:20 UTC (rev 22598)
@@ -0,0 +1,108 @@
+package org.jboss.tools.cdi.ui.wizard;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.IBuffer;
+import org.eclipse.jdt.core.ISourceRange;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
+import org.eclipse.jdt.ui.wizards.NewAnnotationWizardPage;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.common.ui.widget.editor.CheckBoxFieldEditor;
+import org.jboss.tools.common.ui.widget.editor.CompositeEditor;
+import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
+//import org.jboss.tools.common.ui.widget.editor.IFieldEditorFactory;
+import org.jboss.tools.common.ui.widget.editor.LabelFieldEditor;
+
+public class NewQualifierWizardPage extends NewAnnotationWizardPage {
+ IFieldEditor inherited = null;
+ CheckBoxFieldEditor cbInherited = null;
+
+ protected void createTypeMembers(IType newType, final ImportsManager imports,
IProgressMonitor monitor) throws CoreException {
+ ISourceRange range = newType.getSourceRange();
+ IBuffer buf = newType.getCompilationUnit().getBuffer();
+
+ StringBuffer sb = new StringBuffer();
+
+ if(inherited != null && inherited.getValue() == Boolean.TRUE) {
+ imports.addImport("java.lang.annotation.Inherited");
+ sb.append("(a)Inherited").append("\n");
+ }
+
+ imports.addImport("java.lang.annotation.Target");
+ imports.addImport("static java.lang.annotation.ElementType.TYPE");
+ imports.addImport("static java.lang.annotation.ElementType.METHOD");
+ imports.addImport("static java.lang.annotation.ElementType.PARAMETER");
+ imports.addImport("static java.lang.annotation.ElementType.FIELD");
+ sb.append("@Target( {TYPE, METHOD, PARAMETER, FIELD}
)").append("\n");
+
+ imports.addImport("java.lang.annotation.Retention");
+ imports.addImport("static java.lang.annotation.RetentionPolicy.RUNTIME");
+ sb.append("(a)Retention(RUNTIME)").append("\n");
+
+ imports.addImport("java.lang.annotation.Documented");
+ sb.append("(a)Documented").append("\n");
+
+ imports.addImport("javax.inject.Qualifier");
+ sb.append("(a)Qualifier").append("\n");
+
+ buf.replace(range.getOffset(), 0, sb.toString());
+ }
+
+ public void createControl(Composite parent) {
+ super_createControl(parent);
+
+ Composite composite = (Composite)getControl();
+
+ String label = "Add @Inherited";
+
+ inherited =
/*IFieldEditorFactory.INSTANCE.*/createCheckboxEditor("isInherited", label,
false);
+ inherited.doFillIntoGrid(composite);
+
+ ((Button)cbInherited.getCheckBoxControl()).setText(label);
+
+ }
+
+ void super_createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Composite composite= new Composite(parent, SWT.NONE);
+
+ int nColumns= 4;
+
+ GridLayout layout= new GridLayout();
+ layout.numColumns= nColumns;
+ composite.setLayout(layout);
+
+ createContainerControls(composite, nColumns);
+ createPackageControls(composite, nColumns);
+// createEnclosingTypeControls(composite, nColumns);
+
+ createSeparator(composite, nColumns);
+
+ createTypeNameControls(composite, nColumns);
+// createModifierControls(composite, nColumns);
+
+ createCommentControls(composite, nColumns);
+ enableCommentControl(true);
+
+ setControl(composite);
+
+ Dialog.applyDialogFont(composite);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite,
IJavaHelpContextIds.NEW_ANNOTATION_WIZARD_PAGE);
+ }
+
+ public IFieldEditor createCheckboxEditor(String name, String label,
+ boolean defaultValue) {
+ cbInherited = new CheckBoxFieldEditor(name,label,Boolean.valueOf(defaultValue));
+ CompositeEditor editor = new CompositeEditor(name,label, defaultValue);
+ editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,""),
cbInherited,});
+ return editor;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain