JBoss Tools SVN: r24648 - trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2010-09-02 10:32:31 -0400 (Thu, 02 Sep 2010)
New Revision: 24648
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/EventAndObserverMethodHyperlinkDetectorTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6977
Modified: trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/EventAndObserverMethodHyperlinkDetectorTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/EventAndObserverMethodHyperlinkDetectorTest.java 2010-09-02 14:28:05 UTC (rev 24647)
+++ trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/EventAndObserverMethodHyperlinkDetectorTest.java 2010-09-02 14:32:31 UTC (rev 24648)
@@ -28,7 +28,11 @@
public void testObserverMethodHyperlinkDetector() throws Exception {
ArrayList<Region> regionList = new ArrayList<Region>();
+ regionList.add(new Region(1196, 4));
+ regionList.add(new Region(1201, 13));
regionList.add(new Region(1216, 15));
+ regionList.add(new Region(1232, 9));
+ regionList.add(new Region(1264, 18));
checkRegions("JavaSource/org/jboss/jsr299/tck/tests/event/observer/checkedException/TeaCupPomeranian.java", regionList, new EventAndObserverMethodHyperlinkDetector());
}
15 years, 1 month
JBoss Tools SVN: r24645 - branches/jbosstools-3.2.0.M2/usage.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-09-02 10:18:21 -0400 (Thu, 02 Sep 2010)
New Revision: 24645
Added:
branches/jbosstools-3.2.0.M2/usage/org.jboss.tools.usage.feature/
branches/jbosstools-3.2.0.M2/usage/org.jboss.tools.usage.test.feature/
branches/jbosstools-3.2.0.M2/usage/org.jboss.tools.usage.test/
branches/jbosstools-3.2.0.M2/usage/org.jboss.tools.usage/
branches/jbosstools-3.2.0.M2/usage/usage-site/
Log:
bringing trunk changes to M2
15 years, 1 month
JBoss Tools SVN: r24644 - trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-09-02 09:59:29 -0400 (Thu, 02 Sep 2010)
New Revision: 24644
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReportPreferences.java
Log:
[JBIDE-6953] code cleanup
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReportPreferences.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReportPreferences.java 2010-09-02 13:15:59 UTC (rev 24643)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReportPreferences.java 2010-09-02 13:59:29 UTC (rev 24644)
@@ -31,17 +31,10 @@
IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_DEFAULTVALUE);
}
- public static void flush() throws BackingStoreException {
- PreferencesUtils.getPreferences().flush();
- }
-
- public static IPreferenceStore createPreferenceStore() {
- return PreferencesUtils.getStore();
- }
-
public static boolean isAskUser() {
- IEclipsePreferences preferences = PreferencesUtils.getPreferences();
- return preferences.getBoolean(IUsageReportPreferenceConstants.ASK_USER_USAGEREPORT_ID, true);
+ return PreferencesUtils.getPreferences().getBoolean(
+ IUsageReportPreferenceConstants.ASK_USER_USAGEREPORT_ID,
+ IUsageReportPreferenceConstants.ASK_USER_USAGEREPORT_DEFAULTVALUE);
}
public static void setAskUser(boolean askUser) {
@@ -56,4 +49,12 @@
IUsageReportPreferenceConstants.ASK_USER_USAGEREPORT_ID));
}
}
+
+ public static void flush() throws BackingStoreException {
+ PreferencesUtils.getPreferences().flush();
+ }
+
+ public static IPreferenceStore createPreferenceStore() {
+ return PreferencesUtils.getStore();
+ }
}
15 years, 1 month
JBoss Tools SVN: r24643 - trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-09-02 09:15:59 -0400 (Thu, 02 Sep 2010)
New Revision: 24643
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventAndObserverMethodHyperlinkDetector.java
Log:
https://jira.jboss.org/browse/JBIDE-6977
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventAndObserverMethodHyperlinkDetector.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventAndObserverMethodHyperlinkDetector.java 2010-09-02 13:00:27 UTC (rev 24642)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventAndObserverMethodHyperlinkDetector.java 2010-09-02 13:15:59 UTC (rev 24643)
@@ -20,6 +20,7 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.ResolvedBinaryType;
import org.eclipse.jdt.internal.core.ResolvedSourceType;
@@ -35,10 +36,13 @@
import org.jboss.tools.cdi.core.CDICoreNature;
import org.jboss.tools.cdi.core.CDIUtil;
import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.IBeanMethod;
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.IInjectionPointParameter;
import org.jboss.tools.cdi.core.IObserverMethod;
+import org.jboss.tools.cdi.core.IParameter;
import org.jboss.tools.cdi.text.ext.CDIExtensionsPlugin;
public class EventAndObserverMethodHyperlinkDetector extends AbstractHyperlinkDetector{
@@ -103,18 +107,18 @@
ICDIProject cdiProject = cdiNature.getDelegate();
if(cdiProject != null){
IInjectionPoint injectionPoint = findInjectedPoint(cdiProject, element, position, file);
+ IParameter param = findObserverParameter(cdiProject, element, offset, file);
if(injectionPoint != null){
Set<IObserverMethod> observerMethods = cdiProject.resolveObserverMethods(injectionPoint);
if(observerMethods.size() > 0)
hyperlinks.add(new ObserverMethodListHyperlink(textViewer, region, observerMethods, document));
- if(injectionPoint instanceof IInjectionPointParameter){
- Set<IInjectionPoint> events = cdiProject.findObservedEvents((IInjectionPointParameter)injectionPoint);
-
- if(events.size() > 0)
- hyperlinks.add(new EventListHyperlink(textViewer, region, events, document));
- }
+ } else if(param != null) {
+ Set<IInjectionPoint> events = cdiProject.findObservedEvents(param);
+
+ if(events.size() > 0)
+ hyperlinks.add(new EventListHyperlink(textViewer, region, events, document));
}
}
}
@@ -134,4 +138,27 @@
return CDIUtil.findInjectionPoint(beans, element, offset);
}
+ private IParameter findObserverParameter(ICDIProject cdiProject, IJavaElement element, int offset, IFile file) throws JavaModelException {
+ Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+ for (IBean bean: beans) {
+ if(bean instanceof IClassBean) {
+ Set<IBeanMethod> observers = ((IClassBean)bean).getObserverMethods();
+ for (IBeanMethod bm: observers) {
+ if(bm instanceof IObserverMethod) {
+ ISourceRange sr = bm.getMethod().getSourceRange();
+ if(sr.getOffset() <= offset && sr.getOffset() + sr.getLength() >= offset) {
+ IObserverMethod obs = (IObserverMethod)bm;
+ Set<IParameter> ps = obs.getObservedParameters();
+ if(!ps.isEmpty()) {
+ return ps.iterator().next();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
}
15 years, 1 month
JBoss Tools SVN: r24642 - in trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage: reporting and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-09-02 09:00:27 -0400 (Thu, 02 Sep 2010)
New Revision: 24642
Added:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BrowserUtil.java
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences/IUsageReportPreferenceConstants.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences/UsageReportPreferenceInitializer.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReport.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReportEnablementDialog.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/messages.properties
Log:
[JBIDE-6976] link in dialog added, opens in an external browser
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences/IUsageReportPreferenceConstants.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences/IUsageReportPreferenceConstants.java 2010-09-02 12:28:08 UTC (rev 24641)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences/IUsageReportPreferenceConstants.java 2010-09-02 13:00:27 UTC (rev 24642)
@@ -41,4 +41,6 @@
public static final String LAST_VISIT = "last_visit";
public static final String VISIT_COUNT = "visit_count";
+
+ public static final boolean ASK_USER_USAGEREPORT_DEFAULTVALUE = true;
}
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences/UsageReportPreferenceInitializer.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences/UsageReportPreferenceInitializer.java 2010-09-02 12:28:08 UTC (rev 24641)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences/UsageReportPreferenceInitializer.java 2010-09-02 13:00:27 UTC (rev 24642)
@@ -21,6 +21,10 @@
public void initializeDefaultPreferences() {
PreferencesUtils.getStore().setDefault(
+ IUsageReportPreferenceConstants.ASK_USER_USAGEREPORT_ID,
+ IUsageReportPreferenceConstants.ASK_USER_USAGEREPORT_DEFAULTVALUE);
+
+ PreferencesUtils.getStore().setDefault(
IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_ID,
IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_DEFAULTVALUE);
}
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReport.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReport.java 2010-09-02 12:28:08 UTC (rev 24641)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReport.java 2010-09-02 13:00:27 UTC (rev 24642)
@@ -58,9 +58,6 @@
private void askUser() {
UsageReportEnablementDialog dialog = new UsageReportEnablementDialog(
- ReportingMessages.UsageReport_DialogTitle,
- ReportingMessages.UsageReport_DialogMessage,
- ReportingMessages.UsageReport_Checkbox_Text,
true,
PlatformUI.getWorkbench().getActiveWorkbenchWindow());
if (dialog.open() == Window.OK) {
@@ -115,11 +112,14 @@
}
monitor.worked(1);
if (UsageReportPreferences.isAskUser()) {
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
askUserAndReport();
+ } else {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
- } else {
doReport();
}
monitor.worked(2);
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReportEnablementDialog.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReportEnablementDialog.java 2010-09-02 12:28:08 UTC (rev 24641)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReportEnablementDialog.java 2010-09-02 13:00:27 UTC (rev 24642)
@@ -15,37 +15,34 @@
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.usage.internal.JBossToolsUsageActivator;
+import org.jboss.tools.usage.util.BrowserUtil;
/**
* @author Andre Dietisheim
*/
public class UsageReportEnablementDialog extends Dialog {
+ protected static final String USAGE_URL = "http://jboss.org/tools/usage"; // $NON
private Button checkBox;
- private String title;
- private String message;
private boolean reportEnabled;
- private String checkBoxLabel;
- public UsageReportEnablementDialog(String title, String message, String checkBoxLabel,
- boolean reportEnabled, IShellProvider parentShell) {
+ public UsageReportEnablementDialog(boolean reportEnabled, IShellProvider parentShell) {
super(parentShell);
- this.title = title;
- this.message = message;
- this.checkBoxLabel = checkBoxLabel;
this.reportEnabled = reportEnabled;
}
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
this.reportEnabled = checkBox.getSelection();
- }
- else if (buttonId == IDialogConstants.CANCEL_ID) {
+ } else if (buttonId == IDialogConstants.CANCEL_ID) {
this.reportEnabled = false;
}
super.buttonPressed(buttonId);
@@ -53,9 +50,7 @@
protected void configureShell(Shell shell) {
super.configureShell(shell);
- if (title != null) {
- shell.setText(title);
- }
+ shell.setText(ReportingMessages.UsageReport_DialogTitle);
}
protected void createButtonsForButtonBar(Composite parent) {
@@ -67,19 +62,30 @@
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
- if (message != null) {
- Label label = new Label(composite, SWT.WRAP);
- label.setFont(parent.getFont());
- label.setText(message);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.CENTER).grab(true, false)
- .hint(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH, SWT.DEFAULT)
- .applyTo(label);
- }
+
+ // message
+ Link link = new Link(composite, SWT.WRAP);
+ link.setFont(parent.getFont());
+ link.setText(ReportingMessages.UsageReport_DialogMessage);
+ link.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ BrowserUtil.checkedCreateExternalBrowser(USAGE_URL, JBossToolsUsageActivator.PLUGIN_ID, JBossToolsUsageActivator.getDefault().getLog());
+ }
+ });
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.CENTER)
+ .grab(true, false)
+ .hint(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH, SWT.DEFAULT)
+ .applyTo(link);
+
+ // checkbox
checkBox = new Button(composite, SWT.CHECK);
- checkBox.setText(checkBoxLabel);
+ checkBox.setText(ReportingMessages.UsageReport_Checkbox_Text);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.LEFT, SWT.CENTER).applyTo(checkBox);
+
applyDialogFont(composite);
+
return composite;
}
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/messages.properties
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/messages.properties 2010-09-02 12:28:08 UTC (rev 24641)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/messages.properties 2010-09-02 13:00:27 UTC (rev 24642)
@@ -3,7 +3,7 @@
UsageReport_Querying_Enablement=Querying whether reporting is globally enabled
UsageReport_Asking_User=Asking User to allow reporting
UsageReport_Checkbox_Text=Report usage of JBoss Tools to JBoss Tools team.
-UsageReport_DialogMessage=Please allow the JBoss Tools team to receive anonymous usage statistics for this Eclipse installation with JBoss tools.
+UsageReport_DialogMessage=Please allow the JBoss Tools team to receive anonymous usage statistics for this Eclipse installation with JBoss tools (<a>info</a>).
UsageReport_DialogTitle=JBoss Tools Usage
UsageReport_Error_SavePreferences=Could not save preferences {0}
UsageReport_GoogleAnalyticsAccount=UA-17645367-1
Added: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BrowserUtil.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BrowserUtil.java (rev 0)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BrowserUtil.java 2010-09-02 13:00:27 UTC (rev 24642)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.usage.util;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWebBrowser;
+
+public class BrowserUtil {
+
+ /**
+ * Opens a browser for the given url with the given id. If an error occurs
+ * it will be reported to the given log provider with the given plugin id.
+ *
+ * @param url
+ * the url to open a browser for.
+ * @param browserId
+ * the id for the new browser.
+ * @param pluginId
+ * the plugin id to log for.
+ * @param log
+ * the log provider to log against if an error occurred.
+ */
+ public static void checkedCreateInternalBrowser(String url, String browserId, String pluginId, ILog log) {
+ try {
+ openUrl(url, PlatformUI.getWorkbench().getBrowserSupport().createBrowser(browserId), pluginId, log);
+ } catch (PartInitException e) {
+ IStatus errorStatus = StatusUtils.getErrorStatus(pluginId, "Could not open browser for url \"{0}\".", e,
+ url);
+ log.log(errorStatus);
+ }
+ }
+
+
+ public static void checkedCreateExternalBrowser(String url, String pluginId, ILog log) {
+ try {
+ openUrl(url, PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser(), pluginId, log);
+ } catch (PartInitException e) {
+ IStatus errorStatus = StatusUtils.getErrorStatus(pluginId, "Could not open browser for url \"{0}\".", e,
+ url);
+ log.log(errorStatus);
+ }
+ }
+
+ public static void openUrl(String url, IWebBrowser browser, String pluginId, ILog log) {
+ try {
+ browser.openURL(new URL(url));
+ } catch (PartInitException e) {
+ IStatus errorStatus = StatusUtils.getErrorStatus(pluginId, "Could not open browser for url \"{0}\".", e,
+ url);
+ log.log(errorStatus);
+ } catch (MalformedURLException e) {
+ IStatus errorStatus = StatusUtils.getErrorStatus(pluginId, "Could not display malformed url \"{0}\".", e,
+ url);
+ log.log(errorStatus);
+ }
+ }
+}
Property changes on: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BrowserUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 1 month
JBoss Tools SVN: r24641 - in trunk/cdi/tests/org.jboss.tools.cdi.core.test: src/org/jboss/tools/cdi/core/test/tck and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-09-02 08:28:08 -0400 (Thu, 02 Sep 2010)
New Revision: 24641
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/AnimalObserver.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ObserverMethodResolutionTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6977
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/AnimalObserver.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/AnimalObserver.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/AnimalObserver.java 2010-09-02 12:28:08 UTC (rev 24641)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.inject;
+
+import javax.enterprise.event.Observes;
+
+public class AnimalObserver {
+
+ public void observeSomeEvent(@Observes Animal someEvent, Animal injectedAnimal) {
+ }
+}
\ No newline at end of file
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/AnimalObserver.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/InjectionPointTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java 2010-09-02 12:22:10 UTC (rev 24640)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java 2010-09-02 12:28:08 UTC (rev 24641)
@@ -58,4 +58,12 @@
}
}
}
+
+ public void testObserverMethodParameters() {
+ IClassBean bean = getClassBean("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/inject/AnimalObserver.java");
+ assertNotNull("Can't find the bean.", bean);
+ Set<IInjectionPoint> injections = bean.getInjectionPoints();
+ assertEquals(1, injections.size());
+ }
+
}
\ No newline at end of file
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ObserverMethodResolutionTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ObserverMethodResolutionTest.java 2010-09-02 12:22:10 UTC (rev 24640)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ObserverMethodResolutionTest.java 2010-09-02 12:28:08 UTC (rev 24641)
@@ -46,9 +46,9 @@
assertTrue(p.size() == 1);
IParameter observerParameter = p.iterator().next();
- assertTrue(observerParameter instanceof IInjectionPointParameter);
+ assertFalse(observerParameter instanceof IInjectionPointParameter);
- Set<IInjectionPoint> points = tamedObserver.getClassBean().getCDIProject().findObservedEvents((IInjectionPointParameter)observerParameter);
+ Set<IInjectionPoint> points = tamedObserver.getClassBean().getCDIProject().findObservedEvents(observerParameter);
assertTrue(points.size() == 1);
assertTrue(points.contains(tamingEvent));
}
15 years, 1 month
JBoss Tools SVN: r24640 - in trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi: internal/core/impl and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-09-02 08:22:10 -0400 (Thu, 02 Sep 2010)
New Revision: 24640
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.java
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/BeanMethod.java
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/InjectionPointMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ObserverMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/Parameter.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/definition/MethodDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java
Log:
https://jira.jboss.org/browse/JBIDE-6977
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.java 2010-09-02 12:00:50 UTC (rev 24639)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.java 2010-09-02 12:22:10 UTC (rev 24640)
@@ -13,7 +13,9 @@
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
@@ -48,6 +50,10 @@
private boolean isStorageResolved = false;
+ Set<CDICoreNature> dependsOn = new HashSet<CDICoreNature>();
+
+ Set<CDICoreNature> usedBy = new HashSet<CDICoreNature>();
+
public CDICoreNature() {
definitions.setProject(this);
}
@@ -74,6 +80,36 @@
cdiProject.setNature(this);
}
+ public Set<CDICoreNature> getCDIProjects() {
+ return dependsOn;
+ }
+
+ public Set<CDICoreNature> getDependentProjects() {
+ return usedBy;
+ }
+
+ public void addCDIProject(CDICoreNature p) {
+ if(dependsOn.contains(p)) return;
+ dependsOn.add(p);
+ p.addDependentCDIProject(this);
+ //TODO
+ p.resolve();
+ if(p.getDelegate() != null) {
+ p.getDelegate().update();
+ }
+ }
+
+ public void removeCDIProject(CDICoreNature p) {
+ if(!dependsOn.contains(p)) return;
+ p.usedBy.remove(this);
+ dependsOn.remove(p);
+ //TODO
+ }
+
+ public void addDependentCDIProject(CDICoreNature p) {
+ usedBy.add(p);
+ }
+
public DefinitionContext getDefinitions() {
return definitions;
}
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-09-02 12:00:50 UTC (rev 24639)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2010-09-02 12:22:10 UTC (rev 24640)
@@ -283,7 +283,7 @@
* @return the set of injection points with event type observed by given
* parameter of an observer method
*/
- public Set<IInjectionPoint> findObservedEvents(IInjectionPointParameter observedEventParameter);
+ public Set<IInjectionPoint> findObservedEvents(IParameter observedEventParameter);
/**
* Applies the ambiguous dependency resolution rules to a set of beans.
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMethod.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMethod.java 2010-09-02 12:00:50 UTC (rev 24639)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMethod.java 2010-09-02 12:22:10 UTC (rev 24640)
@@ -45,14 +45,17 @@
List<ParameterDefinition> ps = definition.getParameters();
for (ParameterDefinition p: ps) {
- Parameter parameter = newParameter();
+// if(p.isAnnotationPresent(CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME)) {
+// continue;
+// }
+ Parameter parameter = newParameter(p);
parameter.setBeanMethod(this);
parameter.setDefinition(p);
parameters.add(parameter);
}
}
- protected Parameter newParameter() {
+ protected Parameter newParameter(ParameterDefinition p) {
return ((MethodDefinition)definition).parametersAreInjectionPoints() ? new InjectionPointParameter() : new Parameter();
}
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-09-02 12:00:50 UTC (rev 24639)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2010-09-02 12:22:10 UTC (rev 24640)
@@ -745,7 +745,7 @@
if(!((ParametedType)eventType).isAssignableTo((ParametedType)paramType, true)) {
continue;
}
- if(areMatchingEventQualifiers((InjectionPointParameter)param, injectionPoint)) {
+ if(areMatchingEventQualifiers(param, injectionPoint)) {
result.add(om);
}
}
@@ -770,8 +770,8 @@
return ps.isEmpty() ? null : ps.get(0);
}
- private boolean areMatchingEventQualifiers(IInjectionPointParameter observerParam, IInjectionPoint event) {
- Set<IQualifier> qs = ((InjectionPointParameter)observerParam).getQualifiers();
+ private boolean areMatchingEventQualifiers(IParameter observerParam, IInjectionPoint event) {
+ Set<IQualifier> qs = ((Parameter)observerParam).getQualifiers();
List<IType> paramQualifiers = new ArrayList<IType>();
for (IQualifier q: qs) {
if(q.getSourceType() != null) paramQualifiers.add(q.getSourceType());
@@ -786,7 +786,7 @@
return false;
}
- public Set<IInjectionPoint> findObservedEvents(IInjectionPointParameter observedEventParameter) {
+ public Set<IInjectionPoint> findObservedEvents(IParameter observedEventParameter) {
Set<IInjectionPoint> result = new HashSet<IInjectionPoint>();
if(observedEventParameter.getBeanMethod() instanceof IObserverMethod) {
@@ -948,6 +948,11 @@
rebuildXML();
rebuildAnnotationTypes();
rebuildBeans();
+
+ CDICoreNature[] ps = n.getDependentProjects().toArray(new CDICoreNature[0]);
+ for (CDICoreNature p: ps) {
+ p.getDelegate().update();
+ }
}
void rebuildAnnotationTypes() {
@@ -959,7 +964,7 @@
interceptorBindingsByPath.clear();
scopes.clear();
scopesByPath.clear();
- List<AnnotationDefinition> ds = n.getDefinitions().getAllAnnotations();
+ List<AnnotationDefinition> ds = getAllAnnotations();
for (AnnotationDefinition d: ds) {
if((d.getKind() & AnnotationDefinition.STEREOTYPE) > 0) {
StereotypeElement s = new StereotypeElement();
@@ -1005,8 +1010,60 @@
}
}
+ List<AnnotationDefinition> getAllAnnotations() {
+ Set<CDICoreNature> ps = n.getCDIProjects();
+ if(ps == null || ps.isEmpty()) {
+ return n.getDefinitions().getAllAnnotations();
+ }
+ List<AnnotationDefinition> ds = n.getDefinitions().getAllAnnotations();
+ List<AnnotationDefinition> result = new ArrayList<AnnotationDefinition>();
+ result.addAll(ds);
+ Set<IType> types = new HashSet<IType>();
+ for (AnnotationDefinition d: ds) {
+ IType t = d.getType();
+ if(t != null) types.add(t);
+ }
+ for (CDICoreNature p: ps) {
+ List<AnnotationDefinition> ds2 = p.getDefinitions().getAllAnnotations();
+ for (AnnotationDefinition d: ds2) {
+ IType t = d.getType();
+ if(t != null && !types.contains(t)) {
+ types.add(t);
+ result.add(d);
+ }
+ }
+ }
+ return result;
+ }
+
+ List<TypeDefinition> getAllTypeDefinitions() {
+ Set<CDICoreNature> ps = n.getCDIProjects();
+ if(ps == null || ps.isEmpty()) {
+ return n.getDefinitions().getTypeDefinitions();
+ }
+ List<TypeDefinition> ds = n.getDefinitions().getTypeDefinitions();
+ List<TypeDefinition> result = new ArrayList<TypeDefinition>();
+ result.addAll(ds);
+ Set<IType> types = new HashSet<IType>();
+ for (TypeDefinition d: ds) {
+ IType t = d.getType();
+ if(t != null) types.add(t);
+ }
+ for (CDICoreNature p: ps) {
+ List<TypeDefinition> ds2 = p.getDefinitions().getTypeDefinitions();
+ for (TypeDefinition d: ds2) {
+ IType t = d.getType();
+ if(t != null && !types.contains(t)) {
+ types.add(t);
+ result.add(d);
+ }
+ }
+ }
+ return result;
+ }
+
void rebuildBeans() {
- List<TypeDefinition> typeDefinitions = n.getDefinitions().getTypeDefinitions();
+ List<TypeDefinition> typeDefinitions = getAllTypeDefinitions();
List<IBean> beans = new ArrayList<IBean>();
Map<IType, ClassBean> newClassBeans = new HashMap<IType, ClassBean>();
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointMethod.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointMethod.java 2010-09-02 12:00:50 UTC (rev 24639)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointMethod.java 2010-09-02 12:22:10 UTC (rev 24640)
@@ -13,6 +13,7 @@
import org.jboss.tools.cdi.core.CDIUtil;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IInjectionPointMethod;
+import org.jboss.tools.cdi.internal.core.impl.definition.ParameterDefinition;
/**
*
@@ -31,7 +32,7 @@
}
@Override
- protected Parameter newParameter() {
+ protected Parameter newParameter(ParameterDefinition p) {
return new InjectionPointParameter();
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java 2010-09-02 12:00:50 UTC (rev 24639)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java 2010-09-02 12:22:10 UTC (rev 24640)
@@ -47,16 +47,6 @@
return result;
}
- public Set<IQualifier> getQualifiers() {
- Set<IQualifier> result = new HashSet<IQualifier>();
- Set<String> as = getAnnotationTypes();
- for (String s: as) {
- IQualifier q = getCDIProject().getQualifier(s);
- if (q != null) result.add(q);
- }
- return result;
- }
-
/*
* (non-Javadoc)
* @see org.jboss.tools.cdi.core.IInjectionPoint#isDelegate()
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ObserverMethod.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ObserverMethod.java 2010-09-02 12:00:50 UTC (rev 24639)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ObserverMethod.java 2010-09-02 12:22:10 UTC (rev 24640)
@@ -6,11 +6,15 @@
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.IObserverMethod;
import org.jboss.tools.cdi.core.IParameter;
+import org.jboss.tools.cdi.internal.core.impl.definition.ParameterDefinition;
public class ObserverMethod extends BeanMethod implements IObserverMethod {
@Override
- protected Parameter newParameter() {
+ protected Parameter newParameter(ParameterDefinition p) {
+ if(p.isAnnotationPresent(CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME)) {
+ return new Parameter();
+ }
return new InjectionPointParameter();
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/Parameter.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/Parameter.java 2010-09-02 12:00:50 UTC (rev 24639)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/Parameter.java 2010-09-02 12:22:10 UTC (rev 24640)
@@ -1,5 +1,6 @@
package org.jboss.tools.cdi.internal.core.impl;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -9,6 +10,7 @@
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IParameter;
+import org.jboss.tools.cdi.core.IQualifier;
import org.jboss.tools.cdi.internal.core.impl.definition.ParameterDefinition;
import org.jboss.tools.common.text.ITextSourceReference;
@@ -101,4 +103,15 @@
public IBeanMethod getBeanMethod() {
return beanMethod;
}
+
+ public Set<IQualifier> getQualifiers() {
+ Set<IQualifier> result = new HashSet<IQualifier>();
+ Set<String> as = getAnnotationTypes();
+ for (String s: as) {
+ IQualifier q = getCDIProject().getQualifier(s);
+ if (q != null) result.add(q);
+ }
+ return result;
+ }
+
}
\ 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-09-02 12:00:50 UTC (rev 24639)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2010-09-02 12:22:10 UTC (rev 24640)
@@ -30,6 +30,7 @@
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
import org.jboss.tools.cdi.core.ITypeDeclaration;
import org.jboss.tools.cdi.internal.core.impl.definition.MethodDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.ParameterDefinition;
import org.jboss.tools.common.model.project.ext.impl.ValueInfo;
import org.jboss.tools.common.text.ITextSourceReference;
@@ -53,7 +54,7 @@
}
@Override
- protected Parameter newParameter() {
+ protected Parameter newParameter(ParameterDefinition p) {
return new InjectionPointParameter();
}
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-09-02 12:00:50 UTC (rev 24639)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2010-09-02 12:22:10 UTC (rev 24640)
@@ -86,6 +86,9 @@
int paramEnd = content.lastIndexOf(')', declEnd);
if(paramEnd < 0) return;
String paramsString = content.substring(paramStart + 1, paramEnd);
+ if(!parametersAreInjectionPoints && paramsString.indexOf("@Observes") >= 0) {
+ parametersAreInjectionPoints = true;
+ }
if(!parametersAreInjectionPoints && paramsString.indexOf('@') < 0) return;
String[] params = getParams(paramsString);
String[] ps = method.getParameterTypes();
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java 2010-09-02 12:00:50 UTC (rev 24639)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java 2010-09-02 12:22:10 UTC (rev 24640)
@@ -20,15 +20,18 @@
import java.util.Set;
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.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.jboss.tools.cdi.core.CDICoreNature;
+import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.project.ext.AbstractClassPathMonitor;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jst.web.kb.internal.scanner.LibraryScanner;
-import org.jboss.tools.jst.web.kb.internal.scanner.LoadedDeclarations;
-import org.jboss.tools.jst.web.kb.internal.scanner.ScannerException;
public class ClassPathMonitor extends AbstractClassPathMonitor<CDICoreNature>{
IPath[] srcs = new IPath[0];
@@ -41,10 +44,6 @@
model = EclipseResourceUtil.createObjectForResource(getProjectResource()).getModel();
}
- public void validateProjectDependencies() {
- //TODO
- }
-
public Map<String, XModelObject> process() {
Map<String, XModelObject> newJars = new HashMap<String, XModelObject>();
Iterator<String> it = processedPaths.iterator();
@@ -69,15 +68,10 @@
newJars.put(p, b);
}
+ validateProjectDependencies();
return newJars;
-// validateProjectDependencies();
}
- public boolean hasToUpdateProjectDependencies() {
- //TODO
- return false;
- }
-
public IProject getProjectResource() {
return project.getProject();
}
@@ -95,4 +89,66 @@
srcs = newSrcs;
}
+ public void validateProjectDependencies() {
+ List<CDICoreNature> ps = null;
+
+ try {
+ ps = getProjects(project.getProject());
+ } catch (CoreException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ if(ps != null) {
+ Set<CDICoreNature> set = project.getCDIProjects();
+ Set<CDICoreNature> removable = new HashSet<CDICoreNature>();
+ removable.addAll(set);
+ removable.removeAll(ps);
+ ps.removeAll(set);
+ for (CDICoreNature p : ps) {
+ project.addCDIProject(p);
+ }
+ for (CDICoreNature p : removable) {
+ project.removeCDIProject(p);
+ }
+ }
+ }
+
+ public boolean hasToUpdateProjectDependencies() {
+ List<CDICoreNature> ps = null;
+
+ try {
+ ps = getProjects(project.getProject());
+ } catch (CoreException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ if(ps != null) {
+ Set<CDICoreNature> set = project.getCDIProjects();
+ Set<CDICoreNature> removable = new HashSet<CDICoreNature>();
+ removable.addAll(set);
+ removable.removeAll(ps);
+ ps.removeAll(set);
+ for (CDICoreNature p : ps) {
+ return true;
+ }
+ for (CDICoreNature p : removable) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ List<CDICoreNature> getProjects(IProject project) throws CoreException {
+ List<CDICoreNature> list = new ArrayList<CDICoreNature>();
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry[] es = javaProject.getResolvedClasspath(true);
+ for (int i = 0; i < es.length; i++) {
+ if(es[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) {
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(es[i].getPath().lastSegment());
+ if(p == null || !p.isAccessible()) continue;
+ CDICoreNature sp = CDICorePlugin.getCDI(p, false);
+ if(sp != null) list.add(sp);
+ }
+ }
+ return list;
+ }
+
}
15 years, 1 month
JBoss Tools SVN: r24639 - in trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2: action and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2010-09-02 08:00:50 -0400 (Thu, 02 Sep 2010)
New Revision: 24639
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2ComponentsValidator.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2SourceValidator.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2CompositeAttrsProposal.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2CompositeComponentProposal.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2QuickFixProcessor.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2ResourcesFolderProposal.java
Log:
https://jira.jboss.org/browse/JBIDE-6965
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2ComponentsValidator.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2ComponentsValidator.java 2010-09-02 09:04:29 UTC (rev 24638)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2ComponentsValidator.java 2010-09-02 12:00:50 UTC (rev 24639)
@@ -37,6 +37,7 @@
/**
*
* @author yzhishko
+ * @author mareshkau
*
*/
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2SourceValidator.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2SourceValidator.java 2010-09-02 09:04:29 UTC (rev 24638)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2SourceValidator.java 2010-09-02 12:00:50 UTC (rev 24639)
@@ -13,12 +13,15 @@
import java.util.Locale;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator;
import org.eclipse.wst.sse.ui.internal.reconcile.validator.IncrementalHelper;
+import org.eclipse.wst.validation.ValidatorMessage;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -26,6 +29,7 @@
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
import org.eclipse.wst.validation.internal.provisional.core.IValidator;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.jsf2.model.JSF2ComponentModelManager;
import org.jboss.tools.jsf.jsf2.util.JSF2ResourceUtil;
import org.jboss.tools.jsf.web.validation.jsf2.components.IJSF2ValidationComponent;
@@ -36,6 +40,7 @@
/**
*
* @author yzhishko
+ * @author mareshkau
*
*/
@@ -44,7 +49,7 @@
private IDOMDocument document;
private IFile validateFile;
-
+
public void cleanup(IReporter reporter) {
}
@@ -72,7 +77,7 @@
validateFile = (IFile) resource;
reportProblems(reporter,
JSF2XMLValidator.getValidationComponents(document,
- (IFile) resource));
+ (IFile) resource),resource);
}
}
}
@@ -93,11 +98,19 @@
}
private void reportProblems(IReporter reporter,
- IJSF2ValidationComponent[] validationComponents) {
- for (int i = 0; i < validationComponents.length; i++) {
- reporter.addMessage(this, new LocalizedMessage(
- validationComponents[i], validateFile));
+ IJSF2ValidationComponent[] validationComponents,IResource resource) {
+ try {
+ resource.deleteMarkers(JSF2XMLValidator.JSF2_PROBLEM_ID, false, IResource.DEPTH_INFINITE);
+ for (int i = 0; i < validationComponents.length; i++) {
+ Message locMessage = new LocalizedMessage(validationComponents[i], validateFile);
+ reporter.addMessage(this, locMessage);
+ IMarker marker = resource.createMarker(JSF2XMLValidator.JSF2_PROBLEM_ID);
+ marker.setAttributes(locMessage.getAttributes());
+ }
+ } catch (CoreException e) {
+ JSFModelPlugin.getPluginLog().logError(e);
}
+
}
private static class LocalizedMessage extends Message {
@@ -107,19 +120,23 @@
public LocalizedMessage(IJSF2ValidationComponent component,
IFile validateFile) {
this.component = component;
- setAttribute("problemType", "org.jboss.tools.jsf.jsf2problemmarker"); //$NON-NLS-1$ //$NON-NLS-2$
+ setAttribute("problemType", JSF2XMLValidator.JSF2_PROBLEM_ID); //$NON-NLS-1$ //$NON-NLS-2$
setAttribute(IJSF2ValidationComponent.JSF2_TYPE_KEY, component
.getType());
setAttribute(
"validateResourcePath", validateFile == null ? "" : validateFile.getFullPath().toString()); //$NON-NLS-1$//$NON-NLS-2$
setAttribute(JSF2ResourceUtil.COMPONENT_RESOURCE_PATH_KEY,
component.getComponentResourceLocation());
+ setAttribute("lineNumber", getLineNumber());
+ setAttribute("severity", 1);
+ setAttribute(ValidatorMessage.ValidationId, "org.jboss.tools.jsf.jsf2.source");
if (component instanceof JSF2URITempComponent) {
setAttribute(IJSF2ValidationComponent.JSF2_URI_NAME_KEY,
((JSF2URITempComponent) component).getURI());
} else if (component instanceof JSF2AttrTempComponent) {
setAttribute(IJSF2ValidationComponent.JSF2_ATTR_NAME_KEY,
((JSF2AttrTempComponent) component).getName());
+ setAttribute(JSF2ResourceUtil.JSF2_COMPONENT_NAME, ((JSF2AttrTempComponent) component).getElementName());
} else if (component instanceof JSF2CompositeTempComponent) {
String[] attrNames = ((JSF2CompositeTempComponent) component)
.getAttrNames();
@@ -129,8 +146,10 @@
IJSF2ValidationComponent.JSF2_ATTR_NAME_KEY
+ String.valueOf(i), attrNames[i]);
}
+ setAttribute(JSF2ResourceUtil.JSF2_COMPONENT_NAME, ((JSF2CompositeTempComponent) component).getElement().getLocalName());
}
}
+ setAttribute("message",getText());
}
@Override
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2CompositeAttrsProposal.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2CompositeAttrsProposal.java 2010-09-02 09:04:29 UTC (rev 24638)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2CompositeAttrsProposal.java 2010-09-02 12:00:50 UTC (rev 24639)
@@ -51,10 +51,12 @@
}
public JSF2CompositeAttrsProposal(IResource validateResource,
- String compPath, String[] attrs) {
+ String compPath, String[] attrs,String attrName,String elementName) {
super(validateResource);
this.componentPath = compPath;
this.attrs = attrs;
+ this.attrName = attrName;
+ this.elementName=elementName;
}
public String getDisplayString() {
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2CompositeComponentProposal.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2CompositeComponentProposal.java 2010-09-02 09:04:29 UTC (rev 24638)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2CompositeComponentProposal.java 2010-09-02 12:00:50 UTC (rev 24639)
@@ -11,25 +11,18 @@
package org.jboss.tools.jsf.web.validation.jsf2.action;
-import java.io.File;
import java.text.MessageFormat;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.jsf2.util.JSF2ResourceUtil;
import org.jboss.tools.jsf.messages.JSFUIMessages;
@@ -59,10 +52,11 @@
}
public JSF2CompositeComponentProposal(IResource validateResource,
- String compPath, String[] attrs) {
+ String compPath, String[] attrs, String elementName) {
super(validateResource);
this.componentPath = compPath;
this.attrs = attrs;
+ this.elementName=elementName;
}
@SuppressWarnings("unchecked")
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2QuickFixProcessor.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2QuickFixProcessor.java 2010-09-02 09:04:29 UTC (rev 24638)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2QuickFixProcessor.java 2010-09-02 12:00:50 UTC (rev 24639)
@@ -57,18 +57,19 @@
String[] attrs = new String[] { (String) context
.getAttribute(IJSF2ValidationComponent.JSF2_ATTR_NAME_KEY) };
ICompletionProposal proposal = new JSF2CompositeAttrsProposal(
- resource, compPath, attrs);
+ resource, compPath, attrs,(String)context.getAttribute(IJSF2ValidationComponent.JSF2_ATTR_NAME_KEY),
+ (String)context.getAttribute(JSF2ResourceUtil.JSF2_COMPONENT_NAME));
return new ICompletionProposal[] { proposal };
} else if (type
.equals(IJSF2ValidationComponent.JSF2_COMPOSITE_COMPONENT_TYPE)) {
ICompletionProposal proposal = new JSF2CompositeComponentProposal(
- resource, compPath, retriveAttrsFromContext(context));
+ resource, compPath, retriveAttrsFromContext(context),(String)context.getAttribute(JSF2ResourceUtil.JSF2_COMPONENT_NAME));
return new ICompletionProposal[] { proposal };
} else if (type.equals(IJSF2ValidationComponent.JSF2_URI_TYPE)) {
String uriPath = (String) context
.getAttribute(IJSF2ValidationComponent.JSF2_URI_NAME_KEY);
ICompletionProposal proposal = new JSF2ResourcesFolderProposal(
- resource, uriPath);
+ resource, uriPath,(String)context.getAttribute(IJSF2ValidationComponent.JSF2_URI_NAME_KEY));
return new ICompletionProposal[] { proposal };
}
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2ResourcesFolderProposal.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2ResourcesFolderProposal.java 2010-09-02 09:04:29 UTC (rev 24638)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/action/JSF2ResourcesFolderProposal.java 2010-09-02 12:00:50 UTC (rev 24639)
@@ -43,9 +43,10 @@
}
}
- public JSF2ResourcesFolderProposal(IResource validateResource, String compPath) {
+ public JSF2ResourcesFolderProposal(IResource validateResource, String compPath,String URL) {
super(validateResource);
this.componentPath = compPath;
+ this.URL = URL;
}
public String getDisplayString() {
15 years, 1 month