001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.bpel.project;
021:
022: import java.io.IOException;
023: import java.util.HashMap;
024: import java.util.Map;
025: import java.util.Properties;
026: import org.apache.tools.ant.module.api.support.ActionUtils;
027: import org.netbeans.spi.project.ActionProvider;
028: import org.netbeans.spi.project.support.ant.AntProjectHelper;
029: import org.openide.filesystems.FileObject;
030: import org.openide.util.Lookup;
031: import org.netbeans.spi.project.support.ant.ReferenceHelper;
032: import org.openide.*;
033:
034: /** Action provider of the Web project. This is the place where to do
035: * strange things to Web actions. E.g. compile-single.
036: */
037: class IcanproActionProvider implements ActionProvider {
038:
039: // Definition of commands
040:
041: // Commands available from Web project
042: private static final String[] supportedActions = { COMMAND_BUILD,
043: COMMAND_CLEAN, COMMAND_REBUILD, COMMAND_COMPILE_SINGLE
044: //IcanproConstants.COMMAND_REDEPLOY,
045: //IcanproConstants.COMMAND_DEPLOY,
046: };
047:
048: // Project
049: IcanproProject project;
050:
051: // Ant project helper of the project
052: private AntProjectHelper antProjectHelper;
053: private ReferenceHelper refHelper;
054:
055: /** Map from commands to ant targets */
056: Map/*<String,String[]>*/commands;
057:
058: public IcanproActionProvider(IcanproProject project,
059: AntProjectHelper antProjectHelper, ReferenceHelper refHelper) {
060: commands = new HashMap();
061: commands.put(COMMAND_BUILD, new String[] { "dist_se" }); // NOI18N
062: commands.put(COMMAND_CLEAN, new String[] { "clean" }); // NOI18N
063: commands.put(COMMAND_REBUILD,
064: new String[] { "clean", "dist_se" }); // NOI18N
065: //commands.put(IcanproConstants.COMMAND_REDEPLOY, new String[] {"run"}); // NOI18N
066: //commands.put(IcanproConstants.COMMAND_DEPLOY, new String[] {"run"}); // NOI18N
067:
068: this .antProjectHelper = antProjectHelper;
069: this .project = project;
070: this .refHelper = refHelper;
071: }
072:
073: private FileObject findBuildXml() {
074: return project.getProjectDirectory().getFileObject(
075: project.getBuildXmlName());
076: }
077:
078: public String[] getSupportedActions() {
079: return supportedActions;
080: }
081:
082: public void invokeAction(String command, Lookup context)
083: throws IllegalArgumentException {
084: Properties p = null;
085: String[] targetNames = (String[]) commands.get(command);
086: if (command.equals(IcanproConstants.POPULATE_CATALOG)) {
087: BpelProjectRetriever bpRetriever = new BpelProjectRetriever(
088: antProjectHelper.getProjectDirectory());
089: }
090: //EXECUTION PART
091: //// if (command.equals (IcanproConstants.COMMAND_DEPLOY) || command.equals (IcanproConstants.COMMAND_REDEPLOY)) {
092: //// if (!isSelectedServer ()) {
093: //// return;
094: //// }
095: //// } else {
096: //// p = null;
097: //// if (targetNames == null) {
098: //// throw new IllegalArgumentException(command);
099: //// }
100: //// }
101:
102: try {
103: ActionUtils.runTarget(findBuildXml(), targetNames, p);
104: } catch (IOException e) {
105: ErrorManager.getDefault().notify(e);
106: }
107: }
108:
109: public boolean isActionEnabled(String command, Lookup context) {
110:
111: if (findBuildXml() == null) {
112: return false;
113: }
114: return true;
115:
116: }
117:
118: // Private methods -----------------------------------------------------
119:
120: private boolean isDebugged() {
121: return false;
122: }
123: }
|