Author: scabanovich
Date: 2010-06-11 06:27:21 -0400 (Fri, 11 Jun 2010)
New Revision: 22764
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIAnnotationLabelProvider.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIAnnotationSelectionProvider.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/InterceptorBindingSelectionProvider.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorBindingCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorBindingWizardPage.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewScopeCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewScopeWizardPage.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectCDIAnnotationDialog.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/StereotypesSelectionProvider.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/NewCDIAnnotationWizardPage.java
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/NewStereotypeWizardPage.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-11 10:25:48 UTC (rev
22763)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml 2010-06-11 10:27:21 UTC (rev
22764)
@@ -143,6 +143,30 @@
Create a Stereotype Java File
</description>
</wizard>
+
+ <wizard
+ category="org.jboss.tools.cdi.ui"
+ class="org.jboss.tools.cdi.ui.wizard.NewScopeCreationWizard"
+ icon="icons/cdi16.png"
+ id="org.jboss.tools.cdi.ui.wizard.NewScopeCreationWizard"
+ name="Scope Annotation Type"
+ project="false">
+ <description>
+ Create a Scope Java File
+ </description>
+ </wizard>
+
+ <wizard
+ category="org.jboss.tools.cdi.ui"
+
class="org.jboss.tools.cdi.ui.wizard.NewInterceptorBindingCreationWizard"
+ icon="icons/cdi16.png"
+ id="org.jboss.tools.cdi.ui.wizard.NewInterceptorBindingCreationWizard"
+ name="Interceptor Binding Annotation Type"
+ project="false">
+ <description>
+ Create a Interceptor Binding 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-11
10:25:48 UTC (rev 22763)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -32,5 +32,17 @@
public static String NEW_QUALIFIER_WIZARD_PAGE_NAME;
public static String NEW_STEREOTYPE_WIZARD_TITLE;
public static String NEW_STEREOTYPE_WIZARD_PAGE_NAME;
+ public static String NEW_SCOPE_WIZARD_TITLE;
+ public static String NEW_SCOPE_WIZARD_PAGE_NAME;
+ public static String NEW_INTERCEPTOR_BINDING_WIZARD_TITLE;
+ public static String NEW_INTERCEPTOR_BINDING_WIZARD_PAGE_NAME;
+ public static String SELECT_STEREOTYPE;
+ public static String SELECT_INTERCEPTOR_BINDING;
+
+ public static String FIELD_EDITOR_SCOPE_LABEL;
+ public static String FIELD_EDITOR_TARGET_LABEL;
+ public static String FIELD_EDITOR_INTERCEPTOR_BINDINGS_LABEL;
+ public static String FIELD_EDITOR_STEREOTYPES_LABEL;
+
}
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-11
10:25:48 UTC (rev 22763)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2010-06-11
10:27:21 UTC (rev 22764)
@@ -20,4 +20,16 @@
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
+NEW_STEREOTYPE_WIZARD_PAGE_NAME=Stereotype Annotation Type
+NEW_SCOPE_WIZARD_TITLE=New Scope
+NEW_SCOPE_WIZARD_PAGE_NAME=Scope Annotation Type
+NEW_INTERCEPTOR_BINDING_WIZARD_TITLE=New Interceptor Binding
+NEW_INTERCEPTOR_BINDING_WIZARD_PAGE_NAME=Interceptor Binding Annotation Type
+
+SELECT_STEREOTYPE=Select Stereotype Annotation Type
+SELECT_INTERCEPTOR_BINDING=Select Interceptor Binding Annotation Type
+
+FIELD_EDITOR_SCOPE_LABEL=Scope:
+FIELD_EDITOR_TARGET_LABEL=Target:
+FIELD_EDITOR_INTERCEPTOR_BINDINGS_LABEL=Interceptor Bindings:
+FIELD_EDITOR_STEREOTYPES_LABEL=Stereotypes:
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIAnnotationLabelProvider.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIAnnotationLabelProvider.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIAnnotationLabelProvider.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -0,0 +1,15 @@
+package org.jboss.tools.cdi.ui.wizard;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.jboss.tools.cdi.core.ICDIAnnotation;
+
+public class CDIAnnotationLabelProvider extends LabelProvider {
+
+ public String getText(Object element) {
+ if(element instanceof ICDIAnnotation) {
+ return ((ICDIAnnotation)element).getSourceType().getFullyQualifiedName();
+ }
+ return super.getText(element);
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIAnnotationLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIAnnotationSelectionProvider.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIAnnotationSelectionProvider.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIAnnotationSelectionProvider.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.jface.viewers.ILabelProvider;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
+import org.jboss.tools.cdi.core.ICDIAnnotation;
+import org.jboss.tools.cdi.core.ICDIProject;
+import org.jboss.tools.cdi.ui.CDIUIPlugin;
+import org.jboss.tools.cdi.ui.wizard.SelectCDIAnnotationDialog.CDIAnnotationWrapper;
+import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
+import org.jboss.tools.common.ui.widget.editor.ListFieldEditor.ListFieldEditorProvider;
+
+public abstract class CDIAnnotationSelectionProvider implements
ListFieldEditorProvider<ICDIAnnotation> {
+ protected ICDIProject project;
+ protected IFieldEditor editor;
+
+ public CDIAnnotationSelectionProvider() {}
+
+ public void setEditorField(IFieldEditor editor) {
+ this.editor = editor;
+ }
+
+ public void setProject(ICDIProject project) {
+ this.project = project;
+ }
+
+ public ICDIProject getProject() {
+ return project;
+ }
+
+ public FilteredItemsSelectionDialog createSelectionDialog() {
+ Shell shell =
CDIUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
+ SelectCDIAnnotationDialog dialog = new SelectCDIAnnotationDialog(shell);
+ dialog.setTitle(getDialogTitle());
+ dialog.setProvider(this);
+ return dialog;
+ }
+
+ protected abstract String getDialogTitle();
+
+ public ICDIAnnotation getSelected(Object selected) {
+ if(selected instanceof CDIAnnotationWrapper) {
+ return ((CDIAnnotationWrapper)selected).getComponent();
+ } else if(selected instanceof ICDIAnnotation) {
+ return (ICDIAnnotation)selected;
+ }
+ return null;
+ }
+
+ public ILabelProvider createLabelProvider() {
+ return new CDIAnnotationLabelProvider();
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIAnnotationSelectionProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/InterceptorBindingSelectionProvider.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/InterceptorBindingSelectionProvider.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/InterceptorBindingSelectionProvider.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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 org.jboss.tools.cdi.core.ICDIAnnotation;
+import org.jboss.tools.cdi.core.IInterceptorBinding;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+
+public class InterceptorBindingSelectionProvider extends CDIAnnotationSelectionProvider
{
+
+ public InterceptorBindingSelectionProvider() {}
+
+ public ICDIAnnotation[] getSelectableObjects() {
+ if(project == null) return new ICDIAnnotation[0];
+ List<ICDIAnnotation> as = new ArrayList<ICDIAnnotation>();
+ IInterceptorBinding[] ss = project.getInterceptorBindings();
+ List c = (List)editor.getValue();
+ for (IInterceptorBinding s: ss) {
+ if(c.contains(s)) continue;
+ as.add(s);
+ }
+ return as.toArray(new ICDIAnnotation[0]);
+ }
+
+ @Override
+ protected String getDialogTitle() {
+ return CDIUIMessages.SELECT_INTERCEPTOR_BINDING;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/InterceptorBindingSelectionProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
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 2010-06-11
10:25:48 UTC (rev 22763)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIAnnotationWizardPage.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -20,6 +20,7 @@
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.jdt.ui.wizards.NewTypeWizardPage.ImportsManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
@@ -28,6 +29,9 @@
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.core.ICDIAnnotation;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
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;
@@ -66,23 +70,30 @@
}
sb.append("@Target( {" + list.toString() + "}
)").append(lineDelimiter);
}
+
+ protected void addAnnotation(String typeName, ImportsManager imports, StringBuffer sb,
String lineDelimiter) {
+ int i = typeName.lastIndexOf('.');
+ String name = typeName.substring(i + 1);
+ imports.addImport(typeName);
+ sb.append("(a)").append(name).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);
+ addAnnotation(CDIConstants.INHERITED_ANNOTATION_TYPE_NAME, imports, sb,
lineDelimiter);
}
}
protected void addRetentionAnnotation(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
- imports.addImport("java.lang.annotation.Retention");
+ imports.addImport(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME);
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);
+ addAnnotation("java.lang.annotation.Documented", imports, sb,
lineDelimiter);
}
public void createControl(Composite parent) {
@@ -105,11 +116,11 @@
createTypeNameControls(composite, nColumns);
// createModifierControls(composite, nColumns);
+ createCustomFields(composite);
+
createCommentControls(composite, nColumns);
enableCommentControl(true);
- createCustomFields(composite);
-
setControl(composite);
Dialog.applyDialogFont(composite);
@@ -126,7 +137,6 @@
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;
@@ -141,7 +151,7 @@
}
protected void createTargetField(Composite composite, List<String> values) {
- target = createComboField("Target", "Target", composite, values);
+ target = createComboField("Target", CDIUIMessages.FIELD_EDITOR_TARGET_LABEL,
composite, values);
}
protected ITaggedFieldEditor createComboField(String name, String label, Composite
composite, List<String> values) {
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorBindingCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorBindingCreationWizard.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorBindingCreationWizard.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -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 NewInterceptorBindingCreationWizard extends NewCDIAnnotationCreationWizard
{
+
+ public NewInterceptorBindingCreationWizard() {
+ setWindowTitle(CDIUIMessages.NEW_INTERCEPTOR_BINDING_WIZARD_TITLE);
+ }
+
+ protected NewAnnotationWizardPage createAnnotationWizardPage() {
+ return new NewInterceptorBindingWizardPage();
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorBindingCreationWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorBindingWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorBindingWizardPage.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorBindingWizardPage.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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 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.ICDIAnnotation;
+import org.jboss.tools.cdi.core.ICDIProject;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.common.ui.widget.editor.ListFieldEditor;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class NewInterceptorBindingWizardPage extends NewCDIAnnotationWizardPage {
+ protected InterceptorBindingSelectionProvider interceptorBindingsProvider = new
InterceptorBindingSelectionProvider();
+ protected ListFieldEditor interceptorBindings = null;
+
+
+ public NewInterceptorBindingWizardPage() {
+ setTitle(CDIUIMessages.NEW_INTERCEPTOR_BINDING_WIZARD_PAGE_NAME);
+ }
+
+ protected void addAnnotations(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ addInterceptorBindingAnnotation(imports, sb, lineDelimiter);
+ addInheritedAnnotation(imports, sb, lineDelimiter);
+ addInterceptorBindingAnnotations(imports, sb, lineDelimiter);
+ addTargetAnnotation(imports, sb, lineDelimiter, getTargets());
+ addRetentionAnnotation(imports, sb, lineDelimiter);
+ addDocumentedAnnotation(imports, sb, lineDelimiter);
+ }
+
+ protected void addInterceptorBindingAnnotation(ImportsManager imports, StringBuffer sb,
String lineDelimiter) {
+ addAnnotation(CDIConstants.INTERCEPTOR_BINDING_ANNOTATION_TYPE_NAME, imports, sb,
lineDelimiter);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void addInterceptorBindingAnnotations(ImportsManager imports, StringBuffer sb,
String lineDelimiter) {
+ if(interceptorBindings != null) {
+ List list = (List)interceptorBindings.getValue();
+ for (Object o: list) {
+ if(o instanceof ICDIAnnotation) {
+ ICDIAnnotation a = (ICDIAnnotation)o;
+ String typeName = a.getSourceType().getFullyQualifiedName();
+ addAnnotation(typeName, imports, sb, lineDelimiter);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void createCustomFields(Composite composite) {
+ createInheritedField(composite, true);
+ createTargetField(composite);
+ createInterceptorBindingField(composite);
+ }
+
+ protected void createTargetField(Composite composite) {
+ List<String> targetOptions = new ArrayList<String>();
+ targetOptions.add("TYPE,METHOD");
+ targetOptions.add("TYPE");
+ createTargetField(composite, targetOptions);
+ }
+
+ protected void createInterceptorBindingField(Composite composite) {
+ interceptorBindings = new ListFieldEditor("interceptorBindings",
CDIUIMessages.FIELD_EDITOR_INTERCEPTOR_BINDINGS_LABEL, new ArrayList<Object>());
+ interceptorBindings.setProvider(interceptorBindingsProvider);
+ interceptorBindingsProvider.setEditorField(interceptorBindings);
+ interceptorBindings.doFillIntoGrid(composite);
+ setInterceptorBindings(getPackageFragmentRoot());
+ }
+
+ public void setPackageFragmentRoot(IPackageFragmentRoot root, boolean canBeModified) {
+ super.setPackageFragmentRoot(root, canBeModified);
+ setInterceptorBindings(root);
+ }
+
+ void setInterceptorBindings(IPackageFragmentRoot root) {
+ interceptorBindingsProvider.setProject(null);
+ if(root != null) {
+ IJavaProject jp = root.getJavaProject();
+ ICDIProject cdi = CDICorePlugin.getCDIProject(jp.getProject(), true);
+ if(cdi != null) {
+ interceptorBindingsProvider.setProject(cdi);
+ }
+ }
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorBindingWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-11
10:25:48 UTC (rev 22763)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewQualifierWizardPage.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -10,8 +10,8 @@
******************************************************************************/
package org.jboss.tools.cdi.ui.wizard;
-import org.eclipse.jdt.ui.wizards.NewTypeWizardPage.ImportsManager;
import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.ui.CDIUIMessages;
/**
@@ -26,16 +26,15 @@
}
protected void addAnnotations(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ addQualifierAnnotation(imports, sb, lineDelimiter);
addInheritedAnnotation(imports, sb, lineDelimiter);
addTargetAnnotation(imports, sb, lineDelimiter, getTargets());
addRetentionAnnotation(imports, sb, lineDelimiter);
addDocumentedAnnotation(imports, sb, lineDelimiter);
- addQualifierAnnotation(imports, sb, lineDelimiter);
}
protected void addQualifierAnnotation(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
- imports.addImport("javax.inject.Qualifier");
- sb.append("(a)Qualifier").append(lineDelimiter);
+ addAnnotation(CDIConstants.QUALIFIER_ANNOTATION_TYPE_NAME, imports, sb,
lineDelimiter);
}
@Override
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewScopeCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewScopeCreationWizard.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewScopeCreationWizard.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -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 NewScopeCreationWizard extends NewCDIAnnotationCreationWizard {
+
+ public NewScopeCreationWizard() {
+ setWindowTitle(CDIUIMessages.NEW_SCOPE_WIZARD_TITLE);
+ }
+
+ protected NewAnnotationWizardPage createAnnotationWizardPage() {
+ return new NewScopeWizardPage();
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewScopeCreationWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewScopeWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewScopeWizardPage.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewScopeWizardPage.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.cdi.ui.wizard.NewCDIAnnotationWizardPage.CheckBoxEditorWrapper;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class NewScopeWizardPage extends NewCDIAnnotationWizardPage {
+ protected CheckBoxEditorWrapper normal = null;
+ protected CheckBoxEditorWrapper passivating = null;
+
+ public NewScopeWizardPage() {
+ setTitle(CDIUIMessages.NEW_SCOPE_WIZARD_PAGE_NAME);
+ }
+
+ protected void addAnnotations(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ addScopeAnnotation(imports, sb, lineDelimiter);
+ addInheritedAnnotation(imports, sb, lineDelimiter);
+ addTargetAnnotation(imports, sb, lineDelimiter, getTargets());
+ addRetentionAnnotation(imports, sb, lineDelimiter);
+ addDocumentedAnnotation(imports, sb, lineDelimiter);
+ }
+
+ protected String[] getTargets() {
+ return new String[]{"TYPE", "METHOD", "FIELD"};
+ }
+
+ protected void addScopeAnnotation(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ if(normal != null) {
+ if(normal.composite.getValue() == Boolean.FALSE) {
+ addAnnotation(CDIConstants.SCOPE_ANNOTATION_TYPE_NAME, imports, sb, lineDelimiter);
+ } else if(passivating.composite.getValue() == Boolean.FALSE) {
+ addAnnotation(CDIConstants.NORMAL_SCOPE_ANNOTATION_TYPE_NAME, imports, sb,
lineDelimiter);
+ } else {
+ String typeName = CDIConstants.NORMAL_SCOPE_ANNOTATION_TYPE_NAME;
+ int i = typeName.lastIndexOf('.');
+ String name = typeName.substring(i + 1);
+ imports.addImport(typeName);
+ sb.append("(a)").append(name).append("(passivating=true)").append(lineDelimiter);
+ }
+ }
+ }
+
+ @Override
+ protected void createCustomFields(Composite parent) {
+ createInheritedField(parent, true);
+ createNormalField(parent);
+ createPassivatingField(parent);
+ }
+
+ protected void createNormalField(Composite composite) {
+ String label = "is normal scope";
+ normal = createCheckBoxField(composite, "isNormal", label, true);
+ normal.checkBox.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ Object o = evt.getNewValue();
+ passivating.checkBox.setEnabled(o != Boolean.FALSE);
+ }});
+ }
+
+ protected void createPassivatingField(Composite composite) {
+ String label = "is passivating";
+ passivating = createCheckBoxField(composite, "isPassivating", label, false);
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewScopeWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2010-06-11
10:25:48 UTC (rev 22763)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.cdi.ui.wizard;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -21,9 +23,11 @@
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.ICDIAnnotation;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.common.ui.widget.editor.ITaggedFieldEditor;
+import org.jboss.tools.common.ui.widget.editor.ListFieldEditor;
/**
*
@@ -35,38 +39,42 @@
protected CheckBoxEditorWrapper named = null;
protected ITaggedFieldEditor scope = null;
protected Map<String, String> scopes = new TreeMap<String, String>();
+ protected StereotypesSelectionProvider stereotypesProvider = new
StereotypesSelectionProvider();
+ protected InterceptorBindingSelectionProvider interceptorBindingsProvider = new
InterceptorBindingSelectionProvider();
+ protected ListFieldEditor stereotypes = null;
+ protected ListFieldEditor interceptorBindings = null;
+
public NewStereotypeWizardPage() {
setTitle(CDIUIMessages.NEW_STEREOTYPE_WIZARD_PAGE_NAME);
}
protected void addAnnotations(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
+ addStereotypeAnnotation(imports, sb, lineDelimiter);
addInheritedAnnotation(imports, sb, lineDelimiter);
addAlternativeAnnotation(imports, sb, lineDelimiter);
addScopeAnnotation(imports, sb, lineDelimiter);
addNamedAnnotation(imports, sb, lineDelimiter);
- addStereotypeAnnotation(imports, sb, lineDelimiter);
+ addInterceptorBindingAnnotations(imports, sb, lineDelimiter);
+ addSuperStereotypeAnnotations(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);
+ addAnnotation(CDIConstants.STEREOTYPE_ANNOTATION_TYPE_NAME, imports, sb,
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);
+ addAnnotation(CDIConstants.ALTERNATIVE_ANNOTATION_TYPE_NAME, imports, sb,
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);
+ addAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME, imports, sb, lineDelimiter);
}
}
@@ -74,11 +82,38 @@
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);
+ addAnnotation(qScopeName, imports, sb, lineDelimiter);
}
}
+ @SuppressWarnings("unchecked")
+ protected void addSuperStereotypeAnnotations(ImportsManager imports, StringBuffer sb,
String lineDelimiter) {
+ if(stereotypes != null) {
+ List list = (List)stereotypes.getValue();
+ for (Object o: list) {
+ if(o instanceof ICDIAnnotation) {
+ ICDIAnnotation a = (ICDIAnnotation)o;
+ String typeName = a.getSourceType().getFullyQualifiedName();
+ addAnnotation(typeName, imports, sb, lineDelimiter);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void addInterceptorBindingAnnotations(ImportsManager imports, StringBuffer sb,
String lineDelimiter) {
+ if(interceptorBindings != null) {
+ List list = (List)interceptorBindings.getValue();
+ for (Object o: list) {
+ if(o instanceof ICDIAnnotation) {
+ ICDIAnnotation a = (ICDIAnnotation)o;
+ String typeName = a.getSourceType().getFullyQualifiedName();
+ addAnnotation(typeName, imports, sb, lineDelimiter);
+ }
+ }
+ }
+ }
+
@Override
protected void createCustomFields(Composite composite) {
createInheritedField(composite, false);
@@ -86,6 +121,8 @@
createNamedField(composite);
createScopeField(composite);
createTargetField(composite);
+ createInterceptorBindingField(composite);
+ createStereotypeField(composite);
}
protected void createAlternativeField(Composite composite) {
@@ -101,7 +138,7 @@
protected void createScopeField(Composite composite) {
List<String> vs = new ArrayList<String>();
vs.add("");
- scope = createComboField("Scope", "Scope", composite, vs);
+ scope = createComboField("scope", CDIUIMessages.FIELD_EDITOR_SCOPE_LABEL,
composite, vs);
setScopes(getPackageFragmentRoot());
}
@@ -115,6 +152,32 @@
createTargetField(composite, targetOptions);
}
+ protected void createInterceptorBindingField(Composite composite) {
+ interceptorBindings = new ListFieldEditor("interceptorBindings",
CDIUIMessages.FIELD_EDITOR_INTERCEPTOR_BINDINGS_LABEL, new ArrayList<Object>());
+ interceptorBindings.setProvider(interceptorBindingsProvider);
+ interceptorBindingsProvider.setEditorField(interceptorBindings);
+ interceptorBindings.doFillIntoGrid(composite);
+ setInterceptorBindings(getPackageFragmentRoot());
+ interceptorBindings.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ Object o = evt.getNewValue();
+ if(o instanceof List && !((List)o).isEmpty()) {
+ target.setValue("TYPE");
+ target.setEnabled(false);
+ } else {
+ target.setEnabled(true);
+ }
+ }});
+ }
+
+ protected void createStereotypeField(Composite composite) {
+ stereotypes = new ListFieldEditor("stereotypes",
CDIUIMessages.FIELD_EDITOR_STEREOTYPES_LABEL, new ArrayList<Object>());
+ stereotypes.setProvider(stereotypesProvider);
+ stereotypesProvider.setEditorField(stereotypes);
+ stereotypes.doFillIntoGrid(composite);
+ setStereotypes(getPackageFragmentRoot());
+ }
+
public void setPackageFragmentRoot(IPackageFragmentRoot root, boolean canBeModified) {
super.setPackageFragmentRoot(root, canBeModified);
setScopes(root);
@@ -135,7 +198,27 @@
setScopes(new String[]{""});
}
}
+
+ void setInterceptorBindings(IPackageFragmentRoot root) {
+ interceptorBindingsProvider.setProject(null);
+ if(root != null) {
+ IJavaProject jp = root.getJavaProject();
+ ICDIProject cdi = CDICorePlugin.getCDIProject(jp.getProject(), true);
+ if(cdi != null) {
+ interceptorBindingsProvider.setProject(cdi);
+ }
+ }
+ }
+ void setStereotypes(IPackageFragmentRoot root) {
+ stereotypesProvider.setProject(null);
+ if(root != null) {
+ IJavaProject jp = root.getJavaProject();
+ ICDIProject cdi = CDICorePlugin.getCDIProject(jp.getProject(), true);
+ if(cdi != null) stereotypesProvider.setProject(cdi);
+ }
+ }
+
void setScopes(String[] tags) {
scopes.clear();
scopes.put("", "");
@@ -154,5 +237,5 @@
public void setNamed(boolean b) {
if(named != null) named.composite.setValue(b);
}
-
+
}
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectCDIAnnotationDialog.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectCDIAnnotationDialog.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectCDIAnnotationDialog.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -0,0 +1,358 @@
+/*******************************************************************************
+ * 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.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.DialogSettings;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.WorkbenchException;
+import org.eclipse.ui.XMLMemento;
+import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
+import org.eclipse.ui.dialogs.SearchPattern;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.ICDIAnnotation;
+import org.jboss.tools.cdi.core.ICDIProject;
+import org.jboss.tools.cdi.ui.CDIUIPlugin;
+import org.jboss.tools.common.ui.widget.editor.ListFieldEditor.ListFieldEditorProvider;
+/**
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class SelectCDIAnnotationDialog extends FilteredItemsSelectionDialog {
+ private static final String FILE_NAME = "SelectCDIAnnotationHistory.xml";
//$NON-NLS-1$
+ private static final String ROOT_NODE = "historyRootNode"; //$NON-NLS-1$
+ private static final String INFO_NODE = "infoNode"; //$NON-NLS-1$
+ private static final String PROJECT_NAME = "ProjectName"; //$NON-NLS-1$
+ private static final String COMPONENT_NAME = "ComponentName"; //$NON-NLS-1$
+ private static final String DELETED = "Deleted"; //$NON-NLS-1$
+ private static final String SEPARATOR = " - "; //$NON-NLS-1$
+ private static final String YES = "yes"; //$NON-NLS-1$
+ private static final String NO = "no"; //$NON-NLS-1$
+
+ ListFieldEditorProvider<ICDIAnnotation> provider = null;
+
+ public SelectCDIAnnotationDialog(Shell shell) {
+ super(shell);
+
+ setSelectionHistory(new SeamComponentSelectionHistory());
+
+ setListLabelProvider(new CDIAnnotationLabelProvider());
+ setDetailsLabelProvider(new CDIAnnotationLabelProvider());
+
+ XMLMemento memento = loadMemento();
+ if (memento != null)
+ getSelectionHistory().load(memento);
+ }
+
+ public void setProvider(ListFieldEditorProvider<ICDIAnnotation> provider) {
+ this.provider = provider;
+ }
+
+ public void startSearch() {
+ applyFilter();
+ }
+
+ @Override
+ public void okPressed() {
+ super.okPressed();
+ }
+
+ public void stopSearchAndShowResults() {
+ refresh();
+ List list = getSelectedItems().toList();
+ Collections.sort(list,getItemsComparator());
+ setResult(list);
+ }
+
+ protected Control createExtendedContentArea(Composite parent) {
+ return null;
+ }
+
+ protected ItemsFilter createFilter() {
+ return new CDIAnnotionFilter();
+ }
+
+ protected void fillContentProvider(AbstractContentProvider contentProvider,
+ ItemsFilter itemsFilter, IProgressMonitor progressMonitor)
+ throws CoreException {
+
+ progressMonitor.subTask("Wait");
+
+ try {
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+ if(provider != null) {
+
+ ICDIAnnotation[] as = provider.getSelectableObjects();
+ for (ICDIAnnotation component: as) {
+ IProject project = component.getCDIProject().getNature().getProject();
+ contentProvider.add(new CDIAnnotationWrapper(
+ component.getSourceType().getFullyQualifiedName(), project.getName(), component),
+ itemsFilter);
+ }
+ progressMonitor.worked(1);
+ }
+ progressMonitor.done();
+ }
+
+ private static XMLMemento loadMemento() {
+ XMLMemento memento = null;
+ IPath stateLocation = CDIUIPlugin.getDefault().getStateLocation()
+ .append(FILE_NAME);
+ File file = new File(stateLocation.toOSString());
+ if (file.exists()) {
+ FileReader reader = null;
+ try {
+ reader = new FileReader(file);
+
+ memento = XMLMemento.createReadRoot(reader);
+ } catch (IOException ex) {
+ CDIUIPlugin.getDefault().logError(ex);
+ } catch (WorkbenchException ex) {
+ CDIUIPlugin.getDefault().logError(ex);
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException ex) {
+ CDIUIPlugin.getDefault().logError(ex);
+ }
+ }
+ }
+ return memento;
+ }
+
+ private static void saveMemento(XMLMemento xmlMemento) {
+ IPath stateLocation = CDIUIPlugin.getDefault().getStateLocation()
+ .append(FILE_NAME);
+ File file = new File(stateLocation.toOSString());
+ FileWriter writer = null;
+ try {
+ writer = new FileWriter(file);
+
+ xmlMemento.save(writer);
+ } catch (IOException ex) {
+ CDIUIPlugin.getDefault().logError(ex);
+ } finally {
+ try {
+ writer.close();
+ } catch (IOException ex) {
+ CDIUIPlugin.getDefault().logError(ex);
+ }
+ }
+ }
+
+ protected IDialogSettings getDialogSettings() {
+ return new DialogSettings("OPEN_CDI_COMPONENT_DIALOG_NAME"); //TODO
+ }
+
+ public String getElementName(Object item) {
+ if (item instanceof CDIAnnotationWrapper) {
+ CDIAnnotationWrapper componentWrapper = (CDIAnnotationWrapper) item;
+ return componentWrapper.getComponentName();
+ }
+ return null;
+ }
+
+ protected Comparator<CDIAnnotationWrapper> getItemsComparator() {
+ return new CDIAnnotationComparator();
+ }
+
+ protected IStatus validateItem(Object item) {
+ return new Status(getSelectedItems().size() >=
0?IStatus.OK:IStatus.ERROR,CDIUIPlugin.PLUGIN_ID,null);
+ }
+
+ public class CDIAnnotationComparator implements Comparator<CDIAnnotationWrapper>
{
+ public int compare(CDIAnnotationWrapper left, CDIAnnotationWrapper right) {
+ return left.getComponentName().compareTo(right.getComponentName());
+ }
+
+ }
+
+ public class CDIAnnotionFilter extends ItemsFilter {
+
+ public CDIAnnotionFilter() {
+ if(patternMatcher != null && patternMatcher.getPattern() == null ||
patternMatcher.getPattern().length() == 0) {
+ patternMatcher.setPattern("*");
+ }
+ }
+
+ public CDIAnnotionFilter(SearchPattern searchPattern) {
+ super(searchPattern);
+ }
+ public boolean isConsistentItem(Object item) {
+ return true;
+ }
+
+ public boolean matchItem(Object item) {
+ if (item instanceof CDIAnnotationWrapper) {
+ CDIAnnotationWrapper componentWrapper = (CDIAnnotationWrapper) item;
+
+ String qName = componentWrapper.getComponentName();
+ boolean result = patternMatcher.matches(qName);
+ if (!result) {
+ String pattern = patternMatcher.getPattern();
+ if (pattern.indexOf(".") < 0) {
+ int lastIndex = qName.lastIndexOf(".");
+ if (lastIndex >= 0 && (lastIndex + 1) < qName.length())
+ return patternMatcher.matches(qName.substring(lastIndex + 1));
+ }
+ }
+ return result;
+ }
+ return false;
+ }
+ }
+
+ public class SeamComponentSelectionHistory extends SelectionHistory {
+
+ public SeamComponentSelectionHistory() {
+ super();
+ }
+
+ protected Object restoreItemFromMemento(IMemento memento) {
+ XMLMemento mem = (XMLMemento) memento;
+ String projectName = mem.getString(PROJECT_NAME);
+ if (projectName == null)
+ return null;
+ String componentName = mem.getString(COMPONENT_NAME);
+ if (componentName == null)
+ return null;
+ String componentDeleted = mem.getString(DELETED);
+ if (componentDeleted != null && YES.equals(componentDeleted))
+ return null;
+ return new CDIAnnotationWrapper(componentName, projectName);
+ }
+
+ @Override
+ protected void storeItemToMemento(Object item, IMemento memento) {
+// CDIAnnotationWrapper a = (CDIAnnotationWrapper) item;
+// XMLMemento mem = (XMLMemento) memento;
+// mem.putString(PROJECT_NAME, a.getProjectName());
+// mem.putString(COMPONENT_NAME, a.getComponentName());
+ }
+
+ public void save(IMemento memento) {
+ super.save(memento);
+ if (!(memento instanceof XMLMemento))
+ return;
+ XMLMemento xmlMemento = (XMLMemento) memento;
+ saveMemento(xmlMemento);
+ }
+ }
+
+ public class CDIAnnotationLabelProvider implements ILabelProvider {
+
+ public Image getImage(Object element) {
+ return null; //TODO
+ }
+
+ public String getText(Object element) {
+ if (element instanceof CDIAnnotationWrapper) {
+ CDIAnnotationWrapper a = (CDIAnnotationWrapper) element;
+ return a.getComponentName() + SEPARATOR
+ + a.getProjectName();
+ }
+ return null;
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+ }
+
+ public class CDIAnnotationWrapper {
+ private String componentName;
+ private String projectName;
+ private ICDIAnnotation component;
+
+ public CDIAnnotationWrapper(String componentName, String projectName) {
+ this.componentName = componentName;
+ this.projectName = projectName;
+ }
+
+ public CDIAnnotationWrapper(String componentName, String projectName,
+ ICDIAnnotation component) {
+ this(componentName, projectName);
+ this.component = component;
+ }
+
+ public String getComponentName() {
+ return componentName;
+ }
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public ICDIAnnotation getComponent() {
+ if (component == null) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(projectName);
+ if (project != null) {
+ ICDIProject cdiProject = CDICorePlugin.getCDIProject(project, true);
+ if (cdiProject != null) {
+ ICDIAnnotation component =
+ cdiProject.getInterceptorBinding(componentName);
+ if(component == null) cdiProject.getStereotype(componentName);
+ //TODO
+ return component;
+ }
+ }
+ return null;
+ }
+ return component;
+ }
+
+ public boolean equals(Object o) {
+ if(o instanceof CDIAnnotationWrapper) {
+ CDIAnnotationWrapper other = (CDIAnnotationWrapper)o;
+ return componentName.equals(other.componentName) &&
projectName.equals(other.projectName);
+ }
+ return false;
+ }
+
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectCDIAnnotationDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/StereotypesSelectionProvider.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/StereotypesSelectionProvider.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/StereotypesSelectionProvider.java 2010-06-11
10:27:21 UTC (rev 22764)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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 org.jboss.tools.cdi.core.ICDIAnnotation;
+import org.jboss.tools.cdi.core.IStereotype;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+
+public class StereotypesSelectionProvider extends CDIAnnotationSelectionProvider {
+
+ public StereotypesSelectionProvider() {}
+
+ public ICDIAnnotation[] getSelectableObjects() {
+ if(project == null) return new ICDIAnnotation[0];
+ List<ICDIAnnotation> as = new ArrayList<ICDIAnnotation>();
+ IStereotype[] ss = project.getStereotypes();
+ List c = (List)editor.getValue();
+ for (IStereotype s: ss) {
+ if(c.contains(s)) continue;
+ as.add(s);
+ }
+ return as.toArray(new ICDIAnnotation[0]);
+ }
+
+ @Override
+ protected String getDialogTitle() {
+ return CDIUIMessages.SELECT_STEREOTYPE;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/StereotypesSelectionProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain