"Build All artifacts" action added
[fedora-idea.git] / java / compiler / impl / src / com / intellij / compiler / actions / CompileProjectAction.java
blobf5956d391adf2abd94cb012ac8fdbadabe9c4bb3
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.compiler.actions;
18 import com.intellij.history.LocalHistory;
19 import com.intellij.history.LocalHistoryConfiguration;
20 import com.intellij.openapi.actionSystem.AnActionEvent;
21 import com.intellij.openapi.actionSystem.DataContext;
22 import com.intellij.openapi.actionSystem.PlatformDataKeys;
23 import com.intellij.openapi.actionSystem.Presentation;
24 import com.intellij.openapi.compiler.CompileContext;
25 import com.intellij.openapi.compiler.CompileStatusNotification;
26 import com.intellij.openapi.compiler.CompilerBundle;
27 import com.intellij.openapi.compiler.CompilerManager;
28 import com.intellij.openapi.project.Project;
30 public class CompileProjectAction extends CompileActionBase {
31 protected void doAction(DataContext dataContext, final Project project) {
32 CompilerManager.getInstance(project).rebuild(new CompileStatusNotification() {
33 public void finished(boolean aborted, int errors, int warnings, final CompileContext compileContext) {
34 if (!aborted && LocalHistoryConfiguration.getInstance().ADD_LABEL_ON_PROJECT_COMPILATION) {
35 String text = getTemplatePresentation().getText();
36 if (!project.isDisposed()) {
37 LocalHistory.putSystemLabel(project, errors == 0
38 ? CompilerBundle.message("rebuild.lvcs.label.no.errors", text)
39 : CompilerBundle.message("rebuild.lvcs.label.with.errors", text));
43 });
46 public void update(AnActionEvent event) {
47 super.update(event);
48 Presentation presentation = event.getPresentation();
49 if (!presentation.isEnabled()) {
50 return;
52 Project project = PlatformDataKeys.PROJECT.getData(event.getDataContext());
53 presentation.setEnabled(project != null);