Author: scabanovich
Date: 2010-06-08 09:43:24 -0400 (Tue, 08 Jun 2010)
New Revision: 22631
Added:
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/NewCDIAnnotationWizardPage.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
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
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
Log:
https://jira.jboss.org/browse/JBIDE-6414
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml 2010-06-08 13:42:24 UTC (rev
22630)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml 2010-06-08 13:43:24 UTC (rev
22631)
@@ -131,6 +131,18 @@
Create a Qualifier Java File
</description>
</wizard>
+
+ <wizard
+ category="org.jboss.tools.cdi.ui"
+ class="org.jboss.tools.cdi.ui.wizard.NewStereotypeCreationWizard"
+ icon="icons/cdi16.png"
+ id="org.jboss.tools.cdi.ui.wizard.NewStereotypeCreationWizard"
+ name="Stereotype Annotation Type"
+ project="false">
+ <description>
+ Create a Stereotype Java File
+ </description>
+ </wizard>
</extension>
</plugin>
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2010-06-08
13:42:24 UTC (rev 22630)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2010-06-08
13:43:24 UTC (rev 22631)
@@ -27,4 +27,10 @@
public static String CDI_REFACTOR_CONTRIBUTOR_ERROR;
public static String CDI_REFACTOR_CONTRIBUTOR_RENAME_NAMED_BEAN_ACTION_NAME;
public static String RENAME_NAMED_BEAN_WIZARD_FIELD_NAME;
+
+ public static String NEW_QUALIFIER_WIZARD_TITLE;
+ public static String NEW_QUALIFIER_WIZARD_PAGE_NAME;
+ public static String NEW_STEREOTYPE_WIZARD_TITLE;
+ public static String NEW_STEREOTYPE_WIZARD_PAGE_NAME;
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2010-06-08
13:42:24 UTC (rev 22630)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2010-06-08
13:43:24 UTC (rev 22631)
@@ -15,4 +15,9 @@
CDI_REFACTOR_CONTRIBUTOR_MENU_NAME=CDI Refactor
CDI_REFACTOR_CONTRIBUTOR_ERROR=Error
CDI_REFACTOR_CONTRIBUTOR_RENAME_NAMED_BEAN_ACTION_NAME=Rename ''{0}''
Named Bean
-RENAME_NAMED_BEAN_WIZARD_FIELD_NAME=@Named Bean Name
\ No newline at end of file
+RENAME_NAMED_BEAN_WIZARD_FIELD_NAME=@Named Bean Name
+
+NEW_QUALIFIER_WIZARD_TITLE=New Qualifier
+NEW_QUALIFIER_WIZARD_PAGE_NAME=Qualifier Annotation Type
+NEW_STEREOTYPE_WIZARD_TITLE=New Stereotype
+NEW_STEREOTYPE_WIZARD_PAGE_NAME=Stereotype Annotation Type
\ No newline at end of file
Added:
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
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIAnnotationCreationWizard.java 2010-06-08
13:43:24 UTC (rev 22631)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+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;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public abstract class NewCDIAnnotationCreationWizard extends NewElementWizard {
+ protected NewAnnotationWizardPage fPage;
+ protected boolean fOpenEditorOnFinish = true;
+
+ public NewCDIAnnotationCreationWizard() {}
+
+ public void addPages() {
+ super.addPages();
+ if (fPage == null) {
+ fPage = createAnnotationWizardPage();
+ fPage.init(getSelection());
+ }
+ addPage(fPage);
+
+ }
+
+ 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;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIAnnotationCreationWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIAnnotationWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIAnnotationWizardPage.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIAnnotationWizardPage.java 2010-06-08
13:43:24 UTC (rev 22631)
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.ui.wizard;
+
+import java.util.List;
+
+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.corext.codemanipulation.StubUtility;
+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.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+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.ITaggedFieldEditor;
+import org.jboss.tools.common.ui.widget.editor.LabelFieldEditor;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public abstract class NewCDIAnnotationWizardPage extends NewAnnotationWizardPage {
+ protected CheckBoxEditorWrapper inherited = null;
+
+ protected IFieldEditor target = null;
+
+ protected void createTypeMembers(IType newType, final ImportsManager imports,
IProgressMonitor monitor) throws CoreException {
+ ISourceRange range = newType.getSourceRange();
+ IBuffer buf = newType.getCompilationUnit().getBuffer();
+ String lineDelimiter = StubUtility.getLineDelimiterUsed(newType.getJavaProject());
+ StringBuffer sb = new StringBuffer();
+ addAnnotations(imports, sb, lineDelimiter);
+ buf.replace(range.getOffset(), 0, sb.toString());
+ }
+
+ protected abstract void addAnnotations(ImportsManager imports, StringBuffer sb, String
lineDelimiter);
+
+ protected void addTargetAnnotation(ImportsManager imports, StringBuffer sb, String
lineDelimiter, String[] targets) {
+ imports.addImport("java.lang.annotation.Target");
+ StringBuffer list = new StringBuffer();
+ for (int i = 0; i < targets.length; i++) {
+ imports.addImport("static java.lang.annotation.ElementType." + targets[i]);
+ if(i > 0) list.append(", ");
+ list.append(targets[i]);
+ }
+ sb.append("@Target( {" + list.toString() + "}
)").append(lineDelimiter);
+ }
+
+ protected void addInheritedAnnotation(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ if(inherited != null && inherited.composite.getValue() == Boolean.TRUE) {
+ imports.addImport("java.lang.annotation.Inherited");
+ sb.append("(a)Inherited").append(lineDelimiter);
+ }
+ }
+
+ protected void addRetentionAnnotation(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ imports.addImport("java.lang.annotation.Retention");
+ imports.addImport("static java.lang.annotation.RetentionPolicy.RUNTIME");
+ sb.append("(a)Retention(RUNTIME)").append(lineDelimiter);
+ }
+
+ protected void addDocumentedAnnotation(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ imports.addImport("java.lang.annotation.Documented");
+ sb.append("(a)Documented").append(lineDelimiter);
+ }
+
+ public void 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);
+
+ createCustomFields(composite);
+
+ setControl(composite);
+
+ Dialog.applyDialogFont(composite);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite,
IJavaHelpContextIds.NEW_ANNOTATION_WIZARD_PAGE);
+ }
+
+ protected abstract void createCustomFields(Composite composite);
+
+ protected static class CheckBoxEditorWrapper {
+ protected IFieldEditor composite = null;
+ protected CheckBoxFieldEditor checkBox = null;
+ }
+
+ protected CheckBoxEditorWrapper createCheckBoxField(Composite composite, String name,
String label, boolean defaultValue) {
+ CheckBoxEditorWrapper wrapper = new CheckBoxEditorWrapper();
+ wrapper.checkBox = new CheckBoxFieldEditor(name,label,Boolean.valueOf(defaultValue));
+ wrapper.composite = new CompositeEditor(name,label, defaultValue);
+ CompositeEditor editor = new CompositeEditor(name,label, defaultValue);
+ editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,""),
wrapper.checkBox});
+ wrapper.composite = editor;
+ wrapper.composite.doFillIntoGrid(composite);
+ ((Button)wrapper.checkBox.getCheckBoxControl()).setText(label);
+ return wrapper;
+ }
+
+ protected void createInheritedField(Composite composite, boolean defaultValue) {
+ String label = "Add @Inherited";
+ inherited = createCheckBoxField(composite, "isInherited", label,
defaultValue);
+ }
+
+ protected void createTargetField(Composite composite, List<String> values) {
+ target = createComboField("Target", "Target", composite, values);
+ }
+
+ protected ITaggedFieldEditor createComboField(String name, String label, Composite
composite, List<String> values) {
+ ITaggedFieldEditor result = IFieldEditorFactory.INSTANCE.createComboEditor(name, label,
values, values.get(0));
+ ((CompositeEditor)result).addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,
"")});
+ result.doFillIntoGrid(composite);
+ Combo combo = (Combo)result.getEditorControls()[1];
+ Object layoutData = combo.getLayoutData();
+ if(layoutData instanceof GridData) {
+ ((GridData)layoutData).horizontalAlignment = GridData.FILL;
+ }
+ return result;
+ }
+
+ protected String[] getTargets() {
+ if(target == null) {
+ return new String[]{"TYPE", "METHOD", "PARAMETER",
"FIELD"};
+ }
+ String value = (String)target.getValue();
+ String[] vs = value.split(",");
+ for (int i = 0; i < vs.length; i++) vs[i] = vs[i].trim();
+ return vs;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIAnnotationWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
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 2010-06-08
13:42:24 UTC (rev 22630)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierCreationWizard.java 2010-06-08
13:43:24 UTC (rev 22631)
@@ -1,54 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
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.cdi.ui.CDIUIMessages;
-public class NewQualifierCreationWizard extends NewElementWizard {
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class NewQualifierCreationWizard extends NewCDIAnnotationCreationWizard {
- private NewAnnotationWizardPage fPage;
- private boolean fOpenEditorOnFinish = true;
+ public NewQualifierCreationWizard() {
+ setWindowTitle(CDIUIMessages.NEW_QUALIFIER_WIZARD_TITLE);
+ }
- public NewQualifierCreationWizard() {}
-
- public void addPages() {
- super.addPages();
- if (fPage == null) {
- fPage= new NewQualifierWizardPage();
- fPage.init(getSelection());
- }
- addPage(fPage);
-
+ protected NewAnnotationWizardPage createAnnotationWizardPage() {
+ return new NewQualifierWizardPage();
}
- 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();
- }
-
}
Modified:
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 2010-06-08
13:42:24 UTC (rev 22630)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierWizardPage.java 2010-06-08
13:43:24 UTC (rev 22631)
@@ -1,108 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
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.jdt.ui.wizards.NewTypeWizardPage.ImportsManager;
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;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
-public class NewQualifierWizardPage extends NewAnnotationWizardPage {
- IFieldEditor inherited = null;
- CheckBoxFieldEditor cbInherited = null;
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class NewQualifierWizardPage extends NewCDIAnnotationWizardPage {
- protected void createTypeMembers(IType newType, final ImportsManager imports,
IProgressMonitor monitor) throws CoreException {
- ISourceRange range = newType.getSourceRange();
- IBuffer buf = newType.getCompilationUnit().getBuffer();
+ public NewQualifierWizardPage() {
+ setTitle(CDIUIMessages.NEW_QUALIFIER_WIZARD_PAGE_NAME);
+ }
- StringBuffer sb = new StringBuffer();
+ protected void addAnnotations(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ addInheritedAnnotation(imports, sb, lineDelimiter);
+ addTargetAnnotation(imports, sb, lineDelimiter, getTargets());
+ addRetentionAnnotation(imports, sb, lineDelimiter);
+ addDocumentedAnnotation(imports, sb, lineDelimiter);
+ addQualifierAnnotation(imports, sb, lineDelimiter);
+ }
- 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");
-
+ protected void addQualifierAnnotation(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
imports.addImport("javax.inject.Qualifier");
- sb.append("(a)Qualifier").append("\n");
-
- buf.replace(range.getOffset(), 0, sb.toString());
+ sb.append("(a)Qualifier").append(lineDelimiter);
}
- public void createControl(Composite parent) {
- super_createControl(parent);
+ @Override
+ protected void createCustomFields(Composite parent) {
+ createInheritedField(parent, false);
- 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;
- }
-
}
Added:
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
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java 2010-06-08
13:43:24 UTC (rev 22631)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.ui.wizard;
+
+import org.eclipse.jdt.ui.wizards.NewAnnotationWizardPage;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class NewStereotypeCreationWizard extends NewCDIAnnotationCreationWizard {
+
+ public NewStereotypeCreationWizard() {
+ setWindowTitle(CDIUIMessages.NEW_STEREOTYPE_WIZARD_TITLE);
+ }
+
+ protected NewAnnotationWizardPage createAnnotationWizardPage() {
+ return new NewStereotypeWizardPage();
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java 2010-06-08
13:43:24 UTC (rev 22631)
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.ui.wizard;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.ICDIProject;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.common.ui.widget.editor.ITaggedFieldEditor;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class NewStereotypeWizardPage extends NewCDIAnnotationWizardPage {
+ protected CheckBoxEditorWrapper alternative = null;
+ protected CheckBoxEditorWrapper named = null;
+ protected ITaggedFieldEditor scope = null;
+ protected Map<String, String> scopes = new TreeMap<String, String>();
+
+ public NewStereotypeWizardPage() {
+ setTitle(CDIUIMessages.NEW_STEREOTYPE_WIZARD_PAGE_NAME);
+ }
+
+ protected void addAnnotations(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ addInheritedAnnotation(imports, sb, lineDelimiter);
+ addAlternativeAnnotation(imports, sb, lineDelimiter);
+ addScopeAnnotation(imports, sb, lineDelimiter);
+ addNamedAnnotation(imports, sb, lineDelimiter);
+ addStereotypeAnnotation(imports, sb, lineDelimiter);
+ addTargetAnnotation(imports, sb, lineDelimiter, getTargets());
+ addRetentionAnnotation(imports, sb, lineDelimiter);
+ addDocumentedAnnotation(imports, sb, lineDelimiter);
+ }
+
+ protected void addStereotypeAnnotation(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ imports.addImport("javax.enterprise.inject.Stereotype");
+ sb.append("(a)Stereotype").append(lineDelimiter);
+ }
+
+ protected void addAlternativeAnnotation(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ if(alternative != null && alternative.composite.getValue() == Boolean.TRUE) {
+ imports.addImport(CDIConstants.ALTERNATIVE_ANNOTATION_TYPE_NAME);
+ sb.append("(a)Alternative").append(lineDelimiter);
+ }
+ }
+
+ protected void addNamedAnnotation(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ if(named != null && named.composite.getValue() == Boolean.TRUE) {
+ imports.addImport(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ sb.append("(a)Named").append(lineDelimiter);
+ }
+ }
+
+ protected void addScopeAnnotation(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ if(scope != null && scope.getValue() != null &&
scope.getValue().toString().length() > 0) {
+ String scopeName = scope.getValue().toString();
+ String qScopeName = scopes.get(scopeName);
+ imports.addImport(qScopeName);
+ sb.append(scopeName).append(lineDelimiter);
+ }
+ }
+
+ @Override
+ protected void createCustomFields(Composite composite) {
+ createInheritedField(composite, false);
+ createAlternativeField(composite);
+ createScopeField(composite);
+ createTargetField(composite);
+ }
+
+ protected void createAlternativeField(Composite composite) {
+ String label = "Add @Alternative";
+ alternative = createCheckBoxField(composite, "isAlternative", label, false);
+ }
+
+ protected void createNamedField(Composite composite) {
+ String label = "Add @Named";
+ named = createCheckBoxField(composite, "isNamed", label, false);
+ }
+
+ protected void createScopeField(Composite composite) {
+ List<String> vs = new ArrayList<String>();
+ vs.add("");
+ scope = createComboField("Scope", "Scope", composite, vs);
+ setScopes(getPackageFragmentRoot());
+ }
+
+ protected void createTargetField(Composite composite) {
+ List<String> targetOptions = new ArrayList<String>();
+ targetOptions.add("TYPE,METHOD,FIELD");
+ targetOptions.add("METHOD,FIELD");
+ targetOptions.add("TYPE");
+ targetOptions.add("METHOD");
+ targetOptions.add("FIELD");
+ createTargetField(composite, targetOptions);
+ }
+
+ public void setPackageFragmentRoot(IPackageFragmentRoot root, boolean canBeModified) {
+ super.setPackageFragmentRoot(root, canBeModified);
+ setScopes(root);
+ }
+
+ void setScopes(IPackageFragmentRoot root) {
+ if(root != null) {
+ IJavaProject jp = root.getJavaProject();
+ ICDIProject cdi = CDICorePlugin.getCDIProject(jp.getProject(), true);
+ if(cdi != null) {
+ Set<String> scopes = cdi.getScopeNames();
+ String[] tags = scopes.toArray(new String[0]);
+ setScopes(tags);
+ } else {
+ setScopes(new String[]{""});
+ }
+ } else {
+ setScopes(new String[]{""});
+ }
+ }
+
+ void setScopes(String[] tags) {
+ scopes.clear();
+ scopes.put("", "");
+ for (String tag: tags) {
+ if(tag.length() == 0) continue;
+ int i = tag.lastIndexOf('.');
+ String name = "@" + tag.substring(i + 1);
+ scopes.put(name, tag);
+ }
+ if(scope != null) {
+ scope.setTags(scopes.keySet().toArray(new String[0]));
+ scope.setValue("");
+ }
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain