Author: scabanovich
Date: 2009-05-14 11:50:04 -0400 (Thu, 14 May 2009)
New Revision: 15254
Added:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/IKbProject.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-2808
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/plugin.xml 2009-05-14 15:20:00 UTC (rev
15253)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/plugin.xml 2009-05-14 15:50:04 UTC (rev
15254)
@@ -272,4 +272,29 @@
</extension>
+ <extension
+ id="kbbuilder"
+ name="KB Builder"
+ point="org.eclipse.core.resources.builders">
+ <builder
+ hasNature="false">
+ <run
+ class="org.jboss.tools.jst.web.kb.internal.KbBuilder">
+ </run>
+ </builder>
+ </extension>
+ <extension
+ id="kbnature"
+ name="KB Project Nature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.jboss.tools.jst.web.kb.internal.KbProject">
+ </run>
+ </runtime>
+ <builder
+ id="org.jboss.tools.jst.web.kbbuilder">
+ </builder>
+ </extension>
+
</plugin>
Added:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/IKbProject.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/IKbProject.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/IKbProject.java 2009-05-14
15:50:04 UTC (rev 15254)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb;
+
+import org.eclipse.core.resources.IProjectNature;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+
+/**
+ *
+ * @author V.Kabanovich
+ *
+ */
+public interface IKbProject extends IProjectNature {
+ public static String NATURE_ID = "org.jboss.tools.jst.web.kbnature";
//$NON-NLS-1$
+
+ public ITagLibrary[] getTagLibraries();
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/IKbProject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java 2009-05-14
15:50:04 UTC (rev 15254)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ *
+ * @author V.Kabanovich
+ *
+ */
+public class KbBuilder extends IncrementalProjectBuilder {
+ public static String BUILDER_ID = "org.jboss.tools.jst.web.kbbuilder";
//$NON-NLS-1$
+
+ protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
+ throws CoreException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2009-05-14
15:50:04 UTC (rev 15254)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+
+/**
+ *
+ * @author V.Kabanovich
+ *
+ */
+public class KbProject implements IKbProject {
+ IProject project;
+
+ ITagLibrary[] tagLibraries = new ITagLibrary[0];
+
+ public ITagLibrary[] getTagLibraries() {
+ return tagLibraries;
+ }
+
+ public void configure() throws CoreException {
+ addToBuildSpec(KbBuilder.BUILDER_ID);
+ }
+
+ public void deconfigure() throws CoreException {
+ removeFromBuildSpec(KbBuilder.BUILDER_ID);
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ /**
+ *
+ * @param builderID
+ * @throws CoreException
+ */
+ protected void addToBuildSpec(String builderID) throws CoreException {
+ IProjectDescription description = getProject().getDescription();
+ ICommand command = null;
+ ICommand commands[] = description.getBuildSpec();
+ for (int i = 0; i < commands.length && command == null; ++i) {
+ if (commands[i].getBuilderName().equals(builderID))
+ command = commands[i];
+ }
+ if (command == null) {
+ command = description.newCommand();
+ command.setBuilderName(builderID);
+ ICommand[] oldCommands = description.getBuildSpec();
+ ICommand[] newCommands = new ICommand[oldCommands.length + 1];
+ System.arraycopy(oldCommands, 0, newCommands, 0, oldCommands.length);
+ newCommands[oldCommands.length] = command;
+ description.setBuildSpec(newCommands);
+ getProject().setDescription(description, null);
+ }
+ }
+
+ static String EXTERNAL_TOOL_BUILDER =
"org.eclipse.ui.externaltools.ExternalToolBuilder";
+ static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle";
+
+ /**
+ *
+ * @param builderID
+ * @throws CoreException
+ */
+ protected void removeFromBuildSpec(String builderID) throws CoreException {
+ IProjectDescription description = getProject().getDescription();
+ ICommand[] commands = description.getBuildSpec();
+ for (int i = 0; i < commands.length; ++i) {
+ String builderName = commands[i].getBuilderName();
+ if (!builderName.equals(builderID)) {
+ if(!builderName.equals(EXTERNAL_TOOL_BUILDER)) continue;
+ Object handle = commands[i].getArguments().get(LAUNCH_CONFIG_HANDLE);
+ if(handle == null || handle.toString().indexOf(builderID) < 0) continue;
+ }
+ ICommand[] newCommands = new ICommand[commands.length - 1];
+ System.arraycopy(commands, 0, newCommands, 0, i);
+ System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
+ description.setBuildSpec(newCommands);
+ getProject().setDescription(description, null);
+ return;
+ }
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain