Author: akazakov
Date: 2010-12-08 08:43:12 -0500 (Wed, 08 Dec 2010)
New Revision: 27229
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/facet/
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/facet/CDIInstallWizardPage.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/preferences/
Removed:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/references/
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF
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/preferences/CDISettingsPreferencePage.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/preferences/CDIPreferencePageTest.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
Log:
https://jira.jboss.org/browse/JBIDE-7803
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF 2010-12-08 12:56:33 UTC
(rev 27228)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF 2010-12-08 13:43:12 UTC
(rev 27229)
@@ -18,17 +18,18 @@
org.eclipse.jface.text,
org.eclipse.wst.sse.ui,
org.jboss.tools.jst.web.kb,
- org.eclipse.jdt.core;bundle-version="3.5.0",
- org.eclipse.search;bundle-version="3.5.0",
- org.eclipse.wst.sse.core;bundle-version="1.1.400",
- org.eclipse.ltk.ui.refactoring;bundle-version="3.4.100",
- org.eclipse.ui.ide;bundle-version="3.5.0",
- org.jboss.tools.common.model;bundle-version="2.0.0",
- org.jboss.tools.common.model.ui;bundle-version="2.0.0",
- org.jboss.tools.jst.web.ui;bundle-version="2.0.0",
- org.eclipse.core.expressions;bundle-version="3.4.100",
- org.eclipse.ltk.core.refactoring;bundle-version="3.5.0",
- org.jboss.tools.jst.jsp;bundle-version="3.2.0"
+ org.eclipse.jdt.core,
+ org.eclipse.search,
+ org.eclipse.wst.sse.core,
+ org.eclipse.ltk.ui.refactoring,
+ org.eclipse.ui.ide,
+ org.jboss.tools.common.model,
+ org.jboss.tools.common.model.ui,
+ org.jboss.tools.jst.web.ui,
+ org.eclipse.core.expressions,
+ org.eclipse.ltk.core.refactoring,
+ org.jboss.tools.jst.jsp,
+ org.eclipse.wst.common.project.facet.ui
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %Bundle-Vendor.0
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml 2010-12-08 12:56:33 UTC (rev
27228)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml 2010-12-08 13:43:12 UTC (rev
27229)
@@ -231,6 +231,13 @@
</extension>
+ <extension
+ point="org.eclipse.wst.common.project.facet.ui.wizardPages">
+ <wizard-pages action="jst.cdi.1.0.install">
+ <page
class="org.jboss.tools.cdi.ui.wizard.facet.CDIInstallWizardPage"/>
+ </wizard-pages>
+ </extension>
+
<extension
point="org.eclipse.wst.sse.ui.completionProposal">
<proposalCategory
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-12-08
12:56:33 UTC (rev 27228)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2010-12-08
13:43:12 UTC (rev 27229)
@@ -62,5 +62,8 @@
public static String MESSAGE_INTERCEPTOR_BINDINGS_EMPTY;
public static String MAKE_FIELD_STATIC_MARKER_RESOLUTION_TITLE;
-
-}
+
+ public static String CDI_GENERATE_BEANS_XML;
+ public static String CDI_INSTALL_WIZARD_PAGE_FACET;
+ public static String CDI_INSTALL_WIZARD_PAGE_CONFIGURE;
+}
\ No newline at end of file
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-12-08
12:56:33 UTC (rev 27228)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2010-12-08
13:43:12 UTC (rev 27229)
@@ -51,3 +51,7 @@
MESSAGE_INTERCEPTOR_BINDINGS_EMPTY=Interceptor Bindings list is empty
MAKE_FIELD_STATIC_MARKER_RESOLUTION_TITLE=Make ''{0}'' field static
+
+CDI_GENERATE_BEANS_XML=Generate beans.xml file:
+CDI_INSTALL_WIZARD_PAGE_FACET=Context and Dependency Injection (CDI) Facet
+CDI_INSTALL_WIZARD_PAGE_CONFIGURE=Configure Context and Dependency Injection (CDI) Facet
Settings
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDISettingsPreferencePage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDISettingsPreferencePage.java 2010-12-08
12:56:33 UTC (rev 27228)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDISettingsPreferencePage.java 2010-12-08
13:43:12 UTC (rev 27229)
@@ -15,6 +15,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -22,6 +23,7 @@
import org.eclipse.swt.widgets.Control;
import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.CDIUtil;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.common.ui.preferences.SettingsPage;
import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
import org.jboss.tools.common.ui.widget.editor.IFieldEditorFactory;
@@ -35,6 +37,8 @@
private IProject project;
private boolean cdiEnabled;
+ private boolean initialState;
+ private boolean generateBeansXml;
/*
* (non-Javadoc)
@@ -69,8 +73,9 @@
generalGroup.setLayout(gridLayout);
+ initialState = isCDIEnabled(project);
IFieldEditor cdiSupportCheckBox = IFieldEditorFactory.INSTANCE.createCheckboxEditor(
- CDIPreferencesMessages.CDI_SETTINGS_PREFERENCE_PAGE_CDI_SUPPORT,
CDIPreferencesMessages.CDI_SETTINGS_PREFERENCE_PAGE_CDI_SUPPORT, isCDIEnabled(project));
+ CDIPreferencesMessages.CDI_SETTINGS_PREFERENCE_PAGE_CDI_SUPPORT,
CDIPreferencesMessages.CDI_SETTINGS_PREFERENCE_PAGE_CDI_SUPPORT, initialState);
cdiSupportCheckBox.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
Object value = evt.getNewValue();
@@ -83,11 +88,32 @@
cdiEnabled = isCDIEnabled(project);
registerEditor(cdiSupportCheckBox, generalGroup);
+ generateBeansXml = false;
+
+// IFieldEditor generateBeansXmlCheckBox =
IFieldEditorFactory.INSTANCE.createCheckboxEditor(
+// CDIUIMessages.CDI_GENERATE_BEANS_XML, CDIUIMessages.CDI_GENERATE_BEANS_XML,
generateBeansXml);
+// generateBeansXmlCheckBox.addPropertyChangeListener(new PropertyChangeListener() {
+// public void propertyChange(PropertyChangeEvent evt) {
+// Object value = evt.getNewValue();
+// if (value instanceof Boolean) {
+// boolean v = ((Boolean) value).booleanValue();
+// generateBeansXml = v;
+// }
+// }
+// });
+
+// registerEditor(generateBeansXmlCheckBox, generalGroup);
+
validate();
+ checkGenerateBeansXml();
return root;
}
+ private void checkGenerateBeansXml() {
+// getEditor(CDIUIMessages.CDI_GENERATE_BEANS_XML).setEnabled(!initialState &&
cdiEnabled);
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
@@ -95,6 +121,7 @@
@Override
protected void performDefaults() {
getEditor(CDIPreferencesMessages.CDI_SETTINGS_PREFERENCE_PAGE_CDI_SUPPORT).setValue(isCDIEnabled(project));
+ getEditor(CDIUIMessages.CDI_GENERATE_BEANS_XML).setValue(true);
validate();
}
@@ -104,10 +131,12 @@
*/
@Override
public boolean performOk() {
- if(isCDIEnabled()) {
- addCDISupport(project);
- } else {
- removeCDISupport(project);
+ if(isCDIEnabled()!=initialState) {
+ if(isCDIEnabled()) {
+ addCDISupport(project);
+ } else {
+ removeCDISupport(project);
+ }
}
return true;
}
@@ -116,7 +145,7 @@
if(project==null) {
return;
}
- CDIUtil.enableCDI(project);
+ CDIUtil.enableCDI(project, generateBeansXml, new NullProgressMonitor());
}
private void removeCDISupport(IProject project) {
@@ -134,6 +163,7 @@
public void setEnabledCDISuport(boolean enabled) {
cdiEnabled = enabled;
editorRegistry.get(CDIPreferencesMessages.CDI_SETTINGS_PREFERENCE_PAGE_CDI_SUPPORT).setValue(enabled);
+ checkGenerateBeansXml();
}
/*
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/facet/CDIInstallWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/facet/CDIInstallWizardPage.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/facet/CDIInstallWizardPage.java 2010-12-08
13:43:12 UTC (rev 27229)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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.facet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener;
+import org.eclipse.wst.common.project.facet.ui.AbstractFacetWizardPage;
+import org.eclipse.wst.common.project.facet.ui.IFacetWizardPage;
+import org.jboss.tools.cdi.internal.core.project.facet.ICDIFacetDataModelProperties;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.cdi.ui.CDIUiImages;
+import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
+import org.jboss.tools.common.ui.widget.editor.IFieldEditorFactory;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class CDIInstallWizardPage extends AbstractFacetWizardPage implements
IFacetWizardPage, IDataModelListener {
+
+ private boolean generateBeansXml;
+ private IDataModel model = null;
+
+ protected Map<String,IFieldEditor> editorRegistry = new
HashMap<String,IFieldEditor>();
+
+ public CDIInstallWizardPage() {
+ super(CDIUIMessages.CDI_INSTALL_WIZARD_PAGE_FACET);
+ setTitle(CDIUIMessages.CDI_INSTALL_WIZARD_PAGE_FACET);
+ setImageDescriptor(CDIUiImages.getImageDescriptor(CDIUiImages.WELD_WIZARD_IMAGE_PATH));
+ setDescription(CDIUIMessages.CDI_INSTALL_WIZARD_PAGE_CONFIGURE);
+ }
+
+ public void propertyChanged(DataModelEvent event) {
+ }
+
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Composite root = new Composite(parent, SWT.NONE);
+
+ GridData gd = new GridData();
+
+ gd.horizontalSpan = 1;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = false;
+
+ GridLayout gridLayout = new GridLayout(1, false);
+ root.setLayout(gridLayout);
+
+ Composite generalGroup = new Composite(root, SWT.NONE);
+ generalGroup.setLayoutData(gd);
+ gridLayout = new GridLayout(4, false);
+
+ generalGroup.setLayout(gridLayout);
+
+ generateBeansXml = true;
+
+ IFieldEditor generateBeansXmlCheckBox =
IFieldEditorFactory.INSTANCE.createCheckboxEditor(
+ CDIUIMessages.CDI_GENERATE_BEANS_XML, CDIUIMessages.CDI_GENERATE_BEANS_XML,
generateBeansXml);
+ generateBeansXmlCheckBox.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ Object value = evt.getNewValue();
+ if (value instanceof Boolean) {
+ boolean v = ((Boolean) value).booleanValue();
+ setGenerateBeansXml(v);
+ }
+ }
+ });
+ editorRegistry.put(generateBeansXmlCheckBox.getName(), generateBeansXmlCheckBox);
+ generateBeansXmlCheckBox.doFillIntoGrid(generalGroup);
+
+ setControl(root);
+ }
+
+ public void setGenerateBeansXml(boolean generate) {
+ generateBeansXml = generate;
+ model.setProperty(ICDIFacetDataModelProperties.GENERATE_BEANS_XML, generateBeansXml);
+ }
+
+ public void setConfig(Object config) {
+ model = (IDataModel) config;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/facet/CDIInstallWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2010-12-08
12:56:33 UTC (rev 27228)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2010-12-08
13:43:12 UTC (rev 27229)
@@ -12,7 +12,7 @@
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.jboss.tools.cdi.ui.test.marker.CDIMarkerResolutionTest;
-import org.jboss.tools.cdi.ui.test.references.CDIPreferencePageTest;
+import org.jboss.tools.cdi.ui.test.preferences.CDIPreferencePageTest;
import org.jboss.tools.cdi.ui.test.wizard.NewCDIWizardTest;
import junit.framework.Test;
Copied:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/preferences
(from rev 27220,
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/references)
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/preferences/CDIPreferencePageTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/references/CDIPreferencePageTest.java 2010-12-08
08:57:20 UTC (rev 27220)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/preferences/CDIPreferencePageTest.java 2010-12-08
13:43:12 UTC (rev 27229)
@@ -1,4 +1,4 @@
-package org.jboss.tools.cdi.ui.test.references;
+package org.jboss.tools.cdi.ui.test.preferences;
import junit.framework.TestCase;
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2010-12-08
12:56:33 UTC (rev 27228)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2010-12-08
13:43:12 UTC (rev 27229)
@@ -23,6 +23,7 @@
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.IProject;
import org.eclipse.core.resources.IResource;
@@ -38,6 +39,7 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModelMarker;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
@@ -58,7 +60,6 @@
import org.jboss.tools.common.model.filesystems.XFileObject;
import org.jboss.tools.common.model.filesystems.impl.FileSystemImpl;
import org.jboss.tools.common.model.filesystems.impl.FileSystemsImpl;
-import org.jboss.tools.common.model.filesystems.impl.FileSystemsLoader;
import org.jboss.tools.common.model.filesystems.impl.JarSystemImpl;
import org.jboss.tools.common.model.icons.impl.XModelObjectIcon;
import org.jboss.tools.common.model.impl.XModelObjectImpl;
@@ -835,6 +836,29 @@
return null;
}
+ public static Set<IFolder> getSourceFolders(IProject project) {
+ Set<IFolder> folders = new HashSet<IFolder>();
+ IPackageFragmentRoot[] roots;
+ try {
+ // From source folders
+ IJavaProject javaProject = EclipseUtil.getJavaProject(project);
+ if(javaProject!=null) {
+ roots = javaProject.getPackageFragmentRoots();
+ for (int i = 0; i < roots.length; i++) {
+ if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE) {
+ IResource source = roots[i].getCorrespondingResource();
+ if(source instanceof IFolder) {
+ folders.add((IFolder)source);
+ }
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ ModelPlugin.getDefault().logError(e);
+ }
+ return folders;
+ }
+
public static void openResource(IResource resource) {
XModelObject o = getObjectByResource(resource);
if(o == null) o = createObjectForResource(resource);