List of usage examples for org.eclipse.jface.dialogs IMessageProvider NONE
int NONE
To view the source code for org.eclipse.jface.dialogs IMessageProvider NONE.
Click Source Link
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 av a 2s .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 a va 2s. 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. * /*from ww w.j a v a 2 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 av a2 s .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.rcpcompany.uibindings.internal.validators.ValidatorAdapterManager.java
License:Open Source License
@Override public int getObjectSeverity(EObject object) { int severity = IMessageProvider.NONE; for (final IBindingMessage message : getUnboundMessages()) { if (message.matches(object, null, null, FeatureMatchingAlgorithm.IGNORE)) { final int s = message.getMessageType(); if (s > severity) { severity = s;//from w w w .j a v a2 s . c o m } } if (severity == IMessageProvider.ERROR) return severity; } return severity; }
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; }// ww w. j av a 2 s . c o 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. j a va 2 s . c o 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;/*www. j ava2s. co m*/ } // 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.siteview.mde.internal.ui.commands.CommandComposerPart.java
License:Open Source License
public void selectionChanged(SelectionChangedEvent event) { // Clear the previous error message (if any) // Field input value is lost on selection any way setMessage(null, IMessageProvider.NONE); Object selectionObject = null; // if preselection exists use that if (fPC != null) selectionObject = fPC;/*from w ww .j a va2 s .c o m*/ else if (event.getSelection() instanceof IStructuredSelection) selectionObject = (((IStructuredSelection) event.getSelection()).getFirstElement()); if (selectionObject != null && selectionObject.equals(fCommandDetails.getCommand())) return; fCommandDetails.showDetailsFor(selectionObject); }
From source file:com.siteview.mde.internal.ui.editor.targetdefinition.TargetEditor.java
License:Open Source License
public void doSaveAs() { commitPages(true);//from ww w .java 2 s . co m ITargetDefinition target = getTarget(); SaveAsDialog dialog = new SaveAsDialog(getSite().getShell()); dialog.create(); dialog.setMessage(MDEUIMessages.TargetEditor_0, IMessageProvider.NONE); if (target.getHandle() instanceof WorkspaceFileTargetHandle) { WorkspaceFileTargetHandle currentTargetHandle = (WorkspaceFileTargetHandle) target.getHandle(); dialog.setOriginalFile(currentTargetHandle.getTargetFile()); } dialog.open(); IPath path = dialog.getResult(); if (path == null) { return; } if (!"target".equalsIgnoreCase(path.getFileExtension())) { //$NON-NLS-1$ path = path.addFileExtension("target"); //$NON-NLS-1$ } IWorkspace workspace = ResourcesPlugin.getWorkspace(); IFile file = workspace.getRoot().getFile(path); if (target != null) { if (workspace.validateEdit(new IFile[] { file }, getSite().getShell()).isOK()) { try { WorkspaceFileTargetHandle newFileTarget = new WorkspaceFileTargetHandle(file); newFileTarget.save(target); setInput(new FileEditorInput(file)); } catch (CoreException e) { MDEPlugin.log(e); showError(MDEUIMessages.TargetEditor_3, e); } } } }