List of usage examples for com.intellij.openapi.ui DialogBuilder removeAllActions
public void removeAllActions()
From source file:com.android.tools.idea.uibuilder.property.NlIdPropertyItem.java
License:Apache License
@Override public void setValue(Object value) { String newId = value != null ? stripIdPrefix(value.toString()) : ""; String oldId = getValue();//from w w w. j a v a 2 s. c om XmlTag tag = getTag(); if (ourRefactoringChoice != REFACTOR_NO && oldId != null && !oldId.isEmpty() && !newId.isEmpty() && !oldId.equals(newId) && tag != null && tag.isValid()) { // Offer rename refactoring? XmlAttribute attribute = tag.getAttribute(SdkConstants.ATTR_ID, SdkConstants.ANDROID_URI); if (attribute != null) { Module module = getModel().getModule(); Project project = module.getProject(); XmlAttributeValue valueElement = attribute.getValueElement(); if (valueElement != null && valueElement.isValid()) { // Exact replace only, no comment/text occurrence changes since it is non-interactive ValueResourceElementWrapper wrapper = new ValueResourceElementWrapper(valueElement); RenameProcessor processor = new RenameProcessor(project, wrapper, NEW_ID_PREFIX + newId, false /*comments*/, false /*text*/); processor.setPreviewUsages(false); // Do a quick usage search to see if we need to ask about renaming UsageInfo[] usages = processor.findUsages(); if (usages.length > 0) { int choice = ourRefactoringChoice; if (choice == REFACTOR_ASK) { DialogBuilder builder = createDialogBuilder(project); builder.setTitle("Update Usages?"); JPanel panel = new JPanel(new BorderLayout()); // UGH! JLabel label = new JLabel("<html>" + "Update usages as well?<br>" + "This will update all XML references and Java R field references.<br>" + "<br>" + "</html>"); panel.add(label, BorderLayout.CENTER); JBCheckBox checkBox = new JBCheckBox("Don't ask again during this session"); panel.add(checkBox, BorderLayout.SOUTH); builder.setCenterPanel(panel); builder.setDimensionServiceKey("idPropertyDimension"); builder.removeAllActions(); DialogBuilder.CustomizableAction yesAction = builder.addOkAction(); yesAction.setText(Messages.YES_BUTTON); builder.addActionDescriptor(dialogWrapper -> new AbstractAction(Messages.NO_BUTTON) { @Override public void actionPerformed(ActionEvent actionEvent) { dialogWrapper.close(DialogWrapper.NEXT_USER_EXIT_CODE); } }); builder.addCancelAction(); int exitCode = builder.show(); choice = exitCode == DialogWrapper.OK_EXIT_CODE ? REFACTOR_YES : exitCode == DialogWrapper.NEXT_USER_EXIT_CODE ? REFACTOR_NO : ourRefactoringChoice; //noinspection AssignmentToStaticFieldFromInstanceMethod ourRefactoringChoice = checkBox.isSelected() ? choice : REFACTOR_ASK; if (exitCode == DialogWrapper.CANCEL_EXIT_CODE) { return; } } if (choice == REFACTOR_YES) { processor.run(); return; } } } } } super.setValue(!StringUtil.isEmpty(newId) ? NEW_ID_PREFIX + newId : null); }
From source file:com.intellij.lang.ant.config.impl.configuration.BuildFilePropertiesPanel.java
License:Apache License
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();//from w w w .j av a 2 s . c om builder.addCancelAction(); builder.setHelpId("reference.dialogs.buildfileproperties"); boolean isOk = builder.show() == DialogWrapper.OK_EXIT_CODE; if (isOk) { apply(); } beforeClose(); return isOk; }
From source file:com.urswolfer.intellij.plugin.gerrit.ui.diff.CustomizableFrameDiffTool.java
License:Apache License
public void show(DiffRequest request) { Collection hints = request.getHints(); boolean shouldOpenDialog = shouldOpenDialog(hints); if (shouldOpenDialog) { final DialogBuilder builder = new DialogBuilder(request.getProject()); DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, builder.getWindow(), builder, true); if (diffPanel == null) { Disposer.dispose(builder);//ww w. ja v a2s . c o m return; } if (hints.contains(DiffTool.HINT_DIFF_IS_APPROXIMATE)) { diffPanel.setPatchAppliedApproximately(); // todo read only and not variants } final Runnable onOkRunnable = request.getOnOkRunnable(); if (onOkRunnable != null) { builder.setOkOperation(new Runnable() { @Override public void run() { builder.getDialogWrapper().close(0); onOkRunnable.run(); } }); } else { builder.removeAllActions(); } builder.setCenterPanel(diffPanel.getComponent()); builder.setPreferredFocusComponent(diffPanel.getPreferredFocusedComponent()); builder.setTitle(request.getWindowTitle()); builder.setDimensionServiceKey(request.getGroupKey()); new AnAction() { public void actionPerformed(final AnActionEvent e) { builder.getDialogWrapper().close(0); } }.registerCustomShortcutSet( new CustomShortcutSet( KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent()); showDiffDialog(builder, hints); } else { final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey()); DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, frameWrapper.getFrame(), frameWrapper, true); if (diffPanel == null) { Disposer.dispose(frameWrapper); return; } if (hints.contains(DiffTool.HINT_DIFF_IS_APPROXIMATE)) { diffPanel.setPatchAppliedApproximately(); } frameWrapper.setTitle(request.getWindowTitle()); DiffUtil.initDiffFrame(diffPanel.getProject(), frameWrapper, diffPanel, diffPanel.getComponent()); new AnAction() { public void actionPerformed(final AnActionEvent e) { frameWrapper.getFrame().dispose(); } }.registerCustomShortcutSet( new CustomShortcutSet( KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent()); frameWrapper.show(); } }
From source file:io.github.holgerbrandl.send2terminal.connectors.AppleScriptConnector.java
License:BSD License
private static void submitCodeInternal(String codeSelection, boolean switchFocusToTerminal, @Nullable FileType fileType) {/* w w w . j a va 2 s . com*/ try { if (Utils.isMacOSX()) { Runtime runtime = Runtime.getRuntime(); boolean isKotlin = fileType != null && fileType.getName().toLowerCase().equals("kotlin"); boolean pasteModeRequired = isKotlin && Arrays.stream(codeSelection.split("\\r?\\n")).map(String::trim).anyMatch(s -> //is chained call or javadoc s.startsWith(".") || s.startsWith("*")); if (pasteModeRequired && !S2TSettings.getInstance().usePasteMode) { DialogBuilder builder = new DialogBuilder(); JLabel jLabel = new JLabel( "<html>Can not send multi-line expression to terminal. <br>Please vote for <a href='https://youtrack.jetbrains.net/issue/KT-13319'>KT-13319</a> to push for a REPL paste-mode.<br>Alternatively you could use kshell from <a href='https://github.com/khud/sparklin'>https://github.com/khud/sparklin</a> and enable the paste mode support in the preferences of this plugin</html>"); builder.centerPanel(jLabel); // builder.setDimensionServiceKey("GrepConsoleSound"); builder.setTitle("Multi-line Expression Error"); builder.removeAllActions(); builder.addOkAction(); // builder.addCancelAction(); builder.show(); return; } boolean usePasteMode = S2TSettings.getInstance().usePasteMode && isKotlin; // just use paste mode if any line starts with a dot usePasteMode = usePasteMode && pasteModeRequired; if (usePasteMode) { codeSelection = ":paste\n" + codeSelection; } String dquotesExpandedText = codeSelection.replace("\\", "\\\\"); dquotesExpandedText = dquotesExpandedText.replace("\"", "\\\""); // trim to remove tailing newline for blocks and especially line evaluation dquotesExpandedText = dquotesExpandedText.trim(); String evalTarget = S2TSettings.getInstance().codeSnippetEvalTarget; // String evalTarget = "R64"; // http://stackoverflow.com/questions/1870270/sending-commands-and-strings-to-terminal-app-with-applescript String evalSelection; if (evalTarget.equals("Terminal")) { // if (codeSelection.length() > 1000) { // DialogBuilder db = new DialogBuilder(); // db.setTitle("Operation canceled: "); // db.setCenterPanel(new JLabel("Can't paste more that 1024 characters to MacOS terminal.")); // db.addOkAction(); // db.show(); // // return; // } evalSelection = "tell application \"" + "Terminal" + "\" to do script \"" + dquotesExpandedText + "\" in window 0"; if (switchFocusToTerminal) { evalSelection = "tell application \"Terminal\" to activate\n" + evalSelection; } if (usePasteMode) { // https://stackoverflow.com/questions/3690167/how-can-one-invoke-a-keyboard-shortcut-from-within-an-applescript evalSelection = evalSelection + "\n" + "tell application \"System Events\"\n" + // " set currentApplication to name of 1st process whose frontmost is true\n" + // " set currentApplication to process appName\n" + " set currentApplication to path to frontmost application as text\n" + "end tell" + "\n" + // "delay 1\n" + "activate application \"Terminal\"\n" + "tell application \"System Events\"\n" + " keystroke \"d\" using {control down}\n" + "end tell\n" + "\n" + "activate application currentApplication\n"; // "activate \"Intellij IDEA\""; } } else if (evalTarget.equals("iTerm")) { evalSelection = "tell application \"iTerm\" to tell current session of current terminal to write text \"" + dquotesExpandedText + "\""; if (switchFocusToTerminal) { evalSelection = "tell application \"iTerm\" to activate\n" + evalSelection; } } else { if (switchFocusToTerminal) { evalSelection = "tell application \"" + evalTarget + "\" to activate\n" + "tell application \"" + evalTarget + "\" to cmd \"" + dquotesExpandedText + "\""; } else { evalSelection = "tell application \"" + evalTarget + "\" to cmd \"" + dquotesExpandedText + "\""; } } String[] args = { "osascript", "-e", evalSelection }; runtime.exec(args); } } catch (IOException e1) { ConnectorUtils.log.error(e1); } }
From source file:org.cordovastudio.editors.designer.propertyTable.properties.IdProperty.java
License:Apache License
@Override public void setValue(@NotNull final RadViewComponent component, final Object value) throws Exception { final String newId = value != null ? value.toString() : ""; IdManager idManager = IdManager.get(component); final String oldId = component.getId(); if (ourRefactoringChoice != REFACTOR_NO && oldId != null && !oldId.isEmpty() && !newId.isEmpty() && !oldId.equals(newId) && component.getTag().isValid()) { // Offer rename refactoring? XmlTag tag = component.getTag(); XmlAttribute attribute = tag.getAttribute(ATTR_ID, CORDOVASTUDIO_URI); if (attribute != null) { Module module = RadModelBuilder.getModule(component); if (module != null) { XmlAttributeValue valueElement = attribute.getValueElement(); if (valueElement != null && valueElement.isValid()) { final Project project = module.getProject(); // Exact replace only, no comment/text occurrence changes since it is non-interactive RenameProcessor processor = new RenameProcessor(project, valueElement, newId, false /*comments*/, false /*text*/); processor.setPreviewUsages(false); // Do a quick usage search to see if we need to ask about renaming UsageInfo[] usages = processor.findUsages(); if (usages.length > 0) { int choice = ourRefactoringChoice; if (choice == REFACTOR_ASK) { DialogBuilder builder = new DialogBuilder(project); builder.setTitle("Update Usages?"); JPanel panel = new JPanel(new BorderLayout()); // UGH! JLabel label = new JLabel("<html>" + "Update usages as well?<br>" + "This will update all XML references and Java R field references.<br>" + "<br>" + "</html>"); panel.add(label, BorderLayout.CENTER); JBCheckBox checkBox = new JBCheckBox("Don't ask again during this session"); panel.add(checkBox, BorderLayout.SOUTH); builder.setCenterPanel(panel); builder.setDimensionServiceKey("idPropertyDimension"); builder.removeAllActions(); DialogBuilder.CustomizableAction yesAction = builder.addOkAction(); yesAction.setText(Messages.YES_BUTTON); builder.addActionDescriptor(new DialogBuilder.ActionDescriptor() { @Override public Action getAction(final DialogWrapper dialogWrapper) { return new AbstractAction(Messages.NO_BUTTON) { @Override public void actionPerformed(ActionEvent actionEvent) { dialogWrapper.close(DialogWrapper.NEXT_USER_EXIT_CODE); } };//from w ww . j a v a 2 s .c om } }); builder.addCancelAction(); int exitCode = builder.show(); choice = exitCode == DialogWrapper.OK_EXIT_CODE ? REFACTOR_YES : exitCode == DialogWrapper.NEXT_USER_EXIT_CODE ? REFACTOR_NO : ourRefactoringChoice; if (!checkBox.isSelected()) { ourRefactoringChoice = REFACTOR_ASK; } else { ourRefactoringChoice = choice; } if (exitCode == DialogWrapper.CANCEL_EXIT_CODE) { return; } } if (choice == REFACTOR_YES) { processor.run(); // Fall through to also set the value in the layout editor property; otherwise we'll be out of sync } } } } } } if (idManager != null) { idManager.removeComponent(component, false); } //noinspection ConstantConditions super.setValue(component, value); if (idManager != null) { idManager.addComponent(component); } }
From source file:org.jetbrains.idea.svn.integrate.QuickMergeInteractionImpl.java
License:Apache License
@Override public QuickMergeContentsVariants selectMergeVariant() { final QuickMergeWayOptionsPanel panel = new QuickMergeWayOptionsPanel(); final DialogBuilder builder = new DialogBuilder(myProject); builder.removeAllActions(); builder.setTitle("Select Merge Variant"); builder.setCenterPanel(panel.getMainPanel()); panel.setWrapper(builder.getDialogWrapper()); builder.show();//from w ww. ja v a 2 s . co m return panel.getVariant(); }
From source file:org.moe.designer.propertyTable.IdProperty.java
License:Apache License
@Override public void setValue(@NotNull final RadViewComponent component, final Object value) throws Exception { final String newId = value != null ? value.toString() : ""; final String oldId = component.getId(); if (ourRefactoringChoice != REFACTOR_NO && oldId != null && !oldId.isEmpty() && !newId.isEmpty() && !oldId.equals(newId) && component.getTag().isValid()) { // Offer rename refactoring? XmlTag tag = component.getTag(); XmlAttribute attribute = tag.getAttribute(SdkConstants.ATTR_ID, SdkConstants.ANDROID_URI); if (attribute != null) { Module module = RadModelBuilder.getModule(component); if (module != null) { XmlAttributeValue valueElement = attribute.getValueElement(); if (valueElement != null && valueElement.isValid()) { final Project project = module.getProject(); // Exact replace only, no comment/text occurrence changes since it is non-interactive RenameProcessor processor = new RenameProcessor(project, valueElement, newId, false /*comments*/, false /*text*/); processor.setPreviewUsages(false); // Do a quick usage search to see if we need to ask about renaming UsageInfo[] usages = processor.findUsages(); if (usages.length > 0) { int choice = ourRefactoringChoice; if (choice == REFACTOR_ASK) { DialogBuilder builder = new DialogBuilder(project); builder.setTitle("Update Usages?"); JPanel panel = new JPanel(new BorderLayout()); // UGH! JLabel label = new JLabel("<html>" + "Update usages as well?<br>" + "This will update all XML references and Java R field references.<br>" + "<br>" + "</html>"); panel.add(label, BorderLayout.CENTER); JBCheckBox checkBox = new JBCheckBox("Don't ask again during this session"); panel.add(checkBox, BorderLayout.SOUTH); builder.setCenterPanel(panel); builder.setDimensionServiceKey("idPropertyDimension"); builder.removeAllActions(); DialogBuilder.CustomizableAction yesAction = builder.addOkAction(); yesAction.setText(Messages.YES_BUTTON); builder.addActionDescriptor(new DialogBuilder.ActionDescriptor() { @Override public Action getAction(final DialogWrapper dialogWrapper) { return new AbstractAction(Messages.NO_BUTTON) { @Override public void actionPerformed(ActionEvent actionEvent) { dialogWrapper.close(DialogWrapper.NEXT_USER_EXIT_CODE); } };/*from ww w . j ava 2s. c om*/ } }); builder.addCancelAction(); int exitCode = builder.show(); choice = exitCode == DialogWrapper.OK_EXIT_CODE ? REFACTOR_YES : exitCode == DialogWrapper.NEXT_USER_EXIT_CODE ? REFACTOR_NO : ourRefactoringChoice; if (!checkBox.isSelected()) { ourRefactoringChoice = REFACTOR_ASK; } else { ourRefactoringChoice = choice; } if (exitCode == DialogWrapper.CANCEL_EXIT_CODE) { return; } } if (choice == REFACTOR_YES) { processor.run(); // Fall through to also set the value in the layout editor property; otherwise we'll be out of sync } } } } } } //noinspection ConstantConditions super.setValue(component, value); }
From source file:org.napile.idea.thermit.config.impl.configuration.BuildFilePropertiesPanel.java
License:Apache License
private boolean showDialog() { DialogBuilder builder = new DialogBuilder(myBuildFile.getProject()); builder.setCenterPanel(myForm.myWholePanel); builder.setDimensionServiceKey(DIMENSION_SERVICE_KEY); builder.setPreferedFocusComponent(myForm.getPreferedFocusComponent()); builder.setTitle(ThermitBundle.message("build.file.properties.dialog.title")); builder.removeAllActions(); builder.addOkAction();/*from w w w. j ava 2s .c o m*/ builder.addCancelAction(); builder.setHelpId("reference.dialogs.buildfileproperties"); boolean isOk = builder.show() == DialogWrapper.OK_EXIT_CODE; if (isOk) { apply(); } beforeClose(); return isOk; }