List of usage examples for com.intellij.openapi.ui DialogBuilder setDimensionServiceKey
public void setDimensionServiceKey(@NonNls String dimensionServiceKey)
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();//w w w. ja va 2s .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();/*from ww w . j ava2s. com*/ builder.addOkAction(); 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.intellij.packaging.impl.run.AbstractArtifactsBeforeRunTaskProvider.java
License:Apache License
@Override public boolean configureTask(RunConfiguration runConfiguration, T task) { final Artifact[] artifacts = ArtifactManager.getInstance(myProject).getArtifacts(); Set<ArtifactPointer> pointers = new THashSet<ArtifactPointer>(); for (Artifact artifact : artifacts) { pointers.add(ArtifactPointerUtil.getPointerManager(myProject).create(artifact)); }// w w w . j a v a 2 s. c om pointers.addAll(task.getArtifactPointers()); ArtifactChooser chooser = new ArtifactChooser(new ArrayList<ArtifactPointer>(pointers)); chooser.markElements(task.getArtifactPointers()); chooser.setPreferredSize(new Dimension(400, 300)); DialogBuilder builder = new DialogBuilder(myProject); builder.setTitle(CompilerBundle.message("build.artifacts.before.run.selector.title")); builder.setDimensionServiceKey("#BuildArtifactsBeforeRunChooser"); builder.addOkAction(); builder.addCancelAction(); builder.setCenterPanel(chooser); builder.setPreferredFocusComponent(chooser); if (builder.show() == DialogWrapper.OK_EXIT_CODE) { task.setArtifactPointers(chooser.getMarkedElements()); return true; } return false; }
From source file:com.intellij.util.xml.ui.TextControl.java
License:Apache License
@Override protected TextPanel createMainComponent(TextPanel boundedComponent, final Project project) { if (boundedComponent == null) { boundedComponent = new TextPanel(); }/*from w w w . ja va 2s.co m*/ boundedComponent.removeAll(); final Function<String, Document> factory = new Function<String, Document>() { @Override public Document fun(final String s) { return PsiDocumentManager.getInstance(project).getDocument(PsiFileFactory.getInstance(project) .createFileFromText("a.txt", PlainTextLanguage.INSTANCE, "", true, false)); } }; final TextPanel boundedComponent1 = boundedComponent; final EditorTextField editorTextField = new EditorTextField(factory.fun(""), project, PlainTextFileType.INSTANCE) { @Override protected EditorEx createEditor() { final EditorEx editor = super.createEditor(); return boundedComponent1 instanceof MultiLineTextPanel ? makeBigEditor(editor, ((MultiLineTextPanel) boundedComponent1).getRowCount()) : editor; } }; editorTextField.setOneLineMode(false); if (boundedComponent instanceof BigTextPanel) { final ReferenceEditorWithBrowseButton editor = new ReferenceEditorWithBrowseButton(null, editorTextField, factory); boundedComponent.add(editor); editor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EditorTextField textArea = new EditorTextField(editorTextField.getDocument(), project, PlainTextFileType.INSTANCE) { @Override protected EditorEx createEditor() { final EditorEx editor = super.createEditor(); editor.setEmbeddedIntoDialogWrapper(true); return makeBigEditor(editor, 5); } }; textArea.setOneLineMode(false); DialogBuilder builder = new DialogBuilder(project); builder.setDimensionServiceKey("TextControl"); builder.setCenterPanel(textArea); builder.setPreferredFocusComponent(textArea); builder.setTitle(UIBundle.message("big.text.control.window.title")); builder.addCloseButton(); builder.show(); } }); return boundedComponent; } boundedComponent.add(editorTextField); return boundedComponent; }
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);/*from w ww .j a v a 2s . 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: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 w w.ja v a 2 s. co m*/ } }); 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.intellij.plugins.intelliLang.inject.AbstractLanguageInjectionSupport.java
License:Apache License
@Nullable protected static BaseInjection showDefaultInjectionUI(final Project project, BaseInjection injection) { final BaseInjectionPanel panel = new BaseInjectionPanel(injection, project); panel.reset();//from w w w .ja v a 2 s . c o m final DialogBuilder builder = new DialogBuilder(project); LanguageInjectionSupport support = InjectorUtils.findInjectionSupport(injection.getSupportId()); if (support != null && support instanceof AbstractLanguageInjectionSupport) { builder.setHelpId(((AbstractLanguageInjectionSupport) support).getHelpId()); } builder.addOkAction(); builder.addCancelAction(); builder.setDimensionServiceKey("#org.intellij.plugins.intelliLang.inject.config.ui.BaseInjectionDialog"); builder.setCenterPanel(panel.getComponent()); builder.setTitle(EditInjectionSettingsAction.EDIT_INJECTION_TITLE); builder.setOkOperation(new Runnable() { public void run() { try { panel.apply(); builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE); } catch (Exception e) { final Throwable cause = e.getCause(); final String message = e.getMessage() + (cause != null ? "\n " + cause.getMessage() : ""); Messages.showErrorDialog(project, message, "Unable to Save"); } } }); if (builder.show() == DialogWrapper.OK_EXIT_CODE) { return injection; } return null; }
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); } };/* ww w .j a va2 s. com*/ } }); 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();/* ww w . j av a 2s.c o m*/ builder.addOkAction(); builder.addCancelAction(); builder.setHelpId("reference.dialogs.buildfileproperties"); boolean isOk = builder.show() == DialogWrapper.OK_EXIT_CODE; if (isOk) { apply(); } beforeClose(); return isOk; }