com.intellij.ide.IdeBundle Java Examples
The following examples show how to use
com.intellij.ide.IdeBundle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TodoFileNode.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void updateImpl(@Nonnull PresentationData data) { super.updateImpl(data); String newName; if (myBuilder.getTodoTreeStructure().isPackagesShown()) { newName = getValue().getName(); } else { newName = mySingleFileMode ? getValue().getName() : getValue().getVirtualFile().getPresentableUrl(); } data.setPresentableText(newName); int todoItemCount; try { todoItemCount = myBuilder.getTodoTreeStructure().getTodoItemCount(getValue()); } catch (IndexNotReadyException e) { return; } if (todoItemCount > 0) { data.setLocationString(IdeBundle.message("node.todo.items", todoItemCount)); } }
Example #2
Source File: OpenFileAction.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess private static void doOpenFile(@Nullable final Project project, @Nonnull final VirtualFile[] result) { for (final VirtualFile file : result) { if (file.isDirectory()) { ProjectUtil.openAsync(file.getPath(), project, false, UIAccess.current()).doWhenDone(openedProject -> FileChooserUtil.setLastOpenedFile(openedProject, file)); return; } if (OpenProjectFileChooserDescriptor.canOpen(file)) { int answer = Messages.showYesNoDialog(project, IdeBundle.message("message.open.file.is.project", file.getName()), IdeBundle.message("title.open.project"), Messages.getQuestionIcon()); if (answer == 0) { ProjectUtil.openAsync(file.getPath(), project, false, UIAccess.current()).doWhenDone(openedProject -> FileChooserUtil.setLastOpenedFile(openedProject, file)); return; } } FileType type = FileTypeChooser.getKnownFileTypeOrAssociate(file, project); if (type == null) return; if (project != null) { openFile(file, project); } } }
Example #3
Source File: FileTemplateUtil.java From consulo with Apache License 2.0 | 6 votes |
private static String mergeTemplate(String templateContent, final VelocityContext context, boolean useSystemLineSeparators) throws IOException { final StringWriter stringWriter = new StringWriter(); try { VelocityWrapper.evaluate(null, context, stringWriter, templateContent); } catch (final VelocityException e) { LOG.error("Error evaluating template:\n" + templateContent, e); ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog(IdeBundle.message("error.parsing.file.template", e.getMessage()), IdeBundle.message("title.velocity.error"))); } final String result = stringWriter.toString(); if (useSystemLineSeparators) { final String newSeparator = CodeStyleSettingsManager.getSettings(ProjectManagerEx.getInstanceEx().getDefaultProject()).getLineSeparator(); if (!"\n".equals(newSeparator)) { return StringUtil.convertLineSeparators(result, newSeparator); } } return result; }
Example #4
Source File: BrowserLauncherImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void doShowError(@Nullable final String error, @Nullable final WebBrowser browser, @Nullable final Project project, final String title, @Nullable final Runnable launchTask) { AppUIUtil.invokeOnEdt(new Runnable() { @Override public void run() { if (Messages.showYesNoDialog(project, StringUtil.notNullize(error, "Unknown error"), title == null ? IdeBundle.message("browser" + ".error") : title, Messages.OK_BUTTON, IdeBundle.message("button.fix"), null) == Messages.NO) { final BrowserSettings browserSettings = new BrowserSettings(); AsyncResult<Void> result = ShowSettingsUtil.getInstance().editConfigurable(project, browserSettings, browser == null ? null : (Runnable)() -> browserSettings.selectBrowser(browser)); result.doWhenDone(() -> { if (launchTask != null) { launchTask.run(); } }); } } }, project == null ? null : project.getDisposed()); }
Example #5
Source File: ActionMacroManager.java From consulo with Apache License 2.0 | 6 votes |
public void stopRecording(@Nullable Project project) { LOG.assertTrue(myIsRecording); if (myWidget != null) { myWidget.delete(); myWidget = null; } myIsRecording = false; myLastActionInputEvent.clear(); String macroName; do { macroName = Messages.showInputDialog(project, IdeBundle.message("prompt.enter.macro.name"), IdeBundle.message("title.enter.macro.name"), Messages.getQuestionIcon()); if (macroName == null) { myRecordingMacro = null; return; } if (macroName.isEmpty()) macroName = null; } while (macroName != null && !checkCanCreateMacro(macroName)); myLastMacro = myRecordingMacro; addRecordedMacroWithName(macroName); registerActions(); }
Example #6
Source File: GotoCustomRegionDialog.java From consulo with Apache License 2.0 | 6 votes |
@RequiredReadAction protected GotoCustomRegionDialog(@Nullable Project project, @Nonnull Editor editor) { super(project); myEditor = editor; myProject = project; Collection<FoldingDescriptor> descriptors = getCustomFoldingDescriptors(); init(); if (descriptors.size() == 0) { myScrollPane.setVisible(false); myContentPane.add(new JLabel(IdeBundle.message("goto.custom.region.message.unavailable")), BorderLayout.NORTH); setOKActionEnabled(false); } else { myRegionsList.setModel(new MyListModel(orderByPosition(descriptors))); myRegionsList.setSelectedIndex(0); } setTitle(IdeBundle.message("goto.custom.region.command")); }
Example #7
Source File: ModifyKeywordDialog.java From consulo with Apache License 2.0 | 6 votes |
protected JComponent createNorthPanel() { JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gc = new GridBagConstraints(); gc.gridx = 0; gc.gridy = 0; gc.weightx = 0; gc.insets = new Insets(5, 0, 5, 10); gc.anchor = GridBagConstraints.BASELINE; panel.add(new JLabel(IdeBundle.message("editbox.keyword")), gc); gc = new GridBagConstraints(); gc.gridx = 1; gc.gridy = 0; gc.weightx = 1; gc.fill = GridBagConstraints.HORIZONTAL; gc.gridwidth = 2; gc.insets = new Insets(0, 0, 5, 0); panel.add(myKeywordName, gc); panel.setPreferredSize(new Dimension(220, 40)); return panel; }
Example #8
Source File: ActionMacroManager.java From consulo with Apache License 2.0 | 6 votes |
private void addRecordedMacroWithName(@Nullable String macroName) { if (macroName != null) { myRecordingMacro.setName(macroName); myMacros.add(myRecordingMacro); myRecordingMacro = null; } else { for (int i = 0; i < myMacros.size(); i++) { ActionMacro macro = myMacros.get(i); if (IdeBundle.message("macro.noname").equals(macro.getName())) { myMacros.set(i, myRecordingMacro); myRecordingMacro = null; break; } } if (myRecordingMacro != null) { myMacros.add(myRecordingMacro); myRecordingMacro = null; } } }
Example #9
Source File: PackageViewPane.java From consulo with Apache License 2.0 | 6 votes |
@Override public void deleteElement(@Nonnull DataContext dataContext) { List<PsiDirectory> allElements = Arrays.asList(getSelectedDirectories()); List<PsiElement> validElements = new ArrayList<PsiElement>(); for (PsiElement psiElement : allElements) { if (psiElement != null && psiElement.isValid()) validElements.add(psiElement); } final PsiElement[] elements = PsiUtilCore.toPsiElementArray(validElements); LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting")); try { DeleteHandler.deletePsiElement(elements, myProject); } finally { a.finish(); } }
Example #10
Source File: DumbServiceImpl.java From consulo with Apache License 2.0 | 6 votes |
private void showModalProgress() { NoAccessDuringPsiEvents.checkCallContext(); try { ((ApplicationEx2)ApplicationManager.getApplication()).executeSuspendingWriteAction(myProject, IdeBundle.message("progress.indexing"), () -> { assertState(State.SCHEDULED_TASKS); runBackgroundProcess(ProgressManager.getInstance().getProgressIndicator()); assertState(State.SMART, State.WAITING_FOR_FINISH); }); assertState(State.SMART, State.WAITING_FOR_FINISH); } finally { if (myState.get() != State.SMART) { assertState(State.WAITING_FOR_FINISH); updateFinished(); assertState(State.SMART, State.SCHEDULED_TASKS); } } }
Example #11
Source File: TipPanel.java From consulo with Apache License 2.0 | 6 votes |
public void nextTip() { if (myTips.size() == 0) { myBrowser.setText(IdeBundle.message("error.tips.not.found", ApplicationNamesInfo.getInstance().getFullProductName())); return; } GeneralSettings settings = GeneralSettings.getInstance(); int lastTip = settings.getLastTip(); TipAndTrickBean tip; lastTip++; if (lastTip - 1 >= myTips.size()) { tip = myTips.get(0); lastTip = 1; } else { tip = myTips.get(lastTip - 1); } setTip(tip, lastTip, myBrowser, settings); }
Example #12
Source File: SearchAgainAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(final AnActionEvent e) { final Project project = e.getData(CommonDataKeys.PROJECT); final FileEditor editor = e.getData(PlatformDataKeys.FILE_EDITOR); if (editor == null || project == null) return; CommandProcessor commandProcessor = CommandProcessor.getInstance(); commandProcessor.executeCommand( project, new Runnable() { @Override public void run() { PsiDocumentManager.getInstance(project).commitAllDocuments(); IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation(); if(FindManager.getInstance(project).findNextUsageInEditor(editor)) { return; } FindUtil.searchAgain(project, editor, e.getDataContext()); } }, IdeBundle.message("command.find.next"), null ); }
Example #13
Source File: LibraryEditingUtil.java From consulo with Apache License 2.0 | 6 votes |
public static BaseListPopupStep<LibraryType> createChooseTypeStep(final ClasspathPanel classpathPanel, final ParameterizedRunnable<LibraryType> action) { return new BaseListPopupStep<LibraryType>(IdeBundle.message("popup.title.select.library.type"), getSuitableTypes(classpathPanel)) { @Nonnull @Override public String getTextFor(LibraryType value) { String createActionName = value != null ? value.getCreateActionName() : null; return createActionName != null ? createActionName : IdeBundle.message("create.default.library.type.action.name"); } @Override public Icon getIconFor(LibraryType aValue) { return aValue != null ? TargetAWT.to(aValue.getIcon()) : AllIcons.Nodes.PpLib; } @Override public PopupStep onChosen(final LibraryType selectedValue, boolean finalChoice) { return doFinalStep(new Runnable() { @Override public void run() { action.run(selectedValue); } }); } }; }
Example #14
Source File: EarlyAccessProgramConfigurable.java From consulo with Apache License 2.0 | 6 votes |
private static JComponent createWarningPanel() { VerticalLayoutPanel panel = JBUI.Panels.verticalPanel(); panel.setBackground(LightColors.RED); panel.setBorder(new CompoundBorder(JBUI.Borders.customLine(JBColor.GRAY), JBUI.Borders.empty(5))); JBLabel warnLabel = new JBLabel("WARNING", AllIcons.General.BalloonWarning, SwingConstants.LEFT); warnLabel.setFont(UIUtil.getFont(UIUtil.FontSize.BIGGER, warnLabel.getFont()).deriveFont(Font.BOLD)); panel.addComponent(warnLabel); JTextArea textArea = new JTextArea(IdeBundle.message("eap.configurable.warning.text")); textArea.setLineWrap(true); textArea.setFont(JBUI.Fonts.label()); textArea.setOpaque(false); textArea.setEditable(false); panel.addComponent(textArea); return panel; }
Example #15
Source File: TipUIUtil.java From consulo with Apache License 2.0 | 5 votes |
private static void setCantReadText(JEditorPane browser, TipAndTrickBean bean) { try { String plugin = getPoweredByText(bean); String product = ApplicationNamesInfo.getInstance().getFullProductName(); if (!plugin.isEmpty()) { product += " and " + plugin + " plugin"; } String message = IdeBundle.message("error.unable.to.read.tip.of.the.day", bean.fileName, product); browser.read(new StringReader(message), null); } catch (IOException ignored) { } }
Example #16
Source File: SummaryNode.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(@Nonnull PresentationData presentation) { if (DumbService.getInstance(getProject()).isDumb()) return; int todoItemCount = getTodoItemCount(getValue()); int fileCount = getFileCount(getValue()); presentation.setPresentableText(IdeBundle.message("node.todo.summary", todoItemCount, fileCount)); }
Example #17
Source File: CustomFileTypeEditor.java From consulo with Apache License 2.0 | 5 votes |
public void applyEditorTo(AbstractFileType type) throws ConfigurationException { if (myFileTypeName.getText().trim().length() == 0) { throw new ConfigurationException(IdeBundle.message("error.name.cannot.be.empty"), CommonBundle.getErrorTitle()); } else if (myFileTypeDescr.getText().trim().length() == 0) { myFileTypeDescr.setText(myFileTypeName.getText()); } type.setName(myFileTypeName.getText()); type.setDescription(myFileTypeDescr.getText()); type.setSyntaxTable(getSyntaxTable()); }
Example #18
Source File: CopyPathsAction.java From consulo with Apache License 2.0 | 5 votes |
public void update(AnActionEvent event) { final Collection<VirtualFile> files = getFiles(event); final Presentation presentation = event.getPresentation(); final boolean enabled = !files.isEmpty(); presentation.setEnabled(enabled); if (ActionPlaces.isPopupPlace(event.getPlace())) { presentation.setVisible(enabled); } else { presentation.setVisible(true); } presentation.setText((files.size() == 1) ? IdeBundle.message("action.copy.path") : IdeBundle.message("action.copy.paths")); }
Example #19
Source File: NamedLibraryElementNode.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(PresentationData presentation) { presentation.setPresentableText(getValue().getName()); final OrderEntry orderEntry = getValue().getOrderEntry(); if (orderEntry instanceof ModuleExtensionWithSdkOrderEntry) { final ModuleExtensionWithSdkOrderEntry sdkOrderEntry = (ModuleExtensionWithSdkOrderEntry)orderEntry; final Sdk sdk = sdkOrderEntry.getSdk(); presentation.setIcon(SdkUtil.getIcon(((ModuleExtensionWithSdkOrderEntry)orderEntry).getSdk())); if (sdk != null) { //jdk not specified final String path = sdk.getHomePath(); if (path != null) { presentation.setLocationString(FileUtil.toSystemDependentName(path)); } } presentation.setTooltip(null); } else if (orderEntry instanceof LibraryOrderEntry) { presentation.setIcon(getIconForLibrary(orderEntry)); presentation.setTooltip(StringUtil.capitalize(IdeBundle.message("node.projectview.library", ((LibraryOrderEntry)orderEntry).getLibraryLevel()))); } else if(orderEntry instanceof OrderEntryWithTracking) { Image icon = null; CellAppearanceEx cellAppearance = OrderEntryAppearanceService.getInstance().forOrderEntry(orderEntry); if(cellAppearance instanceof ModifiableCellAppearanceEx) { icon = ((ModifiableCellAppearanceEx)cellAppearance).getIcon(); } presentation.setIcon(icon == null ? AllIcons.Toolbar.Unknown : icon); } }
Example #20
Source File: FileTextFieldImpl.java From consulo with Apache License 2.0 | 5 votes |
private void showNoSuggestions(boolean isExplicit) { hideCurrentPopup(); if (!isExplicit) return; final JComponent message = HintUtil.createErrorLabel(IdeBundle.message("file.chooser.completion.no.suggestions")); final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(message, message); builder.setRequestFocus(false).setResizable(false).setAlpha(0.1f).setFocusOwners(new Component[]{myPathTextField}); myNoSuggestionsPopup = builder.createPopup(); myNoSuggestionsPopup.showInScreenCoordinates(getField(), getLocationForCaret(myPathTextField)); }
Example #21
Source File: SplitAction.java From consulo with Apache License 2.0 | 5 votes |
public void update(final AnActionEvent event) { final Project project = event.getData(CommonDataKeys.PROJECT); final Presentation presentation = event.getPresentation(); presentation.setText (myOrientation == SwingConstants.VERTICAL ? IdeBundle.message("action.split.vertically") : IdeBundle.message("action.split.horizontally")); if (project == null) { presentation.setEnabled(false); return; } final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project); presentation.setEnabled(fileEditorManager.hasOpenedFile ()); }
Example #22
Source File: FileTextFieldImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public String getAdText(CompletionResult result) { if (result.myCompletionBase == null) return null; if (result.myCompletionBase.length() == result.myFieldText.length()) return null; String strokeText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction("EditorChooseLookupItemReplace")); return IdeBundle.message("file.chooser.completion.ad.text", strokeText); }
Example #23
Source File: PluginAdvertiserEditorNotificationProvider.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private EditorNotificationPanel createPanel(VirtualFile virtualFile, Set<PluginDescriptor> plugins) { String extension = virtualFile.getExtension(); final EditorNotificationPanel panel = new EditorNotificationPanel(); panel.setText(IdeBundle.message("plugin.advestiser.notification.text", plugins.size())); final PluginDescriptor disabledPlugin = getDisabledPlugin(plugins.stream().map(x -> x.getPluginId().getIdString()).collect(Collectors.toSet())); if (disabledPlugin != null) { panel.createActionLabel("Enable " + disabledPlugin.getName() + " plugin", () -> { myEnabledExtensions.add(extension); consulo.container.plugin.PluginManager.enablePlugin(disabledPlugin.getPluginId().getIdString()); myNotifications.updateAllNotifications(); PluginManagerMain.notifyPluginsWereUpdated("Plugin was successfully enabled", null); }); } else { panel.createActionLabel(IdeBundle.message("plugin.advestiser.notification.install.link", plugins.size()), () -> { final PluginsAdvertiserDialog advertiserDialog = new PluginsAdvertiserDialog(null, new ArrayList<>(plugins)); advertiserDialog.show(); if (advertiserDialog.isUserInstalledPlugins()) { myEnabledExtensions.add(extension); myNotifications.updateAllNotifications(); } }); } panel.createActionLabel("Ignore by file name", () -> { myUnknownFeaturesCollector.ignoreFeature(new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP, virtualFile.getName())); myNotifications.updateAllNotifications(); }); panel.createActionLabel("Ignore by extension", () -> { myUnknownFeaturesCollector.ignoreFeature(new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP, "*." + virtualFile.getExtension())); myNotifications.updateAllNotifications(); }); return panel; }
Example #24
Source File: BrowseMethodHierarchyAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public final void update(final AnActionEvent event){ final Presentation presentation = event.getPresentation(); if (!ActionPlaces.MAIN_MENU.equals(event.getPlace())) { presentation.setText(IdeBundle.message("action.browse.method.hierarchy")); } super.update(event); }
Example #25
Source File: BrowseTypeHierarchyAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public final void update(final AnActionEvent event){ final Presentation presentation = event.getPresentation(); if (!ActionPlaces.MAIN_MENU.equals(event.getPlace())) { presentation.setText(IdeBundle.message("action.browse.type.hierarchy")); } super.update(event); }
Example #26
Source File: ModifyKeywordDialog.java From consulo with Apache License 2.0 | 5 votes |
public ModifyKeywordDialog(Component parent, String initialValue) { super(parent, false); if (initialValue == null || "".equals(initialValue)) { setTitle(IdeBundle.message("title.add.new.keyword")); } else { setTitle(IdeBundle.message("title.edit.keyword")); } init(); myKeywordName.setText(initialValue); }
Example #27
Source File: ScopeChooserConfigurable.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public AnAction[] getChildren(@Nullable AnActionEvent e) { if (myChildren == null) { myChildren = new AnAction[2]; myChildren[0] = new AnAction(IdeBundle.message("add.local.scope.action.text"), IdeBundle.message("add.local.scope.action.text"), myLocalScopesManager.getIcon()) { @RequiredUIAccess @Override public void actionPerformed(AnActionEvent e) { createScope(true, IdeBundle.message("add.scope.dialog.title"), null); } }; myChildren[1] = new AnAction(IdeBundle.message("add.shared.scope.action.text"), IdeBundle.message("add.shared.scope.action.text"), mySharedScopesManager.getIcon()) { @RequiredUIAccess @Override public void actionPerformed(AnActionEvent e) { createScope(false, IdeBundle.message("add.scope.dialog.title"), null); } }; } if (myFromPopup) { final AnAction action = myChildren[getDefaultIndex()]; action.getTemplatePresentation().setIcon(IconUtil.getAddIcon()); return new AnAction[]{action}; } return myChildren; }
Example #28
Source File: ProcessPopup.java From consulo with Apache License 2.0 | 5 votes |
public ProcessPopup(final InfoAndProgressPanel progressPanel) { myProgressPanel = progressPanel; buildActiveContent(); myInactiveContentComponent = new JLabel(IdeBundle.message("progress.window.empty.text"), null, JLabel.CENTER) { @Override public Dimension getPreferredSize() { return getEmptyPreferredSize(); } }; myInactiveContentComponent.setFocusable(true); switchToPassive(); }
Example #29
Source File: DumbServiceImpl.java From consulo with Apache License 2.0 | 5 votes |
private void startBackgroundProcess() { try { ProgressManager.getInstance().run(new Task.Backgroundable(myProject, IdeBundle.message("progress.indexing"), false) { @Override public void run(@Nonnull final ProgressIndicator visibleIndicator) { runBackgroundProcess(visibleIndicator); } }); } catch (Throwable e) { queueUpdateFinished(); LOG.error("Failed to start background index update task", e); } }
Example #30
Source File: NavBarPresentation.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static String calcPresentableText(Object object, boolean forPopup) { if (!NavBarModel.isValid(object)) { return IdeBundle.message("node.structureview.invalid"); } for (NavBarModelExtension modelExtension : NavBarModelExtension.EP_NAME.getExtensionList()) { String text = modelExtension.getPresentableText(object, forPopup); if (text != null) return text; } return object.toString(); }