List of usage examples for com.intellij.openapi.ui Messages showDialog
public static int showDialog(String message, @Nls(capitalization = Nls.Capitalization.Title) String title, String @NotNull [] options, int defaultOptionIndex, @Nullable Icon icon)
From source file:com.android.tools.idea.avdmanager.AccelerationErrorSolution.java
License:Apache License
private Runnable getAction() { switch (myError.getSolution()) { case DOWNLOAD_EMULATOR: case UPDATE_EMULATOR: return new Runnable() { @Override//from w w w. ja v a 2 s.com public void run() { try { showQuickFix(ImmutableList.of(SdkConstants.FD_TOOLS, SdkConstants.FD_PLATFORM_TOOLS)); } finally { reportBack(); } } }; case UPDATE_PLATFORM_TOOLS: return new Runnable() { @Override public void run() { try { showQuickFix(ImmutableList.of(SdkConstants.FD_PLATFORM_TOOLS)); } finally { reportBack(); } } }; case UPDATE_SYSTEM_IMAGES: return new Runnable() { @Override public void run() { try { AvdManagerConnection avdManager = AvdManagerConnection.getDefaultAvdManagerConnection(); showQuickFix(avdManager.getSystemImageUpdates()); } finally { reportBack(); } } }; case INSTALL_KVM: return new Runnable() { @Override public void run() { try { GeneralCommandLine install = createKvmInstallCommand(); if (install == null) { BrowserUtil.browse(KVM_INSTRUCTIONS, myProject); } else { String text = String.format( "Linux systems vary a great deal; the installation steps we will attempt may not work in your particular scenario.\n\n" + "The steps are:\n\n" + " %1$s\n\n" + "If you prefer, you can skip this step and perform the KVM installation steps on your own.\n\n" + "There might be more details at: %2$s\n", install.getCommandLineString(), KVM_INSTRUCTIONS); int response = Messages.showDialog(text, myError.getSolution().getDescription(), new String[] { "Skip", "Proceed" }, 1, Messages.getQuestionIcon()); if (response == 1) { try { execute(install); myChangesMade = true; } catch (ExecutionException ex) { LOG.error(ex); BrowserUtil.browse(KVM_INSTRUCTIONS, myProject); Messages.showWarningDialog(myProject, "Please install KVM on your own", "Installation Failed"); } } else { BrowserUtil.browse(KVM_INSTRUCTIONS, myProject); } } } finally { reportBack(); } } }; case INSTALL_HAXM: case REINSTALL_HAXM: return new Runnable() { @Override public void run() { try { HaxmWizard wizard = new HaxmWizard(false); wizard.init(); myChangesMade = wizard.showAndGet(); } finally { reportBack(); } } }; case TURNOFF_HYPER_V: return new Runnable() { @Override public void run() { try { GeneralCommandLine turnHyperVOff = new ElevatedCommandLine(); turnHyperVOff.setExePath("bcdedit"); turnHyperVOff.addParameters("/set", "hypervisorlaunchtype", "off"); turnHyperVOff.setWorkDirectory(FileUtilRt.getTempDirectory()); try { execute(turnHyperVOff); promptAndReboot(SOLUTION_REBOOT_AFTER_TURNING_HYPER_V_OFF); } catch (ExecutionException ex) { LOG.error(ex); Messages.showWarningDialog(myProject, SOLUTION_TURN_OFF_HYPER_V, "Operation Failed"); } } finally { reportBack(); } } }; default: return new Runnable() { @Override public void run() { try { Messages.showWarningDialog(myProject, myError.getSolutionMessage(), myError.getSolution().getDescription()); } finally { reportBack(); } } }; } }
From source file:com.android.tools.idea.startup.AndroidStudioInitializer.java
License:Apache License
private static void checkInstallation() { String studioHome = PathManager.getHomePath(); if (isEmpty(studioHome)) { LOG.info("Unable to find Studio home directory"); return;/* w w w . j ava 2s.c o m*/ } File studioHomePath = new File(toSystemDependentName(studioHome)); if (!studioHomePath.isDirectory()) { LOG.info(String.format("The path '%1$s' does not belong to an existing directory", studioHomePath.getPath())); return; } File androidPluginLibFolderPath = new File(studioHomePath, join("plugins", "android", "lib")); if (!androidPluginLibFolderPath.isDirectory()) { LOG.info(String.format("The path '%1$s' does not belong to an existing directory", androidPluginLibFolderPath.getPath())); return; } // Look for signs that the installation is corrupt due to improper updates (typically unzipping on top of previous install) // which doesn't delete files that have been removed or renamed String cause = null; File[] children = notNullize(androidPluginLibFolderPath.listFiles()); if (hasMoreThanOneBuilderModelFile(children)) { cause = "(Found multiple versions of builder-model-*.jar in plugins/android/lib.)"; } else if (new File(studioHomePath, join("plugins", "android-designer")).exists()) { cause = "(Found plugins/android-designer which should not be present.)"; } if (cause != null) { String msg = "Your Android Studio installation is corrupt and will not work properly.\n" + cause + "\n" + "This usually happens if Android Studio is extracted into an existing older version.\n\n" + "Please reinstall (and make sure the new installation directory is empty first.)"; String title = "Corrupt Installation"; int option = Messages.showDialog(msg, title, new String[] { "Quit", "Proceed Anyway" }, 0, Messages.getErrorIcon()); if (option == 0) { ApplicationManagerEx.getApplicationEx().exit(); } } }
From source file:com.contentful.ideagenerator.forms.GeneratorDialog.java
License:Apache License
private void showErrorDialog(RetrofitError e) { String title = "Error while logging into space"; String message;/*from w w w . j ava2 s . c o m*/ if (e.getKind() == RetrofitError.Kind.NETWORK) { message = "Please check your network connection and try again."; } else { message = e.getMessage(); if (message == null) { message = "Status code: " + e.getResponse().getStatus(); } } Messages.showDialog(title, message, new String[] { "OK" }, 0, null); }
From source file:com.google.cloud.tools.intellij.debugger.ProjectRepositoryValidator.java
License:Apache License
private void unstash(final @NotNull Project project, @NotNull final Ref<StashInfo> targetStash, @NotNull final VirtualFile root) { if (repoState.getSourceRepository() == null || repoState.getOriginalBranchName() == null || (!repoState.getOriginalBranchName() .equals(repoState.getSourceRepository().getCurrentBranchName()) && !repoState.getOriginalBranchName() .equals(repoState.getSourceRepository().getCurrentRevision()))) { Messages.showErrorDialog(//w w w . jav a 2 s . c om GctBundle.getString("clouddebug.erroroncheckout", repoState.getOriginalBranchName()), "Error"); return; } final GitLineHandler handler = new GitLineHandler(project, root, GitCommand.STASH); handler.addParameters("apply"); handler.addParameters("--index"); addStashParameter(project, handler, targetStash.get().getStash()); final AtomicBoolean conflict = new AtomicBoolean(); handler.addLineListener(new GitLineHandlerAdapter() { @Override public void onLineAvailable(String line, Key outputType) { if (line.contains("Merge conflict")) { conflict.set(true); } } }); GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector( root); GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = new GitLocalChangesWouldBeOverwrittenDetector( root, MERGE); handler.addLineListener(untrackedFilesDetector); handler.addLineListener(localChangesDetector); AccessToken token = DvcsUtil.workingTreeChangeStarted(project); try { final Ref<GitCommandResult> result = Ref.create(); ProgressManager.getInstance() .run(new Task.Modal(handler.project(), GitBundle.getString("unstash.unstashing"), false) { @Override public void run(@NotNull final ProgressIndicator indicator) { indicator.setIndeterminate(true); handler.addLineListener(new GitHandlerUtil.GitLineHandlerListenerProgress(indicator, handler, "stash", false)); Git git = ServiceManager.getService(Git.class); result.set(git .runCommand(new Computable.PredefinedValueComputable<GitLineHandler>(handler))); } }); ServiceManager.getService(project, GitPlatformFacade.class).hardRefresh(root); GitCommandResult res = result.get(); if (conflict.get()) { Messages.showDialog(GctBundle.getString("clouddebug.unstashmergeconflicts"), "Merge Conflicts", new String[] { "Ok" }, 0, Messages.getErrorIcon()); } else if (untrackedFilesDetector.wasMessageDetected()) { GitUntrackedFilesHelper.notifyUntrackedFilesOverwrittenBy(project, root, untrackedFilesDetector.getRelativeFilePaths(), "unstash", null); } else if (localChangesDetector.wasMessageDetected()) { LocalChangesWouldBeOverwrittenHelper.showErrorDialog(project, root, "unstash", localChangesDetector.getRelativeFilePaths()); } else if (!res.success()) { GitUIUtil.showOperationErrors(project, handler.errors(), handler.printableCommandLine()); } else if (res.success()) { ProgressManager.getInstance().run(new Task.Modal(project, GctBundle.getString("clouddebug.removestashx", targetStash.get().getStash()), false) { @Override public void run(@NotNull ProgressIndicator indicator) { if (project == null) { return; } final GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.STASH); h.addParameters("drop"); addStashParameter(project, h, targetStash.get().getStash()); try { h.run(); h.unsilence(); } catch (final VcsException ex) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { GitUIUtil.showOperationError(project, ex, h.printableCommandLine()); } }); } } }); } } finally { DvcsUtil.workingTreeChangeFinished(project, token); } }
From source file:com.google.gct.idea.debugger.ProjectRepositoryValidator.java
License:Apache License
private void unstash(final @NotNull Project project, @NotNull final Ref<StashInfo> targetStash, @NotNull final VirtualFile root) { if (myRepoState.getSourceRepository() == null || myRepoState.getOriginalBranchName() == null || (!myRepoState.getOriginalBranchName() .equals(myRepoState.getSourceRepository().getCurrentBranchName()) && !myRepoState.getOriginalBranchName() .equals(myRepoState.getSourceRepository().getCurrentRevision()))) { Messages.showErrorDialog(/*from ww w . j a v a 2 s. c o m*/ GctBundle.getString("clouddebug.erroroncheckout", myRepoState.getOriginalBranchName()), "Error"); return; } final GitLineHandler handler = new GitLineHandler(project, root, GitCommand.STASH); handler.addParameters("apply"); handler.addParameters("--index"); addStashParameter(project, handler, targetStash.get().getStash()); final AtomicBoolean conflict = new AtomicBoolean(); handler.addLineListener(new GitLineHandlerAdapter() { @Override public void onLineAvailable(String line, Key outputType) { if (line.contains("Merge conflict")) { conflict.set(true); } } }); GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector( root); GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = new GitLocalChangesWouldBeOverwrittenDetector( root, MERGE); handler.addLineListener(untrackedFilesDetector); handler.addLineListener(localChangesDetector); AccessToken token = DvcsUtil.workingTreeChangeStarted(project); try { final Ref<GitCommandResult> result = Ref.create(); ProgressManager.getInstance() .run(new Task.Modal(handler.project(), GitBundle.getString("unstash.unstashing"), false) { @Override public void run(@NotNull final ProgressIndicator indicator) { indicator.setIndeterminate(true); handler.addLineListener(new GitHandlerUtil.GitLineHandlerListenerProgress(indicator, handler, "stash", false)); Git git = ServiceManager.getService(Git.class); result.set(git .runCommand(new Computable.PredefinedValueComputable<GitLineHandler>(handler))); } }); ServiceManager.getService(project, GitPlatformFacade.class).hardRefresh(root); GitCommandResult res = result.get(); if (conflict.get()) { Messages.showDialog(GctBundle.getString("clouddebug.unstashmergeconflicts"), "Merge Conflicts", new String[] { "Ok" }, 0, Messages.getErrorIcon()); } else if (untrackedFilesDetector.wasMessageDetected()) { UntrackedFilesNotifier.notifyUntrackedFilesOverwrittenBy(project, root, untrackedFilesDetector.getRelativeFilePaths(), "unstash", null); } else if (localChangesDetector.wasMessageDetected()) { LocalChangesWouldBeOverwrittenHelper.showErrorDialog(project, root, "unstash", localChangesDetector.getRelativeFilePaths()); } else if (!res.success()) { GitUIUtil.showOperationErrors(project, handler.errors(), handler.printableCommandLine()); } else if (res.success()) { ProgressManager.getInstance().run(new Task.Modal(project, GctBundle.getString("clouddebug.removestashx", targetStash.get().getStash()), false) { @Override public void run(@NotNull ProgressIndicator indicator) { if (myProject == null) { return; } final GitSimpleHandler h = new GitSimpleHandler(myProject, root, GitCommand.STASH); h.addParameters("drop"); addStashParameter(project, h, targetStash.get().getStash()); try { h.run(); h.unsilence(); } catch (final VcsException ex) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { GitUIUtil.showOperationError(myProject, ex, h.printableCommandLine()); } }); } } }); } } finally { DvcsUtil.workingTreeChangeFinished(project, token); } }
From source file:com.google.gct.idea.debugger.ui.CloudDebugHistoricalSnapshots.java
License:Apache License
public CloudDebugHistoricalSnapshots(@NotNull CloudDebugProcessHandler processHandler) { super(new BorderLayout()); myTable = new JBTable() { // Returning the Class of each column will allow different // renderers to be used based on Class @Override//from ww w.jav a 2 s. c o m public Class getColumnClass(int column) { if (column == 0) { return Icon.class; } Object value = getValueAt(0, column); return value != null ? getValueAt(0, column).getClass() : String.class; } // We override prepareRenderer to supply a tooltip in the case of an error. @NotNull @Override public Component prepareRenderer(@NotNull TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); if (c instanceof JComponent) { JComponent jc = (JComponent) c; Breakpoint breakpoint = CloudDebugHistoricalSnapshots.this.getModel().getBreakpoints().get(row); jc.setToolTipText(BreakpointUtil.getUserErrorMessage(breakpoint.getStatus())); } return c; } }; myTable.setModel(new MyModel(null)); myTable.setTableHeader(null); myTable.setShowGrid(false); myTable.setRowMargin(0); myTable.getColumnModel().setColumnMargin(0); myTable.getColumnModel().getColumn(1).setCellRenderer(new SnapshotTimeCellRenderer()); myTable.getColumnModel().getColumn(2).setCellRenderer(new DefaultRenderer()); myTable.getColumnModel().getColumn(3).setCellRenderer(new DefaultRenderer()); myTable.getColumnModel().getColumn(4).setCellRenderer(new MoreCellRenderer()); myTable.resetDefaultFocusTraversalKeys(); myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); myTable.setPreferredScrollableViewportSize(new Dimension(WINDOW_WIDTH_PX, WINDOW_HEIGHT_PX)); myTable.setAutoCreateColumnsFromModel(false); myTable.getEmptyText().setText(GctBundle.getString("clouddebug.nosnapshots")); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableUpDownActions() .disableAddAction(); decorator.setToolbarPosition(ActionToolbarPosition.TOP); decorator.setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { fireDeleteBreakpoints(getSelectedBreakpoints()); } }); decorator.addExtraAction(new AnActionButton(GctBundle.getString("clouddebug.delete.all"), GoogleCloudToolsIcons.CLOUD_DEBUG_DELETE_ALL_BREAKPOINTS) { @Override public void actionPerformed(AnActionEvent e) { if (Messages.showDialog(GctBundle.getString("clouddebug.remove.all"), GctBundle.getString("clouddebug.delete.snapshots"), new String[] { GctBundle.getString("clouddebug.buttondelete"), GctBundle.getString("clouddebug.cancelbutton") }, 1, Messages.getQuestionIcon()) == 0) { MyModel model = (MyModel) myTable.getModel(); fireDeleteBreakpoints(model.getBreakpoints()); } } }); decorator.addExtraAction(new AnActionButton(GctBundle.getString("clouddebug.reactivatesnapshotlocation"), GoogleCloudToolsIcons.CLOUD_DEBUG_REACTIVATE_BREAKPOINT) { @Override public void actionPerformed(AnActionEvent e) { myProcess.getBreakpointHandler().cloneToNewBreakpoints(getSelectedBreakpoints()); } }); this.add(decorator.createPanel()); myProcess = processHandler.getProcess(); onBreakpointsChanged(); myProcess.getXDebugSession().addSessionListener(this); myProcess.addListener(this); // This is the click handler that does one of three things: // 1. Single click on a final snapshot will load the debugger with that snapshot // 2. Single click on a pending snapshot will show the line of code // 3. Single click on "More" will show the breakpoint config dialog. myTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent me) { JTable table = (JTable) me.getSource(); Point p = me.getPoint(); Breakpoint breakpoint = getBreakPoint(p); int col = table.columnAtPoint(p); if (breakpoint != null && col == 4 && supportsMoreConfig(breakpoint)) { BreakpointsDialogFactory.getInstance(myProcess.getXDebugSession().getProject()) .showDialog(myProcess.getBreakpointHandler().getXBreakpoint(breakpoint)); } else if (me.getClickCount() == 1 && breakpoint != null && myTable.getSelectedRows().length == 1) { myProcess.navigateToSnapshot(breakpoint.getId()); } } }); // we use a motion listener to create a hand cursor over a link within a table. myTable.addMouseMotionListener(new MouseMotionListener() { @Override public void mouseDragged(MouseEvent me) { } @Override public void mouseMoved(MouseEvent me) { JTable table = (JTable) me.getSource(); Point p = me.getPoint(); int column = table.columnAtPoint(p); Breakpoint breakpoint = getBreakPoint(p); if (column == 4 && breakpoint != null && supportsMoreConfig(breakpoint)) { if (myTable.getCursor() != HAND_CURSOR) { myTable.setCursor(HAND_CURSOR); } return; } if (myTable.getCursor() != DEFAULT_CURSOR) { myTable.setCursor(DEFAULT_CURSOR); } } }); }
From source file:com.hp.alm.ali.idea.services.EntityService.java
License:Apache License
public Entity lockEntity(Entity entity, boolean silent) { Entity locked = doLock(new EntityRef(entity), silent); if (locked != null) { if (!locked.matches(entity)) { if (!silent) { Messages.showDialog( "Item has been recently modified on the server. Local values have been updated to match the up-to-date revision.", "Entity Update", new String[] { "Continue" }, 0, Messages.getInformationIcon()); }//from w w w . ja va2 s. com fireEntityLoaded(locked, EntityListener.Event.GET); } } return locked; }
From source file:com.hp.alm.ali.idea.ui.tasks.TaskConfigPanel.java
License:Apache License
public TaskConfigPanel(final Project project, String title, final TaskConfig config, String entityType, final ItemListener itemListener) { super(new GridBagLayout()); this.favoritesService = project.getComponent(FavoritesService.class); this.entityType = entityType; this.config = config; project.getComponent(RestService.class).addListener(this); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0;/*from w ww.j a v a 2s . c om*/ c.gridy = 0; final JCheckBox mainCheck = new JCheckBox(title, config.isEnabled()); add(mainCheck, c); c.gridy++; c.insets = new Insets(0, 10, 0, 0); final JRadioButton customQuery = new JRadioButton("Use Custom Query", config.isCustomSelected()); customQuery.setEnabled(mainCheck.isSelected()); add(customQuery, c); c.gridy++; c.insets = new Insets(0, 32, 0, 0); // config.customFilter doesn't have entityType set EntityQuery entityQuery = new EntityQuery(entityType); entityQuery.copyFrom(config.getCustomFilter()); final EntityQueryPicker queryField = new EntityQueryPicker(project, entityQuery, entityType); queryField.addListener(new FilterListener<EntityQuery>() { @Override public void filterChanged(EntityQuery query) { config.getCustomFilter().copyFrom(query); } }); queryField.setEnabled(mainCheck.isSelected() && config.isCustomSelected()); add(queryField, c); c.gridy++; c.insets = new Insets(0, 10, 0, 0); final JRadioButton storedQuery = new JRadioButton("Use Stored Query", !config.isCustomSelected()); storedQuery.setEnabled(mainCheck.isSelected()); add(storedQuery, c); c.gridy++; c.insets = new Insets(0, 32, 0, 0); queryCombo = new JComboBox(); reloadFavorites(); if (!"".equals(config.getStoredQuery())) { // try to reselect stored value select(queryCombo, new ComboItem(config.getStoredQuery())); } enableQueryCombo(mainCheck.isSelected() && storedQuery.isSelected()); add(queryCombo, c); c.gridy++; c.fill = GridBagConstraints.BOTH; c.weighty = 1; add(new JPanel(), c); ButtonGroup group = new ButtonGroup(); group.add(customQuery); group.add(storedQuery); mainCheck.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { boolean selected = mainCheck.isSelected(); config.setEnabled(selected); customQuery.setEnabled(selected); queryField.setEnabled(selected && customQuery.isSelected()); storedQuery.setEnabled(selected); enableQueryCombo(selected && storedQuery.isSelected()); if (selected && !storedQuery.isSelected()) { customQuery.setSelected(true); } itemListener.itemStateChanged(itemEvent); } }); customQuery.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { boolean selected = customQuery.isSelected(); config.setCustomSelected(selected); queryField.setEnabled(selected); } }); storedQuery.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { boolean selected = storedQuery.isSelected(); config.setCustomSelected(!selected); enableQueryCombo(selected); } }); queryCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getStateChange() == ItemEvent.SELECTED) { if (itemEvent.getItem() instanceof ServerFavorites) { RestService restService = project.getComponent(RestService.class); if (!restService.getServerTypeIfAvailable().isConnected()) { Messages.showDialog("Not connected to HP ALM, server favorites are not available.", "Not Connected", new String[] { "Continue" }, 0, Messages.getErrorIcon()); revert(); return; } FavoritesModel favoritesModel = new FavoritesModel(project, TaskConfigPanel.this.entityType); EntityChooser popup = new HierarchicalChooser(project, "favorite", true, false, true, false, favoritesModel); popup.setVisible(true); String selectedValue = popup.getSelectedValue(); if (!selectedValue.isEmpty()) { Entity favorite = favoritesModel .getEntityNode(Integer.valueOf(selectedValue), "favorite").getEntity(); String favoriteName = favorite.getId() + ": " + favorite.getPropertyValue("name") + " (ALM)"; config.setStoredQuery(favoriteName); ComboItem comboItem = new ComboItem(favoriteName); queryCombo.setSelectedItem(comboItem); if (!comboItem.equals(queryCombo.getSelectedItem())) { queryCombo.addItem(comboItem); queryCombo.setSelectedIndex(queryCombo.getItemCount() - 1); } } else { revert(); } } else { config.setStoredQuery(((ComboItem) itemEvent.getItem()).getDisplayValue()); } } } }); }
From source file:com.intellij.ide.util.projectWizard.SdkSettingsStep.java
License:Apache License
@Override public boolean validate() throws ConfigurationException { if (mySdkComboBox.getSelectedSdk() == null) { if (Messages.showDialog(getNoSdkMessage(), IdeBundle.message("title.no.jdk.specified"), new String[] { CommonBundle.getYesButtonText(), CommonBundle.getNoButtonText() }, 1, Messages.getWarningIcon()) != Messages.YES) { return false; }/*from w w w .ja v a 2 s .c om*/ } try { myModel.apply(null, true); } catch (ConfigurationException e) { //IDEA-98382 We should allow Next step if user has wrong SDK if (Messages.showDialog(e.getMessage() + "/nDo you want to proceed?", e.getTitle(), new String[] { CommonBundle.getYesButtonText(), CommonBundle.getNoButtonText() }, 1, Messages.getWarningIcon()) != Messages.YES) { return false; } } return true; }
From source file:com.intellij.refactoring.copy.CopyFilesOrDirectoriesHandler.java
License:Apache License
public static boolean checkFileExist(PsiDirectory targetDirectory, int[] choice, PsiFile file, String name, String title) {//w w w . ja v a 2 s .c o m final PsiFile existing = targetDirectory.findFile(name); if (existing != null && !existing.equals(file)) { int selection; if (choice == null || choice[0] == -1) { String message = String.format("File '%s' already exists in directory '%s'", name, targetDirectory.getVirtualFile().getPath()); String[] options = choice == null ? new String[] { "Overwrite", "Skip" } : new String[] { "Overwrite", "Skip", "Overwrite for all", "Skip for all" }; selection = Messages.showDialog(message, title, options, 0, Messages.getQuestionIcon()); } else { selection = choice[0]; } if (choice != null && selection > 1) { choice[0] = selection % 2; selection = choice[0]; } if (selection == 0 && file != existing) { existing.delete(); } else { return true; } } return false; }