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:com.rcpcompany.uibindings.bindingMessages.ValidationLabelDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { final Integer severity = myObjectSeverities.get(element); if (severity == null) return;/*from w w w . j a v a 2s . c o m*/ if (Activator.getDefault() != null && Activator.getDefault().TRACE_LABEL_DECORATOR) { LogUtils.debug(this, hashCode() + ": " + element + ": severity: " + severity); //$NON-NLS-1$ //$NON-NLS-2$ } switch (severity) { case IMessageProvider.NONE: break; case IMessageProvider.INFORMATION: break; case IMessageProvider.WARNING: decoration.addOverlay(WARNING_IMAGE); break; case IMessageProvider.ERROR: decoration.addOverlay(ERROR_IMAGE); break; default: break; } }
From source file:com.rcpcompany.uibindings.extests.bindingMessages.LabelDecoratorTest.java
License:Open Source License
/** * Test with no propagation of status/*from w w w. j a v a2s .co m*/ */ @Test public void decoratorNoPropagateTest() { // Reset to no errors c0.setAbbreviation("AA"); c1.setAbbreviation("BB"); sleepWithEvents(myLabelDecorator, 2 * VD); testLD(myLabelDecorator, c0, IMessageProvider.NONE, -1); testLD(myLabelDecorator, c1, IMessageProvider.NONE, -1); // Change with no event c0.setAbbreviation("CC"); c1.setAbbreviation("BB"); sleepWithEvents(myLabelDecorator, 2 * VD); testLD(myLabelDecorator, c0, IMessageProvider.NONE, -1); testLD(myLabelDecorator, c1, IMessageProvider.NONE, -1); // !uppercase => warning c0.setAbbreviation("aa"); c1.setAbbreviation("BB"); sleepWithEvents(myLabelDecorator, 2 * VD, c0); testLD(myLabelDecorator, c0, IMessageProvider.WARNING, -1); testLD(myLabelDecorator, c1, IMessageProvider.NONE, -1); // length != 2 => error c0.setAbbreviation("ABC"); c1.setAbbreviation("BB"); sleepWithEvents(myLabelDecorator, 2 * VD, c0); testLD(myLabelDecorator, c0, IMessageProvider.ERROR, -1); testLD(myLabelDecorator, c1, IMessageProvider.NONE, -1); // length != 2 & !uppercase => error c0.setAbbreviation("abc"); c1.setAbbreviation("BB"); sleepWithEvents(myLabelDecorator, 2 * VD); // no change! testLD(myLabelDecorator, c0, IMessageProvider.ERROR, -1); testLD(myLabelDecorator, c1, IMessageProvider.NONE, -1); // Reset to no errors c0.setAbbreviation("AA"); c1.setAbbreviation("DD"); sleepWithEvents(myLabelDecorator, 2 * VD, c0); testLD(myLabelDecorator, c0, IMessageProvider.NONE, -1); testLD(myLabelDecorator, c1, IMessageProvider.NONE, -1); }
From source file:com.rcpcompany.uibindings.extests.bindingMessages.LabelDecoratorTest.java
License:Open Source License
/** * Test with propagation of status/*from ww w . j ava 2 s . c om*/ * <p> * The tree is given as shop->folder->{c0, c1} */ @Test public void testDecoratorePropagateTest() { final Object folder = new Object() { @Override public String toString() { return "FOLDER"; } }; final IPropagationAdapter myAdapter = new IPropagationAdapter() { @Override public Object getParent(Object object) { if (object == c0 || object == c1) return folder; if (object == folder) return myShop; return null; } }; myLabelDecorator.setPropagationAdapter(myAdapter); // Reset to no errors c0.setAbbreviation("AA"); c1.setAbbreviation("BB"); sleepWithEvents(myLabelDecorator, 2 * VD); testLD(myLabelDecorator, myShop, IMessageProvider.NONE, IMessageProvider.NONE); testLD(myLabelDecorator, folder, IMessageProvider.NONE, IMessageProvider.NONE); testLD(myLabelDecorator, c0, IMessageProvider.NONE, IMessageProvider.NONE); testLD(myLabelDecorator, c1, IMessageProvider.NONE, IMessageProvider.NONE); // Change with no event c0.setAbbreviation("CC"); c1.setAbbreviation("BB"); sleepWithEvents(myLabelDecorator, 2 * VD); testLD(myLabelDecorator, myShop, IMessageProvider.NONE, IMessageProvider.NONE); testLD(myLabelDecorator, folder, IMessageProvider.NONE, IMessageProvider.NONE); testLD(myLabelDecorator, c0, IMessageProvider.NONE, IMessageProvider.NONE); testLD(myLabelDecorator, c1, IMessageProvider.NONE, IMessageProvider.NONE); // !uppercase => warning c0.setAbbreviation("aa"); c1.setAbbreviation("BB"); sleepWithEvents(myLabelDecorator, 2 * VD, myShop, folder, c0); testLD(myLabelDecorator, myShop, IMessageProvider.NONE, IMessageProvider.WARNING); testLD(myLabelDecorator, folder, IMessageProvider.NONE, IMessageProvider.WARNING); testLD(myLabelDecorator, c0, IMessageProvider.WARNING, IMessageProvider.WARNING); testLD(myLabelDecorator, c1, IMessageProvider.NONE, IMessageProvider.NONE); // !uppercase && length != 2 => error c0.setAbbreviation("aa"); c1.setAbbreviation("ABC"); sleepWithEvents(myLabelDecorator, 2 * VD, myShop, folder, c1); testLD(myLabelDecorator, myShop, IMessageProvider.NONE, IMessageProvider.ERROR); testLD(myLabelDecorator, folder, IMessageProvider.NONE, IMessageProvider.ERROR); testLD(myLabelDecorator, c0, IMessageProvider.WARNING, IMessageProvider.WARNING); testLD(myLabelDecorator, c1, IMessageProvider.ERROR, IMessageProvider.ERROR); // shop no name && !uppercase => warning+error myShop.setName(""); c0.setAbbreviation("aa"); c1.setAbbreviation("BB"); sleepWithEvents(myLabelDecorator, 2 * VD, folder, c1); testLD(myLabelDecorator, myShop, IMessageProvider.ERROR, IMessageProvider.ERROR); testLD(myLabelDecorator, folder, IMessageProvider.NONE, IMessageProvider.WARNING); testLD(myLabelDecorator, c0, IMessageProvider.WARNING, IMessageProvider.WARNING); testLD(myLabelDecorator, c1, IMessageProvider.NONE, IMessageProvider.NONE); // length != 2 => error myShop.setName("hello"); c0.setAbbreviation("ABC"); c1.setAbbreviation("BB"); sleepWithEvents(myLabelDecorator, 2 * VD, folder, c0); testLD(myLabelDecorator, myShop, IMessageProvider.NONE, IMessageProvider.ERROR); testLD(myLabelDecorator, folder, IMessageProvider.NONE, IMessageProvider.ERROR); testLD(myLabelDecorator, c0, IMessageProvider.ERROR, IMessageProvider.ERROR); testLD(myLabelDecorator, c1, IMessageProvider.NONE, IMessageProvider.NONE); // length != 2 & !uppercase => error c0.setAbbreviation("abc"); c1.setAbbreviation("BB"); sleepWithEvents(myLabelDecorator, 2 * VD); // no change! testLD(myLabelDecorator, myShop, IMessageProvider.NONE, IMessageProvider.ERROR); testLD(myLabelDecorator, folder, IMessageProvider.NONE, IMessageProvider.ERROR); testLD(myLabelDecorator, c0, IMessageProvider.ERROR, IMessageProvider.ERROR); testLD(myLabelDecorator, c1, IMessageProvider.NONE, IMessageProvider.NONE); // Reset to no errors c0.setAbbreviation("AA"); c1.setAbbreviation("DD"); sleepWithEvents(myLabelDecorator, 2 * VD, myShop, folder, c0); testLD(myLabelDecorator, myShop, IMessageProvider.NONE, IMessageProvider.NONE); testLD(myLabelDecorator, folder, IMessageProvider.NONE, IMessageProvider.NONE); testLD(myLabelDecorator, c0, IMessageProvider.NONE, IMessageProvider.NONE); testLD(myLabelDecorator, c1, IMessageProvider.NONE, IMessageProvider.NONE); }
From source file:com.rcpcompany.uibindings.extests.bindingMessages.LabelDecoratorTest.java
License:Open Source License
/** * Tests whether the element - if it is an {@link EObject} - has the specified message type and * whether the specified decorator has the specified decoration. * // ww w . j av a2 s. c o m * @param labelDecorator the decorator * @param element the element in question * @param messageType the expected message for the element * @param decorationType the expected decoration for the element */ private void testLD(ValidationLabelDecorator labelDecorator, Object element, int messageType, int decorationType) { if (element instanceof EObject) { assertEquals(messageType, myValidatorManager.getObjectSeverity((EObject) element)); } if (decorationType == -1) { decorationType = messageType; } myCurrentOverlay = null; final IDecoration decoration = new IDecoration() { @Override public void setForegroundColor(Color color) { fail(); } @Override public void setFont(Font font) { fail(); } @Override public void setBackgroundColor(Color color) { fail(); } @Override public IDecorationContext getDecorationContext() { return DecorationContext.DEFAULT_CONTEXT; } @Override public void addSuffix(String suffix) { fail(); } @Override public void addPrefix(String prefix) { fail(); } @Override public void addOverlay(ImageDescriptor overlay, int quadrant) { fail(); } @Override public void addOverlay(ImageDescriptor overlay) { assertEquals(null, myCurrentOverlay); assertNotNull(overlay); myCurrentOverlay = overlay; } }; labelDecorator.decorate(element, decoration); assertEquals(decorationType, labelDecorator.getElementSeverity(element)); switch (decorationType) { case IMessageProvider.NONE: // No overlay expected assertEquals(null, myCurrentOverlay); break; case IMessageProvider.INFORMATION: // No overlay expected assertEquals(null, myCurrentOverlay); break; case IMessageProvider.WARNING: assertEquals(ValidationLabelDecorator.WARNING_IMAGE, myCurrentOverlay); break; case IMessageProvider.ERROR: assertEquals(ValidationLabelDecorator.ERROR_IMAGE, myCurrentOverlay); break; } }
From source file:com.rcpcompany.uibindings.internal.bindingMessages.ValueBindingMessageImageDecorator.java
License:Open Source License
/** * @see #updateDecoration()//from w ww.j a va 2s .c o m */ protected void updateDecorationDelayed() { if (getBinding().getState() != BindingState.OK) return; /* * As this operation is delayed, the widget might be disposed in the mean time... */ if (getBinding().getUIObservable().isDisposed()) return; if (Activator.getDefault().TRACE_LIFECYCLE_VALUE_BINDING_MESSAGE_DECORATOR) { LogUtils.debug(this, "update delayed " + hashCode() + ": " + getBinding()); //$NON-NLS-1$ //$NON-NLS-2$ } if (VALIDATION_MANAGER != null) { if (getBinding().getModelObservable().isDisposed()) { LogUtils.debug(this, "value is disposed"); return; } /* * Check if the observed object of the binding has changed. If so, then reset the * decoration for the validation manager - this will remove all current messages and set * up a new set... */ final EObject newObservedObject = getBinding().getModelObject(); if (myObservedObject != newObservedObject) { myObservedObject = newObservedObject; VALIDATION_MANAGER.resetDecorator(this); } } /* * Make a list of all the potential messages */ final List<IBindingMessage> ml = new ArrayList<IBindingMessage>(); final BindingMessageSeverity minimumSeverity = IManager.Factory.getManager() .getMessageDecorationMinimumSeverity(); for (final Object v : myMessageProviders) { final IBindingMessage message = (IBindingMessage) ((IObservableValue) v).getValue(); if (message.getSeverity().compareTo(minimumSeverity) < 0) { continue; } ml.add(message); } final IObservableList decoratorMessages = getBinding().getDecorator().getMessages(); if (decoratorMessages != null) { for (final Object m : decoratorMessages) { final IBindingMessage message = (IBindingMessage) m; if (message.getSeverity().compareTo(minimumSeverity) < 0) { continue; } ml.add(message); } } for (final IBindingMessage message : myOutstandingMessages) { if (message.getSeverity().compareTo(minimumSeverity) < 0) { continue; } ml.add(message); } /* * Find the current max type and the combined messages to use... */ int maxType = IMessageProvider.NONE; final List<IBindingMessage> topList = new ArrayList<IBindingMessage>(); for (final IBindingMessage message : ml) { final int type = message.getMessageType(); if (type > maxType) { topList.clear(); maxType = type; } if (type == maxType) { topList.add(message); } } /* * Weed out any superseded messages. * * There has to be at least two messages before there any anything to weed out... */ if (topList.size() > 1) { final IBindingMessage[] ma = topList.toArray(new IBindingMessage[topList.size()]); for (int i = 0; i < ma.length; i++) { final IBindingMessage a = ma[i]; for (int j = i + 1; j < ma.length; j++) { final IBindingMessage b = ma[j]; if (a.supersedes(b)) { topList.remove(b); continue; } if (b.supersedes(a)) { topList.remove(a); break; } } } } /* * Updated the messages */ for (final IBindingMessage m : topList) { if (myMessages.contains(m)) { continue; } myMessagesOL.add(m); } for (final IBindingMessage m : myMessages.toArray(new IBindingMessage[myMessages.size()])) { if (topList.contains(m)) { continue; } myMessagesOL.remove(m); } final StringBuilder sb = new StringBuilder(100); for (final IBindingMessage message : myMessages) { if (sb.length() > 0) { sb.append('\n'); } sb.append(message.getMessage()); } /* * Show the appropriate message decorations */ final Image oldMessageDecorationImage = myMessageDecorationImage; final String oldMessageDecorationMessage = myMessageDecorationMessage; switch (maxType) { case IMessageProvider.NONE: myMessageDecorationImage = null; break; case IMessageProvider.ERROR: myMessageDecorationImage = ERROR_FIELD_DECORATOR.getImage(); break; case IMessageProvider.WARNING: myMessageDecorationImage = WARNING_FIELD_DECORATOR.getImage(); break; case IMessageProvider.INFORMATION: myMessageDecorationImage = INFORMATION_FIELD_DECORATOR.getImage(); break; default: break; } myMessageDecorationMessage = sb.toString(); /* * The alternative stuff is only relevant if the binding is changeable... */ final Image oldAlternativeDecorationImage = myAlternativeDecorationImage; final String oldAlternativeDecorationMessage = myAlternativeDecorationMessage; if (getBinding().isChangeable()) { final IManager manager = IManager.Factory.getManager(); /* * Only show the alternative decorations for controls if they have the focus - but not * for checkboxes */ final Control control = getBinding().getControl(); boolean showAlternativeDecorations = control != null && control.isFocusControl(); if (control instanceof Button && (control.getStyle() & SWT.CHECK) == SWT.CHECK) { showAlternativeDecorations = false; } // TODO TMTM add key bindings if (getQuickfixes().size() > 0 && manager.isQuickfixVBImageDecorationShown()) { myAlternativeDecorationImage = QUICKFIX_FIELD_DECORATOR.getImage(); myAlternativeDecorationMessage = QUICKFIX_FIELD_DECORATOR.getDescription(); } else if (showAlternativeDecorations && getBinding().getDataType().isRequired() && manager.isRequiredVBImageDecorationShown()) { myAlternativeDecorationImage = REQUIRED_FIELD_DECORATOR.getImage(); myAlternativeDecorationMessage = Messages.ValueBindingMessageImageDecorator_ValueRequired; } else if (showAlternativeDecorations && getBinding().getDecorator().getValidUIList() != null && getBinding().getUIAttribute().getFieldAssistAdapter() != null && manager.isAssistVBImageDecorationShown()) { myAlternativeDecorationImage = CONTENT_PROPOSAL_FIELD_DECORATOR.getImage(); myAlternativeDecorationMessage = Messages.ValueBindingMessageImageDecorator_ContentAssistAvailanble; } else { myAlternativeDecorationImage = null; myAlternativeDecorationMessage = null; } } /* * If everything is the same, then do nothing */ if (BasicUtils.equals(oldMessageDecorationImage, myMessageDecorationImage) && BasicUtils.equals(oldMessageDecorationMessage, myMessageDecorationMessage) && BasicUtils.equals(oldAlternativeDecorationImage, myAlternativeDecorationImage) && BasicUtils.equals(oldAlternativeDecorationMessage, myAlternativeDecorationMessage)) return; /* * Update the binding */ getBinding().updateBinding(); }
From source file:com.sabre.buildergenerator.ui.wizard.GenerateBuilderWizardPage.java
License:Open Source License
private void handleStatus(IStatus status) { if (status != null) { switch (status.getSeverity()) { case IStatus.ERROR: setMessage(status.getMessage(), IMessageProvider.ERROR); break; case IStatus.WARNING: setMessage(status.getMessage(), IMessageProvider.WARNING); break; }//from w w w. j av a 2s. co m } else { setMessage(getDescription(), IMessageProvider.NONE); } }
From source file:com.sap.netweaver.porta.ide.eclipse.server.ui.wizard.SapNWRuntimeComposite.java
License:Open Source License
protected void validate() { if (runtime == null) { wizard.setMessage("Internal error: runtime is null", IMessageProvider.ERROR); return;//from w w w .ja v a2s .co m } IStatus status = runtime.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:com.sap.netweaver.porta.ide.eclipse.server.ui.wizard.SapNWServerComposite.java
License:Open Source License
protected void validate() { if (server == null) { wizard.setMessage("Internal error: server is null", IMessageProvider.ERROR); return;/*from ww w . j a v a 2 s. c om*/ } // validate the host IStatus status = validateHost(hostName.getText()); // validate the instance number if (!StatusUtil.hasErrorMessage(status)) { status = StatusUtil.merge(status, validateInstanceNumber(instanceNumber.getText())); } // validate ping status if (!StatusUtil.hasErrorMessage(status)) { status = StatusUtil.merge(status, validatePingStatus()); } if (status == null || status.isOK()) { wizard.setMessage(null, IMessageProvider.NONE); } else if (status.getSeverity() == IStatus.INFO) { wizard.setMessage(status.getMessage(), IMessageProvider.INFORMATION); } else if (status.getSeverity() == IStatus.WARNING) { wizard.setMessage(status.getMessage(), IMessageProvider.WARNING); } else { wizard.setMessage(status.getMessage(), IMessageProvider.ERROR); } pingServer.setEnabled(wizard.getMessageType() != IMessageProvider.ERROR); wizard.update(); }
From source file:com.simplifide.core.ui.wizard.other.NewFilePage.java
License:Open Source License
/** * Returns whether this page's controls currently all contain valid values. * //from w ww . j a v a 2 s .co m * @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 (!resourceGroup.areAllValuesValid()) { // if blank name then fail silently if (resourceGroup.getProblemType() == ResourceAndContainerGroup.PROBLEM_RESOURCE_EMPTY || resourceGroup.getProblemType() == ResourceAndContainerGroup.PROBLEM_CONTAINER_EMPTY) { setMessage(resourceGroup.getProblemMessage()); setErrorMessage(null); } else { setErrorMessage(resourceGroup.getProblemMessage()); } valid = false; } String resourceName = resourceGroup.getResource(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IStatus result = workspace.validateName(resourceName, IResource.FILE); if (!result.isOK()) { setErrorMessage(result.getMessage()); return false; } IStatus linkedResourceStatus = null; if (valid) { //linkedResourceStatus = validateLinkedResource(); linkedResourceStatus = Status.OK_STATUS; 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 (resourceGroup.getAllowExistingResources()) { String problemMessage = NLS.bind(IDEWorkbenchMessages.ResourceGroup_nameExists, getFileName()); 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); } } } if (isFilteredByParent()) { //setMessage(IDEWorkbenchMessages.WizardNewFileCreationPage_resourceWillBeFilteredWarning, IMessageProvider.ERROR); setupLinkedResourceTarget(); valid = false; } return valid; }
From source file:com.siteview.mde.internal.ui.editor.context.InputContext.java
License:Open Source License
/** * @param monitor/*from w w w . ja va 2s . c om*/ */ public void doSaveAs(IProgressMonitor monitor) throws Exception { // Get the editor shell Shell shell = getEditor().getSite().getShell(); // Create the save as dialog SaveAsDialog dialog = new SaveAsDialog(shell); // Set the initial file name to the original file name IFile file = null; if (fEditorInput instanceof IFileEditorInput) { file = ((IFileEditorInput) fEditorInput).getFile(); dialog.setOriginalFile(file); } // Create the dialog dialog.create(); // Warn the user if the underlying file does not exist if (fDocumentProvider.isDeleted(fEditorInput) && (file != null)) { String message = NLS.bind(MDEUIMessages.InputContext_errorMessageFileDoesNotExist, file.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } // Open the dialog if (dialog.open() == Window.OK) { // Get the path to where the new file will be stored IPath path = dialog.getResult(); handleSaveAs(monitor, path); } }