Author: rob.stryker(a)jboss.com
Date: 2012-08-08 06:54:55 -0400 (Wed, 08 Aug 2012)
New Revision: 42913
Modified:
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ProjectUtils.java
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.java
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.properties
Log:
JBIDE-11927 to maintenance
Modified:
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ProjectUtils.java
===================================================================
---
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ProjectUtils.java 2012-08-08
10:51:05 UTC (rev 42912)
+++
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ProjectUtils.java 2012-08-08
10:54:55 UTC (rev 42913)
@@ -10,47 +10,111 @@
******************************************************************************/
package org.jboss.ide.eclipse.archives.core.project;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
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.NullProgressMonitor;
public class ProjectUtils {
-
+
public static boolean addProjectNature(IPath path) {
- IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for( int i = 0; i < allProjects.length; i++ ) {
- if( allProjects[i].getLocation().equals(path)) {
- return addProjectNature(allProjects[i], ArchivesNature.NATURE_ID);
+ IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot()
+ .getProjects();
+ for (int i = 0; i < allProjects.length; i++) {
+ if (allProjects[i].getLocation().equals(path)) {
+ return addProjectNature(allProjects[i],
+ ArchivesNature.NATURE_ID);
}
}
return false;
}
- public static boolean addProjectNature(IProject project, String natureId) {
- boolean added = false;
- try {
- if (project != null && natureId != null) {
- IProjectDescription desc = project.getDescription();
-
- if (!project.hasNature(natureId)) {
- String natureIds[] = desc.getNatureIds();
- String newNatureIds[] = new String[natureIds.length + 1];
-
- System.arraycopy(natureIds, 0, newNatureIds, 1, natureIds.length);
- newNatureIds[0] = natureId;
- desc.setNatureIds(newNatureIds);
-
- project.getProject().setDescription(desc, new NullProgressMonitor());
- added = true;
- }
- }
- } catch (CoreException e) {
- e.printStackTrace();
- }
- return added;
- }
+ public static boolean addProjectNature(IProject project, String natureId) {
+ return addProjectNature(project, natureId, null);
+ }
+
+ /**
+ * @since 3.3
+ */
+ public static boolean addProjectNature(IProject project, String natureId,
IProgressMonitor monitor) {
+ monitor = monitor == null ? new NullProgressMonitor() : monitor;
+ boolean added = false;
+ try {
+ if (project != null && natureId != null) {
+ IProjectDescription desc = project.getDescription();
+ if (!project.hasNature(natureId)) {
+ String natureIds[] = desc.getNatureIds();
+ String newNatureIds[] = new String[natureIds.length + 1];
+
+ System.arraycopy(natureIds, 0, newNatureIds, 1,
+ natureIds.length);
+ newNatureIds[0] = natureId;
+ desc.setNatureIds(newNatureIds);
+
+ project.getProject().setDescription(desc, monitor);
+ added = true;
+ }
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return added;
+ }
+
+ /**
+ * @since 3.3
+ */
+ public static boolean removeProjectNature(IPath path) {
+ IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot()
+ .getProjects();
+ for (int i = 0; i < allProjects.length; i++) {
+ if (allProjects[i].getLocation().equals(path)) {
+ return removeProjectNature(allProjects[i],
+ ArchivesNature.NATURE_ID);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @since 3.3
+ */
+ public static boolean removeProjectNature(IProject project, String natureId) {
+ return removeProjectNature(project, natureId, null);
+ }
+ /**
+ * @since 3.3
+ */
+ public static boolean removeProjectNature(IProject project, String natureId,
IProgressMonitor monitor) {
+ monitor = monitor == null ? new NullProgressMonitor() : monitor;
+ boolean removed = false;
+ try {
+ if (project != null && natureId != null) {
+ IProjectDescription desc = project.getDescription();
+ if (project.hasNature(natureId)) {
+ String natureIds[] = desc.getNatureIds();
+ List<String> l = Arrays.asList(natureIds);
+ ArrayList<String> newDesc = new ArrayList<String>();
+ newDesc.addAll(l);
+ newDesc.remove(natureId);
+ String[] asArr = (String[]) newDesc.toArray(new String[newDesc.size()]);
+ desc.setNatureIds(asArr);
+ project.getProject().setDescription(desc, monitor);
+ removed = true;
+ }
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return removed;
+ }
+
}
Modified:
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml
===================================================================
---
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml 2012-08-08
10:51:05 UTC (rev 42912)
+++
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml 2012-08-08
10:54:55 UTC (rev 42913)
@@ -245,4 +245,64 @@
sequence="M3+M2+Y B">
</key>
</extension>
+
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+
defaultHandler="org.jboss.ide.eclipse.archives.ui.actions.EnableHandler"
+
id="org.jboss.ide.eclipse.archives.ui.actions.enableProjectArchives"
+ name="Add Project Archives Support">
+ </command>
+ <command
+
defaultHandler="org.jboss.ide.eclipse.archives.ui.actions.DisableHandler"
+
id="org.jboss.ide.eclipse.archives.ui.actions.disableProjectArchives"
+ name="Remove Project Archives Support">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+
locationURI="popup:org.eclipse.ui.projectConfigure?before=additions">
+ <command
+
commandId="org.jboss.ide.eclipse.archives.ui.actions.enableProjectArchives"
+ label="Add Project Archives Support"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <and>
+ <count value="1"/>
+ <with variable="activeMenuSelection"/>
+ <iterate ifEmpty="false" operator="and">
+ <adapt type="org.eclipse.core.resources.IResource"/>
+ <not><test
+ forcePluginActivation="false"
+
property="org.eclipse.core.resources.projectNature"
+
value="org.jboss.ide.eclipse.archives.core.archivesNature">
+ </test> </not>
+ </iterate></and>
+ </visibleWhen>
+ </command>
+
+ <command
+
commandId="org.jboss.ide.eclipse.archives.ui.actions.disableProjectArchives"
+ label="Remove Project Archives Support"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <and>
+ <count value="1"/>
+ <with variable="activeMenuSelection"/>
+ <iterate ifEmpty="false" operator="and">
+ <adapt type="org.eclipse.core.resources.IResource"/>
+ <test
+ forcePluginActivation="false"
+
property="org.eclipse.core.resources.projectNature"
+
value="org.jboss.ide.eclipse.archives.core.archivesNature">
+ </test>
+ </iterate></and>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
</plugin>
Modified:
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.java
===================================================================
---
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.java 2012-08-08
10:51:05 UTC (rev 42912)
+++
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.java 2012-08-08
10:54:55 UTC (rev 42913)
@@ -115,6 +115,9 @@
public static String deleteNodeMBDesc;
public static String deleteNodeMBToggle;
+ public static String EnableProjectArchivesJob;
+ public static String DisableProjectArchivesJob;
+ public static String DisableProjectArchivesJobError;
static {
NLS.initializeMessages("org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages",
ArchivesUIMessages.class); //$NON-NLS-1$
Modified:
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.properties
===================================================================
---
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.properties 2012-08-08
10:51:05 UTC (rev 42912)
+++
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.properties 2012-08-08
10:54:55 UTC (rev 42913)
@@ -97,3 +97,6 @@
deleteNodeMBTitle=Delete this node?
deleteNodeMBDesc=Are you sure you want to delete this node? This cannot be undone.
deleteNodeMBToggle=Always delete without prompting.
+EnableProjectArchivesJob=Enabling Project Archives on project {0}
+DisableProjectArchivesJob=Disabling Project Archives on project {0}
+DisableProjectArchivesJobError=Unable to completely remove Project Archives support on
project {0}
\ No newline at end of file
Show replies by date