protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) { if (element instanceof AntDomProperty) { final AntDomProperty property = (AntDomProperty)element; final GenericAttributeValue<PsiFileSystemItem> fileValue = property.getFile(); final String fileName = fileValue.getStringValue(); if (fileName != null) { final PropertiesFile propertiesFile = property.getPropertiesFile(); if (propertiesFile == null) { final PsiFileSystemItem file = fileValue.getValue(); if (file instanceof XmlFile) { holder.createProblem(fileValue, AntBundle.message("file.type.xml.not.supported", fileName)); } else if (file instanceof PsiFile) { holder.createProblem(fileValue, AntBundle.message("file.type.not.supported", fileName)); } else { holder.createProblem(fileValue, AntBundle.message("file.doesnt.exist", fileName)); } } } } }
private JPanel createToolbarPanel() { final DefaultActionGroup group = new DefaultActionGroup(); group.add(new AddAction()); group.add(new RemoveAction()); group.add(new RunAction()); group.add(new ShowAllTargetsAction()); AnAction action = CommonActionsManager.getInstance().createExpandAllAction(myTreeExpander, this); action.getTemplatePresentation().setDescription(AntBundle.message("ant.explorer.expand.all.nodes.action.description")); group.add(action); action = CommonActionsManager.getInstance().createCollapseAllAction(myTreeExpander, this); action.getTemplatePresentation().setDescription(AntBundle.message("ant.explorer.collapse.all.nodes.action.description")); group.add(action); group.add(myAntBuildFilePropertiesAction); group.add(new ContextHelpAction(HelpID.ANT)); final ActionToolbar actionToolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.ANT_EXPLORER_TOOLBAR, group, true); return JBUI.Panels.simplePanel(actionToolBar.getComponent()); }
public void update(AnActionEvent event) { final Presentation presentation = event.getPresentation(); final String place = event.getPlace(); if (ActionPlaces.ANT_EXPLORER_TOOLBAR.equals(place)) { presentation.setText(AntBundle.message("run.ant.file.or.target.action.name")); } else { final TreePath[] paths = myTree.getSelectionPaths(); if (paths != null && paths.length == 1 && ((DefaultMutableTreeNode)paths[0].getLastPathComponent()).getUserObject() instanceof AntBuildFileNodeDescriptor) { presentation.setText(AntBundle.message("run.ant.build.action.name")); } else { if (paths == null || paths.length == 1) { presentation.setText(AntBundle.message("run.ant.target.action.name")); } else { presentation.setText(AntBundle.message("run.ant.targets.action.name")); } } } presentation.setEnabled(canRunSelection()); }
private static AntBuildMessageView prepareMessageView(@Nullable AntBuildMessageView buildMessageViewToReuse, AntBuildFileBase buildFile, String[] targets) throws RunCanceledException { AntBuildMessageView messageView; if (buildMessageViewToReuse != null) { messageView = buildMessageViewToReuse; messageView.emptyAll(); } else { messageView = AntBuildMessageView.openBuildMessageView(buildFile.getProject(), buildFile, targets); if (messageView == null) { throw new RunCanceledException(AntBundle.message("canceled.by.user.error.message")); } } return messageView; }
private static String askUser(SegmentReader reader, Project project) { String prompt = reader.readLimitedString(); String defaultValue = reader.readLimitedString(); String[] choices = reader.readStringArray(); MessagesEx.BaseInputInfo question; if (choices.length == 0) { MessagesEx.InputInfo inputInfo = new MessagesEx.InputInfo(project); inputInfo.setDefaultValue(defaultValue); question = inputInfo; } else { MessagesEx.ChoiceInfo choiceInfo = new MessagesEx.ChoiceInfo(project); choiceInfo.setChoices(choices, defaultValue); question = choiceInfo; } question.setIcon(Messages.getQuestionIcon()); question.setTitle(AntBundle.message("user.inout.request.ant.build.input.dialog.title")); question.setMessage(prompt); question.setIcon(Messages.getQuestionIcon()); return question.forceUserInput(); }
private String getFinishStatusText(boolean isAborted, long buildTimeInMilliseconds) { final String theDateAsString = DateFormatUtil.formatDateTime(Clock.getTime()); final String formattedBuildTime = formatBuildTime(buildTimeInMilliseconds / 1000); if (isAborted) { return AntBundle.message("build.finished.status.ant.build.aborted", formattedBuildTime, theDateAsString); } final int errors = getErrorCount(); final int warnings = getWarningCount(); if (errors == 0 && warnings == 0) { return AntBundle.message("build.finished.status.ant.build.completed.successfully", formattedBuildTime, theDateAsString); } if (errors == 0) { return AntBundle.message("build.finished.status.ant.build.completed.with.warnings", warnings, formattedBuildTime, theDateAsString); } return AntBundle.message("build.finished.status.ant.build.completed.with.errors.warnings", errors, warnings, formattedBuildTime, theDateAsString); }
public static AntInstallation fromHome(String homePath) throws ConfigurationException { File antHome = new File(homePath); String antPath = "'" + antHome.getAbsolutePath() + "'"; checkExists(antHome, AntBundle.message("path.to.ant.does.not.exist.error.message", antPath)); File lib = new File(antHome, LIB_DIR); checkExists(lib, AntBundle.message("lib.directory.not.found.in.ant.path.error.message", antPath)); File antJar = new File(lib, ANT_JAR_FILE); checkExists(antJar, AntBundle.message("ant.jar.not.found.in.directory.error.message", lib.getAbsolutePath())); if (antJar.isDirectory()) { throw new ConfigurationException(AntBundle.message("ant.jar.is.directory.error.message", antJar.getAbsolutePath())); } try { Properties properties = loadProperties(antJar); AntInstallation antInstallation = new AntInstallation(); HOME_DIR.set(antInstallation.getProperties(), antHome.getAbsolutePath()); final String versionProp = properties.getProperty(PROPERTY_VERSION); NAME.set(antInstallation.getProperties(), AntBundle.message("apache.ant.with.version.string.presentation", versionProp)); VERSION.set(antInstallation.getProperties(), versionProp); antInstallation.addClasspathEntry(new AllJarsUnderDirEntry(lib)); return antInstallation; } catch (MalformedURLException e) { LOG.error(e); return null; } }
private boolean showDialog() { DialogBuilder builder = new DialogBuilder(myBuildFile.getProject()); builder.setCenterPanel(myForm.myWholePanel); builder.setDimensionServiceKey(DIMENSION_SERVICE_KEY); builder.setPreferredFocusComponent(myForm.getPreferedFocusComponent()); builder.setTitle(AntBundle.message("build.file.properties.dialog.title")); builder.removeAllActions(); builder.addOkAction(); builder.addCancelAction(); builder.setHelpId("reference.dialogs.buildfileproperties"); boolean isOk = builder.show() == DialogWrapper.OK_EXIT_CODE; if (isOk) { apply(); } beforeClose(); return isOk; }
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { String jdkName = (String)value; if (jdkName == null || jdkName.length() == 0) jdkName = ""; Sdk jdk = GlobalAntConfiguration.findJdk(jdkName); if (jdk == null) { if (myProjectJdkName.length() > 0) { setIcon(AllIcons.General.Jdk); append(AntBundle.message("project.jdk.project.jdk.name.list.column.value", myProjectJdkName), selected && !(SystemInfo.isWinVistaOrNewer && UIManager.getLookAndFeel().getName().contains("Windows")) ? SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES); } else { setIcon(PlatformIcons.INVALID_ENTRY_ICON); append(AntBundle.message("project.jdk.not.specified.list.column.value"), SimpleTextAttributes.ERROR_ATTRIBUTES); } } else { OrderEntryAppearanceService.getInstance().forJdk(jdk, myInComboBox, selected, true).customize(this); } }
private JPanel createToolbarPanel() { final DefaultActionGroup group = new DefaultActionGroup(); group.add(new AddAction()); group.add(new RemoveAction()); group.add(new RunAction()); group.add(new ShowAllTargetsAction()); AnAction action = CommonActionsManager.getInstance().createExpandAllAction(myTreeExpander, this); action.getTemplatePresentation().setDescription(AntBundle.message("ant.explorer.expand.all.nodes.action.description")); group.add(action); action = CommonActionsManager.getInstance().createCollapseAllAction(myTreeExpander, this); action.getTemplatePresentation().setDescription(AntBundle.message("ant.explorer.collapse.all.nodes.action.description")); group.add(action); group.add(myAntBuildFilePropertiesAction); group.add(new ContextHelpAction(HelpID.ANT)); final ActionToolbar actionToolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.ANT_EXPLORER_TOOLBAR, group, true); final JPanel buttonsPanel = new JPanel(new BorderLayout()); buttonsPanel.add(actionToolBar.getComponent(), BorderLayout.CENTER); return buttonsPanel; }
public void actionPerformed(AnActionEvent event) { DataContext dataContext = event.getDataContext(); Project project = PlatformDataKeys.PROJECT.getData(dataContext); VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext); AntConfiguration antConfiguration = AntConfiguration.getInstance(project); try { antConfiguration.addBuildFile(file); ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.ANT_BUILD).activate(null); } catch (AntNoFileException e) { String message = e.getMessage(); if (message == null || message.length() == 0) { message = AntBundle.message("cannot.add.build.files.from.excluded.directories.error.message", e.getFile().getPresentableUrl()); } Messages.showWarningDialog(project, message, AntBundle.message("cannot.add.build.file.dialog.title")); } }
private static void runBuild(final ProgressIndicator progress, @NotNull final AntBuildMessageView errorView, @NotNull final AntBuildFile buildFile, @NotNull final AntBuildListener antBuildListener, @NotNull GeneralCommandLine commandLine) { final Project project = buildFile.getProject(); final long startTime = System.currentTimeMillis(); LocalHistory.getInstance().putSystemLabel(project, AntBundle.message("ant.build.local.history.label", buildFile.getName())); final JUnitProcessHandler handler; try { handler = JUnitProcessHandler.runCommandLine(commandLine); } catch (final ExecutionException e) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { ExecutionErrorDialog.show(e, AntBundle.message("could.not.start.process.erorr.dialog.title"), project); } }); antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0); return; } processRunningAnt(progress, handler, errorView, buildFile, startTime, antBuildListener); handler.waitFor(); }
public String getFinishStatusText(boolean isAborted, long buildTimeInMilliseconds) { int errors = getErrorCount(); int warnings = getWarningCount(); final String theDateAsString = DateFormatUtil.formatDateTime(Clock.getTime()); String formattedBuildTime = formatBuildTime(buildTimeInMilliseconds / 1000); if (isAborted) { return AntBundle.message("build.finished.status.ant.build.aborted", formattedBuildTime, theDateAsString); } else if (errors == 0 && warnings == 0) { return AntBundle.message("build.finished.status.ant.build.completed.successfully", formattedBuildTime, theDateAsString); } else if (errors == 0) { return AntBundle.message("build.finished.status.ant.build.completed.with.warnings", warnings, formattedBuildTime, theDateAsString); } else { return AntBundle .message("build.finished.status.ant.build.completed.with.errors.warnings", errors, warnings, formattedBuildTime, theDateAsString); } }
private JPanel createToolbarPanel() { final DefaultActionGroup group = new DefaultActionGroup(); group.add(new AddAction()); group.add(new RemoveAction()); group.add(new RunAction()); group.add(myAntBuildFilePropertiesAction); group.addSeparator(); group.add(new ShowAllTargetsAction()); group.add(new ShowModuleGrouping()); AnAction action = CommonActionsManager.getInstance().createExpandAllAction(myTreeExpander, this); action.getTemplatePresentation().setDescription(AntBundle.message("ant.explorer.expand.all.nodes.action.description")); group.add(action); action = CommonActionsManager.getInstance().createCollapseAllAction(myTreeExpander, this); action.getTemplatePresentation().setDescription(AntBundle.message("ant.explorer.collapse.all.nodes.action.description")); group.add(action); group.addSeparator(); group.add(new ContextHelpAction(HelpID.ANT)); final ActionToolbar actionToolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.ANT_EXPLORER_TOOLBAR, group, true); final JPanel buttonsPanel = new JPanel(new BorderLayout()); buttonsPanel.add(actionToolBar.getComponent(), BorderLayout.CENTER); return buttonsPanel; }
public void actionPerformed(AnActionEvent e) { Project project = e.getProject(); VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE); AntConfiguration antConfiguration = AntConfiguration.getInstance(project); try { antConfiguration.addBuildFile(file); ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.ANT_BUILD).activate(null); } 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()); } Messages.showWarningDialog(project, message, AntBundle.message("cannot.add.build.file.dialog.title")); } }
private boolean showDialog() { DialogBuilder builder = new DialogBuilder(myBuildFile.getProject()); builder.setCenterPanel(myForm.myWholePanel); builder.setDimensionServiceKey(DIMENSION_SERVICE_KEY); builder.setPreferredFocusComponent(myForm.getPreferedFocusComponent()); builder.setTitle(AntBundle.message("build.file.properties.dialog.title")); builder.removeAllActions(); builder.addOkAction(); builder.addCancelAction(); builder.setHelpId("reference.dialogs.buildfileproperties"); boolean isOk = builder.show() == DialogWrapper.OK_EXIT_CODE; if(isOk) { apply(); } beforeClose(); return isOk; }
private void addBuildFile() { final FileChooserDescriptor descriptor = createXmlDescriptor(); descriptor.setTitle(AntBundle.message("select.ant.build.file.dialog.title")); descriptor.setDescription(AntBundle.message("select.ant.build.file.dialog.description")); final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myProject, null); addBuildFile(files); }
private void addBuildFile(final VirtualFile[] files) { if (files.length == 0) { return; } ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { final AntConfiguration antConfiguration = myConfig; if (antConfiguration == null) { return; } final List<VirtualFile> ignoredFiles = new ArrayList<VirtualFile>(); for (VirtualFile file : files) { try { antConfiguration.addBuildFile(file); } catch (AntNoFileException e) { ignoredFiles.add(e.getFile()); } } if (ignoredFiles.size() != 0) { String messageText; final StringBuilder message = StringBuilderSpinAllocator.alloc(); try { String separator = ""; for (final VirtualFile virtualFile : ignoredFiles) { message.append(separator); message.append(virtualFile.getPresentableUrl()); separator = "\n"; } messageText = message.toString(); } finally { StringBuilderSpinAllocator.dispose(message); } Messages.showWarningDialog(myProject, messageText, AntBundle.message("cannot.add.ant.files.dialog.title")); } } }); }
public void removeBuildFile() { final AntBuildFile buildFile = getCurrentBuildFile(); if (buildFile == null) { return; } final String fileName = buildFile.getPresentableUrl(); final int result = Messages.showYesNoDialog(myProject, AntBundle.message("remove.the.reference.to.file.confirmation.text", fileName), AntBundle.message("confirm.remove.dialog.title"), Messages.getQuestionIcon()); if (result != Messages.YES) { return; } myConfig.removeBuildFile(buildFile); }
private void popupInvoked(final Component comp, final int x, final int y) { Object userObject = null; final TreePath path = myTree.getSelectionPath(); if (path != null) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); if (node != null) { userObject = node.getUserObject(); } } final DefaultActionGroup group = new DefaultActionGroup(); group.add(new RunAction()); group.add(new CreateMetaTargetAction()); group.add(new MakeAntRunConfigurationAction()); group.add(new RemoveMetaTargetsOrBuildFileAction()); group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE)); if (userObject instanceof AntBuildFileNodeDescriptor) { group.add(new RemoveBuildFileAction(this)); } if (userObject instanceof AntTargetNodeDescriptor) { final AntBuildTargetBase target = ((AntTargetNodeDescriptor)userObject).getTarget(); final DefaultActionGroup executeOnGroup = new DefaultActionGroup(AntBundle.message("ant.explorer.execute.on.action.group.name"), true); executeOnGroup.add(new ExecuteOnEventAction(target, ExecuteBeforeCompilationEvent.getInstance())); executeOnGroup.add(new ExecuteOnEventAction(target, ExecuteAfterCompilationEvent.getInstance())); executeOnGroup.addSeparator(); executeOnGroup.add(new ExecuteBeforeRunAction(target)); group.add(executeOnGroup); group.add(new AssignShortcutAction(target.getActionId())); } group.add(myAntBuildFilePropertiesAction); final ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.ANT_EXPLORER_POPUP, group); popupMenu.getComponent().show(comp, x, y); }
public RemoveMetaTargetsOrBuildFileAction() { super(AntBundle.message("remove.meta.targets.action.name"), AntBundle.message("remove.meta.targets.action.description"), null); registerCustomShortcutSet(CommonShortcuts.getDelete(), myTree); Disposer.register(AntExplorer.this, new Disposable() { public void dispose() { RemoveMetaTargetsOrBuildFileAction.this.unregisterCustomShortcutSet(myTree); } }); myTree.registerKeyboardAction(new AbstractAction() { public void actionPerformed(ActionEvent e) { doAction(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); }
@Override public Object[] getChildElements(Object element) { final AntConfiguration configuration = AntConfiguration.getInstance(myProject); if (element == myRoot) { if (!configuration.isInitialized()) { return new Object[] {AntBundle.message("loading.ant.config.progress")}; } final AntBuildFile[] buildFiles = configuration.getBuildFiles(); return buildFiles.length != 0 ? buildFiles : new Object[]{AntBundle.message("ant.tree.structure.no.build.files.message")}; } if (element instanceof AntBuildFile) { final AntBuildFile buildFile = (AntBuildFile)element; final AntBuildModel model = buildFile.getModel(); final List<AntBuildTarget> targets = new ArrayList<AntBuildTarget>(Arrays.asList(myFilteredTargets ? model.getFilteredTargets() : model.getTargets())); Collections.sort(targets, ourTargetComparator); final List<AntBuildTarget> metaTargets = Arrays.asList(configuration.getMetaTargets(buildFile)); Collections.sort(metaTargets, ourTargetComparator); targets.addAll(metaTargets); return targets.toArray(new AntBuildTarget[targets.size()]); } return ArrayUtil.EMPTY_OBJECT_ARRAY; }
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()); } }
public AntBuildFilePropertiesAction(AntExplorer antExplorer) { super(AntBundle.message("build.file.properties.action.name"), AntBundle.message("build.file.properties.action.description"), AntIcons.Properties); myAntExplorer = antExplorer; registerCustomShortcutSet(CommonShortcuts.ALT_ENTER, myAntExplorer); }
@Nullable private static ProcessHandler runBuild(final ProgressIndicator progress, @NotNull final AntBuildMessageView errorView, @NotNull final AntBuildFileBase buildFile, @NotNull final AntBuildListener antBuildListener, @NotNull GeneralCommandLine commandLine) { final Project project = buildFile.getProject(); final long startTime = System.currentTimeMillis(); LocalHistory.getInstance().putSystemLabel(project, AntBundle.message("ant.build.local.history.label", buildFile.getName())); final JUnitProcessHandler handler; try { handler = JUnitProcessHandler.runCommandLine(commandLine); } catch (final ExecutionException e) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { ExecutionErrorDialog.show(e, AntBundle.message("could.not.start.process.error.dialog.title"), project); } }); antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0); return null; } processRunningAnt(progress, handler, errorView, buildFile, startTime, antBuildListener); return handler; }
@Nullable public String getTypeString() { AntBuildMessageView.MessageType type = myMessage.getType(); if (type == AntBuildMessageView.MessageType.BUILD) { return AntBundle.message("ant.build.message.node.prefix.text"); } else if (type == AntBuildMessageView.MessageType.TARGET) { return AntBundle.message("ant.target.message.node.prefix.text"); } else if (type == AntBuildMessageView.MessageType.TASK) { return AntBundle.message("ant.task.message.node.prefix.text"); } return ""; }
/** * @return true if content can be closed */ private boolean closeQuery() { if (myContent == null) { return true; } final AntBuildMessageView messageView = myContent.getUserData(KEY); if (messageView == null || messageView.isStoppedOrTerminateRequested()) { return true; } if (myCloseAllowed) { return true; } final int result = Messages.showYesNoCancelDialog( AntBundle.message("ant.process.is.active.terminate.confirmation.text"), AntBundle.message("close.ant.build.messages.dialog.title"), Messages.getQuestionIcon() ); if (result == 0) { // yes messageView.stopProcess(); myCloseAllowed = true; return true; } if (result == 1) { // no // close content and leave the process running myCloseAllowed = true; return true; } return false; }
public static AntInstallation findNotNullAnt(AbstractProperty<AntReference> property, AbstractProperty.AbstractPropertyContainer container, GlobalAntConfiguration antConfiguration) throws CantRunException { AntReference antReference = property.get(container); if (antReference == PROJECT_DEFAULT) antReference = AntConfigurationImpl.DEFAULT_ANT.get(container); if (antReference == null) throw new CantRunException(AntBundle.message("cant.run.ant.no.ant.configured.error.message")); AntInstallation antInstallation = antReference.find(antConfiguration); if (antInstallation == null) { throw new CantRunException(AntBundle.message("cant.run.ant.ant.reference.is.not.configured.error.message", antReference.getName())); } return antInstallation; }
@Override public String getDescription(AntBeforeRunTask task) { final String targetName = task.getTargetName(); if (targetName == null) { return AntBundle.message("ant.target.before.run.description.empty"); } return AntBundle.message("ant.target.before.run.description", targetName != null? targetName : "<not selected>"); }