Search in sources :

Example 1 with ExecuteCompositeTargetEvent

use of com.intellij.lang.ant.config.impl.ExecuteCompositeTargetEvent in project intellij-community by JetBrains.

the class AntTargetNodeDescriptor method update.

public boolean update() {
    final CompositeAppearance oldText = myHighlightedText;
    final boolean isMeta = myTarget instanceof MetaTarget;
    setIcon(isMeta ? AntIcons.MetaTarget : AntIcons.Target);
    myHighlightedText = new CompositeAppearance();
    final AntBuildFile buildFile = isMeta ? ((MetaTarget) myTarget).getBuildFile() : myTarget.getModel().getBuildFile();
    final Color color = buildFile.isTargetVisible(myTarget) ? UIUtil.getLabelForeground() : UIUtil.getLabelDisabledForeground();
    TextAttributes nameAttributes = new TextAttributes(color, null, null, EffectType.BOXED, myTarget.isDefault() ? Font.BOLD : Font.PLAIN);
    myHighlightedText.getEnding().addText(myTarget.getDisplayName(), nameAttributes);
    AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(myProject);
    final ArrayList<String> addedNames = new ArrayList<>(4);
    for (final ExecutionEvent event : antConfiguration.getEventsForTarget(myTarget)) {
        final String presentableName;
        if ((event instanceof ExecuteCompositeTargetEvent)) {
            presentableName = ((ExecuteCompositeTargetEvent) event).getMetaTargetName();
            if (presentableName.equals(myTarget.getName())) {
                continue;
            }
        } else {
            presentableName = event.getPresentableName();
        }
        if (!addedNames.contains(presentableName)) {
            addedNames.add(presentableName);
            myHighlightedText.getEnding().addText(" (" + presentableName + ')', ourPostfixAttributes);
        }
    }
    final RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
    final VirtualFile vFile = buildFile.getVirtualFile();
    if (vFile != null) {
        for (AntBeforeRunTask task : runManager.getBeforeRunTasks(AntBeforeRunTaskProvider.ID)) {
            if (task.isRunningTarget(myTarget)) {
                myHighlightedText.getEnding().addText(" (Before Run/Debug)", ourPostfixAttributes);
                break;
            }
        }
    }
    myName = myHighlightedText.getText();
    final AntBuildTargetBase target = getTarget();
    if (!addShortcutText(target.getActionId())) {
        if (target.isDefault()) {
            addShortcutText(((AntBuildModelBase) target.getModel()).getDefaultTargetActionId());
        }
    }
    return !Comparing.equal(myHighlightedText, oldText);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RunManagerEx(com.intellij.execution.RunManagerEx) JBColor(com.intellij.ui.JBColor) MetaTarget(com.intellij.lang.ant.config.impl.MetaTarget) ArrayList(java.util.ArrayList) CompositeAppearance(com.intellij.openapi.roots.ui.util.CompositeAppearance) ExecuteCompositeTargetEvent(com.intellij.lang.ant.config.impl.ExecuteCompositeTargetEvent) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) AntBeforeRunTask(com.intellij.lang.ant.config.impl.AntBeforeRunTask)

Example 2 with ExecuteCompositeTargetEvent

use of com.intellij.lang.ant.config.impl.ExecuteCompositeTargetEvent in project intellij-community by JetBrains.

the class SaveMetaTargetDialog method doOKAction.

protected void doOKAction() {
    final ExecuteCompositeTargetEvent eventObject = createEventObject();
    if (myAntConfiguration.getTargetForEvent(eventObject) == null) {
        myAntConfiguration.setTargetForEvent(myBuildFile, eventObject.getMetaTargetName(), eventObject);
        super.doOKAction();
    } else {
        Messages.showInfoMessage(getContentPane(), AntBundle.message("save.meta.data.such.sequence.of.targets.already.exists.error.message"), getTitle());
    }
}
Also used : ExecuteCompositeTargetEvent(com.intellij.lang.ant.config.impl.ExecuteCompositeTargetEvent)

Example 3 with ExecuteCompositeTargetEvent

use of com.intellij.lang.ant.config.impl.ExecuteCompositeTargetEvent in project intellij-community by JetBrains.

the class SaveMetaTargetDialog method createEventObject.

private ExecuteCompositeTargetEvent createEventObject() {
    final ListModel model = myTargetList.getModel();
    final int size = model.getSize();
    final String[] names = ArrayUtil.newStringArray(size);
    for (int idx = 0; idx < size; idx++) {
        names[idx] = (String) model.getElementAt(idx);
    }
    final ExecuteCompositeTargetEvent event = new ExecuteCompositeTargetEvent(names);
    event.setPresentableName(myTfName.getText().trim());
    return event;
}
Also used : ExecuteCompositeTargetEvent(com.intellij.lang.ant.config.impl.ExecuteCompositeTargetEvent)

Aggregations

ExecuteCompositeTargetEvent (com.intellij.lang.ant.config.impl.ExecuteCompositeTargetEvent)3 RunManagerEx (com.intellij.execution.RunManagerEx)1 AntBeforeRunTask (com.intellij.lang.ant.config.impl.AntBeforeRunTask)1 MetaTarget (com.intellij.lang.ant.config.impl.MetaTarget)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 CompositeAppearance (com.intellij.openapi.roots.ui.util.CompositeAppearance)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 JBColor (com.intellij.ui.JBColor)1 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)1 ArrayList (java.util.ArrayList)1