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:gov.redhawk.sca.internal.ui.wizards.WaveformSelectionWizardPage.java
License:Open Source License
@Override public void createControl(final Composite parent) { setupDialogSettings();/* ww w . ja va 2 s . c o m*/ GridData gd; // create the top level composite for the dialog area final Composite composite = new Composite(parent, SWT.NONE); setControl(composite); final GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.makeColumnsEqualWidth = false; layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 5; // SUPPRESS CHECKSTYLE MagicNumber layout.horizontalSpacing = 5; // SUPPRESS CHECKSTYLE MagicNumber composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); // Build the separator line final Label titleBarSeparator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; titleBarSeparator.setLayoutData(gd); this.waveformSelectionList = new FormFilteredTree(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter()); gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.horizontalSpan = 2; this.waveformSelectionList.setLayoutData(gd); this.contentProvider = new InstallApplicationContentProvider(); this.contentProvider.addContentCompletionListener(new JobChangeAdapter() { @Override public void done(final IJobChangeEvent event) { String waveformId = WaveformSelectionWizardPage.this.sadSelection; if (waveformId == null) { waveformId = WaveformSelectionWizardPage.this.waveformSelectionPageSettings .get(WaveformSelectionWizardPage.WAVEFORM_ID); } final String id = waveformId; if (!getControl().isDisposed()) { getControl().getDisplay().asyncExec(new Runnable() { @Override public void run() { final IStatus loadStatus = WaveformSelectionWizardPage.this.contentProvider .getLoadStatus(); if (loadStatus != null && !loadStatus.isOK()) { int severity = 0; if (loadStatus.getSeverity() == IStatus.WARNING) { severity = IMessageProvider.WARNING; } else if (loadStatus.getSeverity() == IStatus.ERROR) { severity = IMessageProvider.ERROR; } ScaUiPlugin.getDefault().getLog().log(loadStatus); setMessage("Problems occurred while scanning for waveforms.\nSee log for details.", severity); } restorePreviousWaveformSelection(id); } }); } } }); this.waveformSelectionList.getViewer().setContentProvider(this.contentProvider); this.waveformSelectionList.getViewer() .setLabelProvider(new AdapterFactoryLabelProvider(new WizardSadItemProviderAdapterFactory())); this.waveformSelectionList.getViewer().addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(final DoubleClickEvent event) { if (getWizard().canFinish()) { if (getWizard().performFinish()) { getWizard().getContainer().getShell().dispose(); } } } }); this.waveformSelectionList.getViewer().setComparator(new ViewerComparator() { private Comparator<String> viewerComparator; @Override protected Comparator<String> getComparator() { if (this.viewerComparator == null) { this.viewerComparator = new Comparator<String>() { @Override public int compare(final String s1, final String s2) { return s1.compareToIgnoreCase(s2); } }; } return this.viewerComparator; } }); this.waveformSelectionList.getViewer().setInput(this.domMgr); final Label label = new Label(composite, SWT.NONE); label.setText("Waveform Name:"); gd = new GridData(SWT.LEFT, SWT.CENTER, false, false); label.setLayoutData(gd); final Text waveformNameTextBox = new Text(composite, SWT.BORDER); gd = new GridData(SWT.FILL, SWT.CENTER, true, false); waveformNameTextBox.setLayoutData(gd); waveformNameTextBox.addModifyListener(new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { WaveformSelectionWizardPage.this.defaultNameChanged = true; WaveformSelectionWizardPage.this.waveformName = waveformNameTextBox.getText(); updateFinished(); } }); this.startWaveform = new Button(composite, SWT.CHECK); this.startWaveform.setText("Start the Waveform after launching"); this.startWaveform.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(false, false).create()); restoreShouldAutoStartWaveform(); this.startWaveform.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(final SelectionEvent e) { WaveformSelectionWizardPage.this.autoStart = WaveformSelectionWizardPage.this.startWaveform .getSelection(); } @Override public void widgetDefaultSelected(final SelectionEvent e) { // PASS } }); this.waveformSelectionList.getViewer().addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { final Object selected = ((StructuredSelection) event.getSelection()).getFirstElement(); if (selected instanceof SoftwareAssembly) { if (WaveformSelectionWizardPage.this.sad == selected) { return; } WaveformSelectionWizardPage.this.sad = (SoftwareAssembly) selected; if (WaveformSelectionWizardPage.this.getWizard() instanceof BasicLaunchWaveformWizard) { ((BasicLaunchWaveformWizard) WaveformSelectionWizardPage.this.getWizard()) .reinitalizePages(); } if (WaveformSelectionWizardPage.this.defaultNameChanged) { // PASS since user had explicitly set the Waveform name } else if (WaveformSelectionWizardPage.this.sad == null) { waveformNameTextBox.setText(""); WaveformSelectionWizardPage.this.defaultNameChanged = false; } else { final SimpleDateFormat dateFormat = new SimpleDateFormat("DDD_HHmmssSSS"); final String initialValue = WaveformSelectionWizardPage.this.sad.getName() + "_" + dateFormat.format(new Date()); waveformNameTextBox.setText(initialValue); WaveformSelectionWizardPage.this.defaultNameChanged = false; } } updateFinished(); } }); this.setPageComplete(false); }
From source file:gov.redhawk.ui.parts.WizardNewFileCreationPage.java
License:Open Source License
/** * Checks whether the linked resource target is valid. Sets the error * message accordingly and returns the status. * //w w w .j av a 2s . c o m * @return IStatus validation result from the CreateLinkedResourceGroup */ protected IStatus validateLinkedResource() { final IPath containerPath = this.resourceGroup.getContainerFullPath(); final IPath newFilePath = containerPath.append(this.resourceGroup.getResource()); final IFile newFileHandle = createFileHandle(newFilePath); final IStatus status = this.linkedResourceGroup.validateLinkLocation(newFileHandle); if (status.getSeverity() == IStatus.ERROR) { if (this.firstLinkCheck) { setMessage(status.getMessage()); } else { setErrorMessage(status.getMessage()); } } else if (status.getSeverity() == IStatus.WARNING) { setMessage(status.getMessage(), IMessageProvider.WARNING); setErrorMessage(null); } return status; }
From source file:gov.redhawk.ui.parts.WizardNewFileCreationPage.java
License:Open Source License
/** * Returns whether this page's controls currently all contain valid values. * //from w w w . ja va 2 s . c om * @return <code>true</code> if all controls are valid, and * <code>false</code> if at least one is invalid */ protected boolean validatePage() { boolean valid = true; if (!this.resourceGroup.areAllValuesValid()) { // if blank name then fail silently if (this.resourceGroup.getProblemType() == ResourceAndContainerGroup.PROBLEM_RESOURCE_EMPTY || this.resourceGroup.getProblemType() == ResourceAndContainerGroup.PROBLEM_CONTAINER_EMPTY) { setMessage(this.resourceGroup.getProblemMessage()); setErrorMessage(null); } else { setErrorMessage(this.resourceGroup.getProblemMessage()); } valid = false; } final String resourceName = this.resourceGroup.getResource(); final IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IStatus result = workspace.validateName(resourceName, IResource.FILE); if (!result.isOK()) { setErrorMessage(result.getMessage()); return false; } IStatus linkedResourceStatus = null; if (valid) { linkedResourceStatus = validateLinkedResource(); if (linkedResourceStatus.getSeverity() == IStatus.ERROR) { valid = false; } } // validateLinkedResource sets messages itself if (valid && (linkedResourceStatus == null || linkedResourceStatus.isOK())) { setMessage(null); setErrorMessage(null); // perform "resource exists" check if it was skipped in ResourceAndContainerGroup if (this.resourceGroup.getAllowExistingResources()) { final String problemMessage = NLS.bind(IDEWorkbenchMessages.ResourceGroup_nameExists, getFileName()); final IPath resourcePath = getContainerFullPath().append(getFileName()); if (workspace.getRoot().getFolder(resourcePath).exists()) { setErrorMessage(problemMessage); valid = false; } if (workspace.getRoot().getFile(resourcePath).exists()) { setMessage(problemMessage, IMessageProvider.WARNING); } } } return valid; }
From source file:info.evanchik.eclipse.karaf.wtp.ui.KarafRuntimeComposite.java
License:Open Source License
/** * Validate the state of the wizard based on the results of the listeners on * the various controls./* w w w . ja va 2 s. co m*/ */ protected void validateWizardState() { if (karafRuntimeWC == null) { wizard.setMessage("", IMessageProvider.ERROR); return; } final IStatus status = karafRuntimeWC.validate(null); if (status == null || status.isOK()) { wizard.setMessage(null, IMessageProvider.NONE); } else if (status.getSeverity() == IStatus.WARNING) { wizard.setMessage(status.getMessage(), IMessageProvider.WARNING); } else { wizard.setMessage(status.getMessage(), IMessageProvider.ERROR); } wizard.update(); }
From source file:io.sarl.eclipse.log.IssueInformationPage.java
License:Apache License
/** Update the page status and change the "finish" state button. *//* ww w . j a v a2s. co m*/ protected void updatePageStatus() { final boolean ok; if (Strings.isEmpty(this.titleField.getText())) { ok = false; setMessage(Messages.IssueInformationPage_5, IMessageProvider.ERROR); } else if (Strings.isEmpty(this.trackerLogin.getText())) { ok = false; setMessage(Messages.IssueInformationPage_6, IMessageProvider.ERROR); } else if (Strings.isEmpty(this.trackerPassword.getText())) { ok = false; setMessage(Messages.IssueInformationPage_7, IMessageProvider.ERROR); } else { ok = true; if (Strings.isEmpty(this.descriptionField.getText())) { setMessage(Messages.IssueInformationPage_8, IMessageProvider.WARNING); } else { setMessage(null, IMessageProvider.NONE); } } setPageComplete(ok); }
From source file:io.sarl.eclipse.wizards.sreinstall.AbstractSREInstallPage.java
License:Apache License
/** * Updates the status message on the page, based on the status of the SRE and other * status provided by the page./*from w ww. j a v a 2 s . c o m*/ */ protected void updatePageStatus() { if (this.status.isOK()) { setMessage(null, IMessageProvider.NONE); } else { switch (this.status.getSeverity()) { case IStatus.ERROR: setMessage(this.status.getMessage(), IMessageProvider.ERROR); break; case IStatus.INFO: setMessage(this.status.getMessage(), IMessageProvider.INFORMATION); break; case IStatus.WARNING: setMessage(this.status.getMessage(), IMessageProvider.WARNING); break; default: break; } } setPageComplete(this.status.isOK() || this.status.getSeverity() == IStatus.INFO); }
From source file:melnorme.lang.ide.ui.preferences.common.AbstractComponentsPrefPage.java
License:Open Source License
public static int statusLevelToMessageType(StatusLevel statusLevel) { switch (statusLevel) { case OK:/*from www.ja v a2 s .co m*/ return IMessageProvider.NONE; case INFO: return IMessageProvider.INFORMATION; case WARNING: return IMessageProvider.WARNING; case ERROR: return IMessageProvider.ERROR; } throw assertFail(); }
From source file:melnorme.lang.ide.ui.utils.DialogPageUtils.java
License:Open Source License
public static int severityToMessageType(IStatus status) { switch (status.getSeverity()) { case IStatus.ERROR: return IMessageProvider.ERROR; case IStatus.WARNING: return IMessageProvider.WARNING; case IStatus.INFO: return IMessageProvider.INFORMATION; case IStatus.OK: return IMessageProvider.NONE; default:/*from w w w. j a va 2 s . co m*/ return IMessageProvider.NONE; } }
From source file:mil.jpeojtrs.sca.dcd.diagram.part.DcdDiagramEditor.java
License:Open Source License
/** * @generated//from ww w .j a v a 2 s . c o 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.DcdDiagramEditor_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.DcdDiagramEditor_SaveAsErrorTitle, Messages.DcdDiagramEditor_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) { StatusManager.getManager() .handle(new Status(x.getStatus().getSeverity(), "mil.jpeojtrs.sca.dcd.diagram", Messages.DcdDiagramEditor_SaveErrorMessage, x), StatusManager.SHOW | StatusManager.LOG); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:mil.jpeojtrs.sca.sad.diagram.part.SadDiagramEditor.java
License:Open Source License
/** * @generated/*from w ww . j av a 2 s . c o 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.SadDiagramEditor_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.SadDiagramEditor_SaveAsErrorTitle, Messages.SadDiagramEditor_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) { StatusManager.getManager() .handle(new Status(x.getStatus().getSeverity(), "mil.jpeojtrs.sca.dcd.diagram", Messages.SadDiagramEditor_SaveErrorMessage, x), StatusManager.SHOW | StatusManager.LOG); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }