List of usage examples for com.intellij.openapi.ui DialogBuilder setPreferredFocusComponent
public void setPreferredFocusComponent(JComponent component)
From source file:com.android.tools.idea.apk.viewer.ApkEditor.java
License:Apache License
@Override public void selectApkAndCompare() { FileChooserDescriptor desc = new FileChooserDescriptor(true, false, false, false, false, false); desc.withFileFilter(file -> ApkFileSystem.EXTENSIONS.contains(file.getExtension())); VirtualFile file = FileChooser.chooseFile(desc, myProject, null); if (file == null) { // user canceled return;/* w ww . j a v a 2 s. c o m*/ } VirtualFile newApk = ApkFileSystem.getInstance().getRootByLocal(file); assert newApk != null; DialogBuilder builder = new DialogBuilder(myProject); builder.setTitle(myRoot.getName() + " vs " + newApk.getName()); ApkDiffParser parser = new ApkDiffParser(myRoot, newApk); ApkDiffPanel panel = new ApkDiffPanel(parser); builder.setCenterPanel(panel.getContainer()); builder.setPreferredFocusComponent(panel.getPreferredFocusedComponent()); builder.show(); }
From source file:com.intellij.history.integration.ui.views.HistoryDialog.java
License:Apache License
private boolean showAsDialog(CreatePatchConfigurationPanel p) { final DialogBuilder b = new DialogBuilder(myProject); JComponent createPatchPanel = p.getPanel(); b.setPreferredFocusComponent(IdeFocusTraversalPolicy.getPreferredFocusedComponent(createPatchPanel)); b.setTitle(message("create.patch.dialog.title")); b.setCenterPanel(createPatchPanel);/*ww w .j a va2 s . c o m*/ p.installOkEnabledListener(new Consumer<Boolean>() { public void consume(final Boolean aBoolean) { b.setOkActionEnabled(aBoolean); } }); return b.show() == DialogWrapper.OK_EXIT_CODE; }
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();//w ww . j a v a 2 s. 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; }
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)); }//from w w w . j a va 2 s. co m 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. j a v a 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.theoryinpractice.testng.configuration.browser.GroupList.java
License:Apache License
public static String showDialog(PsiClass[] classes, JComponent component) { GroupList groupList = new GroupList(classes); DialogBuilder builder = new DialogBuilder(component); builder.setCenterPanel(groupList);/*ww w . ja va 2s. c o m*/ builder.setPreferredFocusComponent(groupList.list); builder.setTitle("Choose Test Group"); return builder.show() != 0 ? null : groupList.getSelected(); }
From source file:com.theoryinpractice.testng.configuration.browser.MethodList.java
License:Apache License
public static PsiMethod showDialog(PsiClass psiClass, JComponent component) { MethodList list = new MethodList(psiClass); DialogBuilder builder = new DialogBuilder(component); builder.setCenterPanel(list);// w w w .j a v a 2 s . c om builder.setPreferredFocusComponent(list.list); builder.setTitle("Choose Test Method"); return builder.show() != 0 ? null : list.getSelected(); }
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 ww w. ja va2 s . co 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:consulo.devkit.module.library.ConsuloPluginLibraryType.java
License:Apache License
@Nullable @Override// w ww . jav a2 s . c o m public NewLibraryConfiguration createNewLibrary(@NotNull JComponent jComponent, @Nullable VirtualFile virtualFile, @NotNull Project project) { DialogBuilder builder = new DialogBuilder(); builder.title("Enter Plugin ID"); ChoosePluginPanel centerPanel = new ChoosePluginPanel(project); builder.centerPanel(centerPanel); builder.setPreferredFocusComponent(centerPanel.getTextField()); builder.dimensionKey("ConsuloPluginLibraryType#ChoosePluginPanel"); if (!builder.showAndGet()) { return null; } IdeaPluginDescriptor pluginDescriptor = centerPanel.getPluginDescriptor(); if (pluginDescriptor == null) { Messages.showErrorDialog(project, "Plugin is not found", ApplicationInfo.getInstance().getFullVersion()); return null; } Ref<VirtualFile> libRef = Ref.create(); String pluginId = pluginDescriptor.getPluginId().getIdString(); new Task.Modal(project, "Downloading plugin: " + pluginDescriptor.getPluginId().getIdString(), false) { @Override public void run(@NotNull ProgressIndicator progressIndicator) { String url = RepositoryHelper.buildUrlForDownload(UpdateSettings.getInstance().getChannel(), pluginId, null, true, false); try { File tempFile = FileUtil.createTempFile("download", "zip"); HttpRequests.request(url).saveToFile(tempFile, progressIndicator); File depDir = new File(project.getBasePath(), DEP_LIBRARY); depDir.mkdir(); ZipUtil.extract(tempFile, depDir, null); tempFile.delete(); libRef.set(LocalFileSystem.getInstance() .refreshAndFindFileByIoFile(new File(depDir, pluginId + "/lib"))); } catch (IOException e) { // } } }.queue(); VirtualFile libDirectory = libRef.get(); if (libDirectory == null) { Messages.showErrorDialog(project, "Plugin directory is not found", ApplicationInfo.getInstance().getFullVersion()); return null; } return new NewLibraryConfiguration(LIBRARY_PREFIX + pluginId, this, DummyLibraryProperties.INSTANCE) { @Override public void addRoots(@NotNull LibraryEditor libraryEditor) { for (VirtualFile file : libDirectory.getChildren()) { if (file.isDirectory()) { continue; } VirtualFile localVirtualFileByPath = ArchiveVfsUtil.getArchiveRootForLocalFile(file); if (localVirtualFileByPath == null) { continue; } libraryEditor.addRoot(localVirtualFileByPath, BinariesOrderRootType.getInstance()); } } }; }
From source file:manuylov.maxim.ocaml.toolWindow.OCamlToolWindowSettingsAction.java
License:Open Source License
public void showSettingsDialog() { final OCamlSettings settings = OCamlSettings.getInstance(myProject); final OCamlToolWindowSettingsForm settingsForm = new OCamlToolWindowSettingsForm(myProject); settingsForm.setSelectedSdk(settings.getTopLevelSdk()); settingsForm.setCmdParams(settings.getTopLevelCmdOptions()); settingsForm.setWorkingDirectory(settings.getTopLevelCmdWorkingDir()); final DialogBuilder dialogBuilder = new DialogBuilder(myProject); dialogBuilder.setCenterPanel(settingsForm.getRootPanel()); dialogBuilder.addOkAction().setText("Ok"); dialogBuilder.addCancelAction().setText("Cancel"); dialogBuilder.setPreferredFocusComponent(settingsForm.getSdkComboBox()); dialogBuilder.setTitle("OCaml Top Level Console Settings"); dialogBuilder.setOkOperation(new Runnable() { public void run() { settings.setTopLevelSdk(settingsForm.getSelectedSdk()); settings.setTopLevelCmdOptions(settingsForm.getCmdParams()); settings.setTopLevelCmdWorkingDir(settingsForm.getWorkingDirectory()); dialogBuilder.getWindow().setVisible(false); if (myAction != null) { myAction.run();/*from w ww . java2 s.c o m*/ } } }); dialogBuilder.show(); }