use of com.intellij.lang.ant.config.AntBuildFileBase in project intellij-community by JetBrains.
the class AntWorkspaceConfiguration method loadFileProperties.
public void loadFileProperties() throws InvalidDataException {
final Element properties = myProperties.getAndSet(null);
if (properties == null) {
return;
}
for (final AntBuildFile buildFile : AntConfiguration.getInstance(myProject).getBuildFileList()) {
final Element fileElement = findChildByUrl(properties, buildFile.getVirtualFile().getUrl());
if (fileElement == null) {
continue;
}
((AntBuildFileBase) buildFile).readWorkspaceProperties(fileElement);
}
}
use of com.intellij.lang.ant.config.AntBuildFileBase in project intellij-community by JetBrains.
the class RunTargetAction method update.
@Override
public void update(AnActionEvent e) {
super.update(e);
final Presentation presentation = e.getPresentation();
Pair<AntBuildFileBase, AntDomTarget> antTarget = findAntTarget(e);
if (antTarget == null) {
presentation.setEnabled(false);
presentation.setText(AntActionsBundle.message("action.RunTargetAction.text", ""));
} else {
presentation.setEnabled(true);
presentation.setText(AntActionsBundle.message("action.RunTargetAction.text", "'" + antTarget.second.getName().getValue() + "'"));
}
}
use of com.intellij.lang.ant.config.AntBuildFileBase in project intellij-community by JetBrains.
the class RunTargetAction method findAntTarget.
@Nullable
private static Pair<AntBuildFileBase, AntDomTarget> findAntTarget(@NotNull AnActionEvent e) {
final Editor editor = e.getData(CommonDataKeys.EDITOR);
final Project project = e.getProject();
if (project == null || editor == null) {
return null;
}
final VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE);
if (file == null) {
return null;
}
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (!(psiFile instanceof XmlFile)) {
return null;
}
final XmlFile xmlFile = (XmlFile) psiFile;
final AntBuildFileBase antFile = AntConfigurationBase.getInstance(project).getAntBuildFile(xmlFile);
if (antFile == null) {
return null;
}
final PsiElement element = xmlFile.findElementAt(editor.getCaretModel().getOffset());
if (element == null) {
return null;
}
final XmlTag xmlTag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
if (xmlTag == null) {
return null;
}
DomElement dom = AntSupport.getAntDomElement(xmlTag);
while (dom != null && !(dom instanceof AntDomTarget)) {
dom = dom.getParent();
}
final AntDomTarget domTarget = (AntDomTarget) dom;
if (domTarget == null) {
return null;
}
return Pair.create(antFile, domTarget);
}
use of com.intellij.lang.ant.config.AntBuildFileBase in project intellij-community by JetBrains.
the class AntBuildMessageView method buildFinished.
void buildFinished(boolean isProgressAborted, final long buildTimeInMilliseconds, @NotNull final AntBuildListener antBuildListener, OutputPacketProcessor dispatcher) {
final boolean aborted = isProgressAborted || myIsAborted;
dispatcher.processOutput(new Printable() {
@Override
public void printOn(Printer printer) {
if (!myProject.isDisposed()) {
// if not disposed
final String message = getFinishStatusText(aborted, buildTimeInMilliseconds);
addCommand(new FinishBuildCommand(message));
final StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
if (statusBar != null) {
statusBar.setInfo(message);
}
final AntBuildFileBase buildFile = myBuildFile;
final boolean isBackground = buildFile != null && buildFile.isRunInBackground();
final boolean shouldActivate = !isBackground || getErrorCount() > 0;
UIUtil.invokeLaterIfNeeded(() -> {
final Runnable finishRunnable = () -> {
final int errorCount = getErrorCount();
try {
final AntBuildFileBase buildFile1 = myBuildFile;
if (buildFile1 != null) {
if (errorCount == 0 && buildFile1.isViewClosedWhenNoErrors()) {
close();
} else if (errorCount > 0) {
myTreeView.scrollToFirstError();
} else {
myTreeView.scrollToStatus();
}
} else {
myTreeView.scrollToLastMessage();
}
} finally {
VirtualFileManager.getInstance().asyncRefresh(() -> antBuildListener.buildFinished(aborted ? AntBuildListener.ABORTED : AntBuildListener.FINISHED_SUCCESSFULLY, errorCount));
}
};
if (shouldActivate) {
final ToolWindow toolWindow = !myProject.isDisposed() ? ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW) : null;
if (toolWindow != null) {
// can be null if project is closed
toolWindow.activate(finishRunnable, false);
} else {
finishRunnable.run();
}
} else {
finishRunnable.run();
}
});
}
}
});
ApplicationManager.getApplication().invokeLater(() -> flushWhenSmart(false), ModalityState.any(), myProject.getDisposed());
}
use of com.intellij.lang.ant.config.AntBuildFileBase in project intellij-community by JetBrains.
the class AntWorkspaceConfiguration method writeExternal.
public void writeExternal(Element parentNode) throws WriteExternalException {
DefaultJDOMExternalizer.writeExternal(this, parentNode);
for (final AntBuildFile buildFile : AntConfiguration.getInstance(myProject).getBuildFileList()) {
Element element = new Element(BUILD_FILE);
element.setAttribute(URL, buildFile.getVirtualFile().getUrl());
((AntBuildFileBase) buildFile).writeWorkspaceProperties(element);
parentNode.addContent(element);
}
}
Aggregations