JBoss Tools SVN: r22767 - in trunk/vpe: plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2010-06-11 08:18:35 -0400 (Fri, 11 Jun 2010)
New Revision: 22767
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6287 , Dialog and SWTBot test were updated.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java 2010-06-11 11:41:35 UTC (rev 22766)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java 2010-06-11 12:18:35 UTC (rev 22767)
@@ -63,7 +63,6 @@
private final int DIALOG_WIDTH = 450;
private final int DIALOG_HEIGHT = 650;
private VpeController vpeController;
- private Text textStringValue;
private Text propsKey;
private Text propsValue;
private Button newFile;
@@ -75,7 +74,8 @@
private Group propsFilesGroup;
private Status propsKeyStatus;
private Status propsValueStatus;
- private Status selectedTextStatus;
+ private Status rbComboStatus;
+
private Table tagsTable;
public ExternalizeStringsWizardPage(String pageName, VpeController vpeController) {
@@ -91,7 +91,7 @@
this.bm = vpeController.getPageContext().getBundle();
propsKeyStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
propsValueStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- selectedTextStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
+ rbComboStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
}
public ExternalizeStringsWizardPage(String pageName) {
@@ -116,19 +116,19 @@
propsStringGroup.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
propsStringGroup.setText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
- /*
- * Create Text String label
- */
- Label textStringLabel = new Label(propsStringGroup, SWT.NONE);
- textStringLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1, 1));
- textStringLabel.setText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_TEXT_STRING);
- /*
- * Create Text String value
- */
- textStringValue = new Text(propsStringGroup, SWT.BORDER);
- textStringValue.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
- textStringValue.setText(Constants.EMPTY);
- textStringValue.setEditable(false);
+// /*
+// * Create Text String label
+// */
+// Label textStringLabel = new Label(propsStringGroup, SWT.NONE);
+// textStringLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1, 1));
+// textStringLabel.setText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_TEXT_STRING);
+// /*
+// * Create Text String value
+// */
+// textStringValue = new Text(propsStringGroup, SWT.BORDER);
+// textStringValue.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
+// textStringValue.setText(Constants.EMPTY);
+// textStringValue.setEditable(false);
/*
* Create Properties Key label
@@ -144,15 +144,6 @@
propsKey.setText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_KEY);
propsKey.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- if ((propsKey.getText() == null)
- || (Constants.EMPTY.equalsIgnoreCase(propsKey.getText().trim()))) {
- propsKeyStatus = new Status(
- IStatus.ERROR,
- VpePlugin.PLUGIN_ID,
- VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_KEY_MUST_BE_SET);
- } else {
- propsKeyStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- }
updateStatus();
}
});
@@ -167,18 +158,10 @@
*/
propsValue = new Text(propsStringGroup, SWT.BORDER);
propsValue.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
- propsValue.setText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_VALUE);
+ propsValue.setText(Constants.EMPTY);
+ propsValue.setEditable(false);
propsValue.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- if ((propsValue.getText() == null)
- || (Constants.EMPTY.equalsIgnoreCase(propsValue.getText().trim()))) {
- propsValueStatus = new Status(
- IStatus.ERROR,
- VpePlugin.PLUGIN_ID,
- VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_VALUE_MUST_BE_SET);
- } else {
- propsValueStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- }
updateStatus();
}
});
@@ -235,8 +218,15 @@
if (bundleFile != null) {
bundlePath = bundleFile.getFullPath().toString();
updateTable(bundleFile);
- }
+ } else {
+ VpePlugin.getDefault().logError(
+ "Could not get Bundle File for resource '" //$NON-NLS-1$
+ + rbCombo.getText() + "'"); //$NON-NLS-1$
+ }
propsFile.setText(bundlePath);
+
+ updateDuplicateKeyStatus();
+ updateStatus();
setPageComplete(isPageComplete());
}
});
@@ -291,7 +281,7 @@
VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_INITIALIZATION_ERROR);
} else {
ISelection sel = vpeController.getSourceEditor().getSelectionProvider().getSelection();
- if ((textStringValue != null) && (propsKey != null)
+ if ((propsValue != null) && (propsKey != null)
&& isSelectionCorrect(sel)) {
/*
* TODO: One must add functionality
@@ -303,20 +293,11 @@
IStructuredSelection structuredSelection = (IStructuredSelection) sel;
textSelection = (TextSelection) sel;
text = textSelection.getText();
- if (text.trim().length() < 1) {
- selectedTextStatus = new Status(
- IStatus.ERROR,
- VpePlugin.PLUGIN_ID,
- VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_SELECTED_TEXT_IS_EMPTY);
- } else if ((text.indexOf(Constants.GT) != -1) || (text.indexOf(Constants.LT) != -1)) {
- selectedTextStatus = new Status(
- IStatus.ERROR,
- VpePlugin.PLUGIN_ID,
- VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_WRONG_SELECTED_TEXT);
- } else {
- selectedTextStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- }
/*
+ * Update text string field
+ */
+ propsValue.setText(text);
+ /*
* Update status message.
*/
updateStatus();
@@ -341,10 +322,6 @@
VpePlugin.getDefault().logWarning(
VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_INITIALIZATION_ERROR);
}
- /*
- * Update text string field
- */
- textStringValue.setText(text);
/*
* Initialize bundle messages field
@@ -374,12 +351,36 @@
}
}
+ private boolean isDuplicatedKey(String key) {
+ boolean isDupliacted = false;
+ if ((tagsTable.getItemCount() > 0) && (null != key)) {
+ TableItem[] items = tagsTable.getItems();
+ for (TableItem tableItem : items) {
+ if (key.equalsIgnoreCase(tableItem.getText(0))) {
+ isDupliacted = true;
+ break;
+ }
+ }
+ }
+ return isDupliacted;
+ }
+
private void updateTable(IFile file) {
if ((file != null) && file.exists()) {
try {
+ /*
+ * Rad file content
+ */
BufferedReader in = new BufferedReader(new InputStreamReader(
file.getContents()));
String line = in.readLine();
+ /*
+ * Clear the table
+ */
+ tagsTable.clearAll();
+ /*
+ * Fill in new values
+ */
int i = 0;
while (line != null) {
TableItem tableItem = null;
@@ -395,10 +396,15 @@
line = in.readLine();
}
} catch (CoreException e) {
- e.printStackTrace();
+ VpePlugin.getDefault().logError(
+ "Could not load file content for '" + file + "'", e); //$NON-NLS-1$ //$NON-NLS-2$
} catch (IOException e) {
- e.printStackTrace();
+ VpePlugin.getDefault().logError(
+ "Could not read file: '" + file + "'", e); //$NON-NLS-1$ //$NON-NLS-2$
}
+ } else {
+ VpePlugin.getDefault().logError(
+ "Bundle File'" + file + "' does not exist!"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -454,8 +460,58 @@
return true;
}
+ private void updateDuplicateKeyStatus() {
+ if (isDuplicatedKey(propsKey.getText())) {
+ rbComboStatus = new Status(
+ IStatus.ERROR,
+ VpePlugin.PLUGIN_ID,
+ VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_KEY_ALREADY_EXISTS);
+ } else {
+ rbComboStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
+ }
+ }
+
+ private void updatePropertiesValueStatus() {
+ String text = propsValue.getText();
+ if ((text == null)
+ || (Constants.EMPTY.equalsIgnoreCase(text.trim()))
+ || (text.indexOf(Constants.GT) != -1)
+ || (text.indexOf(Constants.LT) != -1)) {
+ propsValueStatus = new Status(
+ IStatus.ERROR,
+ VpePlugin.PLUGIN_ID,
+ VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_WRONG_SELECTED_TEXT);
+ } else {
+ propsValueStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
+ }
+ }
+
+ private void updatePropertiesKeyStatus() {
+ if ((propsKey.getText() == null)
+ || (Constants.EMPTY.equalsIgnoreCase(propsKey.getText().trim()))) {
+ propsKeyStatus = new Status(
+ IStatus.ERROR,
+ VpePlugin.PLUGIN_ID,
+ VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_KEY_MUST_BE_SET);
+ } else {
+ propsKeyStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
+ }
+ }
+
private void updateStatus() {
- applyStatus(this, new IStatus[] {selectedTextStatus, propsKeyStatus, propsValueStatus});
+ /*
+ * Update all statuses
+ */
+ updatePropertiesKeyStatus();
+ updatePropertiesValueStatus();
+ updateDuplicateKeyStatus();
+ /*
+ * Apply status to the dialog
+ */
+ applyStatus(this, new IStatus[] {propsKeyStatus, propsValueStatus, rbComboStatus});
+ /*
+ * Set page complete
+ */
setPageComplete(isPageComplete());
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2010-06-11 11:41:35 UTC (rev 22766)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2010-06-11 12:18:35 UTC (rev 22767)
@@ -179,6 +179,7 @@
public static String EXTRNALIZE_STRINGS_DIALOG_DEFAULT_VALUE;
public static String EXTRNALIZE_STRINGS_DIALOG_PROPERTY_NAME;
public static String EXTRNALIZE_STRINGS_DIALOG_PROPERTY_VALUE;
+ public static String EXTRNALIZE_STRINGS_DIALOG_KEY_ALREADY_EXISTS;
public static String COULD_NOT_OPEN_VPE_RESOURCES_DIALOG;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2010-06-11 11:41:35 UTC (rev 22766)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2010-06-11 12:18:35 UTC (rev 22767)
@@ -167,6 +167,7 @@
EXTRNALIZE_STRINGS_DIALOG_DEFAULT_VALUE=value
EXTRNALIZE_STRINGS_DIALOG_PROPERTY_NAME=Property name
EXTRNALIZE_STRINGS_DIALOG_PROPERTY_VALUE=Property value
+EXTRNALIZE_STRINGS_DIALOG_KEY_ALREADY_EXISTS=Such a key already exists
# Other messages
CANNOT_LOAD_TAGLIBS_FROM_PAGE_CONTEXT=Cannot load taglibs from PageContext!
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-06-11 11:41:35 UTC (rev 22766)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-06-11 12:18:35 UTC (rev 22767)
@@ -23,6 +23,7 @@
import org.jboss.tools.vpe.ui.bot.test.smoke.RenameJSPFileTest;
import org.jboss.tools.vpe.ui.bot.test.smoke.RenameXHTMLFileTest;
import org.jboss.tools.vpe.ui.bot.test.smoke.XHTMLPageCreationTest;
+import org.jboss.tools.vpe.ui.bot.test.wizard.ExternalizeStringsDialogTest;
import org.jboss.tools.vpe.ui.bot.test.wizard.ImportUnknownTagsWizardTest;
import org.jboss.tools.vpe.ui.bot.test.wizard.NewXHTMLPageWizardTest;
import org.jboss.tools.vpe.ui.bot.test.wizard.VPESourceCodeTemplatesPreferencePageTest;
@@ -53,6 +54,8 @@
suite.addTestSuite(ImportUnknownTagsWizardTest.class);
suite.addTestSuite(NewXHTMLPageWizardTest.class);
suite.addTestSuite(VPESourceCodeTemplatesPreferencePageTest.class);
+ suite.addTestSuite(ExternalizeStringsDialogTest.class);
+
return new TestSetup(suite);
}
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java 2010-06-11 11:41:35 UTC (rev 22766)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java 2010-06-11 12:18:35 UTC (rev 22767)
@@ -13,6 +13,7 @@
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.jboss.tools.vpe.messages.VpeUIMessages;
@@ -31,7 +32,12 @@
@Override
protected void closeUnuseDialogs() {
-
+// try {
+// SWTBotShell shell = bot.shell(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_TITLE);
+// shell.close();
+// } catch (Exception e) {
+// // Do nothing
+// }
}
@Override
@@ -56,21 +62,21 @@
bot.toolbarButtonWithTooltip(VpeUIMessages.EXTENALIZE_STRINGS).click();
bot.shell(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_TITLE).setFocus();
bot.shell(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_TITLE).activate();
-
/*
* Check properties key and value fields
*/
- SWTBotText defKeyText = bot.textInGroup(
- VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_KEY,
+ SWTBotText defKeyText = bot.textWithLabelInGroup(
+ VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
if (null != defKeyText) {
- assertText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_KEY, defKeyText);
+ assertText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_KEY,
+ defKeyText);
}
- SWTBotText defValueText = bot.textInGroup(
- VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_VALUE,
+ SWTBotText defValueText = bot.textWithLabelInGroup(
+ VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
if (null != defValueText) {
- assertText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_VALUE, defValueText);
+ assertText("User", defValueText); //$NON-NLS-1$
}
SWTBotCheckBox checkBox = bot.checkBox();
assertNotNull("Cannot find checkbox '" //$NON-NLS-1$
@@ -119,7 +125,7 @@
"Messages.properties"); //$NON-NLS-1$
editor2.toTextEditor().selectLine(3);
String line = editor2.toTextEditor().getSelection();
- assertEquals("'Messages.properties' was updated incorrectly", "key=value", line); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("'Messages.properties' was updated incorrectly", "key=User", line); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testNewFileInExternalizeStringsDialog() throws Throwable {
@@ -178,6 +184,6 @@
"externalize.properties"); //$NON-NLS-1$
editor2.toTextEditor().selectLine(1);
String line = editor2.toTextEditor().getSelection();
- assertEquals("Created file is incorrect", "key=value", line); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Created file is incorrect", "key=Input", line); //$NON-NLS-1$ //$NON-NLS-2$
}
}
14 years, 7 months
JBoss Tools SVN: r22766 - trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-06-11 07:41:35 -0400 (Fri, 11 Jun 2010)
New Revision: 22766
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
Log:
https://jira.jboss.org/browse/JBIDE-6447
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2010-06-11 10:53:05 UTC (rev 22765)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2010-06-11 11:41:35 UTC (rev 22766)
@@ -188,10 +188,11 @@
while(it.hasNext()) {
IBean b = it.next();
if(b.isAlternative()) {
- //TODO check that alternative is enabled in beans.xml
- // otherwise it should be excluded from result
- containsAlternatives = true;
- break;
+ if(b.isSelectedAlternative()) {
+ containsAlternatives = true;
+ } else {
+ it.remove();
+ }
}
}
@@ -492,6 +493,14 @@
return result;
}
+ public boolean isTypeAlternative(String qualifiedName) {
+ return beansXMLData.getTypeAlternativeTypes().contains(qualifiedName);
+ }
+
+ public boolean isStereotypeAlternative(String qualifiedName) {
+ return beansXMLData.getStereotypeAlternativeTypes().contains(qualifiedName);
+ }
+
public Set<IType> getQualifierTypes() {
Set<IType> result = new HashSet<IType>();
List<AnnotationDefinition> ds = n.getDefinitions().getAllAnnotations();
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2010-06-11 10:53:05 UTC (rev 22765)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2010-06-11 11:41:35 UTC (rev 22766)
@@ -457,7 +457,15 @@
* @see org.jboss.tools.cdi.core.IBean#isSelectedAlternative()
*/
public boolean isSelectedAlternative() {
- // TODO
- return isAlternative();
+ if(getDefinition().getAlternativeAnnotation() != null && getCDIProject().isTypeAlternative(getBeanClass().getFullyQualifiedName())) {
+ return true;
+ }
+ Set<IStereotypeDeclaration> ds = getStereotypeDeclarations();
+ for (IStereotypeDeclaration d: ds) {
+ IStereotype s = d.getStereotype();
+ if(s != null && s.isAlternative() &&
+ getCDIProject().isStereotypeAlternative(s.getSourceType().getFullyQualifiedName()) ) return true;
+ }
+ return false;
}
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2010-06-11 10:53:05 UTC (rev 22765)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2010-06-11 11:41:35 UTC (rev 22766)
@@ -185,7 +185,16 @@
* @see org.jboss.tools.cdi.core.IBean#isSelectedAlternative()
*/
public boolean isSelectedAlternative() {
- // TODO
- return isAlternative();
+ if(getDefinition().getAlternativeAnnotation() != null && getCDIProject().isTypeAlternative(getBeanClass().getFullyQualifiedName())) {
+ return true;
+ }
+ Set<IStereotypeDeclaration> ds = getStereotypeDeclarations();
+ for (IStereotypeDeclaration d: ds) {
+ IStereotype s = d.getStereotype();
+ if(s != null && s.isAlternative() &&
+ getCDIProject().isStereotypeAlternative(s.getSourceType().getFullyQualifiedName()) ) return true;
+ }
+ return false;
}
+
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2010-06-11 10:53:05 UTC (rev 22765)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2010-06-11 11:41:35 UTC (rev 22766)
@@ -237,7 +237,15 @@
* @see org.jboss.tools.cdi.core.IBean#isSelectedAlternative()
*/
public boolean isSelectedAlternative() {
- // TODO
- return isAlternative();
+ if(getDefinition().getAlternativeAnnotation() != null && getCDIProject().isTypeAlternative(getBeanClass().getFullyQualifiedName())) {
+ return true;
+ }
+ Set<IStereotypeDeclaration> ds = getStereotypeDeclarations();
+ for (IStereotypeDeclaration d: ds) {
+ IStereotype s = d.getStereotype();
+ if(s != null && s.isAlternative() &&
+ getCDIProject().isStereotypeAlternative(s.getSourceType().getFullyQualifiedName()) ) return true;
+ }
+ return false;
}
}
\ No newline at end of file
14 years, 7 months
JBoss Tools SVN: r22765 - in trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi: internal/core/impl and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-06-11 06:53:05 -0400 (Fri, 11 Jun 2010)
New Revision: 22765
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
Log:
https://jira.jboss.org/browse/JBIDE-6414
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2010-06-11 10:27:21 UTC (rev 22764)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2010-06-11 10:53:05 UTC (rev 22765)
@@ -191,6 +191,7 @@
*/
IStereotype getStereotype(IPath path);
+ IInterceptorBinding[] getInterceptorBindings();
/**
* Returns interceptor binding model element for fully qualified name of
* interceptor binding annotation type
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2010-06-11 10:27:21 UTC (rev 22764)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2010-06-11 10:53:05 UTC (rev 22765)
@@ -39,6 +39,7 @@
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.core.IInterceptorBinding;
import org.jboss.tools.cdi.core.IObserverMethod;
import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IParameter;
@@ -695,6 +696,18 @@
return stereotypesByPath.get(path);
}
+ public IInterceptorBinding[] getInterceptorBindings() {
+ IInterceptorBinding[] result = new IInterceptorBinding[interceptorBindings.size()];
+ synchronized (interceptorBindings) {
+ int i=0;
+ for (IInterceptorBinding s: interceptorBindings.values()) {
+ result[i++] = s;
+ }
+ }
+ return result;
+
+ }
+
public InterceptorBindingElement getInterceptorBinding(String qualifiedName) {
return interceptorBindings.get(qualifiedName);
}
14 years, 7 months
JBoss Tools SVN: r22764 - in trunk/cdi/plugins/org.jboss.tools.cdi.ui: src/org/jboss/tools/cdi/ui and 1 other directories.
by jbosstools-commits@lists.jboss.org
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("@").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("@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("@Retention(RUNTIME)").append(lineDelimiter);
}
protected void addDocumentedAnnotation(ImportsManager imports, StringBuffer sb, String lineDelimiter) {
- imports.addImport("java.lang.annotation.Documented");
- sb.append("@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("@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("@").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("@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("@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("@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
14 years, 7 months
JBoss Tools SVN: r22763 - in trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui: widget/editor and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-06-11 06:25:48 -0400 (Fri, 11 Jun 2010)
New Revision: 22763
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/BaseListFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ListFieldEditor.java
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties
Log:
https://jira.jboss.org/browse/JBIDE-6414
Modified: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java 2010-06-11 10:06:32 UTC (rev 22762)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIMessages.java 2010-06-11 10:25:48 UTC (rev 22763)
@@ -62,6 +62,10 @@
public static String TEXT_FIELD_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE;
+ public static String BUTTON_ADD;
+
+ public static String BUTTON_REMOVE;
+
static {
NLS.initializeMessages(BUNDLE_NAME, CommonUIMessages.class);
}
Modified: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties 2010-06-11 10:06:32 UTC (rev 22762)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/messages.properties 2010-06-11 10:25:48 UTC (rev 22763)
@@ -22,4 +22,7 @@
COMPOSITE_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT=Editor supports only grid layout
COMPOSITE_EDITOR_THIS_METOD_CAN_BE_INVOKED=This metod can be invoked after getEditorControls(parent) only
TEXT_FIELD_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE=Parent control should be Composite
-TEXT_FIELD_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT=Editor supports only grid layout
\ No newline at end of file
+TEXT_FIELD_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT=Editor supports only grid layout
+
+BUTTON_ADD=Add
+BUTTON_REMOVE=Remove
\ No newline at end of file
Added: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/BaseListFieldEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/BaseListFieldEditor.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/BaseListFieldEditor.java 2010-06-11 10:25:48 UTC (rev 22763)
@@ -0,0 +1,289 @@
+/*******************************************************************************
+ * 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.common.ui.widget.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.common.ui.CommonUIMessages;
+
+/**
+ * This editor allows to add to a list several items by 'Add' button.
+ * If ListFieldEditorProvider is not set, selection dialog will have nothing to pick up.
+ *
+ * @author Viacheslav Kabanovich
+ */
+public class BaseListFieldEditor extends BaseFieldEditor {
+ private ListViewer viewer = null;
+ private ActionPanel actionPanel;
+
+ public BaseListFieldEditor(String name, String label, Object defaultValue) {
+ super(name, label, defaultValue);
+ }
+
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ Composite root = (Composite)composite;
+ createLabelControl(root);
+ createListView(root);
+ createActionBar(root);
+ return new Control[] {getLabelControl(), viewer.getControl(), actionPanel};
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void createListView(Composite parent) {
+ viewer = new ListViewer(parent, SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
+ viewer.setContentProvider(new IStructuredContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ return (inputElement instanceof List) ? ((List<Object>) inputElement).toArray() : new Object[0];
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ viewer.refresh();
+ }
+ });
+ viewer.setLabelProvider(createLabelProvider());
+ viewer.setInput(getValue());
+ }
+
+ protected ILabelProvider createLabelProvider() {
+ return new LabelProvider();
+ }
+
+ protected void createActionBar(Composite parent) {
+ actionPanel = new ActionPanel(parent, new BaseAction[] { new AddAction(),
+ new RemoveAction() });
+ viewer.addSelectionChangedListener(actionPanel);
+ }
+
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[]{getLabelControl(), viewer.getControl(), actionPanel};//new Control[] { root };
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ return 3;
+ }
+
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite,
+ "Error_Basic_Editor_Composite");
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ "Error_JBoss_Basic_Editor_Support");
+ Composite aComposite = (Composite) parent;
+ getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
+
+ GridData gdLabel = new GridData();
+ gdLabel.horizontalSpan = 1;
+ getLabelControl().setLayoutData(gdLabel);
+
+ GridData gd = new GridData();
+ gd.horizontalSpan = gl.numColumns - 2;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.FILL;
+ ((Control) getEditorControls()[1]).setLayoutData(gd);
+
+ GridData dgAction = new GridData();
+ dgAction.horizontalSpan = 1;
+ dgAction.verticalAlignment = GridData.FILL;
+ ((Control) getEditorControls()[2]).setLayoutData(dgAction);
+ }
+
+ protected int convertHorizontalDLUsToPixels(Control control, int dlus) {
+ GC gc= new GC(control);
+ gc.setFont(control.getFont());
+ int averageWidth= gc.getFontMetrics().getAverageCharWidth();
+ gc.dispose();
+ double horizontalDialogUnitSize = averageWidth * 0.25;
+ return (int)Math.round(dlus * horizontalDialogUnitSize);
+ }
+
+ public class ActionPanel extends Composite implements ISelectionChangedListener {
+ private BaseAction[] actions = null;
+
+ public ActionPanel(Composite parent, int style, BaseAction[] actions) {
+ super(parent, style);
+ this.actions = actions;
+ setLayout(new GridLayout(1, false));
+ for (BaseAction action : this.actions) {
+ new ActionButton(this, SWT.PUSH, action);
+ }
+ }
+
+ public ActionPanel(Composite parent, BaseAction[] actions) {
+ this(parent, SWT.NONE, actions);
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ for (BaseAction action : actions) {
+ action.setSelection(event.getSelection());
+ }
+ }
+ }
+
+ public class ActionButton implements IPropertyChangeListener {
+ private Button button;
+ private BaseAction action;
+
+ public ActionButton(Composite parent, int style, BaseAction action) {
+ this.button = new Button(parent, style);
+ this.action = action;
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL, GridData.BEGINNING, false, false);
+
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ gd.widthHint = convertHorizontalDLUsToPixels(button, IDialogConstants.BUTTON_WIDTH);
+ this.button.setLayoutData(gd);
+ this.action.addPropertyChangeListener(this);
+ this.button.setText(action.getText());
+ this.button.setEnabled(action.isEnabled());
+ this.button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ ActionButton.this.action.run();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ }
+
+ public Control getControl() {
+ return button;
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IAction.ENABLED)) {
+ button.setEnabled(((Boolean) event.getNewValue())
+ .booleanValue());
+ }
+ }
+ }
+
+ public static abstract class BaseAction extends Action {
+ Object[] objects = new Object[0];
+
+ public BaseAction(String name) {
+ super(name);
+ updateEnablement();
+ }
+
+ public void setSelection(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ List<Object> rts = new ArrayList<Object>();
+ for (Object rt : ((IStructuredSelection) selection).toArray()) {
+ rts.add(rt);
+ }
+ objects = rts.toArray(new Object[] {});
+ } else {
+ objects = new Object[0];
+ }
+ updateEnablement();
+ }
+
+ protected abstract void updateEnablement();
+ }
+
+ public class AddAction extends BaseAction {
+
+ public AddAction() {
+ super(CommonUIMessages.BUTTON_ADD);
+ setEnabled(true);
+ }
+
+ @Override
+ protected void updateEnablement() {
+ }
+
+ @Override
+ public void run() {
+ List<?> current = (List<?>)getValue();
+ List<Object> added = runAddAction();
+ added.removeAll(current);
+ if(!added.isEmpty()) {
+ added.addAll(current);
+ setValue(added);
+ viewer.setInput(getValue());
+ viewer.refresh();
+ }
+ }
+ }
+
+ /**
+ * Returns list of objects to be added.
+ * @return
+ */
+ protected List<Object> runAddAction() {
+ return new ArrayList<Object>();
+ }
+
+ public class RemoveAction extends BaseAction {
+ public RemoveAction() {
+ super(CommonUIMessages.BUTTON_REMOVE);
+ }
+
+ @Override
+ protected void updateEnablement() {
+ setEnabled(objects.length > 0);
+ }
+
+ @Override
+ public void run() {
+ List<?> current = (List<?>)getValue();
+ List<Object> changed = new ArrayList<Object>();
+ changed.addAll(current);
+ for (Object rt : objects) {
+ changed.remove(rt);
+ }
+ if(changed.size() != current.size()) {
+ setValue(changed);
+ }
+ viewer.setInput(getValue());
+ viewer.refresh();
+ }
+
+ }
+
+}
Property changes on: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/BaseListFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ListFieldEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ListFieldEditor.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ListFieldEditor.java 2010-06-11 10:25:48 UTC (rev 22763)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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.common.ui.widget.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
+
+/**
+ * This editor allows to add to a list several items invoking by 'Add' button a selection dialog
+ * derived from FilteredItemsSelectionDialog.
+ * If ListFieldEditorProvider is not set, selection dialog will have nothing to pick up.
+ *
+ * @author Viacheslav Kabanovich
+ */
+public class ListFieldEditor extends BaseListFieldEditor {
+
+ public static interface ListFieldEditorProvider<T> {
+
+ public FilteredItemsSelectionDialog createSelectionDialog();
+
+ public T getSelected(Object selected);
+
+ public T[] getSelectableObjects();
+
+ public ILabelProvider createLabelProvider();
+ }
+
+ ListFieldEditorProvider<?> provider = null;
+
+ public ListFieldEditor(String name, String label, Object defaultValue) {
+ super(name, label, defaultValue);
+ }
+
+ public void setProvider(ListFieldEditorProvider<?> provider) {
+ this.provider = provider;
+ }
+
+ protected ILabelProvider createLabelProvider() {
+ if(provider != null) {
+ return provider.createLabelProvider();
+ }
+ return new LabelProvider();
+ }
+
+ protected List<Object> runAddAction() {
+ List<Object> added = new ArrayList<Object>();
+ if(provider != null) {
+ FilteredItemsSelectionDialog dialog = provider.createSelectionDialog();
+ int result = dialog.open();
+ if(result == FilteredItemsSelectionDialog.OK) {
+ Object[] os = dialog.getResult();
+ if(os != null) {
+ for (Object o: os) {
+ Object v = provider.getSelected(o);
+ if(v != null) {
+ added.add(v);
+ }
+ }
+ }
+ }
+ }
+ return added;
+ }
+
+}
Property changes on: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/widget/editor/ListFieldEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 7 months
JBoss Tools SVN: r22762 - in trunk/cdi: plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences and 8 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-06-11 06:06:32 -0400 (Fri, 11 Jun 2010)
New Revision: 22762
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GameBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/NumberProducer.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/PrimitiveTestQualifer.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/TestQualifer.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/Cat.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptor.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptorBinding.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InjectInterceptorBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/AssignabilityOfRawAndParameterizedTypesTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseResolutionByTypeTest.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IParametedType.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ParametedType.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParametedTypeFactory.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/beans.xml
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanDefinitionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanSpecializationTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6418 https://jira.jboss.org/browse/JBIDE-5808
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -106,30 +106,42 @@
}
/**
- * Sorts CDI beans which may be injected. Sets for alternative beans higher
- * position and for nonalternative beans lower position.
- *
+ * Sorts CDI beans which may be injected. The following order will be used:
+ * 1) selected alternative beans
+ * 2) nonalternative beans
+ * 3) non-seleceted alternatives
+ * 4) decorators
+ * 5) interceptors
+ *
* @param beans
- * @param element
*/
public static List<IBean> sortBeans(Set<IBean> beans) {
Set<IBean> alternativeBeans = new HashSet<IBean>();
+ Set<IBean> selectedAlternativeBeans = new HashSet<IBean>();
Set<IBean> nonAlternativeBeans = new HashSet<IBean>();
+ Set<IBean> decorators = new HashSet<IBean>();
+ Set<IBean> interceptors = new HashSet<IBean>();
for (IBean bean : beans) {
-// if (bean == null || bean instanceof IDecorator || bean instanceof IInterceptor) {
-// continue;
-// }
- if (bean.isAlternative()) {
+ if (bean.isSelectedAlternative()) {
+ selectedAlternativeBeans.add(bean);
+ } else if (bean.isAlternative()) {
alternativeBeans.add(bean);
+ } else if (bean instanceof IDecorator) {
+ decorators.add(bean);
+ } else if (bean instanceof IInterceptor) {
+ interceptors.add(bean);
} else {
nonAlternativeBeans.add(bean);
}
}
ArrayList<IBean> sortedBeans = new ArrayList<IBean>();
+ sortedBeans.addAll(selectedAlternativeBeans);
+ sortedBeans.addAll(nonAlternativeBeans);
sortedBeans.addAll(alternativeBeans);
- sortedBeans.addAll(nonAlternativeBeans);
+ sortedBeans.addAll(decorators);
+ sortedBeans.addAll(interceptors);
return sortedBeans;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -115,6 +115,14 @@
boolean isAlternative();
/**
+ * Determines if the bean is a selected alternative.
+ *
+ * @return <tt>true</tt> if the bean is a selected alternative, and <tt>false</tt>
+ * otherwise.
+ */
+ boolean isSelectedAlternative();
+
+ /**
* Returns the location of @Alternative declaration of this bean. May be
* declared in a stereotype.
*
@@ -166,4 +174,13 @@
* @return "true" if the bean is enabled
*/
boolean isEnabled();
+
+ /**
+ * Determines if the bean is nullable such as a producer method with a non-primitive
+ * return type or a producer field with a non-primitive type.
+ *
+ * @return <tt>true</tt> if the {@code create()} method may return a null
+ * value, and <tt>false</tt> otherwise
+ */
+ boolean isNullable();
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IParametedType.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IParametedType.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IParametedType.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -33,4 +33,11 @@
* @return signature of the declaration
*/
public String getSignature();
+
+ /**
+ * Returns true if the type is a primitive type.
+ *
+ * @return true if the type is a primitive type
+ */
+ boolean isPrimitive();
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -41,5 +41,8 @@
defaultPreferences.put(CDIPreferences.MISSING_NONBINDING_IN_QUALIFIER_TYPE_MEMBER, CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.UNSATISFIED_INJECTION_POINTS, CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.AMBIGUOUS_INJECTION_POINTS, CDIPreferences.WARNING);
+ defaultPreferences.put(CDIPreferences.INJECT_RESOLVES_TO_NULLABLE_BEAN, CDIPreferences.WARNING);
+ defaultPreferences.put(CDIPreferences.INJECTED_DECORATOR, CDIPreferences.WARNING);
+ defaultPreferences.put(CDIPreferences.INJECTED_INTERCEPTOR, CDIPreferences.WARNING);
}
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -63,6 +63,8 @@
public static final String PRODUCER_FIELD_TYPE_HAS_WILDCARD = INSTANCE.createSeverityOption("producerFieldTypeHasWildcard"); //$NON-NLS-1$
// - producer field type is a type variable
public static final String PRODUCER_FIELD_TYPE_IS_VARIABLE = INSTANCE.createSeverityOption("producerFieldTypeIsVariable"); //$NON-NLS-1$
+// - an injection point of primitive type resolves to a bean that may have null values, such as a producer method with a non-primitive return type or a producer field with a non-primitive type
+ public static final String INJECT_RESOLVES_TO_NULLABLE_BEAN = INSTANCE.createSeverityOption("injectResolvesToNullableBean"); //$NON-NLS-1$
// - matching object in the Java EE component environment is not of the same type
// as the producer field declaration (3.5.1)
public static final String PRODUCER_FIELD_TYPE_DOES_NOT_MATCH_JAVA_EE_OBJECT = INSTANCE.createSeverityOption("producerFieldTypeDoesNotMatchJavaEeObject"); //$NON-NLS-1$
@@ -193,6 +195,10 @@
public static final String INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE = INSTANCE.createSeverityOption("interceptorOrDecoratorIsAlternative"); //$NON-NLS-1$
// - interceptor declared using @Interceptor does not declare any interceptor binding (9.2 non-portable)
public static final String MISSING_INTERCEPTOR_BINDING = INSTANCE.createSeverityOption("missingInterceptorBinding"); //$NON-NLS-1$
+// - a decorator can not be injected
+ public static final String INJECTED_DECORATOR = INSTANCE.createSeverityOption("injectedDecorator"); //$NON-NLS-1$
+// - an interceptor can not be injected
+ public static final String INJECTED_INTERCEPTOR = INSTANCE.createSeverityOption("injectedInterceptor"); //$NON-NLS-1$
//Specialization
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -113,4 +113,7 @@
return r == null ? 0 : r.getOffset();
}
-}
+ public boolean isNullable() {
+ return typeDeclaration==null?false:!typeDeclaration.isPrimitive();
+ }
+}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -444,4 +444,20 @@
return result;
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBean#isNullable()
+ */
+ public boolean isNullable() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBean#isSelectedAlternative()
+ */
+ public boolean isSelectedAlternative() {
+ // TODO
+ return isAlternative();
+ }
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ParametedType.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ParametedType.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ParametedType.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2009 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,
@@ -35,6 +35,7 @@
protected String arrayPrefix = "";
protected String signature;
protected List<ParametedType> parameterTypes = new ArrayList<ParametedType>();
+ protected boolean primitive;
boolean inheritanceIsBuilt = false;
protected ParametedType superType = null;
@@ -49,6 +50,18 @@
public ParametedType() {}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IParametedType#isPrimitive()
+ */
+ public boolean isPrimitive() {
+ return primitive;
+ }
+
+ public void setPrimitive(boolean primitive) {
+ this.primitive = primitive;
+ }
+
public ParametedTypeFactory getFactory() {
return typeFactory;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -179,4 +179,13 @@
public IAnnotationDeclaration getProducesAnnotation() {
return getDefinition().getProducesAnnotation();
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBean#isSelectedAlternative()
+ */
+ public boolean isSelectedAlternative() {
+ // TODO
+ return isAlternative();
+ }
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -231,4 +231,13 @@
public IAnnotationDeclaration getProducesAnnotation() {
return produces;
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBean#isSelectedAlternative()
+ */
+ public boolean isSelectedAlternative() {
+ // TODO
+ return isAlternative();
+ }
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2009 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,
@@ -35,6 +35,7 @@
inheritanceIsBuilt = type.inheritanceIsBuilt;
inheritedTypes = type.inheritedTypes;
superType = type.superType;
+ primitive = type.primitive;
}
public int getLength() {
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -86,7 +86,8 @@
for (int i = 0; i < params.length; i++) {
if(ps.length <= i) {
- CDICorePlugin.getDefault().logError(new IllegalArgumentException("Cannot parse method parameters for " + paramsString));
+ // CDICorePlugin.getDefault().logError(new IllegalArgumentException("Cannot parse method parameters for " + paramsString));
+ // The source code may be broken. Just ignore such errors.
break;
}
if(!parametersAreInjectionPoints && params[i].indexOf('@') < 0) {
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParametedTypeFactory.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParametedTypeFactory.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParametedTypeFactory.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -74,6 +74,7 @@
if(primitives.containsKey(typeSignature)) {
typeSignature = primitives.get(typeSignature);
result.setSignature(result.getArrayPrefix() + typeSignature);
+ result.setPrimitive(true);
}
int startToken = typeSignature.indexOf('<');
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -964,17 +964,37 @@
addError(CDIValidationMessages.INJECTION_TYPE_IS_VARIABLE, CDIPreferences.INJECTION_TYPE_IS_VARIABLE, declaration, injection.getResource());
}
- /*
- * 5.2.1. Unsatisfied and ambiguous dependencies
- * - If an unsatisfied or unresolvable ambiguous dependency exists, the container automatically detects the problem and treats it as a deployment problem.
- */
- if(declaration!=null && !(injection instanceof IInjectionPointParameter)) {
+ if(declaration!=null && !(injection instanceof IInjectionPointMethod)) {
Set<IBean> beans = cdiProject.getBeans(true, injection);
+ ITextSourceReference reference = injection instanceof IInjectionPointParameter?injection:declaration;
+ /*
+ * 5.2.1. Unsatisfied and ambiguous dependencies
+ * - If an unsatisfied or unresolvable ambiguous dependency exists, the container automatically detects the problem and treats it as a deployment problem.
+ */
if(beans.isEmpty()) {
- addError(CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, CDIPreferences.UNSATISFIED_INJECTION_POINTS, declaration, injection.getResource());
+ addError(CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, CDIPreferences.UNSATISFIED_INJECTION_POINTS, reference, injection.getResource());
} else if(beans.size()>1) {
- addError(CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, CDIPreferences.AMBIGUOUS_INJECTION_POINTS, declaration, injection.getResource());
- }
+ addError(CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, CDIPreferences.AMBIGUOUS_INJECTION_POINTS, reference, injection.getResource());
+ } else if(beans.size()==1) {
+ IBean bean = beans.iterator().next();
+ /*
+ * 5.2.4. Primitive types and null values
+ * - injection point of primitive type resolves to a bean that may have null values, such as a producer method with a non-primitive return type or a producer field with a non-primitive type
+ */
+ if(bean.isNullable() && injection.getType()!=null && injection.getType().isPrimitive()) {
+ addError(CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, CDIPreferences.INJECT_RESOLVES_TO_NULLABLE_BEAN, reference, injection.getResource());
+ }
+ /*
+ * 5.1.4. Inter-module injection
+ * - a decorator can not be injected
+ * - an interceptor can not be injected
+ */
+ if(bean instanceof IDecorator) {
+ addError(CDIValidationMessages.INJECTED_DECORATOR, CDIPreferences.INJECTED_DECORATOR, reference, injection.getResource());
+ } else if(bean instanceof IInterceptor) {
+ addError(CDIValidationMessages.INJECTED_INTERCEPTOR, CDIPreferences.INJECTED_INTERCEPTOR, reference, injection.getResource());
+ }
+ }
}
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -35,6 +35,7 @@
public static String PRODUCER_FIELD_TYPE_HAS_WILDCARD;
public static String PRODUCER_FIELD_TYPE_IS_VARIABLE;
public static String PRODUCER_FIELD_TYPE_DOES_NOT_MATCH_JAVA_EE_OBJECT;
+ public static String INJECT_RESOLVES_TO_NULLABLE_BEAN;
public static String INJECTION_TYPE_IS_VARIABLE;
public static String STEREOTYPE_IS_ANNOTATED_TYPED;
public static String MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_QUALIFIER_TYPE_MEMBER;
@@ -96,6 +97,8 @@
public static String INTERCEPTOR_IS_ALTERNATIVE;
public static String DECORATOR_IS_ALTERNATIVE;
public static String MISSING_INTERCEPTOR_BINDING;
+ public static String INJECTED_DECORATOR;
+ public static String INJECTED_INTERCEPTOR;
public static String ILLEGAL_SPECIALIZING_MANAGED_BEAN;
public static String ILLEGAL_SPECIALIZING_SESSION_BEAN;
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-06-11 10:06:32 UTC (rev 22762)
@@ -122,20 +122,29 @@
- X specializes Y and Y has a name and X declares a name explicitly, using @Named
- interceptor or decorator is annotated @Specializes (Non-Portable behavior)
+5.2.1. Unsatisfied and ambiguous dependencies
+- If an unsatisfied or unresolvable ambiguous dependency exists, the container automatically detects the problem and
+ treats it as a deployment problem.
+
5.2.2. Legal injection point types
- injection point type is a type variable
+5.1.4. Inter-module injection
+- a decorator can not be injected
+- an interceptor can not be injected
+
+5.2.4. Primitive types and null values
+- if an injection point of primitive type resolves to a bean that may have null values, such as a producer method
+ with a non-primitive return type or a producer field with a non-primitive type, the container automatically detects the problem
+ and treats it as a deployment problem.
+
5.2.5. Qualifier annotations with members
- array-valued or annotation-valued member of a qualifier type is not annotated @Nonbinding (Non-Portable behavior)
-5.2.1. Unsatisfied and ambiguous dependencies
-- If an unsatisfied or unresolvable ambiguous dependency exists, the container automatically detects the problem and
- treats it as a deployment problem.
-
5.5.7. Injection point metadata
- bean that declares any scope other than @Dependent has an injection point of type
InjectionPoint and qualifier @Default
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-06-11 10:06:32 UTC (rev 22762)
@@ -15,6 +15,7 @@
PRODUCER_FIELD_TYPE_IS_VARIABLE=Producer field type is a type variable
PRODUCER_FIELD_TYPE_DOES_NOT_MATCH_JAVA_EE_OBJECT=Matching object in the Java EE component environment is not of the same type as the producer field declaration
INJECTION_TYPE_IS_VARIABLE=Injection point type is a type variable
+INJECT_RESOLVES_TO_NULLABLE_BEAN=Injection point of primitive type resolves to the bean that may have a null value
STEREOTYPE_IS_ANNOTATED_TYPED=Stereotype is annotated @Typed
MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_QUALIFIER_TYPE_MEMBER=Annotation-valued member of a qualifier type is not annotated @Nonbinding
MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_QUALIFIER_TYPE_MEMBER=Array-valued member of a qualifier type is not annotated @Nonbinding
@@ -75,6 +76,8 @@
INTERCEPTOR_IS_ALTERNATIVE=Interceptor is an alternative
DECORATOR_IS_ALTERNATIVE=Decorator is an alternative
MISSING_INTERCEPTOR_BINDING=Interceptor declared using @Interceptor does not declare any interceptor binding
+INJECTED_DECORATOR=Injection point resolves to a decorator
+INJECTED_INTERCEPTOR=Injection point resolves to an interceptor
ILLEGAL_SPECIALIZING_MANAGED_BEAN=Managed bean class annotated @Specializes does not directly extend the bean class of another managed bean
ILLEGAL_SPECIALIZING_SESSION_BEAN=Session bean class annotated @Specializes does not directly extend the bean class of another session bean
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -50,6 +50,7 @@
{CDIPreferences.PRODUCER_FIELD_TYPE_HAS_WILDCARD, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_producerFieldTypeHasWildcard_label},
{CDIPreferences.PRODUCER_FIELD_TYPE_IS_VARIABLE, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_producerFieldTypeIsVariable_label},
// {CDIPreferences.PRODUCER_FIELD_TYPE_DOES_NOT_MATCH_JAVA_EE_OBJECT, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_producerFieldTypeDoesNotMatchJavaEeObject_label},
+ {CDIPreferences.INJECT_RESOLVES_TO_NULLABLE_BEAN, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_injectResolvesToNullableBean_label},
{CDIPreferences.INJECTION_TYPE_IS_VARIABLE, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_injectionTypeIsVariable_label},
{CDIPreferences.STEREOTYPE_IS_ANNOTATED_TYPED, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_stereotypeIsAnnotatedTyped_label},
{CDIPreferences.MISSING_NONBINDING_IN_QUALIFIER_TYPE_MEMBER, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingNonbindingInQualifierTypeMember_label},
@@ -117,6 +118,8 @@
// {CDIPreferences.OBSERVER_IN_INTERCEPTOR_OR_DECORATOR, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_observerInInterceptorOrDecorator_label},
{CDIPreferences.INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_interceptorOrDecoratorIsAlternative_label},
// {CDIPreferences.MISSING_INTERCEPTOR_BINDING, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingInterceptorBinding_label},
+ {CDIPreferences.INJECTED_DECORATOR, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_injectedDecorator_label},
+ {CDIPreferences.INJECTED_INTERCEPTOR, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_injectedInterceptor_label},
},
CDICorePlugin.PLUGIN_ID
);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -50,6 +50,7 @@
public static String CDIValidatorConfigurationBlock_pb_producerFieldTypeHasWildcard_label;
public static String CDIValidatorConfigurationBlock_pb_producerFieldTypeIsVariable_label;
public static String CDIValidatorConfigurationBlock_pb_producerFieldTypeDoesNotMatchJavaEeObject_label;
+ public static String CDIValidatorConfigurationBlock_pb_injectResolvesToNullableBean_label;
public static String CDIValidatorConfigurationBlock_pb_injectionTypeIsVariable_label;
public static String CDIValidatorConfigurationBlock_pb_stereotypeIsAnnotatedTyped_label;
public static String CDIValidatorConfigurationBlock_pb_missingNonbindingInQualifierTypeMember_label;
@@ -105,6 +106,8 @@
public static String CDIValidatorConfigurationBlock_pb_observerInInterceptorOrDecorator_label;
public static String CDIValidatorConfigurationBlock_pb_interceptorOrDecoratorIsAlternative_label;
public static String CDIValidatorConfigurationBlock_pb_missingInterceptorBinding_label;
+ public static String CDIValidatorConfigurationBlock_pb_injectedDecorator_label;
+ public static String CDIValidatorConfigurationBlock_pb_injectedInterceptor_label;
// Specializing
public static String CDIValidatorConfigurationBlock_section_specializing;
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties 2010-06-11 10:06:32 UTC (rev 22762)
@@ -39,6 +39,7 @@
CDIValidatorConfigurationBlock_pb_producerFieldTypeHasWildcard_label=Wildcard in producer field type:
CDIValidatorConfigurationBlock_pb_producerFieldTypeIsVariable_label=Variable in producer field type:
CDIValidatorConfigurationBlock_pb_producerFieldTypeDoesNotMatchJavaEeObject_label=Producer field type conflicts Java EE object:
+CDIValidatorConfigurationBlock_pb_injectResolvesToNullableBean_label=Injection point of primitive type resolves to a nullabe bean:
CDIValidatorConfigurationBlock_pb_injectionTypeIsVariable_label=Injection type is variable:
CDIValidatorConfigurationBlock_pb_stereotypeIsAnnotatedTyped_label=Stereotype has @Typed:
CDIValidatorConfigurationBlock_pb_missingNonbindingInQualifierTypeMember_label=Missing @Nonbinding in qualifier type member:
@@ -94,6 +95,8 @@
CDIValidatorConfigurationBlock_pb_observerInInterceptorOrDecorator_label=Interceptor or decorator has a method annotated @Disposes:
CDIValidatorConfigurationBlock_pb_interceptorOrDecoratorIsAlternative_label=Interceptor or decorator is an alternative:
CDIValidatorConfigurationBlock_pb_missingInterceptorBinding_label=Missing interceptor binding:
+CDIValidatorConfigurationBlock_pb_injectedDecorator_label=Decorator can not be injected:
+CDIValidatorConfigurationBlock_pb_injectedInterceptor_label=Interceptor can not be injected:
##Specializing
CDIValidatorConfigurationBlock_section_specializing=Specializing
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GameBroken.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GameBroken.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GameBroken.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -0,0 +1,24 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.inject;
+
+import javax.inject.Inject;
+
+@SuppressWarnings("unused")
+class GameBroken {
+ @Inject @PrimitiveTestQualifer private int numberBroken;
+
+ @Inject @PrimitiveTestQualifer private Integer number2;
+ @Inject @TestQualifer private int number3;
+ @Inject @TestQualifer private Integer number4;
+
+ @Inject
+ public void setNumber() {
+
+ }
+
+ @Inject
+ public void setNumber2(@PrimitiveTestQualifer int numberBroken,
+ @PrimitiveTestQualifer Integer number2,
+ @TestQualifer int number3,
+ @TestQualifer Integer number4) {
+ }
+}
\ No newline at end of file
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GameBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/NumberProducer.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/NumberProducer.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/NumberProducer.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -0,0 +1,18 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.inject;
+
+import javax.enterprise.inject.Produces;
+
+class NumberProducer {
+
+ @Produces
+ @PrimitiveTestQualifer
+ public Integer getNumber() {
+ return null;
+ }
+
+ @Produces
+ @TestQualifer
+ public int getNumber2() {
+ return 0;
+ }
+}
\ No newline at end of file
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/NumberProducer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/PrimitiveTestQualifer.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/PrimitiveTestQualifer.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/PrimitiveTestQualifer.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.inject;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@Qualifier
+public @interface PrimitiveTestQualifer {
+
+}
\ No newline at end of file
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/PrimitiveTestQualifer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/TestQualifer.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/TestQualifer.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/TestQualifer.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.inject;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@Qualifier
+public @interface TestQualifer {
+
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/TestQualifer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/Cat.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/Cat.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/Cat.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -0,0 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.jbt.validation.interceptors;
+
+class Cat
+{
+ @CatInterceptorBinding
+ public String hello() {
+ return "hello";
+ }
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/Cat.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptor.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptor.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptor.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.jbt.validation.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+@CatInterceptorBinding
+class CatInterceptor extends Cat
+{
+
+ @AroundInvoke
+ public Object intercept(InvocationContext ctx) throws Exception {
+ return ctx.proceed();
+ }
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptorBinding.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptorBinding.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptorBinding.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.jbt.validation.interceptors;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+@Inherited
+@InterceptorBinding
+@Target( { TYPE, METHOD })
+@Retention(RUNTIME)
+@interface CatInterceptorBinding
+{
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptorBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InjectInterceptorBroken.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InjectInterceptorBroken.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InjectInterceptorBroken.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.interceptors;
+
+import javax.inject.Inject;
+
+public class InjectInterceptorBroken {
+
+ @Inject CatInterceptor cat;
+}
\ No newline at end of file
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InjectInterceptorBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/beans.xml
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/beans.xml 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/beans.xml 2010-06-11 10:06:32 UTC (rev 22762)
@@ -3,6 +3,7 @@
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.NamedInterceptorBroken</class>
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.FordInterceptor</class>
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.InterceptorWithWrongScopeBroken</class>
- <class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.AltrenativeInterceptorBroken</class>
+ <class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.AlternativeInterceptorBroken</class>
+ <class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.CatInterceptor</class>
</interceptors>
</beans>
\ No newline at end of file
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -10,17 +10,16 @@
******************************************************************************/
package org.jboss.tools.cdi.core.test;
-import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.internal.core.JavaModelManager;
-//import org.jboss.tools.cdi.core.test.tck.NamedBeanRefactoringTest;
+import org.jboss.tools.cdi.core.test.tck.AssignabilityOfRawAndParameterizedTypesTest;
import org.jboss.tools.cdi.core.test.tck.BeanDefinitionTest;
import org.jboss.tools.cdi.core.test.tck.BeanSpecializationTest;
import org.jboss.tools.cdi.core.test.tck.DefaultNamedTest;
import org.jboss.tools.cdi.core.test.tck.EnterpriseQualifierDefinitionTest;
+import org.jboss.tools.cdi.core.test.tck.EnterpriseResolutionByTypeTest;
import org.jboss.tools.cdi.core.test.tck.EnterpriseScopeDefinitionTest;
import org.jboss.tools.cdi.core.test.tck.EnterpriseStereotypeDefinitionTest;
import org.jboss.tools.cdi.core.test.tck.InjectionPointTest;
@@ -32,7 +31,6 @@
import org.jboss.tools.cdi.core.test.tck.StereotypeDefinitionTest;
import org.jboss.tools.cdi.core.test.tck.StereotypeInheritenceTest;
import org.jboss.tools.cdi.core.test.tck.ValidationTest;
-import org.jboss.tools.tests.AbstractPluginsLoadTest;
/**
* @author Alexey Kazakov
@@ -42,7 +40,7 @@
public static Test suite() {
// it could be done here because it is not needed to be enabled back
JavaModelManager.getIndexManager().disable();
-
+
TestSuite suite = new TestSuite("CDI Core Tests");
suite.addTestSuite(BeanDefinitionTest.class);
suite.addTestSuite(NameDefinitionTest.class);
@@ -58,8 +56,9 @@
suite.addTestSuite(InjectionPointTest.class);
suite.addTestSuite(BeanSpecializationTest.class);
suite.addTestSuite(ResolutionByTypeTest.class);
+ suite.addTestSuite(EnterpriseResolutionByTypeTest.class);
+ suite.addTestSuite(AssignabilityOfRawAndParameterizedTypesTest.class);
suite.addTestSuite(ValidationTest.class);
return new CDICoreTestSetup(suite);
}
-
}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/AssignabilityOfRawAndParameterizedTypesTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/AssignabilityOfRawAndParameterizedTypesTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/AssignabilityOfRawAndParameterizedTypesTest.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.core.test.tck;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.cdi.core.IBean;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class AssignabilityOfRawAndParameterizedTypesTest extends TCKTest {
+
+ /**
+ * Section 5.2 - Typesafe resolution
+ * kb) Test with a raw type.
+ *
+ * @throws CoreException
+ */
+ public void testAssignabilityToRawType() throws CoreException {
+ Set<IBean> beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized.Dao");
+ assertEquals("Wrong number of the beans", 4, beans.size());
+ }
+
+ // TODO continue implementing tests.
+}
\ No newline at end of file
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/AssignabilityOfRawAndParameterizedTypesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanDefinitionTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanDefinitionTest.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanDefinitionTest.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -125,7 +125,7 @@
Set<IBean> beans = getBeans("org.jboss.jsr299.tck.tests.definition.bean.Tarantula");
assertEquals("There should be the only bean with org.jboss.jsr299.tck.tests.definition.bean.Tarantula type", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(bean, "org.jboss.jsr299.tck.tests.definition.bean.Tarantula",
+ assertContainsBeanTypes(bean, "org.jboss.jsr299.tck.tests.definition.bean.Tarantula",
"org.jboss.jsr299.tck.tests.definition.bean.Spider",
"org.jboss.jsr299.tck.tests.definition.bean.Animal",
"java.lang.Object",
@@ -148,7 +148,7 @@
Set<IBean> beans = getBeans("org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope");
assertEquals("There should be the only bean with org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope type", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(bean, "org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope",
+ assertContainsBeanTypes(bean, "org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope",
"org.jboss.jsr299.tck.tests.definition.bean.AbstractAntelope",
"org.jboss.jsr299.tck.tests.definition.bean.Animal",
"java.lang.Object");
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanSpecializationTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanSpecializationTest.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanSpecializationTest.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -30,7 +30,7 @@
Set<IBean> beans = cdiProject.getBeans(true, "org.jboss.jsr299.tck.tests.inheritance.specialization.simple.LazyFarmer", "org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Landowner");
assertEquals("Wrong number of beans.", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(false, bean, "org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Farmer");
+ assertContainsBeanTypes(false, bean, "org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Farmer");
assertContainsQualifierType(true, bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Landowner",
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Lazy",
@@ -48,7 +48,7 @@
Set<IBean> beans = cdiProject.getBeans(true, "org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.LazyFarmerLocal", "org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.Landowner");
assertEquals("Wrong number of beans.", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(false, bean, "org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.FarmerLocal");
+ assertContainsBeanTypes(false, bean, "org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.FarmerLocal");
assertContainsQualifierType(true, bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.Landowner",
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.Lazy",
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseResolutionByTypeTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseResolutionByTypeTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseResolutionByTypeTest.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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.core.test.tck;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.cdi.core.IBean;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class EnterpriseResolutionByTypeTest extends TCKTest {
+
+ /**
+ * Section 2.2.2 - Restricting the bean types of a bean
+ * b) Check session bean.
+ *
+ * @throws CoreException
+ */
+ public void testBeanTypesOnSessionBean() throws CoreException {
+ Set<IBean> beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.CapercaillieLocal");
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ assertContainsBeanTypes(beans.iterator().next(), "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.CapercaillieLocal", "java.lang.Object");
+ beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.ScottishBirdLocal");
+ assertEquals("Wrong number of the beans", 0, beans.size());
+ }
+}
\ No newline at end of file
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseResolutionByTypeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -37,7 +37,7 @@
public void testDefaultBindingTypeAssumed() throws CoreException {
Set<IBean> beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tuna");
assertEquals("Wrong number of the beans", 1, beans.size());
- assertContainsBeanType(false, beans.iterator().next(), "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tuna");
+ assertContainsBeanTypes(false, beans.iterator().next(), "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tuna");
}
/**
@@ -131,6 +131,20 @@
}
/**
+ * 5.1.4. Inter-module injection
+ * i) Check a disabled managed bean is not injectable.
+ *
+ * @throws CoreException
+ */
+ public void testPolicyNotAvailableInNonDeploymentArchive() throws CoreException {
+ Set<IBean> beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Spider");
+ assertFalse("Wrong number of the beans", beans.isEmpty());
+ assertDoesNotContainBeanClasses(beans, new String[]{"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.CrabSpider", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.DaddyLongLegs"});
+ beans = cdiProject.getBeans("crabSpider", true);
+ assertTrue("Wrong nuber of the beans", beans.isEmpty());
+ }
+
+ /**
* Section 2.2.2 - Restricting the bean types of a bean
* a) Check managed bean.
*
@@ -142,7 +156,7 @@
IBean bean = beans.iterator().next();
beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Bird");
assertEquals("Wrong number of the beans", 0, beans.size());
- assertContainsBeanType(bean, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Canary", "java.lang.Object");
+ assertContainsBeanTypes(bean, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Canary", "java.lang.Object");
}
/**
@@ -166,8 +180,8 @@
beans = cdiProject.getBeans(true, parametedType, new IQualifierDeclaration[0]);
assertEquals("Wrong number of the beans", 0, beans.size());
- assertContainsBeanType(false, bean, "java.lang.Object");
- assertContainsBeanType(false, bean, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.FlightlessBird");
+ assertContainsBeanTypes(false, bean, "java.lang.Object");
+ assertContainsBeanTypes(false, bean, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.FlightlessBird");
assertContainsBeanTypeSignatures(false, bean, "QFlightlessBird<QAustralian;>;");
}
@@ -180,7 +194,7 @@
public void testBeanTypesOnProducerMethod() throws CoreException {
Set<IBean> beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Parrot");
assertEquals("Wrong number of the beans", 1, beans.size());
- assertContainsBeanType(beans.iterator().next(), "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Parrot", "java.lang.Object");
+ assertContainsBeanTypes(beans.iterator().next(), "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Parrot", "java.lang.Object");
beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Bird");
assertEquals("Wrong number of the beans", 0, beans.size());
@@ -201,8 +215,8 @@
assertEquals("Wrong number of the beans", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(false, bean, "java.lang.Object");
- assertContainsBeanType(false, bean, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Cat");
+ assertContainsBeanTypes(false, bean, "java.lang.Object");
+ assertContainsBeanTypes(false, bean, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Cat");
assertContainsBeanTypeSignatures(false, bean, "QCat<QEuropean;>;");
beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.DomesticCat", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tame");
@@ -224,8 +238,8 @@
assertEquals("Wrong number of the beans", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(false, bean, "java.lang.Object");
- assertContainsBeanType(false, bean, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Cat");
+ assertContainsBeanTypes(false, bean, "java.lang.Object");
+ assertContainsBeanTypes(false, bean, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Cat");
assertContainsBeanTypeSignatures(false, bean, "QCat<QAfrican;>;");
beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Lion", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Wild");
@@ -241,7 +255,7 @@
public void testBeanTypesOnProducerField() throws CoreException {
Set<IBean> beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Dove");
assertEquals("Wrong number of the beans", 1, beans.size());
- assertContainsBeanType(beans.iterator().next(), "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Dove", "java.lang.Object");
+ assertContainsBeanTypes(beans.iterator().next(), "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Dove", "java.lang.Object");
beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Bird");
assertEquals("Wrong number of the beans", 0, beans.size());
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -224,11 +224,11 @@
fail(message.toString());
}
- protected void assertContainsBeanType(IBean bean, String... typeNames) {
- assertContainsBeanType(true, bean, typeNames);
+ protected void assertContainsBeanTypes(IBean bean, String... typeNames) {
+ assertContainsBeanTypes(true, bean, typeNames);
}
- protected void assertContainsBeanType(boolean checkTheNumberOfTypes, IBean bean, String... typeNames) {
+ protected void assertContainsBeanTypes(boolean checkTheNumberOfTypes, IBean bean, String... typeNames) {
if(checkTheNumberOfTypes) {
assertEquals("Wrong number of types.", typeNames.length, bean.getLegalTypes().size());
}
@@ -272,6 +272,17 @@
}
}
+ public static void assertDoesNotContainBeanClasses(Set<IBean> beans, String... beanClassNames) throws CoreException {
+ StringBuffer sb = new StringBuffer("[");
+ for (String beanClassName : beanClassNames) {
+ sb.append(beanClassName).append("; ");
+ }
+ sb.append("]");
+ for (String beanClassName : beanClassNames) {
+ assertTrue("Found " + beanClassName + " among " + sb.toString(), doesNotContainBeanClass(beans, beanClassName));
+ }
+ }
+
public static void assertContainsBeanClasses(Set<IBean> beans, String... beanClassNames) throws CoreException {
assertContainsBeanClasses(true, beans, beanClassNames);
}
@@ -294,6 +305,15 @@
assertTrue("Didn't find " + beanClassName, containsBeanClass(beans, beanClassName));
}
+ private static boolean doesNotContainBeanClass(Set<IBean> beans, String beanClassName) throws CoreException {
+ for (IBean bean : beans) {
+ if(beanClassName.equals(bean.getBeanClass().getFullyQualifiedName())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
private static boolean containsBeanClass(Set<IBean> beans, String beanClassName) throws CoreException {
for (IBean bean : beans) {
if(beanClassName.equals(bean.getBeanClass().getFullyQualifiedName())) {
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-06-11 09:57:56 UTC (rev 22761)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-06-11 10:06:32 UTC (rev 22762)
@@ -885,6 +885,28 @@
}
/**
+ * 5.1.4. Inter-module injection
+ * - a decorator can not be injected
+ *
+ * @throws Exception
+ */
+ public void testDecoratorNotResolved() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/decorator/House.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.INJECTED_DECORATOR, 23);
+ }
+
+ /**
+ * 5.1.4. Inter-module injection
+ * - an interceptor can not be injected
+ *
+ * @throws Exception
+ */
+ public void testInterceptorNotResolved() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/interceptors/InjectInterceptorBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.INJECTED_INTERCEPTOR, 7);
+ }
+
+ /**
* 5.2.1. Unsatisfied and ambiguous dependencies
* - If an unresolvable ambiguous dependency exists, the container automatically detects the problem and treats it as a deployment problem.
*
@@ -922,6 +944,23 @@
}
/**
+ * 5.2.4. Primitive types and null values
+ * - injection point of primitive type resolves to a bean that may have null values, such as a producer method with a non-primitive return type or a producer field with a non-primitive type
+ *
+ * @throws Exception
+ */
+ public void testPrimitiveInjectionPointResolvedToNonPrimitiveProducerMethod() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/inject/GameBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 7, 19);
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 9);
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 10);
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 11);
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 20);
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 21);
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 22);
+ }
+
+ /**
* 5.2.5. Qualifier annotations with members
* - annotation-valued member of a qualifier type is not annotated @Nonbinding (Non-Portable behavior)
*
14 years, 7 months
JBoss Tools SVN: r22761 - trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2010-06-11 05:57:56 -0400 (Fri, 11 Jun 2010)
New Revision: 22761
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java
Log:
https://jira.jboss.org/browse/JBIDE-6348
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java 2010-06-11 08:37:44 UTC (rev 22760)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java 2010-06-11 09:57:56 UTC (rev 22761)
@@ -196,7 +196,7 @@
subclass.setDiscriminatorValue(StringHelper.unqualify(pastClass.getClassName()));
subclass.setAbstract(pastClass.isAbstract());
if (subclass instanceof JoinedSubclass) {
- ((JoinedSubclass) subclass).setTable(new Table(pastClass.getClassName().toUpperCase()));
+ ((JoinedSubclass) subclass).setTable(new Table(StringHelper.unqualify(pastClass.getClassName()).toUpperCase()));
((JoinedSubclass) subclass).setKey((KeyValue) pc.getIdentifierProperty().getValue());
}
if (pastClass.getIdentifierProperty() != null) {
14 years, 7 months
JBoss Tools SVN: r22760 - trunk/build/aggregate.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2010-06-11 04:37:44 -0400 (Fri, 11 Jun 2010)
New Revision: 22760
Modified:
trunk/build/aggregate/aggregateRepos.jbds.properties.UNUSED
trunk/build/aggregate/aggregateRepos.jbosstools.properties
Log:
Add TPTP Galileo site to resolve missing dep 'org.eclipse.tptp.monitoring.profile.server.feature.group 4.2.200'
Modified: trunk/build/aggregate/aggregateRepos.jbds.properties.UNUSED
===================================================================
--- trunk/build/aggregate/aggregateRepos.jbds.properties.UNUSED 2010-06-11 08:24:03 UTC (rev 22759)
+++ trunk/build/aggregate/aggregateRepos.jbds.properties.UNUSED 2010-06-11 08:37:44 UTC (rev 22760)
@@ -31,10 +31,11 @@
# associate sites to add to the resulting repo
associate.sites=http://download.jboss.org/jbosstools/updates/helios/,\
+http://download.eclipse.org/eclipse/updates/3.6milestones/,\
+http://download.eclipse.org/eclipse/updates/3.6/,\
http://download.eclipse.org/birt/update-site/2.6-interim/,\
http://download.eclipse.org/birt/update-site/2.6/,\
-http://download.eclipse.org/eclipse/updates/3.6milestones/,\
-http://download.eclipse.org/eclipse/updates/3.6/,\
+http://download.eclipse.org/tptp/updates/galileo/,\
http://m2eclipse.sonatype.org/sites/m2e/,\
http://m2eclipse.sonatype.org/sites/m2e-extras/
Modified: trunk/build/aggregate/aggregateRepos.jbosstools.properties
===================================================================
--- trunk/build/aggregate/aggregateRepos.jbosstools.properties 2010-06-11 08:24:03 UTC (rev 22759)
+++ trunk/build/aggregate/aggregateRepos.jbosstools.properties 2010-06-11 08:37:44 UTC (rev 22760)
@@ -31,10 +31,11 @@
# associate sites to add to the resulting repo
associate.sites=http://download.jboss.org/jbosstools/updates/helios/,\
+http://download.eclipse.org/eclipse/updates/3.6milestones/,\
+http://download.eclipse.org/eclipse/updates/3.6/,\
http://download.eclipse.org/birt/update-site/2.6-interim/,\
http://download.eclipse.org/birt/update-site/2.6/,\
-http://download.eclipse.org/eclipse/updates/3.6milestones/,\
-http://download.eclipse.org/eclipse/updates/3.6/,\
+http://download.eclipse.org/tptp/updates/galileo/,\
http://m2eclipse.sonatype.org/sites/m2e/,\
http://m2eclipse.sonatype.org/sites/m2e-extras/,\
http://subclipse.tigris.org/update_1.6.x/,\
14 years, 7 months
JBoss Tools SVN: r22759 - trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2010-06-11 04:24:03 -0400 (Fri, 11 Jun 2010)
New Revision: 22759
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java
Log:
Merged revision 22214 to trunk
https://svn.jboss.org/repos/jbosstools/branches/3.2.helios
.......
r22214 | mareshkau
https://jira.jboss.org/browse/JBIDE-6429
.......
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java 2010-06-11 08:12:58 UTC (rev 22758)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java 2010-06-11 08:24:03 UTC (rev 22759)
@@ -20,10 +20,6 @@
import org.mozilla.interfaces.nsIAccessibleCoordinateType;
import org.mozilla.interfaces.nsIAccessibleRetrieval;
import org.mozilla.interfaces.nsIAccessibleText;
-import org.mozilla.interfaces.nsIBoxObject;
-import org.mozilla.interfaces.nsIDOMDocument;
-import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMNSDocument;
import org.mozilla.interfaces.nsIDOMNSElement;
import org.mozilla.interfaces.nsIDOMNSHTMLElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -74,18 +70,12 @@
*/
static public Rectangle getElementBounds(nsIDOMNode domNode) {
try {
- nsIDOMElement domElement = queryInterface(domNode, nsIDOMElement.class);
-
nsIDOMNSElement htmlElement = queryInterface(domNode, nsIDOMNSElement.class);
nsIDOMNSHTMLElement domNSHTMLElement = queryInterface(domNode, nsIDOMNSHTMLElement.class);
- nsIDOMDocument document = domElement.getOwnerDocument();
-
- nsIDOMNSDocument nsDocument = queryInterface(document, nsIDOMNSDocument.class);
- nsIBoxObject boxObject = nsDocument.getBoxObjectFor(domElement);
Rectangle rectangle = new Rectangle(findPosX(domNSHTMLElement),
findPosY(domNSHTMLElement),
- boxObject.getWidth(),
- boxObject.getHeight());
+ htmlElement.getClientWidth(),
+ htmlElement.getClientHeight());
if (BrowserPlugin.PRINT_ELEMENT_BOUNDS) {
System.out.println("getElementBounds(IDOMNode) returns "
@@ -102,10 +92,6 @@
htmlElement.getClientTop(), htmlElement
.getClientWidth(), htmlElement
.getClientHeight()));
- System.out.println("nsIBoxObject getX,getY,getWidth,getHeight"
- + new Rectangle(boxObject.getX(), boxObject.getY(),
- boxObject.getWidth(), boxObject.getHeight()));
-
}
return rectangle;
14 years, 7 months
JBoss Tools SVN: r22758 - in trunk/as/plugins: org.jboss.ide.eclipse.as.ui and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2010-06-11 04:12:58 -0400 (Fri, 11 Jun 2010)
New Revision: 22758
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBossServerType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-2814 - adding search capability for new jboss runtime
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBossServerType.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBossServerType.java 2010-06-11 07:49:24 UTC (rev 22757)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBossServerType.java 2010-06-11 08:12:58 UTC (rev 22758)
@@ -31,7 +31,7 @@
public static final JBossServerType AS = new JBossServerType(
"AS", //$NON-NLS-1$
"bin"+File.separatorChar + SYSTEM_JAR_NAME, //$NON-NLS-1$
- new String[]{"5.0", "4.2", "4.0", "3.2"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[]{"6.0", "5.0", "4.2", "4.0", "3.2"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
public static final JBossServerType EAP = new JBossServerType(
"EAP", //$NON-NLS-1$
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java 2010-06-11 08:12:58 UTC (rev 22758)
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * 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.ide.eclipse.as.ui.wizards;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.TaskModel;
+import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
+import org.eclipse.wst.server.core.model.RuntimeLocatorDelegate;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import org.eclipse.wst.server.ui.internal.wizard.TaskWizard;
+import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
+import org.eclipse.wst.server.ui.internal.wizard.fragment.NewRuntimeWizardFragment;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.JBossServerType;
+import org.jboss.ide.eclipse.as.core.util.ServerBeanLoader;
+
+public class JBossRuntimeLocator extends RuntimeLocatorDelegate {
+
+ public JBossRuntimeLocator() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void searchForRuntimes(IPath path, IRuntimeSearchListener listener,
+ IProgressMonitor monitor) {
+ ServerBeanLoader loader = new ServerBeanLoader();
+ IRuntimeWorkingCopy wc = searchForRuntimes(path, loader, monitor);
+ if( wc != null )
+ listener.runtimeFound(wc);
+ }
+
+ public IRuntimeWorkingCopy searchForRuntimes(IPath path, ServerBeanLoader loader, IProgressMonitor monitor) {
+ if( loader.getServerType(path.toFile()) != JBossServerType.UNKNOWN) {
+ // return found
+ return createRuntime(path, loader);
+ }
+ File[] children = path.toFile().listFiles();
+ monitor.beginTask("Searching for JBoss runtime...", children.length); //$NON-NLS-1$
+ if( children != null ) {
+ for( int i = 0; i < children.length; i++ ) {
+ if( children[i].isDirectory()) {
+ SubProgressMonitor newMon = new SubProgressMonitor(monitor, 1);
+ IRuntimeWorkingCopy wc = searchForRuntimes(path.append(children[i].getName()), loader, newMon);
+ if( wc != null ) {
+ monitor.done();
+ return wc;
+ }
+ } else {
+ monitor.worked(1);
+ }
+ }
+ }
+ monitor.done();
+ return null;
+ }
+
+ public static IRuntimeWorkingCopy createRuntime(IPath path) {
+ return createRuntime(path, new ServerBeanLoader());
+ }
+
+ public static IRuntimeWorkingCopy createRuntime(IPath path, ServerBeanLoader loader) {
+ JBossServerType type = loader.getServerType(path.toFile());
+ if( type == JBossServerType.AS)
+ return createASRuntime(path, loader);
+ if( type == JBossServerType.EAP)
+ return createEAPRuntime(path, loader);
+ if( type == JBossServerType.SOAP)
+ return createSOAPRuntime(path, loader);
+ return null;
+ }
+
+ private static IRuntimeWorkingCopy createASRuntime(IPath path, ServerBeanLoader loader) {
+ String version = new ServerBeanLoader().getFullServerVersion(new File(path.toFile(), JBossServerType.AS.getSystemJarPath()));
+ String runtimeTypeId = null;
+ if( version.compareTo("4.0") < 0 ) //$NON-NLS-1$
+ runtimeTypeId=IJBossToolingConstants.AS_32;
+ else if( version.compareTo("4.2") < 0 ) //$NON-NLS-1$
+ runtimeTypeId=IJBossToolingConstants.AS_40;
+ else if( version.compareTo("5.0") < 0 ) //$NON-NLS-1$
+ runtimeTypeId=IJBossToolingConstants.AS_42;
+ else if( version.compareTo("5.1") < 0 ) //$NON-NLS-1$
+ runtimeTypeId=IJBossToolingConstants.AS_50;
+ else if( version.compareTo("6.0") < 0 ) //$NON-NLS-1$
+ runtimeTypeId=IJBossToolingConstants.AS_51;
+ else
+ runtimeTypeId=IJBossToolingConstants.AS_60;
+ if( runtimeTypeId != null ) {
+ try {
+ IRuntimeWorkingCopy wc = createRuntimeWorkingCopy(runtimeTypeId, path.toOSString(), IJBossRuntimeResourceConstants.DEFAULT_CONFIGURATION);
+ return launchRuntimeWizard(wc);
+ } catch( CoreException ce) {
+ }
+ }
+ return null;
+ }
+ private static IRuntimeWorkingCopy createEAPRuntime(IPath path, ServerBeanLoader loader) {
+ String version = new ServerBeanLoader().getFullServerVersion(new File(path.toFile(), JBossServerType.EAP.getSystemJarPath()));
+ String runtimeTypeId = null;
+ if( version.compareTo("5.0") < 0 ) //$NON-NLS-1$
+ runtimeTypeId=IJBossToolingConstants.EAP_43;
+ else
+ runtimeTypeId=IJBossToolingConstants.EAP_50;
+
+ if( runtimeTypeId != null ) {
+ try {
+ IRuntimeWorkingCopy wc = createRuntimeWorkingCopy(runtimeTypeId, path.toOSString(), IJBossRuntimeResourceConstants.DEFAULT_CONFIGURATION);
+ return launchRuntimeWizard(wc);
+ } catch( CoreException ce) {
+ }
+ }
+ return null;
+ }
+
+ private static IRuntimeWorkingCopy createSOAPRuntime(IPath path, ServerBeanLoader loader) {
+ return createEAPRuntime(path, loader);
+ }
+
+ private static IRuntimeWorkingCopy launchRuntimeWizard(final IRuntimeWorkingCopy wc) {
+ final IRuntimeWorkingCopy[] wcRet = new IRuntimeWorkingCopy[1];
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ IRuntimeWorkingCopy wc2 = showWizard(wc);
+ wcRet[0] = wc2;
+ }
+ });
+ return wcRet[0];
+ }
+
+ // Copied from RuntimePreferencePage
+ protected static IRuntimeWorkingCopy showWizard(final IRuntimeWorkingCopy runtimeWorkingCopy) {
+ String title = null;
+ WizardFragment fragment = null;
+ TaskModel taskModel = new TaskModel();
+ if (runtimeWorkingCopy == null) {
+ title = Messages.wizNewRuntimeWizardTitle;
+ fragment = new WizardFragment() {
+ protected void createChildFragments(List<WizardFragment> list) {
+ list.add(new NewRuntimeWizardFragment());
+ list.add(WizardTaskUtil.SaveRuntimeFragment);
+ }
+ };
+ } else {
+ title = Messages.wizEditRuntimeWizardTitle;
+ final WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(runtimeWorkingCopy.getRuntimeType().getId());
+ if (fragment2 == null) {
+ return null;
+ }
+ taskModel.putObject(TaskModel.TASK_RUNTIME, runtimeWorkingCopy);
+ fragment = new WizardFragment() {
+ protected void createChildFragments(List<WizardFragment> list) {
+ list.add(fragment2);
+ list.add(WizardTaskUtil.SaveRuntimeFragment);
+ }
+ };
+ }
+ TaskWizard wizard = new TaskWizard(title, fragment, taskModel);
+ wizard.setForcePreviousAndNextButtons(true);
+ WizardDialog dialog = new WizardDialog(new Shell(), wizard);
+ int result = dialog.open();
+ if( result == Window.OK ) {
+ IRuntime rt = (IRuntime)taskModel.getObject(TaskModel.TASK_RUNTIME);
+ if( rt != null ) {
+ IRuntimeWorkingCopy rtwc = rt.createWorkingCopy();
+ return rtwc;
+ }
+ }
+ return null;
+ }
+
+ public static IRuntimeWorkingCopy createRuntimeWorkingCopy(String runtimeId, String homeDir,
+ String config) throws CoreException {
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null, null,
+ runtimeId);
+ IRuntimeType runtimeType = runtimeTypes[0];
+ IRuntimeWorkingCopy runtimeWC = runtimeType.createRuntime(null,
+ new NullProgressMonitor());
+ runtimeWC.setLocation(new Path(homeDir));
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_VM_ID, JavaRuntime.getDefaultVMInstall().getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_VM_TYPE_ID, JavaRuntime.getDefaultVMInstall()
+ .getVMInstallType().getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, config);
+ return runtimeWC;
+ }
+
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2010-06-11 07:49:24 UTC (rev 22757)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2010-06-11 08:12:58 UTC (rev 22758)
@@ -564,5 +564,13 @@
id="org.jboss.ide.eclipse.as.ui.launchConfigurationTypeImage1">
</launchConfigurationTypeImage>
</extension>
+ <extension
+ point="org.eclipse.wst.server.core.runtimeLocators">
+ <runtimeLocator
+ class="org.jboss.ide.eclipse.as.ui.wizards.JBossRuntimeLocator"
+ id="org.jboss.ide.eclipse.as.ui.wizards.jboss.runtimeLocator"
+ typeIds="org.jboss.ide.eclipse.as.32,org.jboss.ide.eclipse.as.40,org.jboss.ide.eclipse.as.42,org.jboss.ide.eclipse.as.50,org.jboss.ide.eclipse.as.51,org.jboss.ide.eclipse.as.60,org.jboss.ide.eclipse.as.eap.43,org.jboss.ide.eclipse.as.eap.50">
+ </runtimeLocator>
+ </extension>
</plugin>
14 years, 7 months