List of usage examples for org.eclipse.jface.dialogs IMessageProvider INFORMATION
int INFORMATION
To view the source code for org.eclipse.jface.dialogs IMessageProvider INFORMATION.
Click Source Link
From source file:org.eclipse.tm4e.languageconfiguration.internal.wizards.SelectLanguageConfigurationWizardPage.java
License:Open Source License
private static void applyToStatusLine(DialogPage page, IStatus status) { String message = Status.OK_STATUS.equals(status) ? null : status.getMessage(); switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null);//from ww w . j a va2s .com break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: if (message != null && message.length() == 0) { message = null; } page.setMessage(null); page.setErrorMessage(message); break; } }
From source file:org.eclipse.tm4e.ui.internal.wizards.AbstractWizardPage.java
License:Open Source License
/** * Applies the status to the status line of a dialog page. *//*from ww w . ja v a2 s . c o m*/ private static void applyToStatusLine(DialogPage page, IStatus status) { String message = Status.OK_STATUS.equals(status) ? null : status.getMessage(); switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: if (message != null && message.length() == 0) { message = null; } page.setMessage(null); page.setErrorMessage(message); break; } }
From source file:org.eclipse.ui.forms.examples.internal.rcp.ErrorMessagesPage.java
License:Open Source License
private void configureFormText(final Form form, FormText text) { text.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { String is = (String) e.getHref(); try { int index = Integer.parseInt(is); IMessage[] messages = form.getChildrenMessages(); IMessage message = messages[index]; Control c = message.getControl(); ((FormText) e.widget).getShell().dispose(); if (c != null) c.setFocus();/* ww w . java2 s . c o m*/ } catch (NumberFormatException ex) { } } }); text.setImage("error", getImage(IMessageProvider.ERROR)); text.setImage("warning", getImage(IMessageProvider.WARNING)); text.setImage("info", getImage(IMessageProvider.INFORMATION)); }
From source file:org.eclipse.ui.forms.examples.internal.rcp.ErrorMessagesPage.java
License:Open Source License
String createFormTextContent(IMessage[] messages) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.println("<form>"); for (int i = 0; i < messages.length; i++) { IMessage message = messages[i];/*from ww w. ja v a 2 s. c o m*/ pw.print("<li vspace=\"false\" style=\"image\" indent=\"16\" value=\""); switch (message.getMessageType()) { case IMessageProvider.ERROR: pw.print("error"); break; case IMessageProvider.WARNING: pw.print("warning"); break; case IMessageProvider.INFORMATION: pw.print("info"); break; } pw.print("\"> <a href=\""); pw.print(i + ""); pw.print("\">"); if (message.getPrefix() != null) pw.print(message.getPrefix()); pw.print(message.getMessage()); pw.println("</a></li>"); } pw.println("</form>"); pw.flush(); return sw.toString(); }
From source file:org.eclipse.ui.forms.examples.internal.rcp.ErrorMessagesPage.java
License:Open Source License
private void createDecoratedTextField(String label, FormToolkit toolkit, Composite parent, final IMessageManager mmng) { toolkit.createLabel(parent, label);/* w w w.j a v a 2s .c om*/ final Text text = toolkit.createText(parent, ""); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = 150; text.setLayoutData(gd); text.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { String s = text.getText(); // flag length if (s.length() > 0 && s.length() <= 5) { mmng.addMessage("textLength", "Text is longer than 0 characters", null, IMessageProvider.INFORMATION, text); } else if (s.length() > 5 && s.length() <= 10) { mmng.addMessage("textLength", "Text is longer than 5 characters", null, IMessageProvider.WARNING, text); } else if (s.length() > 10) { mmng.addMessage("textLength", "Text is longer than 10 characters", null, IMessageProvider.ERROR, text); } else { mmng.removeMessage("textLength", text); } // flag type boolean badType = false; for (int i = 0; i < s.length(); i++) { if (!Character.isLetter(s.charAt(i))) { badType = true; break; } } if (badType) { mmng.addMessage("textType", "Text must only contain letters", null, IMessageProvider.ERROR, text); } else { mmng.removeMessage("textType", text); } } }); }
From source file:org.eclipse.ui.forms.examples.internal.rcp.NewStylePage.java
License:Open Source License
protected void createFormContent(IManagedForm managedForm) { final ScrolledForm form = managedForm.getForm(); final FormToolkit toolkit = managedForm.getToolkit(); toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_HOVER); GridLayout layout = new GridLayout(); layout.numColumns = 2;/*from www .j a va 2s .c o m*/ layout.marginHeight = 10; layout.marginWidth = 6; layout.horizontalSpacing = 20; form.getBody().setLayout(layout); Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); Composite client = toolkit.createComposite(section); section.setClient(client); section.setText("Header features"); section.setDescription("Use the switches below to control basic heading parameters."); GridData gd = new GridData(GridData.FILL_BOTH); section.setLayoutData(gd); layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; client.setLayout(layout); final Button tbutton = toolkit.createButton(client, "Add title", SWT.CHECK); final Button sbutton = toolkit.createButton(client, "Short title", SWT.RADIO); sbutton.setSelection(true); sbutton.setEnabled(false); gd = new GridData(); gd.horizontalIndent = 10; sbutton.setLayoutData(gd); final Button lbutton = toolkit.createButton(client, "Long title", SWT.RADIO); gd = new GridData(); gd.horizontalIndent = 10; lbutton.setLayoutData(gd); lbutton.setEnabled(false); tbutton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateTitle(form, tbutton.getSelection(), sbutton.getSelection()); sbutton.setEnabled(tbutton.getSelection()); lbutton.setEnabled(tbutton.getSelection()); } }); sbutton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateTitle(form, tbutton.getSelection(), sbutton.getSelection()); } }); lbutton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateTitle(form, tbutton.getSelection(), sbutton.getSelection()); } }); final Button ibutton = toolkit.createButton(client, "Add image", SWT.CHECK); ibutton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateImage(form, ibutton.getSelection()); } }); final Button tbbutton = toolkit.createButton(client, "Add tool bar", SWT.CHECK); final Button albutton = toolkit.createButton(client, "Set tool bar allignment to SWT.BOTTOM", SWT.CHECK); albutton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { form.getForm().setToolBarVerticalAlignment(albutton.getSelection() ? SWT.BOTTOM : SWT.TOP); form.reflow(true); } }); gd = new GridData(); gd.horizontalIndent = 10; albutton.setLayoutData(gd); albutton.setEnabled(false); tbbutton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addToolBar(toolkit, form, tbbutton.getSelection()); albutton.setEnabled(tbbutton.getSelection()); } }); final Button gbutton = toolkit.createButton(client, "Paint background gradient", SWT.CHECK); gbutton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addHeadingGradient(toolkit, form, gbutton.getSelection()); } }); final Button clbutton = toolkit.createButton(client, "Add head client", SWT.CHECK); clbutton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addHeadClient(toolkit, form, clbutton.getSelection()); } }); final Button mbutton = toolkit.createButton(client, "Add drop-down menu", SWT.CHECK); mbutton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addMenu(toolkit, form, mbutton.getSelection()); } }); final Button dbutton = toolkit.createButton(client, "Add drag support", SWT.CHECK); dbutton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (dbutton.getSelection()) { addDragSupport(form); dbutton.setEnabled(false); } } }); section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); Composite client2 = toolkit.createComposite(section); section.setClient(client2); section.setText("Messages and active state"); section.setDescription("Use the buttons below to control messages and active state."); gd = new GridData(GridData.FILL_BOTH); section.setLayoutData(gd); layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; layout.numColumns = 4; client2.setLayout(layout); final Button shortMessage = toolkit.createButton(client2, "Short message", SWT.RADIO); shortMessage.setSelection(true); gd = new GridData(); gd.horizontalSpan = 4; shortMessage.setLayoutData(gd); final Button longMessage = toolkit.createButton(client2, "Long message", SWT.RADIO); gd = new GridData(); gd.horizontalSpan = 4; longMessage.setLayoutData(gd); final IHyperlinkListener listener = new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { String title = e.getLabel(); String details = (String) e.getHref(); if (details == null) { details = title; title = null; } switch (form.getForm().getMessageType()) { case IMessageProvider.NONE: case IMessageProvider.INFORMATION: if (title == null) title = "Forms Information"; MessageDialog.openInformation(form.getShell(), title, details); break; case IMessageProvider.WARNING: if (title == null) title = "Forms Warning"; MessageDialog.openWarning(form.getShell(), title, details); break; case IMessageProvider.ERROR: if (title == null) title = "Forms Error"; MessageDialog.openError(form.getShell(), title, details); break; } } }; final Button hyperMessage = toolkit.createButton(client2, "Message as hyperlink", SWT.CHECK); gd = new GridData(); gd.horizontalSpan = 4; hyperMessage.setLayoutData(gd); hyperMessage.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (hyperMessage.getSelection()) form.getForm().addMessageHyperlinkListener(listener); else form.getForm().removeMessageHyperlinkListener(listener); } }); Control[] children = client.getChildren(); ArrayList buttons = new ArrayList(); for (int i = 0; i < children.length; i++) { if (children[i] instanceof Button) { Button button = (Button) children[i]; if ((button.getStyle() & SWT.CHECK) != 0 && !button.equals(dbutton)) { buttons.add(button); } } } final Button[] checkboxes = (Button[]) buttons.toArray(new Button[buttons.size()]); final Button manageMessage = toolkit.createButton(client2, "Use message manager", SWT.CHECK); gd = new GridData(); gd.horizontalSpan = 4; manageMessage.setLayoutData(gd); SelectionAdapter mmListener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (manageMessage.getSelection() && e.widget instanceof Button) addRemoveMessage((Button) e.widget, form.getMessageManager()); } }; for (int i = 0; i < checkboxes.length; i++) checkboxes[i].addSelectionListener(mmListener); final Button autoUpdate = toolkit.createButton(client2, "Auto update message manager", SWT.CHECK); gd = new GridData(); gd.horizontalSpan = 4; autoUpdate.setLayoutData(gd); autoUpdate.setSelection(true); autoUpdate.setEnabled(false); autoUpdate.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { form.getMessageManager().setAutoUpdate(autoUpdate.getSelection()); } }); shortMessage.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { form.setMessage(getErrorMessage(form.getMessageType(), longMessage.getSelection()), form.getMessageType()); } }); longMessage.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { form.setMessage(getErrorMessage(form.getMessageType(), longMessage.getSelection()), form.getMessageType()); } }); final Button error = toolkit.createButton(client2, "Error", SWT.PUSH); error.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { form.setMessage(getErrorMessage(IMessageProvider.ERROR, longMessage.getSelection()), IMessageProvider.ERROR); } }); final Button warning = toolkit.createButton(client2, "Warning", SWT.PUSH); warning.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { form.setMessage(getErrorMessage(IMessageProvider.WARNING, longMessage.getSelection()), IMessageProvider.WARNING); } }); final Button info = toolkit.createButton(client2, "Info", SWT.PUSH); info.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { form.setMessage(getErrorMessage(IMessageProvider.INFORMATION, longMessage.getSelection()), IMessageProvider.INFORMATION); } }); final Button cancel = toolkit.createButton(client2, "Cancel", SWT.PUSH); cancel.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { form.setMessage(null, 0); } }); manageMessage.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean selection = manageMessage.getSelection(); if (!selection) autoUpdate.setSelection(true); autoUpdate.setEnabled(selection); IMessageManager mm = form.getMessageManager(); mm.setAutoUpdate(false); if (selection) { for (int i = 0; i < checkboxes.length; i++) { addRemoveMessage(checkboxes[i], mm); } } else { mm.removeAllMessages(); } mm.setAutoUpdate(true); error.setEnabled(!selection); warning.setEnabled(!selection); info.setEnabled(!selection); cancel.setEnabled(!selection); if (selection) { hyperMessage.setSelection(false); form.getForm().removeMessageHyperlinkListener(listener); } hyperMessage.setEnabled(!selection); } }); final Button busy = toolkit.createButton(client2, "Start Progress", SWT.PUSH); busy.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // IWorkbenchSiteProgressService service = // (IWorkbenchSiteProgressService)getSite().getAdapter(IWorkbenchSiteProgressService.class); if (form.getForm().isBusy()) { form.getForm().setBusy(false); busy.setText("Start Progress"); } else { form.getForm().setBusy(true); busy.setText("Stop Progress"); } } }); gd = new GridData(); gd.horizontalSpan = 2; busy.setLayoutData(gd); }
From source file:org.eclipse.ui.forms.examples.internal.rcp.NewStylePage.java
License:Open Source License
private void addRemoveMessage(Button button, IMessageManager mm) { if (button.getSelection()) mm.addMessage(button, button.getText() + " is checked.", null, IMessageProvider.INFORMATION, button); else/* w w w . j a v a 2s .c om*/ mm.removeMessage(button, button); }
From source file:org.eclipse.ui.internal.editors.text.HyperlinkDetectorsConfigurationBlock.java
License:Open Source License
/** * Applies the status to the status line of a dialog page. * * @param status the status/*from w w w.j a v a2 s .co m*/ */ private void applyToStatusLine(IStatus status) { String message = status.getMessage(); switch (status.getSeverity()) { case IStatus.OK: fPreferencePage.setMessage(message, IMessageProvider.NONE); fPreferencePage.setErrorMessage(null); break; case IStatus.WARNING: fPreferencePage.setMessage(message, IMessageProvider.WARNING); fPreferencePage.setErrorMessage(null); break; case IStatus.INFO: fPreferencePage.setMessage(message, IMessageProvider.INFORMATION); fPreferencePage.setErrorMessage(null); break; default: if (message.length() == 0) { message = null; } fPreferencePage.setMessage(null); fPreferencePage.setErrorMessage(message); break; } }
From source file:org.eclipse.ui.internal.monitoring.preferences.FilterInputDialog.java
License:Open Source License
public FilterInputDialog(Shell parentShell, String message) { super(parentShell); create(); setMessage(message, IMessageProvider.INFORMATION); }
From source file:org.eclipse.ui.texteditor.MessageRegion.java
License:Open Source License
/** * Show the new message in the message text and update the image. Base the background color on * whether or not there are errors.//from w w w .j av a2 s . c om * * @param newMessage The new value for the message * @param newType One of the IMessageProvider constants. If newType is IMessageProvider.NONE * show the title. * @see IMessageProvider */ public void updateText(String newMessage, int newType) { Image newImage = null; boolean showingError = false; switch (newType) { case IMessageProvider.NONE: hideRegion(); return; case IMessageProvider.INFORMATION: newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO); break; case IMessageProvider.WARNING: newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); break; case IMessageProvider.ERROR: newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); showingError = true; break; } if (newMessage == null) {//No message so clear the area hideRegion(); return; } showRegion(); // Any more updates required if (newMessage.equals(messageText.getText()) && newImage == messageImageLabel.getImage()) return; messageImageLabel.setImage(newImage); messageText.setText(newMessage); if (showingError) setMessageColors(JFaceColors.getErrorBackground(messageComposite.getDisplay())); else { lastMessageText = newMessage; setMessageColors(JFaceColors.getBannerBackground(messageComposite.getDisplay())); } }