List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:com.microsoft.tfs.client.common.ui.controls.connect.ServerListControl.java
License:Open Source License
private void onClearButtonSelected(final SelectionEvent e) { final ServerListConfigurationEntry[] serverListEntries = serverListTable.getSelectedServerListEntries(); final String title; final String message; if (serverListEntries.length == 1) { title = Messages.getString("ServerListControl.ClearServersTitle"); //$NON-NLS-1$ message = MessageFormat.format(Messages.getString("ServerListControl.ClearServerPromptFormat"), //$NON-NLS-1$ serverListEntries[0].getName()); } else {/*from ww w . j ava 2 s .com*/ title = Messages.getString("ServerListControl.ClearServersTitle"); //$NON-NLS-1$ message = Messages.getString("ServerListControl.ClearServersPrompt"); //$NON-NLS-1$ } if (!MessageDialog.openQuestion(getShell(), title, message)) { return; } removeCredentials(serverListEntries); refreshTable(); serverListTable.setFocus(); }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.WorkItemsCheckinControl.java
License:Open Source License
/** * Call this method before evaluating the {@link PendingCheckin} to ensure * the subcontrol is in a consistent state. Raises errors to the user to * correct some problems./*from w w w .ja va 2s. com*/ * * @return true if the subcontrol is in a valid state for checkin to * proceed, false if it is not */ public boolean validateForCheckin() { final WorkItemCheckinInfo[] workItemInfos = workItemTable.getSelectedWorkItems(); final WorkItem[] workItems = WorkItemHelpers.workItemCheckinInfosToWorkItems(workItemInfos); if (workItems.length == 0) { return true; } final IStatus status = WorkItemHelpers.syncWorkItemsToLatest(getShell(), workItems); if (!status.isOK()) { return false; } if (WorkItemHelpers.anyWorkItemsAreInvalid(workItems)) { final String title = Messages.getString("WorkItemsCheckinControl.ValidationErrorDialogTitle"); //$NON-NLS-1$ final String message = Messages.getString("WorkItemsCheckinControl.ValidationErrorDialogText"); //$NON-NLS-1$ MessageDialog.openError(getShell(), title, message); return false; } if (WorkItemHelpers.anyWorkItemsAreDirty(workItems)) { final String title = Messages.getString("WorkItemsCheckinControl.SaveDialogTitle"); //$NON-NLS-1$ final String message = Messages.getString("WorkItemsCheckinControl.SaveDialogText"); //$NON-NLS-1$ if (MessageDialog.openQuestion(getShell(), title, message) == false) { return false; } if (!WorkItemHelpers.saveAllDirtyWorkItems(getShell(), workItems)) { return false; } } // None of the associated work items are dirty at this point. for (final WorkItemCheckinInfo workItemInfo : workItemInfos) { if (!validateTransition(workItemInfo)) { return false; } } return true; }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.FindLabelDialog.java
License:Open Source License
private void deleteLabel(final VersionControlLabel label) { if (!MessageDialog.openQuestion(getShell(), MessageFormat.format(Messages.getString("FindLabelDialog.DeleteLabelFormat"), label.getName()), //$NON-NLS-1$ Messages.getString("FindLabelDialog.AreYouSureYouWishToDeleteThisLabel"))) //$NON-NLS-1$ {//from ww w . j av a2 s. c o m return; } final DeleteLabelCommand deleteCommand = new DeleteLabelCommand(repository, label); final IStatus deleteStatus = UICommandExecutorFactory.newUICommandExecutor(getShell()) .execute(deleteCommand); if (!deleteStatus.isOK()) { return; } control.deleteLabel(label); }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.ShelvesetSearchControl.java
License:Open Source License
public void deleteSelectedShelvesets() { final Shelveset[] selectedShelvesets = getSelectedShelvesets(); if (selectedShelvesets == null || selectedShelvesets.length == 0) { return;/*from ww w .j a va2s.co m*/ } String title, message; if (selectedShelvesets.length == 1) { title = Messages.getString("ShelvesetSearchControl.DeleteShelvesetDialogTitle"); //$NON-NLS-1$ message = MessageFormat.format( Messages.getString("ShelvesetSearchControl.DeleteShelvesetDialogMessageFormat"), //$NON-NLS-1$ selectedShelvesets[0].getName()); } else { title = Messages.getString("ShelvesetSearchControl.DeleteShelvesetsDialogTitle"); //$NON-NLS-1$ message = Messages.getString("ShelvesetSearchControl.DeleteShelvesetsDialogMessage"); //$NON-NLS-1$ } if (!MessageDialog.openQuestion(getShell(), title, message)) { return; } final DeleteShelvesetsCommand deleteCommand = new DeleteShelvesetsCommand(repository, selectedShelvesets); UICommandExecutorFactory.newUICommandExecutor(getShell()).execute(deleteCommand); /* * Ignore the status -- we could have an error deleting some shelvesets * but have succeeded in deleting others. The command will tell us what * it actually did here. */ shelvesetsTable.removeShelvesets(deleteCommand.getDeletedShelvesets()); }
From source file:com.microsoft.tfs.client.common.ui.controls.workspaces.WorkspacesControl.java
License:Open Source License
private void editClicked() { final Workspace selectedWorkspace = workspacesTable.getSelectedWorkspace(); /* See if this workspace is immutable */ final boolean immutable = isWorkspaceImmutable(selectedWorkspace); final WorkspaceData dataToEdit = new WorkspaceData(selectedWorkspace); final WorkspaceData oldData = new WorkspaceData(selectedWorkspace); boolean keepGoing = true; while (keepGoing) { final WorkspaceEditDialog dialog = new WorkspaceEditDialog(getShell(), true, dataToEdit, connection); dialog.setImmutable(immutable);/*from w w w . j a v a 2 s . c o m*/ if (IDialogConstants.OK_ID == dialog.open()) { final UpdateWorkspaceCommand command = new UpdateWorkspaceCommand(selectedWorkspace, dataToEdit.getWorkspaceDetails().getName(), dataToEdit.getWorkspaceDetails().getComment(), dataToEdit.getWorkingFolderDataCollection().createWorkingFolders(), dataToEdit.getWorkspaceDetails().getWorkspaceOptions(), dataToEdit.getWorkspaceDetails().getWorkspaceLocation(), dataToEdit.getWorkspaceDetails().getPermissionProfile()); if (commandExecutor.execute(command).isOK()) { final WorkspaceEditEvent event = new WorkspaceEditEvent(this, oldData, selectedWorkspace); final WorkspaceEditListener listener = (WorkspaceEditListener) editListeners.getListener(); listener.onWorkspaceEdited(event); workspacesTable.refresh(); keepGoing = false; /* * Check to see if any folders changed. */ final WorkingFolder[] oldFolders = oldData.getWorkingFolderDataCollection() .createWorkingFolders(); final WorkingFolder[] newFolders = dataToEdit.getWorkingFolderDataCollection() .createWorkingFolders(); Arrays.sort(oldFolders, new WorkingFolderComparator(WorkingFolderComparatorType.SERVER_PATH)); Arrays.sort(newFolders, new WorkingFolderComparator(WorkingFolderComparatorType.SERVER_PATH)); final boolean foldersChanged = Arrays.equals(oldFolders, newFolders) == false; final WorkspaceOptions oldOptions = oldData.getWorkspaceDetails().getWorkspaceOptions(); final WorkspaceOptions newOptions = dataToEdit.getWorkspaceDetails().getWorkspaceOptions(); final boolean fileTimeChanged = !oldOptions.contains(WorkspaceOptions.SET_FILE_TO_CHECKIN) && newOptions.contains(WorkspaceOptions.SET_FILE_TO_CHECKIN) && newFolders.length > 0; final GetOptions getOptions = fileTimeChanged ? GetOptions.GET_ALL : GetOptions.NONE; if (foldersChanged || fileTimeChanged) { /* * Prompt to get latest. * * Prefer the file time message if folders also changed * since the force get will handle everything. */ final boolean getNow = MessageDialog.openQuestion(getShell(), Messages.getString("WorkspacesControl.WorkspaceModifiedDialogTitle"), //$NON-NLS-1$ fileTimeChanged ? Messages.getString("WorkspacesControl.SetFileTimeToCheckinGetPrompt") //$NON-NLS-1$ : Messages.getString("WorkspacesControl.WorkspaceChangedMessage")); //$NON-NLS-1$ if (getNow) { final RepositoryManager manager = TFSCommonUIClientPlugin.getDefault() .getProductPlugin().getRepositoryManager(); TFSRepository repository = manager.getRepository(selectedWorkspace); if (repository == null) { repository = new TFSRepository(selectedWorkspace); } /* * GetTask will not prompt for * "all files up to date" like GetLatestTask does, * and it accepts GetOptions. A GetRequest with a * null item spec means "get the whole workspace." */ final GetTask task = new GetTask(getShell(), repository, new GetRequest[] { new GetRequest(null, LatestVersionSpec.INSTANCE) }, getOptions); task.run(); } } } } else { keepGoing = false; } } workspacesTable.setFocus(); }
From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.ApplyLabelDialog.java
License:Open Source License
@Override protected void okPressed() { labelName = nameText.getText().trim(); comment = commentText.getText().trim(); serverPath = pathText.getText();//w w w . j a v a 2 s . c o m versionSpec = versionControl.getVersionSpec(); final String scope = ServerPath.equals(serverPath, ServerPath.ROOT) ? ServerPath.ROOT : ServerPath.getTeamProject(serverPath); if (versionSpec == null || (versionSpec instanceof ChangesetVersionSpec && ((ChangesetVersionSpec) versionSpec).getChangeset() == 0)) { String errorMessage = Messages.getString("ApplyLabelDialog.InvalidVersionError"); //$NON-NLS-1$ if (versionControl.getVersionType() == VersionDescription.DATE) { errorMessage = Messages.getString("ApplyLabelDialog.InvalidDateError"); //$NON-NLS-1$ } else if (versionControl.getVersionType() == VersionDescription.CHANGESET) { errorMessage = Messages.getString("ApplyLabelDialog.InvalidChangesetError"); //$NON-NLS-1$ } MessageDialog.openError(getShell(), Messages.getString("ApplyLabelDialog.InvalidVersionDialogTitle"), //$NON-NLS-1$ errorMessage); return; } if (labelName.length() == 0) { MessageDialog.openError(getShell(), Messages.getString("ApplyLabelDialog.InvalidNameDialogTitle"), //$NON-NLS-1$ Messages.getString("ApplyLabelDialog.LabelRequiresName")); //$NON-NLS-1$ return; } if (labelName.length() > NAME_MAX_LENGTH) { final String title = Messages.getString("ApplyLabelDialog.InvalidNameDialogTitle"); //$NON-NLS-1$ final String messageFormat = Messages.getString("ApplyLabelDialog.LabelTooLongFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, (NAME_MAX_LENGTH + 1)); MessageDialog.openError(getShell(), title, message); return; } if (comment.length() > COMMENT_MAX_LENGTH) { final String title = Messages.getString("ApplyLabelDialog.CommentTooLongDialogTitle"); //$NON-NLS-1$ final String messageFormat = Messages.getString("ApplyLabelDialog.CommentTooLongFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, ApplyLabelDialog.COMMENT_MAX_LENGTH); MessageDialog.openError(getShell(), title, message); return; } for (int i = 0; i < INVALID_NAME_CHARS.length; i++) { if (labelName.indexOf(INVALID_NAME_CHARS[i]) >= 0) { final String title = Messages.getString("ApplyLabelDialog.InvalidNameDialogTitle"); //$NON-NLS-1$ final String messageFormat = Messages.getString("ApplyLabelDialog.InvalidCharInLabelFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, INVALID_NAME_CHARS[i]); MessageDialog.openError(getShell(), title, message); return; } } if (serverPath.length() == 0 || !ServerPath.isServerPath(serverPath)) { final String title = Messages.getString("ApplyLabelDialog.InvalidPathDialogTitle"); //$NON-NLS-1$ final String message = Messages.getString("ApplyLabelDialog.NotValidServerPath"); //$NON-NLS-1$ MessageDialog.openError(getShell(), title, message); return; } final QueryItemsCommand queryItemsCommand = new QueryItemsCommand(repository, new ItemSpec[] { new ItemSpec(serverPath, RecursionType.NONE) }, versionSpec, DeletedState.NON_DELETED, ItemType.ANY, GetItemsOptions.UNSORTED); final QueryLabelsCommand queryLabelsCommand = new QueryLabelsCommand(repository, labelName, scope, null); final CommandList queryAllCommand = new CommandList( Messages.getString("ApplyLabelDialog.QueryLabelCommandText"), //$NON-NLS-1$ Messages.getString("ApplyLabelDialog.QueryLabelErrorText")); //$NON-NLS-1$ queryAllCommand.addCommand(queryItemsCommand); queryAllCommand.addCommand(queryLabelsCommand); final IStatus queryStatus = UICommandExecutorFactory.newUICommandExecutor(getShell()) .execute(queryAllCommand); if (!queryStatus.isOK()) { return; } /* Make sure the item exists at that version */ final ItemSet[] querySets = queryItemsCommand.getItemSets(); if (querySets.length != 1 || querySets[0].getItems().length != 1) { final String spec = VersionSpecHelper.getVersionSpecDescription(versionSpec); final String messageFormat = Messages.getString("ApplyLabelDialog.ItemNotOnServerFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, serverPath, spec); MessageDialog.openError(getShell(), Messages.getString("ApplyLabelDialog.InvalidPathDialogTitle"), //$NON-NLS-1$ message); return; } recursionType = querySets[0].getItems()[0].getItemType() == ItemType.FOLDER ? RecursionType.FULL : RecursionType.NONE; /* * See if there exists an existing label with that name. Note that the * user may have entered a wildcard in the Name field, which will cause * us to get multiple results back. Thus, examine each and do a proper * name comparison. */ final VersionControlLabel[] existingLabels = queryLabelsCommand.getLabels(); final List existingLabelList = new ArrayList(); for (int i = 0; i < existingLabels.length; i++) { if (existingLabels[i].getName().equalsIgnoreCase(labelName)) { existingLabelList.add(existingLabels[i]); } } if (existingLabelList.size() > 0) { String message; if (existingLabelList.size() == 1) { message = Messages.getString("ApplyLabelDialog.SingleLabelExists"); //$NON-NLS-1$ } else { final String messageFormat = Messages.getString("ApplyLabelDialog.MultiLabelsExistFormat"); //$NON-NLS-1$ message = MessageFormat.format(messageFormat, existingLabelList.size()); } if (!MessageDialog.openQuestion(getShell(), Messages.getString("ApplyLabelDialog.ConfirmOverriteDialogTitle"), //$NON-NLS-1$ message)) { return; } deleteExisting = (VersionControlLabel[]) existingLabelList .toArray(new VersionControlLabel[existingLabelList.size()]); } super.okPressed(); }
From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.ConflictDialog.java
License:Open Source License
/** * Prompt the user to cancel running resolutions. (If there are any.) * * @return true to exit, false otherwise *///from ww w. jav a2 s . com private boolean cancelResolution() { synchronized (runningResolutionList) { if (runningResolutionList.size() == 0) { return true; } String message; if (runningResolutionList.size() == 1) { message = Messages.getString("ConflictDialog.ConfirmSingleConflictDialogText"); //$NON-NLS-1$ } else { message = Messages.getString("ConflictDialog.ConfirmMultiConflictsDialogText"); //$NON-NLS-1$ } final boolean cancelling = MessageDialog.openQuestion(getShell(), Messages.getString("ConflictDialog.ConfirmCancelDialogTitle"), //$NON-NLS-1$ message); if (!cancelling) { return false; } for (final Iterator i = runningResolutionList.iterator(); i.hasNext();) { final ConflictResolution resolution = (ConflictResolution) i.next(); resolution.removeStatusListener(this); resolution.cancel(); } } return true; }
From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.EditLabelDialog.java
License:Open Source License
@Override protected void okPressed() { if (!labelModified) { editLabelResults = new EditLabelResults(null, null, null); setReturnCode(IDialogConstants.CANCEL_ID); close();//from w ww . jav a 2s .c o m return; } if (initialLabel == null) { final String labelName = nameText.getText().trim(); if (labelName.length() == 0) { final String title = Messages.getString("EditLabelDialog.InvalidNameDialogTitle"); //$NON-NLS-1$ final String message = Messages.getString("EditLabelDialog.InvalidNameDialogText"); //$NON-NLS-1$ MessageDialog.openError(getShell(), title, message); return; } if (labelName.length() >= ApplyLabelDialog.NAME_MAX_LENGTH) { final String title = Messages.getString("EditLabelDialog.NametooLongDialogTitle"); //$NON-NLS-1$ final String messageFormat = Messages.getString("EditLabelDialog.NameTooLongFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, (ApplyLabelDialog.NAME_MAX_LENGTH + 1)); MessageDialog.openError(getShell(), title, message); return; } for (int i = 0; i < ApplyLabelDialog.INVALID_NAME_CHARS.length; i++) { if (labelName.indexOf(ApplyLabelDialog.INVALID_NAME_CHARS[i]) >= 0) { final String title = Messages.getString("EditLabelDialog.InvalidNameDialogTitle"); //$NON-NLS-1$ final String messageFormat = Messages.getString("EditLabelDialog.InvalidCharInLabelFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, ApplyLabelDialog.INVALID_NAME_CHARS[i]); MessageDialog.openError(getShell(), title, message); return; } } } if (commentText.getText().trim().length() > ApplyLabelDialog.COMMENT_MAX_LENGTH) { final String title = Messages.getString("EditLabelDialog.CommentTooLongDialogTitle"); //$NON-NLS-1$ final String messageFormat = Messages.getString("EditLabelDialog.CommentTooLongFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, ApplyLabelDialog.COMMENT_MAX_LENGTH); MessageDialog.openError(getShell(), title, message); return; } getButton(BUTTON_ADD_ID).setEnabled(false); getButton(BUTTON_REMOVE_ID).setEnabled(false); nameText.setEnabled(false); commentText.setEnabled(false); labelItemsTable.setEnabled(false); getButton(IDialogConstants.OK_ID).setEnabled(false); final IProgressMonitor progressMonitor = progressMonitorControl.getProgressMonitor(); progressMonitor.beginTask(Messages.getString("EditLabelDialog.ProgressAnalyzingLabel"), //$NON-NLS-1$ IProgressMonitor.UNKNOWN); new Thread(new Runnable() { @Override public void run() { final boolean isDelete; final ItemSpec[] deletes; final LabelItemSpec[] adds; synchronized (labelContentsTree) { final LabelContentsTreeDelta delta = labelContentsTree.getDelta(); isDelete = (initialLabel != null && delta.getExistsCount() == 0 && delta.getAdds().length == 0); deletes = delta.getDeletes(); adds = delta.getAdds(); } final Shell shell = getShell(); if (shell == null) { return; } shell.getDisplay().syncExec(new Runnable() { @Override public void run() { try { if (isDelete && !MessageDialog.openQuestion(getShell(), Messages.getString("EditLabelDialog.RemoveLabelDialogTitle"), //$NON-NLS-1$ Messages.getString("EditLabelDialog.RemoveLabelDialogText"))) //$NON-NLS-1$ { progressMonitor.done(); nameText.setEnabled(initialLabel == null); commentText.setEnabled(true); labelItemsTable.setEnabled(true); getButton(BUTTON_ADD_ID).setEnabled(true); getButton(BUTTON_REMOVE_ID).setEnabled(!labelItemsTable.getSelection().isEmpty()); getButton(IDialogConstants.OK_ID).setEnabled(nameText.getText().length() > 0); return; } VersionControlLabel newLabel; if (isDelete) { newLabel = null; } else { final String name = initialLabel != null ? initialLabel.getName() : nameText.getText().trim(); final String owner = initialLabel != null ? initialLabel.getOwner() : VersionControlConstants.AUTHENTICATED_USER; final String ownerDisplayName = initialLabel != null ? initialLabel.getOwnerDisplayName() : null; final String scope = initialLabel != null ? initialLabel.getScope() : null; final String comment = commentText.getText().trim(); newLabel = new VersionControlLabel(name, owner, ownerDisplayName, scope, comment); } editLabelResults = new EditLabelResults(newLabel, deletes, adds); EditLabelDialog.super.okPressed(); } catch (final Throwable e) { progressMonitor.done(); MessageDialog.openError(getShell(), Messages.getString("EditLabelDialog.LabelErrorDialogTitle"), //$NON-NLS-1$ e.getMessage()); nameText.setEnabled(initialLabel == null); commentText.setEnabled(true); labelItemsTable.setEnabled(true); getButton(BUTTON_ADD_ID).setEnabled(true); getButton(BUTTON_REMOVE_ID).setEnabled(!labelItemsTable.getSelection().isEmpty()); getButton(IDialogConstants.OK_ID).setEnabled(nameText.getText().length() > 0); return; } } }); } }).start(); }
From source file:com.microsoft.tfs.client.common.ui.framework.helper.MessageBoxHelpers.java
License:Open Source License
public static boolean dialogYesNoPrompt(Shell parent, String dialogTitle, final String yesNoMessage) { parent = ShellUtils.getBestParent(parent); dialogTitle = sanitizeTitle(dialogTitle); return MessageDialog.openQuestion(parent, dialogTitle, yesNoMessage); }
From source file:com.microsoft.tfs.client.common.ui.tasks.vc.WorkingFolderTask.java
License:Open Source License
protected void getLatestForServerPath(final String promptTitle) { final String messageFormat = Messages.getString("WorkingFolderTask.GetLatestFolderFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, serverPath); final boolean getNow = MessageDialog.openQuestion(getShell(), promptTitle, message); if (getNow) { final TypedServerItem[] items = new TypedServerItem[] { new TypedServerItem(serverPath, ServerItemType.FOLDER), }; final GetLatestTask task = new GetLatestTask(getShell(), repository, items); task.run();/* ww w . ja va 2 s . co m*/ } }