"Build All artifacts" action added
authornik <Nikolay.Chashnikov@jetbrains.com>
Wed, 9 Dec 2009 12:40:45 +0000 (15:40 +0300)
committernik <Nikolay.Chashnikov@jetbrains.com>
Wed, 9 Dec 2009 13:02:34 +0000 (16:02 +0300)
java/compiler/impl/src/com/intellij/compiler/actions/BuildAllArtifactsAction.java [new file with mode: 0644]
java/compiler/impl/src/com/intellij/compiler/actions/BuildArtifactActionGroup.java
platform/platform-resources-en/src/messages/ActionsBundle.properties
resources/src/idea/IdeaActions.xml

diff --git a/java/compiler/impl/src/com/intellij/compiler/actions/BuildAllArtifactsAction.java b/java/compiler/impl/src/com/intellij/compiler/actions/BuildAllArtifactsAction.java
new file mode 100644 (file)
index 0000000..e21e418
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.compiler.actions;
+
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.compiler.CompilerManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.packaging.artifacts.Artifact;
+import com.intellij.packaging.artifacts.ArtifactManager;
+import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+* @author nik
+*/
+public class BuildAllArtifactsAction extends AnAction {
+  public BuildAllArtifactsAction() {
+    super("Build All Artifacts", "Build all configured artifacts", null);
+  }
+
+  @Override
+  public void update(AnActionEvent e) {
+    e.getPresentation().setEnabled(e.getData(PlatformDataKeys.PROJECT) != null);
+  }
+
+  @Override
+  public void actionPerformed(AnActionEvent e) {
+    final Project project = e.getData(PlatformDataKeys.PROJECT);
+    if (project == null) return;
+
+    List<Artifact> toBuild = new ArrayList<Artifact>();
+    for (Artifact artifact : ArtifactManager.getInstance(project).getSortedArtifacts()) {
+      if (!StringUtil.isEmpty(artifact.getOutputPath())) {
+        toBuild.add(artifact);
+      }
+    }
+    CompilerManager.getInstance(project).make(ArtifactCompileScope.createArtifactsScope(project, toBuild), null);
+  }
+}
index cae981933a703c43063caf92dd6abd9e018b7674..521e1d2dbbaa6f8d1772862d31ebc146cab88365 100644 (file)
  */
 package com.intellij.compiler.actions;
 
-import com.intellij.openapi.actionSystem.ActionGroup;
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.packaging.artifacts.Artifact;
@@ -50,6 +47,11 @@ public class BuildArtifactActionGroup extends ActionGroup {
         actions.add(new BuildArtifactAction(project, artifact));
       }
     }
+    if (actions.size() > 1) {
+      actions.add(0, new BuildAllArtifactsAction());
+      actions.add(1, Separator.getInstance());
+    }
     return actions.toArray(new AnAction[actions.size()]);
   }
+
 }
index f865108d50b614d502e26db8ee31d373ab7a03c9..c7471702fe8a130f36a6a509ff14fa73ec309b07 100644 (file)
@@ -556,9 +556,8 @@ action.RunAPT.text=Process {0} _Annotations
 action.RunAPT.description=Run Annotation Processors on the selected scope
 action.GenerateAntBuild.text=_Generate Ant Build...
 action.GenerateAntBuild.description=Generate Ant Build File from the Project
+action.BuildAllArtifacts.text=Build All Artifacts
 group.BuildArtifactsGroup.text=Build Artifact
-action.BuildJar.text=Build _Jars...
-action.BuildJar.description=Archive module output directories into jar files
 group.RunMenu.text=R_un
 group.RunnerActions.text=Run/Debug
 action.editRunConfigurations.text=Edit Configu_rations
index eb8474183030affdbc3435b581e2ee461f8e7513..25b0ceb6666819c2511648832098f833aa01aeab 100644 (file)
       <add-to-group group-id="RefactoringMenu" anchor="after" relative-to-action="ReplaceMethodWithMethodObject"/>
     </action>
 
+    <action id="BuildAllArtifacts" class="com.intellij.compiler.actions.BuildAllArtifactsAction"/>
+
     <group id="BuildMenu" popup="true">
       <action id="CompileDirty" class="com.intellij.compiler.actions.CompileDirtyAction" icon="/actions/compile.png"/>
       <action id="MakeModule" class="com.intellij.compiler.actions.MakeModuleAction"/>