use of com.intellij.lang.ant.config.AntBuildFile in project intellij-community by JetBrains.
the class AntKeymapExtension method createGroup.
public KeymapGroup createGroup(final Condition<AnAction> filtered, Project project) {
final Map<AntBuildFile, KeymapGroup> buildFileToGroup = new HashMap<>();
final KeymapGroup result = KeymapGroupFactory.getInstance().createGroup(KeyMapBundle.message("ant.targets.group.title"), AllIcons.Nodes.KeymapAnt);
final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
final String[] ids = actionManager.getActionIds(project != null ? AntConfiguration.getActionIdPrefix(project) : AntConfiguration.ACTION_ID_PREFIX);
Arrays.sort(ids);
if (project != null) {
final AntConfiguration antConfiguration = AntConfiguration.getInstance(project);
ApplicationManager.getApplication().runReadAction(() -> {
for (final String id : ids) {
if (filtered != null && !filtered.value(actionManager.getActionOrStub(id))) {
continue;
}
final AntBuildFile buildFile = antConfiguration.findBuildFileByActionId(id);
if (buildFile != null) {
KeymapGroup subGroup = buildFileToGroup.get(buildFile);
if (subGroup == null) {
subGroup = KeymapGroupFactory.getInstance().createGroup(buildFile.getPresentableName());
buildFileToGroup.put(buildFile, subGroup);
result.addGroup(subGroup);
}
subGroup.addActionId(id);
} else {
LOG.info("no buildfile found for actionId=" + id);
}
}
});
}
return result;
}
use of com.intellij.lang.ant.config.AntBuildFile 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.AntBuildFile in project intellij-community by JetBrains.
the class AddAntBuildFile method actionPerformed.
public void actionPerformed(@NotNull AnActionEvent e) {
final Project project = e.getProject();
if (project == null) {
return;
}
final VirtualFile[] contextFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (contextFiles == null || contextFiles.length == 0) {
return;
}
final AntConfiguration antConfiguration = AntConfiguration.getInstance(project);
final Set<VirtualFile> files = new HashSet<>();
files.addAll(Arrays.asList(contextFiles));
for (AntBuildFile buildFile : antConfiguration.getBuildFileList()) {
files.remove(buildFile.getVirtualFile());
}
int filesAdded = 0;
final StringBuilder errors = new StringBuilder();
for (VirtualFile file : files) {
try {
antConfiguration.addBuildFile(file);
filesAdded++;
} catch (AntNoFileException ex) {
String message = ex.getMessage();
if (message == null || message.length() == 0) {
message = AntBundle.message("cannot.add.build.files.from.excluded.directories.error.message", ex.getFile().getPresentableUrl());
}
if (errors.length() > 0) {
errors.append("\n");
}
errors.append(message);
}
}
if (errors.length() > 0) {
Messages.showWarningDialog(project, errors.toString(), AntBundle.message("cannot.add.build.file.dialog.title"));
}
if (filesAdded > 0) {
ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.ANT_BUILD).activate(null);
}
}
use of com.intellij.lang.ant.config.AntBuildFile in project intellij-community by JetBrains.
the class TargetChooserDialog method initTree.
private Tree initTree() {
@NonNls final DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
final Tree tree = new Tree(root);
tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
final TreePath selectionPath = tree.getSelectionPath();
if (selectionPath != null) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
final Object userObject = node.getUserObject();
if (userObject instanceof AntTargetNodeDescriptor) {
final AntTargetNodeDescriptor antBuildTarget = (AntTargetNodeDescriptor) userObject;
mySelectedTarget = antBuildTarget.getAntTarget();
} else {
mySelectedTarget = null;
}
}
}
});
tree.setCellRenderer(new MyTreeCellRenderer());
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
tree.setLineStyleAngled();
TreeUtil.installActions(tree);
new TreeSpeedSearch(tree, new Convertor<TreePath, String>() {
public String convert(final TreePath path) {
final Object userObject = ((DefaultMutableTreeNode) path.getLastPathComponent()).getUserObject();
if (userObject instanceof AntTargetNodeDescriptor) {
final AntBuildTarget target = ((AntTargetNodeDescriptor) userObject).getAntTarget();
return target.getDisplayName();
}
return null;
}
});
DefaultMutableTreeNode selectedNode = null;
final AntConfiguration antConfiguration = AntConfigurationImpl.getInstance(myProject);
for (AntBuildFile buildFile : antConfiguration.getBuildFileList()) {
final DefaultMutableTreeNode buildFileNode = new DefaultMutableTreeNode(buildFile);
DefaultMutableTreeNode selection = processFileTargets(antConfiguration.getMetaTargets(buildFile), buildFile, buildFileNode);
if (selection != null) {
selectedNode = selection;
}
selection = processFileTargets(antConfiguration.getModel(buildFile).getTargets(), buildFile, buildFileNode);
if (selection != null) {
selectedNode = selection;
}
root.add(buildFileNode);
}
TreeUtil.expandAll(tree);
TreeUtil.selectInTree(selectedNode, true, tree);
return tree;
}
use of com.intellij.lang.ant.config.AntBuildFile in project intellij-community by JetBrains.
the class AntArtifactProperties method findTarget.
@Nullable
public AntBuildTarget findTarget(final AntConfiguration antConfiguration) {
String fileUrl = getFileUrl();
String targetName = getTargetName();
if (fileUrl == null || targetName == null)
return null;
for (AntBuildFile buildFile : antConfiguration.getBuildFileList()) {
final VirtualFile file = buildFile.getVirtualFile();
if (file != null && file.getUrl().equals(fileUrl)) {
final AntBuildModel buildModel = buildFile.getModel();
return buildModel != null ? buildModel.findTarget(targetName) : null;
}
}
return null;
}
Aggregations