List of usage examples for org.eclipse.jface.dialogs IMessageProvider WARNING
int WARNING
To view the source code for org.eclipse.jface.dialogs IMessageProvider WARNING.
Click Source Link
From source file:ac.soton.eventb.classdiagrams.diagram.part.ClassdiagramsDiagramEditor.java
License:Open Source License
/** * @generated//from w ww .java 2 s . co m */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.ClassdiagramsDiagramEditor_SavingDeletedFile, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.ClassdiagramsDiagramEditor_SaveAsErrorTitle, Messages.ClassdiagramsDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.ClassdiagramsDiagramEditor_SaveErrorTitle, Messages.ClassdiagramsDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:ac.soton.eventb.statemachines.diagram.part.StatemachinesDiagramEditor.java
License:Open Source License
/** * @generated/* w w w. j a va 2 s . co m*/ */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.StatemachinesDiagramEditor_SavingDeletedFile, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.StatemachinesDiagramEditor_SaveAsErrorTitle, Messages.StatemachinesDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.StatemachinesDiagramEditor_SaveErrorTitle, Messages.StatemachinesDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:ac.soton.fmusim.components.diagram.part.ComponentsDiagramEditor.java
License:Open Source License
/** * @generated//w w w . j a v a 2 s.co m */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.ComponentsDiagramEditor_SavingDeletedFile, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.ComponentsDiagramEditor_SaveAsErrorTitle, Messages.ComponentsDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.ComponentsDiagramEditor_SaveErrorTitle, Messages.ComponentsDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:ac.soton.multisim.diagram.part.MultisimDiagramEditor.java
License:Open Source License
/** * @generated//from w ww . j a v a2s .co m */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.MultisimDiagramEditor_SavingDeletedFile, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.MultisimDiagramEditor_SaveAsErrorTitle, Messages.MultisimDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.MultisimDiagramEditor_SaveErrorTitle, Messages.MultisimDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:ag.ion.noa4e.ui.wizards.application.LocalApplicationWizardDefinePage.java
License:LGPL
/** * Checks page state./*ww w . ja v a2s . co m*/ * * @author Andreas Brker */ private void checkPageState() { System.out.println("LOAWDP: checkPageState"); String home = textHome.getText(); if (home.length() != 0) { File file = new File(home); if (file.canRead()) { try { IApplicationAssistant applicationAssistant = OfficeApplicationRuntime .getApplicationAssistant(EditorCorePlugin.getDefault().getLibrariesLocation()); ILazyApplicationInfo applicationInfo = applicationAssistant.findLocalApplicationInfo(home); if (applicationInfo == null) { setPageComplete(true); setMessage(Messages.LocalApplicationWizardDefinePage_message_warning_path_invalid, IMessageProvider.WARNING); } else { if (applicationInfo.getMajorVersion() == 1 && applicationInfo.getMinorVersion() == 9) { setPageComplete(true); setMessage(Messages.LocalApplicationWizardDefinePage_message_warning_beta_release, IMessageProvider.WARNING); } else if (applicationInfo.getMajorVersion() == 1) { setPageComplete(true); setMessage(Messages.LocalApplicationWizardDefinePage_message_warning_version_old, IMessageProvider.WARNING); } else { setPageComplete(true); setMessage(null); } } } catch (Throwable throwable) { setPageComplete(true); setMessage(null); } } else { setPageComplete(false); setMessage(Messages.LocalApplicationWizardDefinePage_message_error_path_not_available, IMessageProvider.ERROR); } } else { setPageComplete(false); setMessage(null); } }
From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.wizards.FXGraphWizardPage.java
License:Open Source License
protected void revalidate() { if (getClazz().getName() == null || getClazz().getName().trim().length() == 0) { setPageComplete(false);/* ww w .j a v a 2 s . co m*/ setMessage("Enter a name", IMessageProvider.ERROR); } else if (Character.isLowerCase(getClazz().getName().charAt(0))) { setPageComplete(true); setMessage("An FXGraph file should start with an uppercase", IMessageProvider.WARNING); } else { setPageComplete(true); setMessage(null); } }
From source file:at.bestsolution.efxclipse.tooling.fxml.wizards.FXMLWizardPage.java
License:Open Source License
protected void revalidate() { if (getClazz().getName() == null || getClazz().getName().trim().length() == 0) { setPageComplete(false);/* www . j a v a2 s . c o m*/ setMessage("Enter a name", IMessageProvider.ERROR); } else if (Character.isLowerCase(getClazz().getName().charAt(0))) { setPageComplete(true); setMessage("An FXML file should start with an uppercase", IMessageProvider.WARNING); } else { setPageComplete(true); setMessage(null); } }
From source file:at.bestsolution.efxclipse.tooling.pde.e4.project.PluginContentPage.java
License:Open Source License
protected void validatePage() { String errorMessage = validateProperties(); if (errorMessage == null && fGenerateActivator.getSelection()) { IStatus status = JavaConventions.validateJavaTypeName(fClassText.getText().trim(), PDEJavaHelper.getJavaSourceLevel(null), PDEJavaHelper.getJavaComplianceLevel(null)); if (status.getSeverity() == IStatus.ERROR) { errorMessage = status.getMessage(); } else if (status.getSeverity() == IStatus.WARNING) { setMessage(status.getMessage(), IMessageProvider.WARNING); }/*from w w w . j a va 2s .c om*/ } if (errorMessage == null) { String eeid = fEEChoice.getText(); if (fEEChoice.isEnabled()) { IExecutionEnvironment ee = VMUtil.getExecutionEnvironment(eeid); if (ee != null && ee.getCompatibleVMs().length == 0) { errorMessage = PDEUIMessages.NewProjectCreationPage_invalidEE; } } } setErrorMessage(errorMessage); setPageComplete(errorMessage == null); }
From source file:at.rc.tacos.client.view.VehicleForm.java
License:Open Source License
/** * Creates the status section for the vehicle * /* www . j a va2 s. c om*/ * @param parent * the parent composite */ private void createStatusSection(Composite parent) { // create the section Group group = new Group(parent, SWT.NONE); group.setText("Einsatzstatus"); group.setLayout(new GridLayout()); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); group.setBackground(CustomColors.SECTION_BACKGROUND); // composite to add the client area Composite client = new Composite(group, SWT.NONE); client.setBackground(CustomColors.SECTION_BACKGROUND); // layout GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.horizontalSpacing = 15; layout.makeColumnsEqualWidth = false; client.setLayout(layout); GridData clientDataLayout = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); client.setLayoutData(clientDataLayout); // Selection listener for the combos SelectionListener listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { // Ready for action status and out of order is activated if (readyButton.getSelection() && outOfOrder.getSelection()) { getShell().getDisplay().beep(); setErrorMessage( "Ein Fahrzeug kann nicht auer Dienst gestellt werden, wenn es noch einsatzbereit ist."); outOfOrder.setSelection(false); return; } if (outOfOrder.getSelection()) { setMessage("Das Fahrzeug kann keinem Transport zugeordnet werden da es nicht Einsatzbereit ist", IMessageProvider.WARNING); return; } else checkRequiredFields(); } }; // Ready for action readyButton = new Button(client, SWT.CHECK); readyButton.setBackground(CustomColors.SECTION_BACKGROUND); readyButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { // Ready for action status and out of order is activated if (readyButton.getSelection() && outOfOrder.getSelection()) { getShell().getDisplay().beep(); setErrorMessage( "Ein Fahrzeug kann nicht auer Dienst gestellt werden, wenn es noch einsatzbereit ist."); readyButton.setSelection(false); return; } if (!readyButton.getSelection()) { getShell().getDisplay().beep(); setMessage("Das Fahrzeug kann keinem Transport zugeordnet werden da es nicht Einsatzbereit ist", IMessageProvider.WARNING); return; } else checkRequiredFields(); } }); readyButton.setText("Einsatzbereit"); // Out of Order outOfOrder = new Button(client, SWT.CHECK); outOfOrder.setBackground(CustomColors.SECTION_BACKGROUND); outOfOrder.addSelectionListener(listener); outOfOrder.setText("Auer Dienst"); }
From source file:at.rc.tacos.client.view.VehicleForm.java
License:Open Source License
/** * Helper method to determine wheter all fields are valid *//*from ww w.j ava2 s .c o m*/ private void checkRequiredFields() { setErrorMessage(null); setMessage(FORM_DESCRIPTION, IMessageProvider.INFORMATION); // Check the crew if (driverComboViewer.getSelection().isEmpty()) { setErrorMessage("Dem Fahrzeug wurde noch kein Fahrer zugewiesen."); readyButton.setSelection(false); return; } if (medic1ComboViewer.getSelection().isEmpty()) { setMessage("Dem Fahrzeug wurde noch kein Sanitter zugewiesen.", IMessageProvider.WARNING); return; } if (medic2ComboViewer.getSelection().isEmpty()) { setMessage("Dem Fahrzeug fehlt ein Sanitter.", IMessageProvider.WARNING); return; } }