List of usage examples for com.intellij.openapi.ui Messages showOkCancelDialog
@OkCancelResult @Deprecated public static int showOkCancelDialog(String message, @Nls(capitalization = Nls.Capitalization.Title) String title, Icon icon)
From source file:com.ritesh.idea.plugin.ui.toolswindow.reviewpanel.ReviewPanelController.java
License:Apache License
public boolean confirmReviewPublish() { return Messages.showOkCancelDialog("Do you want to discard your review?", "Confirmation", AllIcons.General.BalloonWarning) != Messages.OK; }
From source file:nieldw.plugins.idea.ImportSettings.java
License:Apache License
public static void doImport(String path) { File saveFile = new File(path); try {/*from w ww .j a v a 2 s . c o m*/ if (!saveFile.exists()) { Messages.showErrorDialog(IdeBundle.message("error.cannot.find.file", presentableFileName(saveFile)), IdeBundle.message("title.file.not.found")); return; } ZipEntry magicEntry = new ZipFile(saveFile).getEntry("IntelliJ IDEA Global Settings"); if (magicEntry == null) { Messages.showErrorDialog( IdeBundle.message("error.file.contains.no.settings.to.import", presentableFileName(saveFile), promptLocationMessage()), IdeBundle.message("title.invalid.file")); return; } ArrayList<ExportableComponent> registeredComponents = new ArrayList<ExportableComponent>(); Map<File, Set<ExportableComponent>> filesToComponents = ExportSettingsAction .getRegisteredComponentsAndFiles(registeredComponents); List<ExportableComponent> components = getComponentsStored(saveFile, registeredComponents); ChooseComponentsToImportDialog dialog = new ChooseComponentsToImportDialog(components, filesToComponents, IdeBundle.message("title.select.components.to.import"), IdeBundle.message("prompt.check.components.to.import")); dialog.show(); if (!dialog.isOK()) return; Set<ExportableComponent> chosenComponents = dialog.getExportableComponents(); Set<String> relativeNamesToExtract = new HashSet<String>(); for (ExportableComponent chosenComponent : chosenComponents) { File[] exportFiles = chosenComponent.getExportFiles(); for (File exportFile : exportFiles) { File configPath = new File(PathManager.getConfigPath()); String rPath = FileUtil.getRelativePath(configPath, exportFile); assert rPath != null; String relativePath = FileUtil.toSystemIndependentName(rPath); relativeNamesToExtract.add(relativePath); } } relativeNamesToExtract.add(PluginManager.INSTALLED_TXT); File tempFile = new File(PathManager.getPluginTempPath() + "/" + saveFile.getName()); FileUtil.copy(saveFile, tempFile); File outDir = new File(PathManager.getConfigPath()); ImportSettingsFilenameFilter filenameFilter = new ImportSettingsFilenameFilter(relativeNamesToExtract); StartupActionScriptManager.ActionCommand unzip = new StartupActionScriptManager.UnzipCommand(tempFile, outDir, filenameFilter); StartupActionScriptManager.addActionCommand(unzip); // remove temp file StartupActionScriptManager.ActionCommand deleteTemp = new StartupActionScriptManager.DeleteCommand( tempFile); StartupActionScriptManager.addActionCommand(deleteTemp); UpdateSettings.getInstance().forceCheckForUpdateAfterRestart(); String key = ApplicationManager.getApplication().isRestartCapable() ? "message.settings.imported.successfully.restart" : "message.settings.imported.successfully"; int ret = Messages.showOkCancelDialog( IdeBundle.message(key, ApplicationNamesInfo.getInstance().getProductName(), ApplicationNamesInfo.getInstance().getFullProductName()), IdeBundle.message("title.restart.needed"), Messages.getQuestionIcon()); if (ret == Messages.OK) { ((ApplicationEx) ApplicationManager.getApplication()).restart(true); } } catch (ZipException e1) { Messages.showErrorDialog(IdeBundle.message("error.reading.settings.file", presentableFileName(saveFile), e1.getMessage(), promptLocationMessage()), IdeBundle.message("title.invalid.file")); } catch (IOException e1) { Messages.showErrorDialog(IdeBundle.message("error.reading.settings.file.2", presentableFileName(saveFile), e1.getMessage()), IdeBundle.message("title.error.reading.file")); } }
From source file:org.jetbrains.idea.svn.integrate.IntegratedSelectedOptionsDialog.java
License:Apache License
public IntegratedSelectedOptionsDialog(final Project project, final SVNURL currentBranch, final String selectedBranchUrl) { super(project, true); myMustSelectBeforeOk = true;//from w w w . j a v a2s .c om myProject = project; mySelectedBranchUrl = selectedBranchUrl; myVcs = SvnVcs.getInstance(myProject); mySelectedRepositoryUUID = SvnUtil.getRepositoryUUID(myVcs, currentBranch); setTitle(SvnBundle.message("action.Subversion.integrate.changes.dialog.title")); init(); myWorkingCopiesList.setModel(new DefaultListModel()); myWorkingCopiesList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { setOKActionEnabled((!myMustSelectBeforeOk) || (myWorkingCopiesList.getSelectedIndex() != -1)); } }); setOKActionEnabled((!myMustSelectBeforeOk) || (myWorkingCopiesList.getSelectedIndex() != -1)); final List<WorkingCopyInfo> workingCopyInfoList = new ArrayList<WorkingCopyInfo>(); final Set<String> workingCopies = SvnBranchMapperManager.getInstance().get(mySelectedBranchUrl); if (workingCopies != null) { for (String workingCopy : workingCopies) { workingCopyInfoList.add(new WorkingCopyInfo(workingCopy, underProject(new File(workingCopy)))); } } Collections.sort(workingCopyInfoList, WorkingCopyInfoComparator.getInstance()); for (WorkingCopyInfo info : workingCopyInfoList) { ((DefaultListModel) myWorkingCopiesList.getModel()).addElement(info); } if (!workingCopyInfoList.isEmpty()) { myWorkingCopiesList.setSelectedIndex(0); } SvnConfiguration svnConfig = SvnConfiguration.getInstance(myVcs.getProject()); myDryRunCheckbox.setSelected(svnConfig.isMergeDryRun()); myIgnoreWhitespacesCheckBox.setSelected(svnConfig.isIgnoreSpacesInMerge()); mySourceInfoLabel.setText(SvnBundle .message("action.Subversion.integrate.changes.branch.info.source.label.text", currentBranch)); myTargetInfoLabel.setText(SvnBundle .message("action.Subversion.integrate.changes.branch.info.target.label.text", selectedBranchUrl)); final String addText = SvnBundle.message("action.Subversion.integrate.changes.dialog.add.wc.text"); final AnAction addAction = new AnAction(addText, addText, IconUtil.getAddIcon()) { { registerCustomShortcutSet(CommonShortcuts.INSERT, myWorkingCopiesList); } public void actionPerformed(final AnActionEvent e) { final VirtualFile vFile = FileChooser .chooseFile(FileChooserDescriptorFactory.createSingleFolderDescriptor(), myProject, null); if (vFile != null) { final File file = new File(vFile.getPath()); if (hasDuplicate(file)) { return; // silently do not add duplicate } final String repositoryUUID = SvnUtil.getRepositoryUUID(myVcs, file); // local not consistent copy can not prevent us from integration: only remote local copy is really involved if ((mySelectedRepositoryUUID != null) && (!mySelectedRepositoryUUID.equals(repositoryUUID))) { if (Messages.OK == Messages.showOkCancelDialog((repositoryUUID == null) ? SvnBundle.message( "action.Subversion.integrate.changes.message.not.under.control.text") : SvnBundle.message("action.Subversion.integrate.changes.message.another.wc.text"), getTitle(), UIUtil.getWarningIcon())) { onOkToAdd(file); } } else { onOkToAdd(file); } } } }; myGroup.add(addAction); final String removeText = SvnBundle.message("action.Subversion.integrate.changes.dialog.remove.wc.text"); myGroup.add(new AnAction(removeText, removeText, PlatformIcons.DELETE_ICON) { { registerCustomShortcutSet(CommonShortcuts.getDelete(), myWorkingCopiesList); } public void update(final AnActionEvent e) { final Presentation presentation = e.getPresentation(); final int idx = (myWorkingCopiesList == null) ? -1 : myWorkingCopiesList.getSelectedIndex(); presentation.setEnabled(idx != -1); } public void actionPerformed(final AnActionEvent e) { final int idx = myWorkingCopiesList.getSelectedIndex(); if (idx != -1) { final DefaultListModel model = (DefaultListModel) myWorkingCopiesList.getModel(); final WorkingCopyInfo info = (WorkingCopyInfo) model.get(idx); model.removeElementAt(idx); SvnBranchMapperManager.getInstance().remove(mySelectedBranchUrl, new File(info.getLocalPath())); } } }); }
From source file:org.jetbrains.plugins.groovy.config.GroovyConfigUtils.java
License:Apache License
public boolean tryToSetUpGroovyFacetOnTheFly(final Module module) { final Project project = module.getProject(); final Library[] libraries = getAllSDKLibraries(project); if (libraries.length > 0) { final Library library = libraries[0]; int result = Messages.showOkCancelDialog( GroovyBundle.message("groovy.like.library.found.text", module.getName(), library.getName(), getSDKLibVersion(library)), GroovyBundle.message("groovy.like.library.found"), JetgroovyIcons.Groovy.Groovy_32x32); if (result == 0) { AccessToken accessToken = WriteAction.start(); try { ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel(); LibraryOrderEntry entry = model.addLibraryEntry(libraries[0]); LibrariesUtil.placeEntryToCorrectPlace(model, entry); model.commit();/*from w w w . ja v a 2 s .co m*/ return true; } finally { accessToken.finish(); } } } return false; }
From source file:org.jetbrains.plugins.groovy.gant.GantRunner.java
License:Apache License
@Override public boolean ensureRunnerConfigured(@Nullable Module module, RunProfile profile, Executor executor, final Project project) { if (!(GantUtils.getSDKInstallPath(module, project).length() > 0)) { int result = Messages.showOkCancelDialog("Gant is not configured. Do you want to configure it?", "Configure Gant SDK", JetgroovyIcons.Groovy.Gant_16x16); if (result == 0) { ShowSettingsUtil.getInstance().editConfigurable(project, new GantConfigurable(project)); }//from www . j a v a2 s . c o m if (!(GantUtils.getSDKInstallPath(module, project).length() > 0)) { return false; } } return true; }
From source file:org.onehippo.intellij.groovy.actions.ScheduleFileAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent event) { final Project project = event.getData(CommonDataKeys.PROJECT); if (project == null) { return;/* w ww . j ava 2s . c o m*/ } final GroovySessionComponent sessionComponent = project.getComponent(GroovySessionComponent.class); final FileEditorManager editorManager = FileEditorManager.getInstance(project); final Editor selectedTextEditor = editorManager.getSelectedTextEditor(); if (selectedTextEditor == null) { Util.showError(project, "No document selected"); return; } final Document document = selectedTextEditor.getDocument(); final VirtualFile currentFile = FileDocumentManager.getInstance().getFile(document); if (currentFile == null) { Util.showError(project, "No document selected"); return; } // check if groovy file final FileType fileType = currentFile.getFileType(); if (fileType != GroovyFileType.GROOVY_FILE_TYPE) { final int result = Messages.showOkCancelDialog( "File" + currentFile.getName() + " doesn't seems to be a groovy file", CommonBundle.getWarningTitle(), Messages.getWarningIcon()); if (result != 0) { return; } } FileDialogData existingData = new FileDialogData(); final SessionState state = sessionComponent.getState(); if (state != null) { final Map<String, FileDialogData> items = state.getItems(); final FileDialogData dialogData = items.get(currentFile.getCanonicalPath()); if (dialogData != null) { existingData = dialogData; } } final String content = selectedTextEditor.getDocument().getText(); final ScheduleDialog dialog = new ScheduleDialog(project, existingData); existingData.setContent(content); dialog.setTitle("Groovy Script Settings"); dialog.show(); switch (dialog.getExitCode()) { case DialogWrapper.OK_EXIT_CODE: processFile(dialog.getData(), sessionComponent, project); break; case DialogWrapper.CANCEL_EXIT_CODE: Util.showMessage(project, "File not saved"); break; } }
From source file:view.PluginViewFactory.java
License:Apache License
private void viewComponentInit() { TableCellEditor editor = new DefaultCellEditor(mPropNameComboBox); mPropTable.setRowHeight(30);/*from w w w.j ava2 s .co m*/ mPropTable.setModel(new PropertyTableModel()); mPropTable.setAutoscrolls(true); mPropTable.getColumnModel().getColumn(COLUMN_PROPERTY_NAME).setCellEditor(editor); mPropTable.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent tableModelEvent) { if (mIsUpdateDone == false) return; int row = tableModelEvent.getFirstRow(); int col = tableModelEvent.getColumn(); String name = mPropTable.getValueAt(row, COLUMN_PROPERTY_NAME).toString(); if (col == COLUMN_PROPERTY_NAME) { cellChangeToCurrentValueAtRow(row); } else if (col == COLUMN_PROPERTY_VALUE) { Property property = mDeviceManager.getProperty(name); Object valueObject = mPropTable.getValueAt(row, COLUMN_PROPERTY_VALUE); if (valueObject == null) { return; } else if ("".equals(name)) { mPropTable.setValueAt(null, row, COLUMN_PROPERTY_VALUE); return; } String value = valueObject.toString(); if (property != null) { if (!value.equals(mDeviceManager.getProperty(name))) { try { mDeviceManager.setPropertyValue(name, value); saveTable(); } catch (NullValueException e) { cellChangeToCurrentValueAtRow(row); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } } else if (value != null) { mDeviceManager.putProperty(name, new Property(name, value)); } } else { System.out.println("Error : Col Number Over"); } } }); mDeviceListComboBox.setPrototypeDisplayValue("XXXXXXXXXXXXX"); mDeviceListComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { if (ItemEvent.SELECTED == itemEvent.getStateChange()) { SelectedDeviceChanged(); } } }); mTableViewListComboBox.setPrototypeDisplayValue("XXXXXXXXXXXXX"); mTableViewListComboBox.setEditable(true); mTableViewListComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getStateChange() == ItemEvent.DESELECTED) return; String tableView = itemEvent.getItem().toString(); if (TABLE_VIEW_LIST_PROPERTY_NAME.equals(tableView)) { showMessage("Cannot use that table view name", "Error"); return; } updateTable(tableView); } }); mRefreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { mDeviceManager.updatePropFromDevice(); } }); final JFileChooser jFileChooser = new JFileChooser(); jFileChooser.setCurrentDirectory(new File(mProject.getBasePath())); jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); jFileChooser.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { File selectedFile = jFileChooser.getSelectedFile(); if (selectedFile == null) return; mIsChosenFileExist = selectedFile.exists(); mIsChosenFileWritable = selectedFile.getParentFile().canWrite(); } }); mSavePropFileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (jFileChooser.showSaveDialog(mPluginViewContent) == JFileChooser.CANCEL_OPTION) return; if (!mIsChosenFileWritable) { showMessage("Please choose writable path.", "Android Property Manager"); return; } else if (mIsChosenFileExist) { if (Messages.showOkCancelDialog("Overwrite file?", "Android Property Manager", Messages.getInformationIcon()) != Messages.OK) { return; } } String[] values = mPropertiesComponent .getValues(mTableViewListComboBox.getSelectedItem().toString()); ArrayList<String> propertyNames; if (ALL_TABLE_VIEW_PROPERTY_NAME == mTableViewListComboBox.getSelectedItem().toString()) { propertyNames = mDeviceManager.getPropertyNames(); } else { propertyNames = new ArrayList<>(Arrays.asList(values)); } mDeviceManager.savePropFile(jFileChooser.getSelectedFile().getPath(), propertyNames); } }); mLoadPropFileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (jFileChooser.showDialog(mPluginViewContent, "Choose") == JFileChooser.CANCEL_OPTION) return; if (mIsChosenFileExist) { mDeviceManager.loadPropFile(jFileChooser.getSelectedFile().getPath()); mDeviceManager.updatePropFromDevice(); } else { showMessage("Please select exist file.", "Android Property Manager"); } } }); mPushPropFileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (jFileChooser.showDialog(mPluginViewContent, "Choose") == JFileChooser.CANCEL_OPTION) return; if (mIsChosenFileExist) { String oldPropDirPath = mProject.getBasePath(); mDeviceManager.pushPropFile(jFileChooser.getSelectedFile().getPath(), oldPropDirPath); PluginViewFactory.getInstance() .setHint("Property file is saved at system/build.prop of device file system"); } else { showMessage("Please select exist file.", "Android Property Manager"); } } }); mRestartRuntimeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { try { PluginViewFactory.getInstance().setHint("Device is restarting runtime..."); mDeviceManager.restartRuntime(); } catch (TimeoutException e) { e.printStackTrace(); } catch (AdbCommandRejectedException e) { e.printStackTrace(); } catch (ShellCommandUnresponsiveException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }); mRebootDeviceButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { try { PluginViewFactory.getInstance().setHint("Device is rebooting..., so now it is offline state"); mDeviceManager.rebootDevice(); } catch (TimeoutException e) { e.printStackTrace(); } catch (AdbCommandRejectedException e) { e.printStackTrace(); } catch (ShellCommandUnresponsiveException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }); }