private void onSaveAs() { if (mySchemesTableModel.isProjectScheme(getSelectedScheme())) { int rowToSelect = mySchemesTableModel.exportProjectScheme(); if (rowToSelect > 0) { mySchemesTable.getSelectionModel().setSelectionInterval(rowToSelect, rowToSelect); } } else { CodeStyleScheme[] schemes = CodeStyleSchemes.getInstance().getSchemes(); ArrayList<String> names = new ArrayList<String>(); for (CodeStyleScheme scheme : schemes) { names.add(scheme.getName()); } String selectedName = getSelectedScheme().getName(); SaveSchemeDialog saveDialog = new SaveSchemeDialog(myParent, ApplicationBundle.message("title.save.code.style.scheme.as"), names, selectedName); if (saveDialog.showAndGet()) { int row = mySchemesTableModel.createNewScheme(getSelectedScheme(), saveDialog.getSchemeName()); mySchemesTable.getSelectionModel().setSelectionInterval(row, row); } } }
protected void initTables() { initBooleanField("JD_ALIGN_PARAM_COMMENTS", ApplicationBundle.message("checkbox.align.parameter.descriptions"), ALIGNMENT_GROUP); initBooleanField("JD_ALIGN_EXCEPTION_COMMENTS", ApplicationBundle.message("checkbox.align.thrown.exception.descriptions"), ALIGNMENT_GROUP); initBooleanField("JD_ADD_BLANK_AFTER_DESCRIPTION", ApplicationBundle.message("checkbox.after.description"), BLANK_LINES_GROUP); initBooleanField("JD_ADD_BLANK_AFTER_PARM_COMMENTS", ApplicationBundle.message("checkbox.after.parameter.descriptions"), BLANK_LINES_GROUP); initBooleanField("JD_ADD_BLANK_AFTER_RETURN", ApplicationBundle.message("checkbox.after.return.tag"), BLANK_LINES_GROUP); initBooleanField("JD_KEEP_INVALID_TAGS", ApplicationBundle.message("checkbox.keep.invalid.tags"), INVALID_TAGS_GROUP); initBooleanField("JD_KEEP_EMPTY_PARAMETER", ApplicationBundle.message("checkbox.keep.empty.param.tags"), INVALID_TAGS_GROUP); initBooleanField("JD_KEEP_EMPTY_RETURN", ApplicationBundle.message("checkbox.keep.empty.return.tags"), INVALID_TAGS_GROUP); initBooleanField("JD_KEEP_EMPTY_EXCEPTION", ApplicationBundle.message("checkbox.keep.empty.throws.tags"), INVALID_TAGS_GROUP); initBooleanField("JD_LEADING_ASTERISKS_ARE_ENABLED", ApplicationBundle.message("checkbox.enable.leading.asterisks"), OTHER_GROUP); initBooleanField("JD_USE_THROWS_NOT_EXCEPTION", ApplicationBundle.message("checkbox.use.throws.rather.than.exception"), OTHER_GROUP); initBooleanField("WRAP_COMMENTS", ApplicationBundle.message("checkbox.wrap.at.right.margin"), OTHER_GROUP); initBooleanField("JD_P_AT_EMPTY_LINES", ApplicationBundle.message("checkbox.generate.p.on.empty.lines"), OTHER_GROUP); initBooleanField("JD_KEEP_EMPTY_LINES", ApplicationBundle.message("checkbox.keep.empty.lines"), OTHER_GROUP); initBooleanField("JD_DO_NOT_WRAP_ONE_LINE_COMMENTS", ApplicationBundle.message("checkbox.do.not.wrap.one.line.comments"), OTHER_GROUP); initBooleanField("JD_PRESERVE_LINE_FEEDS", ApplicationBundle.message("checkbox.preserve.line.feeds"), OTHER_GROUP); initBooleanField("JD_PARAM_DESCRIPTION_ON_NEW_LINE", ApplicationBundle.message("checkbox.param.description.on.new.line"), OTHER_GROUP); }
@Nullable private static NotificationLabels getNotificationLabels(@NotNull CommonCodeStyleSettings.IndentOptions userOptions, @NotNull CommonCodeStyleSettings.IndentOptions detectedOptions) { if (userOptions.USE_TAB_CHARACTER) { if (!detectedOptions.USE_TAB_CHARACTER) { return new NotificationLabels(ApplicationBundle.message("code.style.space.indent.detected", detectedOptions.INDENT_SIZE), ApplicationBundle.message("code.style.detector.use.tabs")); } } else { String restoreToSpaces = ApplicationBundle.message("code.style.detector.use.spaces", userOptions.INDENT_SIZE); if (detectedOptions.USE_TAB_CHARACTER) { return new NotificationLabels(ApplicationBundle.message("code.style.tab.usage.detected", userOptions.INDENT_SIZE), restoreToSpaces); } if (userOptions.INDENT_SIZE != detectedOptions.INDENT_SIZE) { return new NotificationLabels(ApplicationBundle.message("code.style.different.indent.size.detected", detectedOptions.INDENT_SIZE, userOptions.INDENT_SIZE), restoreToSpaces); } } return null; }
public void editMacro() { if (getSelectedRowCount() != 1) { return; } final int selectedRow = getSelectedRow(); final Couple<String> pair = myMacros.get(selectedRow); final String title = ApplicationBundle.message("title.edit.variable"); final String macroName = pair.getFirst(); final PathMacroEditor macroEditor = new PathMacroEditor(title, macroName, pair.getSecond(), new EditValidator()); if (macroEditor.showAndGet()) { myMacros.remove(selectedRow); myMacros.add(Couple.of(macroEditor.getName(), macroEditor.getValue())); Collections.sort(myMacros, MACRO_COMPARATOR); myTableModel.fireTableDataChanged(); } }
@Override 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, 5); panel.add(new JLabel(ApplicationBundle.message("label.name")), 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(mySchemeName, gc); panel.setPreferredSize(JBUI.size(220, 40)); return panel; }
@Override protected void doOKAction() { if (getSchemeName().trim().isEmpty()) { Messages.showMessageDialog(getContentPane(), ApplicationBundle.message("error.scheme.must.have.a.name"), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); return; } else if ("default".equals(getSchemeName())) { Messages.showMessageDialog(getContentPane(), ApplicationBundle.message("error.illegal.scheme.name"), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); return; } else if (myExistingNames.contains(getSchemeName())) { Messages.showMessageDialog( getContentPane(), ApplicationBundle.message("error.a.scheme.with.this.name.already.exists.or.was.deleted.without.applying.the.changes"), CommonBundle.getErrorTitle(), Messages.getErrorIcon() ); return; } super.doOKAction(); }
@Override public void actionPerformed(@NotNull AnActionEvent event) { if (!isAvailable()) return; Project project = event.getProject(); CreateDesktopEntryDialog dialog = new CreateDesktopEntryDialog(project); if (!dialog.showAndGet()) { return; } final boolean globalEntry = dialog.myGlobalEntryCheckBox.isSelected(); ProgressManager.getInstance().run(new Task.Backgroundable(project, ApplicationBundle.message("desktop.entry.title")) { @Override public void run(@NotNull ProgressIndicator indicator) { createDesktopEntry(getProject(), indicator, globalEntry); } }); }
@Override public void actionPerformed(AnActionEvent e) { new Thread("show delayed msg") { @Override public void run() { super.run(); //noinspection EmptyCatchBlock TimeoutUtil.sleep(3000); //noinspection SSBasedInspection SwingUtilities.invokeLater(new Runnable() { @Override public void run() { MessageDialogBuilder.yesNo("Nothing happens after that", "Some message goes here").yesText( ApplicationBundle.message("command.exit")).noText( CommonBundle.message("button.cancel")).show(); } }); } }.start(); }
@Nullable protected String validate(int index) { if (myRulesModel.getSize() < index) { return null; } final Object target = myRulesModel.getElementAt(index); if (target instanceof StdArrangementMatchRule) { for (int i = 0; i < index; i++) { final Object element = myRulesModel.getElementAt(i); if (element instanceof StdArrangementMatchRule && target.equals(element)) { return ApplicationBundle.message("arrangement.settings.validation.duplicate.matching.rule"); } } } return null; }
public ArrangementRuleAliasDialog(@Nullable Project project, @NotNull ArrangementStandardSettingsManager settingsManager, @NotNull ArrangementColorsProvider colorsProvider, @NotNull Collection<StdArrangementRuleAliasToken> tokens, @NotNull Set<String> tokensInUse) { super(project, false); final List<StdArrangementRuleAliasToken> tokenList = ContainerUtil.newArrayList(tokens); myEditor = new ArrangementRuleAliasesListEditor(settingsManager, colorsProvider, tokenList, tokensInUse); if (!tokenList.isEmpty()) { myEditor.selectItem(tokenList.get(0)); } setTitle(ApplicationBundle.message("arrangement.settings.section.rule.custom.token.title")); init(); }
public ArrangementGroupingRulesPanel(@NotNull ArrangementStandardSettingsManager settingsManager, @NotNull ArrangementColorsProvider colorsProvider) { super(new GridBagLayout()); myControl = new ArrangementGroupingRulesControl(settingsManager, colorsProvider); TitleWithToolbar top = new TitleWithToolbar( ApplicationBundle.message("arrangement.settings.section.groups"), ArrangementConstants.ACTION_GROUP_GROUPING_RULES_CONTROL_TOOLBAR, ArrangementConstants.GROUPING_RULES_CONTROL_TOOLBAR_PLACE, myControl ); add(top, new GridBag().coverLine().fillCellHorizontally().weightx(1)); add(myControl, new GridBag().fillCell().weightx(1).weighty(1).insets(0, ArrangementConstants.HORIZONTAL_PADDING, 0, 0)); }
@Override public void searchResultsUpdated(SearchResults sr) { if (myComponent.getSearchTextComponent().getText().isEmpty()) { updateUIWithEmptyResults(); } else { int matches = sr.getMatchesCount(); boolean tooManyMatches = matches > mySearchResults.getMatchesLimit(); myComponent.setStatusText(tooManyMatches ? ApplicationBundle.message("editorsearch.toomuch", mySearchResults.getMatchesLimit()) : ApplicationBundle.message("editorsearch.matches", matches)); myClickToHighlightLabel.setVisible(tooManyMatches); if (!tooManyMatches && matches <= 0) { myComponent.setNotFoundBackground(); } else { myComponent.setRegularBackground(); } } myComponent.updateActions(); }
@Override public void customize(JList list, Integer value, int index, boolean selected, boolean hasFocus) { int tabPlacement = value.intValue(); String text; if (UISettings.TABS_NONE == tabPlacement) { text = ApplicationBundle.message("combobox.tab.placement.none"); } else if (SwingConstants.TOP == tabPlacement) { text = ApplicationBundle.message("combobox.tab.placement.top"); } else if (SwingConstants.LEFT == tabPlacement) { text = ApplicationBundle.message("combobox.tab.placement.left"); } else if (SwingConstants.BOTTOM == tabPlacement) { text = ApplicationBundle.message("combobox.tab.placement.bottom"); } else if (SwingConstants.RIGHT == tabPlacement) { text = ApplicationBundle.message("combobox.tab.placement.right"); } else { throw new IllegalArgumentException("unknown tabPlacement: " + tabPlacement); } setText(text); }
@Override protected void init() { super.init(); myEnableCheckBox = new JCheckBox(ApplicationBundle.message("checkbox.enable.javadoc.formatting")); myEnableCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { update(); } }); myPanel.setBorder(new CustomLineBorder(OnePixelDivider.BACKGROUND, 1, 0, 0, 0)); myJavaDocPanel.add(BorderLayout.CENTER, myPanel); myJavaDocPanel.add(myEnableCheckBox, BorderLayout.NORTH); }
protected void addComponents() { super.addComponents(); myLabelIndent = new JTextField(4); add(myLabelIndentLabel = new JLabel(ApplicationBundle.message("editbox.indent.label.indent")), myLabelIndent); myLabelIndentAbsolute = new JCheckBox(ApplicationBundle.message("checkbox.indent.absolute.label.indent")); add(myLabelIndentAbsolute, true); myCbDontIndentTopLevelMembers = new JCheckBox(ApplicationBundle.message("checkbox.do.not.indent.top.level.class.members")); add(myCbDontIndentTopLevelMembers); myCbUseRelativeIndent = new JCheckBox(ApplicationBundle.message("checkbox.use.relative.indents")); add(myCbUseRelativeIndent); }
private void composePanel() { myPanel = new JPanel(new GridBagLayout()); myComboBox = new ComboBox(); for (QualifyJavadocOptions options : QualifyJavadocOptions.values()) { myComboBox.addItem(options); } myComboBox.setRenderer(new ListCellRendererWrapper() { @Override public void customize(final JList list, final Object value, final int index, final boolean selected, final boolean hasFocus) { if (value instanceof QualifyJavadocOptions) { setText(((QualifyJavadocOptions)value).getPresentableText()); } } }); JLabel title = new JLabel(ApplicationBundle.message("radio.use.fully.qualified.class.names.in.javadoc")); myPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); GridBagConstraints left = new GridBagConstraints(); left.anchor = GridBagConstraints.WEST; GridBagConstraints right = new GridBagConstraints(); right.anchor = GridBagConstraints.WEST; right.weightx = 1.0; right.insets = new Insets(0, 5, 0, 0); myPanel.add(title, left); myPanel.add(myComboBox, right); }
private JPanel createGeneralOptionsPanel() { OptionGroup group = new OptionGroup(ApplicationBundle.message("title.general")); myCbUseSingleClassImports = new JCheckBox(ApplicationBundle.message("checkbox.use.single.class.import")); group.add(myCbUseSingleClassImports); myCbUseFQClassNames = new JCheckBox(ApplicationBundle.message("checkbox.use.fully.qualified.class.names")); group.add(myCbUseFQClassNames); myCbInsertInnerClassImports = new JCheckBox(ApplicationBundle.message("checkbox.insert.imports.for.inner.classes")); group.add(myCbInsertInnerClassImports); myFqnInJavadocOption = new FullyQualifiedNamesInJavadocOptionProvider(mySettings); group.add(myFqnInJavadocOption.getPanel()); myClassCountField = new JTextField(3); myNamesCountField = new JTextField(3); final JPanel panel = new JPanel(new GridBagLayout()); panel.add(new JLabel(ApplicationBundle.message("editbox.class.count.to.use.import.with.star")), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 3, 0, 0), 0, 0)); panel.add(myClassCountField, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 1, 0, 0), 0, 0)); panel.add(new JLabel(ApplicationBundle.message("editbox.names.count.to.use.static.import.with.star")), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 3, 0, 0), 0, 0)); panel.add(myNamesCountField, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 1, 0, 0), 0, 0)); group.add(panel); return group.createPanel(); }
@Override protected String getActionText(final AnActionEvent e) { String text = ApplicationBundle.message("action.add"); if (e.getPresentation().isEnabled()) { final DomElementsGroupNode selectedNode = getDomElementsGroupNode(getTreeView(e)); if (selectedNode != null) { final Type type = selectedNode.getChildDescription().getType(); text += " " + TypePresentationService.getService().getTypePresentableName(ReflectionUtil.getRawType(type)); } } return text; }
public JavaCodeFoldingOptionsProvider() { super(JavaCodeFoldingSettings.getInstance()); checkBox("INLINE_PARAMETER_NAMES_FOR_LITERAL_CALL_ARGUMENTS", ApplicationBundle.message("checkbox.collapse.boolean.parameters")); checkBox("COLLAPSE_ONE_LINE_METHODS", ApplicationBundle.message("checkbox.collapse.one.line.methods")); checkBox("COLLAPSE_ACCESSORS", ApplicationBundle.message("checkbox.collapse.simple.property.accessors")); checkBox("COLLAPSE_INNER_CLASSES", ApplicationBundle.message("checkbox.collapse.inner.classes")); checkBox("COLLAPSE_ANONYMOUS_CLASSES", ApplicationBundle.message("checkbox.collapse.anonymous.classes")); checkBox("COLLAPSE_ANNOTATIONS", ApplicationBundle.message("checkbox.collapse.annotations")); checkBox("COLLAPSE_CLOSURES", ApplicationBundle.message("checkbox.collapse.closures")); checkBox("COLLAPSE_CONSTRUCTOR_GENERIC_PARAMETERS", ApplicationBundle.message("checkbox.collapse.generic.constructor.parameters")); checkBox("COLLAPSE_I18N_MESSAGES", ApplicationBundle.message("checkbox.collapse.i18n.messages")); checkBox("COLLAPSE_SUPPRESS_WARNINGS", ApplicationBundle.message("checkbox.collapse.suppress.warnings")); checkBox("COLLAPSE_END_OF_LINE_COMMENTS", ApplicationBundle.message("checkbox.collapse.end.of.line.comments")); }
@Override public JComponent createComponent() { mySuppressWay = new JCheckBox(ApplicationBundle.message("checkbox.suppress.with.suppresswarnings")); final JPanel panel = new JPanel(new BorderLayout()); panel.add(mySuppressWay, BorderLayout.WEST); return panel; }
@NotNull @Override public JComponent createComponent() { if (myJdkPanel == null) { myJdkPanel = new JPanel(new GridBagLayout()); myCbProjectJdk = new JdkComboBox(myJdksModel); myCbProjectJdk.insertItemAt(new JdkComboBox.NoneJdkComboBoxItem(), 0); myCbProjectJdk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (myFreeze) return; myJdksModel.setProjectSdk(myCbProjectJdk.getSelectedJdk()); clearCaches(); } }); myJdkPanel.add(new JLabel(ProjectBundle.message("module.libraries.target.jdk.project.radio")), new GridBagConstraints(0, 0, 3, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 4, 0), 0, 0)); myJdkPanel.add(myCbProjectJdk, new GridBagConstraints(0, 1, 1, 1, 0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 4, 0, 0), 0, 0)); final JButton setUpButton = new JButton(ApplicationBundle.message("button.new")); myCbProjectJdk.setSetupButton(setUpButton, myProject, myJdksModel, new JdkComboBox.NoneJdkComboBoxItem(), null, false); myJdkPanel.add(setUpButton, new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 4, 0, 0), 0, 0)); final JButton editButton = new JButton(ApplicationBundle.message("button.edit")); myCbProjectJdk.setEditButton(editButton, myProject, new Computable<Sdk>() { @Override @Nullable public Sdk compute() { return myJdksModel.getProjectSdk(); } }); myJdkPanel.add(editButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 4, 0, 0), 0, 0)); } return myJdkPanel; }
public void addMacro() { final String title = ApplicationBundle.message("title.add.variable"); final PathMacroEditor macroEditor = new PathMacroEditor(title, "", "", new AddValidator(title)); if (macroEditor.showAndGet()) { final String name = macroEditor.getName(); myMacros.add(Couple.of(name, macroEditor.getValue())); Collections.sort(myMacros, MACRO_COMPARATOR); final int index = indexOfMacroWithName(name); LOG.assertTrue(index >= 0); myTableModel.fireTableDataChanged(); setRowSelectionInterval(index, index); } }
public String getColumnName(int columnIndex) { switch (columnIndex) { case NAME_COLUMN: return ApplicationBundle.message("column.name"); case VALUE_COLUMN: return ApplicationBundle.message("column.value"); } return null; }
public boolean isOK(String name, String value) { if(name.length() == 0) return false; if (hasMacroWithName(name)) { Messages.showErrorDialog(PathMacroTable.this, ApplicationBundle.message("error.variable.already.exists", name), myTitle); return false; } return true; }
@Override public void initialize(@NotNull ManagingFS managingFS, @NotNull FileWatcherNotificationSink notificationSink) { myManagingFS = managingFS; myNotificationSink = notificationSink; boolean disabled = Boolean.parseBoolean(System.getProperty(PROPERTY_WATCHER_DISABLED)); myExecutable = getExecutable(); if (disabled) { LOG.info("Native file watcher is disabled"); } else if (myExecutable == null) { LOG.info("Native file watcher is not supported on this platform"); } else if (!myExecutable.exists()) { notifyOnFailure(ApplicationBundle.message("watcher.exe.not.found"), null); } else if (!myExecutable.canExecute()) { notifyOnFailure(ApplicationBundle.message("watcher.exe.not.exe", myExecutable), new NotificationListener() { @Override public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) { ShowFilePathAction.openFile(myExecutable); } }); } else { try { startupProcess(false); LOG.info("Native file watcher is operational."); } catch (IOException e) { LOG.warn(e.getMessage()); notifyOnFailure(ApplicationBundle.message("watcher.failed.to.start"), null); } } }
private void startupProcess(boolean restart) throws IOException { if (myIsShuttingDown) { return; } if (ShutDownTracker.isShutdownHookRunning()) { myIsShuttingDown = true; return; } if (myStartAttemptCount++ > MAX_PROCESS_LAUNCH_ATTEMPT_COUNT) { notifyOnFailure(ApplicationBundle.message("watcher.failed.to.start"), null); return; } if (restart) { shutdownProcess(); } LOG.info("Starting file watcher: " + myExecutable); ProcessBuilder processBuilder = new ProcessBuilder(myExecutable.getAbsolutePath()); Process process = processBuilder.start(); myProcessHandler = new MyProcessHandler(process); myProcessHandler.addProcessListener(new MyProcessAdapter()); myProcessHandler.startNotify(); if (restart) { List<String> recursive = myRecursiveWatchRoots; List<String> flat = myFlatWatchRoots; if (recursive.size() + flat.size() > 0) { setWatchRoots(recursive, flat, true); } } }
public void notifyOnFailure(final String cause, @Nullable final NotificationListener listener) { LOG.warn(cause); if (myFailureShownToTheUser.compareAndSet(false, true)) ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { String title = ApplicationBundle.message("watcher.slow.sync"); Notifications.Bus.notify(NOTIFICATION_GROUP.getValue().createNotification(title, cause, NotificationType.WARNING, listener)); } }, ModalityState.NON_MODAL); }
public void deleteElement(@NotNull DataContext dataContext) { final VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext); if (files == null || files.length == 0) return; Project project = CommonDataKeys.PROJECT.getData(dataContext); String message = createConfirmationMessage(files); int returnValue = Messages.showOkCancelDialog(message, UIBundle.message("delete.dialog.title"), ApplicationBundle.message("button.delete"), CommonBundle.getCancelButtonText(), Messages.getQuestionIcon()); if (returnValue != Messages.OK) return; Arrays.sort(files, FileComparator.getInstance()); final List<String> problems = ContainerUtil.newLinkedList(); new WriteCommandAction.Simple(project) { @Override protected void run() throws Throwable { for (final VirtualFile file : files) { try { file.delete(this); } catch (IOException e) { LOG.info(e); problems.add(file.getName()); } } } }.execute(); if (!problems.isEmpty()) { reportDeletionProblem(problems); } }
private void updateState() { if (!myFailureDetected) { try { // This might not work in all cases, but hopefully is a more reliable method than the current one (checking for font smoothing) // see https://msdn.microsoft.com/en-us/library/aa380798%28v=vs.85%29.aspx boolean newValue = User32.INSTANCE.GetSystemMetrics(0x1000) != 0; // 0x1000 is SM_REMOTESESSION LOG.debug("Detected remote desktop: ", newValue); if (newValue != myRemoteDesktopConnected) { myRemoteDesktopConnected = newValue; if (myRemoteDesktopConnected) { // We postpone notification to avoid recursive initialization of RemoteDesktopDetector // (in case it's initialized by request from com.intellij.notification.EventLog) ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, ApplicationBundle.message("remote.desktop.detected.title"), ApplicationBundle .message("remote.desktop.detected.message"), NotificationType.INFORMATION)); } }); } } } catch (Throwable e) { myRemoteDesktopConnected = false; myFailureDetected = true; LOG.warn("Error while calling GetSystemMetrics", e); } } }
private static void install(File entryFile, boolean globalEntry) throws IOException, ExecutionException { if (globalEntry) { String prompt = ApplicationBundle.message("desktop.entry.sudo.prompt"); exec(new GeneralCommandLine("xdg-desktop-menu", "install", "--mode", "system", entryFile.getAbsolutePath()), prompt); exec(new GeneralCommandLine("xdg-desktop-menu", "forceupdate", "--mode", "system"), prompt); } else { exec(new GeneralCommandLine("xdg-desktop-menu", "install", "--mode", "user", entryFile.getAbsolutePath()), null); exec(new GeneralCommandLine("xdg-desktop-menu", "forceupdate", "--mode", "user"), null); } }
protected CreateLauncherScriptDialog(Project project) { super(project); init(); setTitle(ApplicationBundle.message("launcher.script.title")); String productName = ApplicationNamesInfo.getInstance().getProductName(); myTitle.setText(myTitle.getText().replace("$APP_NAME$", productName)); myNameField.setText(defaultScriptName()); }
@Override public Map<String, Set<String>> findPossibleExtension(@NotNull String prefix, final Project project) { loadHugeFilesIfNecessary(); final boolean perProject = CodeStyleFacade.getInstance(project).projectUsesOwnSettings(); final Map<String, Set<String>> result = new THashMap<String, Set<String>>(); int count = 0; final Set<String> prefixes = getProcessedWordsWithoutStemming(prefix); for (String opt : prefixes) { Set<OptionDescription> configs = getAcceptableDescriptions(opt); if (configs == null) continue; for (OptionDescription description : configs) { String groupName = description.getGroupName(); if (perProject) { if (Comparing.strEqual(groupName, ApplicationBundle.message("title.global.code.style"))) { groupName = ApplicationBundle.message("title.project.code.style"); } } else { if (Comparing.strEqual(groupName, ApplicationBundle.message("title.project.code.style"))) { groupName = ApplicationBundle.message("title.global.code.style"); } } Set<String> foundHits = result.get(groupName); if (foundHits == null) { foundHits = new THashSet<String>(); result.put(groupName, foundHits); } foundHits.add(description.getHit()); count++; } } if (count > LOAD_FACTOR) { result.clear(); } return result; }
@Override protected void addTabOptions() { super.addTabOptions(); myCbSmartTabs = new JCheckBox(ApplicationBundle.message("checkbox.indent.smart.tabs")); add(myCbSmartTabs, true); }
@Override protected void addComponents() { super.addComponents(); myContinuationIndentField = createIndentTextField(); myContinuationIndentLabel = new JLabel(ApplicationBundle.message("editbox.indent.continuation.indent")); add(myContinuationIndentLabel, myContinuationIndentField); myCbKeepIndentsOnEmptyLines = new JCheckBox(ApplicationBundle.message("checkbox.indent.keep.indents.on.empty.lines")); add(myCbKeepIndentsOnEmptyLines); }
@Override public void setEnabled(final boolean enabled) { super.setEnabled(enabled); boolean smartTabsChecked = enabled && myCbUseTab.isSelected(); boolean smartTabsValid = smartTabsChecked && isSmartTabValid(getUIIndent(), getUITabSize()); myCbSmartTabs.setEnabled(smartTabsValid); myCbSmartTabs.setToolTipText( smartTabsChecked && !smartTabsValid ? ApplicationBundle.message("tooltip.indent.must.be.multiple.of.tab.size.for.smart.tabs.to.operate") : null); myContinuationIndentField.setEnabled(enabled); myContinuationIndentLabel.setEnabled(enabled); }
private JComponent createSettingsPanel() { JPanel result = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0)); result.add(new JLabel(ApplicationBundle.message("label.font.size"))); myFontSizeSlider = new JSlider(SwingConstants.HORIZONTAL, 0, FontSize.values().length - 1, 3); myFontSizeSlider.setMinorTickSpacing(1); myFontSizeSlider.setPaintTicks(true); myFontSizeSlider.setPaintTrack(true); myFontSizeSlider.setSnapToTicks(true); UIUtil.setSliderIsFilled(myFontSizeSlider, true); result.add(myFontSizeSlider); result.setBorder(BorderFactory.createLineBorder(JBColor.border(), 1)); myFontSizeSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (myIgnoreFontSizeSliderChange) { return; } EditorColorsManager colorsManager = EditorColorsManager.getInstance(); EditorColorsScheme scheme = colorsManager.getGlobalScheme(); scheme.setQuickDocFontSize(FontSize.values()[myFontSizeSlider.getValue()]); applyFontSize(); } }); String tooltipText = ApplicationBundle.message("quickdoc.tooltip.font.size.by.wheel"); result.setToolTipText(tooltipText); myFontSizeSlider.setToolTipText(tooltipText); result.setVisible(false); result.setOpaque(true); myFontSizeSlider.setOpaque(true); return result; }
@Override public boolean iteration() { if (myStopFormatting) { return true; } if (!myFilesCountingFinished) { updateIndicatorText(ApplicationBundle.message("bulk.reformat.prepare.progress.text"), ""); countingIteration(); return true; } updateIndicatorFraction(myFilesProcessed); if (myFileTreeIterator.hasNext()) { final PsiFile file = myFileTreeIterator.next(); myFilesProcessed++; if (file.isWritable() && canBeFormatted(file) && acceptedByFilters(file)) { updateIndicatorText(ApplicationBundle.message("bulk.reformat.process.progress.text"), getPresentablePath(file)); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { DumbService.getInstance(myProject).withAlternativeResolveEnabled(new Runnable() { @Override public void run() { performFileProcessing(file); } }); } }); } } return true; }
protected void handleFileTooBigException(Logger logger, FilesTooBigForDiffException e, @NotNull PsiFile file) { logger.info("Error while calculating changed ranges for: " + file.getVirtualFile(), e); if (!ApplicationManager.getApplication().isUnitTestMode()) { Notification notification = new Notification(ApplicationBundle.message("reformat.changed.text.file.too.big.notification.groupId"), ApplicationBundle.message("reformat.changed.text.file.too.big.notification.title"), ApplicationBundle.message("reformat.changed.text.file.too.big.notification.text", file.getName()), NotificationType.INFORMATION); notification.notify(file.getProject()); } }
@Nullable private static Pattern compilePattern(CodeStyleSettings settings, JTextField field, String patternText) { try { return Pattern.compile(patternText); } catch (PatternSyntaxException pse) { settings.FORMATTER_TAGS_ACCEPT_REGEXP = false; showError(field, ApplicationBundle.message("settings.code.style.general.formatter.marker.invalid.regexp")); return null; } }
void export() { ListPopup popup = JBPopupFactory.getInstance().createListPopup( new BaseListPopupStep<String>(ApplicationBundle.message("scheme.exporter.ui.export.as.title"), enumExporters()) { @Override public PopupStep onChosen(final String selectedValue, boolean finalChoice) { return doFinalStep(new Runnable() { @Override public void run() { exportSchemeUsing(selectedValue); } }); } }); popup.showInCenterOf(myParentComponent); }