Search in sources :

Example 1 with AntBuildFileBase

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);
    }
}
Also used : AntBuildFile(com.intellij.lang.ant.config.AntBuildFile) AntBuildFileBase(com.intellij.lang.ant.config.AntBuildFileBase) Element(org.jdom.Element)

Example 2 with AntBuildFileBase

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() + "'"));
    }
}
Also used : AntBuildFileBase(com.intellij.lang.ant.config.AntBuildFileBase) Presentation(com.intellij.openapi.actionSystem.Presentation) AntDomTarget(com.intellij.lang.ant.dom.AntDomTarget)

Example 3 with AntBuildFileBase

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) AntBuildFileBase(com.intellij.lang.ant.config.AntBuildFileBase) DomElement(com.intellij.util.xml.DomElement) XmlFile(com.intellij.psi.xml.XmlFile) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor) AntDomTarget(com.intellij.lang.ant.dom.AntDomTarget) PsiElement(com.intellij.psi.PsiElement) XmlTag(com.intellij.psi.xml.XmlTag) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with AntBuildFileBase

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());
}
Also used : AntBuildFileBase(com.intellij.lang.ant.config.AntBuildFileBase) Printable(com.intellij.execution.testframework.Printable) Printer(com.intellij.execution.testframework.Printer)

Example 5 with AntBuildFileBase

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);
    }
}
Also used : AntBuildFile(com.intellij.lang.ant.config.AntBuildFile) AntBuildFileBase(com.intellij.lang.ant.config.AntBuildFileBase) Element(org.jdom.Element)

Aggregations

AntBuildFileBase (com.intellij.lang.ant.config.AntBuildFileBase)5 AntBuildFile (com.intellij.lang.ant.config.AntBuildFile)2 AntDomTarget (com.intellij.lang.ant.dom.AntDomTarget)2 Element (org.jdom.Element)2 Printable (com.intellij.execution.testframework.Printable)1 Printer (com.intellij.execution.testframework.Printer)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 XmlFile (com.intellij.psi.xml.XmlFile)1 XmlTag (com.intellij.psi.xml.XmlTag)1 DomElement (com.intellij.util.xml.DomElement)1 Nullable (org.jetbrains.annotations.Nullable)1