List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning
public static void openWarning(Shell parent, String title, String message)
From source file:com.microsoft.tfs.client.common.ui.teambuild.actions.EditBuildDefinitionFromDetailsAction.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) *//* w w w.j a v a2 s .com*/ @Override public void run(final IAction action) { IBuildDefinition buildDefinition = getSelectedBuildDetail().getBuildDefinition(); // Get a fresh copy of the build definition. This makes sure edits we // make will get ignored on Cancel but also that we have a fresh copy of // the definition so reduce the risk of overwriting someone else's // changes. buildDefinition = BuildHelpers.getUpToDateBuildDefinition(getShell(), buildDefinition); if (buildDefinition == null || buildDefinition.getSourceProviders().length == 0) { return; } final BuildDefinitionDialog dialog; if (buildDefinition.getSourceProviders() != null && buildDefinition.getSourceProviders().length > 0 && BuildSourceProviders.isTfGit(buildDefinition.getSourceProviders()[0])) { dialog = (BuildDefinitionDialog) EGitHelpers.getGitBuildDefinitionDialog(getShell(), buildDefinition); if (dialog == null) { final String errorMessage = Messages.getString("BuildHelpers.EGitRequired"); //$NON-NLS-1$ final String title = Messages.getString("EditBuildDefinitionFromDetailsAction.EGitNotInstalled"); //$NON-NLS-1$ log.error("Cannot edit the build definition. EGit plugin is requered for this action."); //$NON-NLS-1$ MessageDialog.openError(getShell(), title, errorMessage); return; } } else { dialog = new TfsBuildDefinitionDialog(getShell(), buildDefinition); } try { if (dialog.open() == IDialogConstants.OK_ID) { dialog.commitChangesIfNeeded(); // Reload build definitions in case a name has changed or // something. if (BuildExplorer.getInstance() != null && !BuildExplorer.getInstance().isDisposed()) { BuildExplorer.getInstance().reloadBuildDefinitions(); } // We should redraw and build agents at this point because we // may // have added new ones. if (BuildExplorer.getInstance() != null && !BuildExplorer.getInstance().isDisposed() && BuildExplorer.getInstance().getQueueEditorPage() != null) { BuildExplorer.getInstance().getQueueEditorPage().reloadBuildAgents(); } } } catch (final BuildException e) { final String title = Messages .getString("EditBuildDefinitionFromDetailsAction.CannotEditDefinitionTitle"); //$NON-NLS-1$ log.warn(title, e); MessageDialog.openWarning(getShell(), title, e.getMessage()); } catch (final Exception e) { final String title = Messages .getString("EditBuildDefinitionFromDetailsAction.FailedEditDefinitionTitle"); //$NON-NLS-1$ log.error(title, e); MessageDialog.openError(getShell(), title, e.getLocalizedMessage()); } }
From source file:com.microsoft.tfs.client.common.ui.teambuild.teamexplorer.actions.EditBuildDefinitionAction.java
License:Open Source License
@Override public void doRun(final IAction action) { // Get a fresh copy of the build definition. This makes sure edits we // make will get ignored on Cancel but also that we have a fresh copy of // the definition so reduce the risk of overwriting someone else's // changes.// w w w. j av a 2s .c om final IBuildDefinition buildDefinition = BuildHelpers.getUpToDateBuildDefinition(getShell(), selectedDefinition); // Make sure the build hasn't been deleted. if (buildDefinition == null) { final BuildDefinitionEventArg arg = new BuildDefinitionEventArg(selectedDefinition); getContext().getEvents().notifyListener(TeamExplorerEvents.BUILD_DEFINITION_DELETED, arg); return; } final BuildDefinitionDialog dialog; if (buildDefinition.getSourceProviders() != null && buildDefinition.getSourceProviders().length > 0 && BuildSourceProviders.isTfGit(buildDefinition.getSourceProviders()[0])) { dialog = (BuildDefinitionDialog) EGitHelpers.getGitBuildDefinitionDialog(getShell(), buildDefinition); if (dialog == null) { final String errorMessage = Messages.getString("BuildHelpers.EGitRequired"); //$NON-NLS-1$ final String title = Messages.getString("EditBuildDefinitionFromDetailsAction.EGitNotInstalled"); //$NON-NLS-1$ log.error("Cannot edit the build definition. EGit plugin is requered for this action."); //$NON-NLS-1$ MessageDialog.openError(getShell(), title, errorMessage); return; } } else { dialog = new TfsBuildDefinitionDialog(getShell(), buildDefinition); } try { if (dialog.open() == IDialogConstants.OK_ID) { dialog.commitChangesIfNeeded(); // We should redraw build definitions at this point if (BuildExplorer.getInstance() != null && !BuildExplorer.getInstance().isDisposed()) { BuildExplorer.getInstance().reloadBuildDefinitions(); } // We should redraw and build agents at this point because we // may // have added new ones. if (BuildExplorer.getInstance() != null && !BuildExplorer.getInstance().isDisposed() && BuildExplorer.getInstance().getQueueEditorPage() != null) { BuildExplorer.getInstance().getQueueEditorPage().reloadBuildAgents(); } if (selectedDefinition != null) { final BuildDefinitionEventArg arg = new BuildDefinitionEventArg(selectedDefinition); getContext().getEvents().notifyListener(TeamExplorerEvents.BUILD_DEFINITION_CHANGED, arg); } } } catch (final BuildException e) { final String title = Messages .getString("EditBuildDefinitionFromDetailsAction.CannotEditDefinitionTitle"); //$NON-NLS-1$ log.warn(title, e); MessageDialog.openWarning(getShell(), title, e.getMessage()); } catch (final Exception e) { final String title = Messages .getString("EditBuildDefinitionFromDetailsAction.FailedEditDefinitionTitle"); //$NON-NLS-1$ log.error(title, e); MessageDialog.openError(getShell(), title, e.getLocalizedMessage()); } }
From source file:com.microsoft.tfs.client.common.ui.teambuild.teamexplorer.helpers.BuildHelpers.java
License:Open Source License
public static boolean newBuildDefinition(final Shell shell, final TeamExplorerContext context) { final IBuildServer buildServer = context.getBuildServer(); final String projectName = context.getCurrentProjectInfo().getName(); final IBuildDefinition buildDefinition = buildServer.createBuildDefinition(projectName); final BuildDefinitionDialog dialog; if (isGitProject(context)) { buildDefinition.setDefaultSourceProvider(BuildSourceProviders.createGitSourceProvider()); dialog = (BuildDefinitionDialog) EGitHelpers.getGitBuildDefinitionDialog(shell, buildDefinition); if (dialog == null) { final String errorMessage = Messages.getString("BuildHelpers.EGitRequired"); //$NON-NLS-1$ final String title = Messages.getString("BuildHelpers.FailedCreateDefinitionTitle"); //$NON-NLS-1$ log.error("Cannot edit the build definition. EGit plugin is requered for this action."); //$NON-NLS-1$ MessageDialog.openError(shell, title, errorMessage); return false; }/*from w w w.j a v a2 s .com*/ } else { buildDefinition.setDefaultSourceProvider(BuildSourceProviders.createTfVcSourceProvider()); dialog = new TfsBuildDefinitionDialog(shell, buildDefinition); } try { if (dialog.open() == IDialogConstants.OK_ID) { dialog.commitChangesIfNeeded(); return true; } } catch (final BuildException e) { final String title = Messages.getString("BuildHelpers.CannotCreateDefinitionTitle"); //$NON-NLS-1$ log.warn(title, e); MessageDialog.openWarning(shell, title, e.getMessage()); } catch (final Exception e) { final String title = Messages.getString("BuildHelpers.FailedCreateDefinitionTitle"); //$NON-NLS-1$ log.error(title, e); MessageDialog.openError(shell, title, e.getLocalizedMessage()); } return false; }
From source file:com.microsoft.tfs.client.common.ui.teamexplorer.helpers.PendingChangesHelpers.java
License:Open Source License
public static PendingCheckin getPendingCheckin(final Shell shell, final PendingChangesViewModel model, final boolean evaluatePolicies) { // Warn if there are on Included pending changes. final PendingChange[] changes = model.getIncludedUnfilteredPendingChanges(); if (changes.length == 0) { MessageDialog.openWarning(shell, Messages.getString("PendingChangesView.NoChangesDialogTitle"), //$NON-NLS-1$ Messages.getString("PendingChangesView.NoChangesDialogText")); //$NON-NLS-1$ return null; }/*from w w w .ja v a 2 s . co m*/ final TFSRepository repository = model.getRepository(); final Workspace workspace = model.getWorkspace(); final PendingChange[] allChanges = model.getAllPendingChanges(); final PolicyEvaluator policyEvaluator = evaluatePolicies ? new PolicyEvaluator(repository.getVersionControlClient(), new ExtensionPointPolicyLoader()) : null; return new StandardPendingCheckin(workspace, allChanges, changes, model.getComment(), model.getCheckinNote(), model.getAssociatedWorkItems(), policyEvaluator); }
From source file:com.microsoft.tfs.client.common.ui.views.PendingChangesView.java
License:Open Source License
private void checkin() { /*/*ww w. j a v a 2s.c o m*/ * Get the PendingCheckin that the control has been keeping up-to-date. * This has most of the information required for check-in. */ final PendingCheckin pendingCheckin = getCheckinControl().getPendingCheckin(); final int changeCount = pendingCheckin.getPendingChanges().getCheckedPendingChanges().length; if (changeCount == 0) { MessageDialog.openWarning(getSite().getShell(), Messages.getString("PendingChangesView.NoChangesDialogTitle"), //$NON-NLS-1$ Messages.getString("PendingChangesView.ChangeChangesDialogText")); //$NON-NLS-1$ return; } /* * Validate the pending change (checked work items, notes, policies, * etc.). The control's validation method may raise dialogs to fix * problems (policy override comment, save dirty editors, etc.). */ final ValidationResult validationResult = getCheckinControl().validateForCheckin(); if (validationResult.getSucceeded() == false) { return; } /* * Confirm the checkin. */ String message; if (changeCount > 1) { final String messageFormat = Messages.getString("PendingChangesView.MultiChangesConfirmTextFormat"); //$NON-NLS-1$ message = MessageFormat.format(messageFormat, changeCount); } else { message = Messages.getString("PendingChangesView.SingleChangeConfirmTextFormat"); //$NON-NLS-1$ } CodeMarkerDispatch.dispatch(BEFORE_CONFIRM_DIALOG); if (!ToggleMessageHelper.openYesNoQuestion(getSite().getShell(), Messages.getString("PendingChangesView.ConfirmCheckinDialogTitle"), //$NON-NLS-1$ message, Messages.getString("PendingChangesView.CheckinWithoutPromptCheckboxText"), //$NON-NLS-1$ false, UIPreferenceConstants.PROMPT_BEFORE_CHECKIN)) { return; } /* * Build the override information from the validation result. */ PolicyOverrideInfo policyOverrideInfo = null; if (validationResult.getPolicyOverrideReason() != null && validationResult.getPolicyOverrideReason().length() > 0) { policyOverrideInfo = new PolicyOverrideInfo(validationResult.getPolicyOverrideReason(), validationResult.getPolicyFailures()); } final CheckinTask checkinTask = new CheckinTask(getSite().getShell(), repository, pendingCheckin, policyOverrideInfo); checkinTask.run(); if (checkinTask.getPendingChangesCleared()) { getCheckinControl().afterCheckin(); } }
From source file:com.microsoft.tfs.client.eclipse.ui.actions.vc.SwitchToBranchAction.java
License:Open Source License
@Override public void doRun(final IAction action) { final AdaptedSelectionInfo selectionInfo = ActionHelpers.adaptSelectionToStandardResources(getSelection(), PluginResourceFilters.STANDARD_FILTER, true); if (ActionHelpers.ensureNonZeroResourceCountAndSingleRepository(selectionInfo, getShell()) == false) { return;// w w w . j ava 2 s . c om } final IResource resource = selectionInfo.getResources()[0]; if (resource.getLocation() == null) { return; } /* * Error if there are pending changes. */ final PendingChange[] relatedChanges = selectionInfo.getPendingChanges(); if (relatedChanges != null && relatedChanges.length > 0) { MessageDialog.openWarning(getShell(), Messages.getString("SwitchToBranchAction.NotAllowedDialogTitle"), //$NON-NLS-1$ Messages.getString("SwitchToBranchAction.NotAllowedDialogText")); //$NON-NLS-1$ return; } /* * Get the project for the resource, since we only switch entire * projects. */ final IProject project = resource.getProject(); final Workspace workspace = selectionInfo.getRepositories()[0].getWorkspace(); final String localPath = project.getLocation().toOSString(); final String serverPath = workspace.getMappedServerPath(localPath); final SwitchToBranchDialog dialog = new SwitchToBranchDialog(getShell(), workspace, serverPath); if (IDialogConstants.CANCEL_ID == dialog.open() || ServerPath.equals(serverPath, dialog.getSwitchToServerPath())) { return; } final SwitchToBranchCommand command = new SwitchToBranchCommand(workspace, project, serverPath, dialog.getSwitchToServerPath()); UICommandExecutorFactory.newUICommandExecutor(getShell()).execute(new ResourceChangingCommand(command)); }
From source file:com.microsoft.tfs.client.eclipse.ui.connectionconflict.EclipseUIConnectionConflictHandler.java
License:Open Source License
private void notifyConflict() { final Shell parentShell = ShellUtils.getWorkbenchShell(); UIHelpers.runOnUIThread(true, new Runnable() { @Override//from w ww .j a v a 2s. co m public void run() { MessageDialog.openWarning(parentShell, Messages.getString("EclipseConnectionConflictHandler.ConnectionExistsDialogTitle"), //$NON-NLS-1$ Messages.getString("EclipseConnectionConflictHandler.ConnectionExistsDialogText")); //$NON-NLS-1$ } }); }
From source file:com.mind_era.knime_rapidminer.knime.nodes.preferences.RapidMinerPreferencePage.java
License:Open Source License
public RapidMinerPreferencePage() { super(GRID);// w w w . ja v a 2s . com final IPreferenceStore preferenceStore = RapidMinerNodePlugin.getDefault().getPreferenceStore(); setPreferenceStore(preferenceStore); preferenceStore.addPropertyChangeListener(new IPropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent pce) { if (pce.getProperty().equals(PreferenceConstants.RAPIDMINER_PATH)) { final Object old = pce.getOldValue(); final Object newValue = pce.getNewValue(); if (newValue != null && !newValue.equals(old)) { MessageDialog.openWarning(RapidMinerPreferencePage.this.getShell(), "Restart Eclipse", "Please restart eclipse to get the effects of the new RapidMiner path."); // RapidMinerInit.init(true); } } } }); setDescription("RapidMiner related preferences"); }
From source file:com.motorola.studio.android.common.utilities.EclipseUtils.java
License:Apache License
/** * Show a warning message using the given title and message * /* w w w . j a va 2s . co m*/ * @param title * of the dialog * @param message * to be displayed in the dialog. */ public static void showWarningDialog(final String title, final String message) { Display.getDefault().asyncExec(new Runnable() { public void run() { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow ww = workbench.getActiveWorkbenchWindow(); Shell shell = ww.getShell(); MessageDialog.openWarning(shell, title, message); } }); }
From source file:com.netxforge.netxstudio.screens.ch9.NewEditExpression.java
License:Open Source License
public void addData() { if (ScreenUtil.isNewOperation(getOperation()) && owner != null) { Command c = new AddCommand(editingService.getEditingDomain(), owner.getContents(), expression); editingService.getEditingDomain().getCommandStack().execute(c); if (whoRefers != null && feature != null) { // We also set the reference to this expression, we need to // referee and a feature for this. Command cSetRef = null;//from ww w .j a v a2 s. co m if (whoRefers instanceof EObject) { cSetRef = new SetCommand(editingService.getEditingDomain(), (EObject) whoRefers, feature, expression); } if (cSetRef != null) { editingService.getEditingDomain().getCommandStack().execute(cSetRef); } } } else if (ScreenUtil.isEditOperation(getOperation())) { // If edit, we have been operating on a copy of the object, so we // have // to replace. // invalid, and we should cancel the action and warn the user. if (expression.cdoInvalid()) { MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Conflict", "There is a conflict with another user. Your changes can't be saved."); return; } // Command c = new ReplaceCommand(editingService.getEditingDomain(), // owner.getContents(), original, expression); // editingService.getEditingDomain().getCommandStack().execute(c); } // After our edit, we shall be dirty if (editingService.isDirty()) { editingService.doSave(new NullProgressMonitor()); } }