List of usage examples for org.eclipse.jface.resource JFaceResources getImage
public static Image getImage(String key)
null
if none. From source file:org.eclipse.birt.report.designer.internal.ui.views.attributes.page.BookMarkExpressionPage.java
License:Open Source License
public void buildUI(Composite parent) { super.buildUI(parent); container.setLayout(WidgetUtil.createGridLayout(2, 15)); noteSection = new FormTextSection("", container, true); //$NON-NLS-1$ noteSection.setWidth(450);//from www .j a v a 2 s .c o m noteSection.setFillText(false); noteSection.setText(generateNoteSectionText(MESSAGE_GENERAL)); noteSection.setImage("image", //$NON-NLS-1$ JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); noteSection.setColor("color", ColorManager.getColor(127, 127, 127)); //$NON-NLS-1$ addSection(PageSectionId.GENERAL_LIBRARY_NOTE, noteSection); bookMarkProvider = new ExpressionPropertyDescriptorProvider(IReportItemModel.BOOKMARK_PROP, ReportDesignConstants.REPORT_ITEM); bookMarkSection = new ExpressionSection(bookMarkProvider.getDisplayName(), container, true); bookMarkSection.setProvider(bookMarkProvider); bookMarkSection.setWidth(500); addSection(PageSectionId.BOOKMARKEXPRESSION_BOOKMARK, bookMarkSection); createSections(); layoutSections(); }
From source file:org.eclipse.birt.report.designer.ui.dialogs.StyleBuilder.java
License:Open Source License
private void createDialogTitleArea(Composite parent) { Composite contents = new Composite(parent, SWT.NONE); contents.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); FormLayout layout = new FormLayout(); contents.setLayout(layout);//w w w. j av a 2 s. com dialogTitleArea = new Composite(contents, SWT.NONE); initializeDialogUnits(dialogTitleArea); FormData titleAreaData = new FormData(); titleAreaData.top = new FormAttachment(0, 0); titleAreaData.left = new FormAttachment(0, 0); titleAreaData.right = new FormAttachment(100, 0); dialogTitleArea.setLayoutData(titleAreaData); layout = new FormLayout(); dialogTitleArea.setLayout(layout); // add a dispose listener dialogTitleArea.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (titleAreaColor != null) { titleAreaColor.dispose(); } } }); // Determine the background color of the title bar Display display = dialogTitleArea.getDisplay(); Color background; Color foreground; if (titleAreaRGB != null) { titleAreaColor = new Color(display, titleAreaRGB); background = titleAreaColor; foreground = null; } else { background = JFaceColors.getBannerBackground(display); foreground = JFaceColors.getBannerForeground(display); } dialogTitleArea.setBackground(background); int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); // Dialog image @ right titleImageLabel = new Label(dialogTitleArea, SWT.CENTER); titleImageLabel.setBackground(background); if (titleAreaImage == null) titleImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER)); else titleImageLabel.setImage(titleAreaImage); FormData imageData = new FormData(); imageData.top = new FormAttachment(0, 0); // Note: do not use horizontalSpacing on the right as that would be a // regression from // the R2.x style where there was no margin on the right and images are // flush to the right // hand side. see reopened comments in 41172 imageData.right = new FormAttachment(100, 0); // horizontalSpacing titleImageLabel.setLayoutData(imageData); // Title label @ top, left titleLabel = new Label(dialogTitleArea, SWT.LEFT); JFaceColors.setColors(titleLabel, foreground, background); titleLabel.setFont(JFaceResources.getBannerFont()); titleLabel.setText(" ");//$NON-NLS-1$ FormData titleData = new FormData(); titleData.top = new FormAttachment(0, verticalSpacing); titleData.right = new FormAttachment(titleImageLabel); titleData.left = new FormAttachment(0, horizontalSpacing); titleLabel.setLayoutData(titleData); // Message image @ bottom, left messageImageLabel = new Label(dialogTitleArea, SWT.CENTER); messageImageLabel.setBackground(background); // Message label @ bottom, center messageLabel = new Text(dialogTitleArea, SWT.WRAP | SWT.READ_ONLY); JFaceColors.setColors(messageLabel, foreground, background); messageLabel.setText(" \n "); // two lines//$NON-NLS-1$ messageLabel.setFont(JFaceResources.getDialogFont()); messageLabelHeight = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; // Filler labels leftFillerLabel = new Label(dialogTitleArea, SWT.CENTER); leftFillerLabel.setBackground(background); bottomFillerLabel = new Label(dialogTitleArea, SWT.CENTER); bottomFillerLabel.setBackground(background); setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing); determineTitleImageLargest(); Label titleBarSeparator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR); titleBarSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); }
From source file:org.eclipse.birt.report.designer.ui.dialogs.StyleBuilder.java
License:Open Source License
public void setTitleMessage(String newMessage, int newType) { Image newImage = null;/*from www. j a va 2s . c o m*/ if (newMessage != null) { switch (newType) { case IMessageProvider.NONE: break; case IMessageProvider.INFORMATION: newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_INFO); break; case IMessageProvider.WARNING: newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_WARNING); break; case IMessageProvider.ERROR: newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_ERROR); break; } } showTitleMessage(newMessage, newImage); }
From source file:org.eclipse.cdt.internal.ui.newui.StatusMessageLine.java
License:Open Source License
/** * Find an image associated with the status. *//* w w w .j a va 2 s. c o m*/ private Image findImage(IStatus status) { if (status.isOK()) { return null; } else if (status.matches(IStatus.ERROR)) { return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); } else if (status.matches(IStatus.WARNING)) { return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); } else if (status.matches(IStatus.INFO)) { return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO); } return null; }
From source file:org.eclipse.cdt.internal.ui.refactoring.dialogs.ValidatingLabeledTextField.java
License:Open Source License
public void addElement(String description, String initialText, boolean readOnly, final Validator validator) { Label label = new Label(this, SWT.NONE); label.setText(description);//w w w .j a va2 s . co m label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); final Text textField = new Text(this, SWT.BORDER | SWT.SINGLE); textField.setText(initialText); textField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); if (readOnly) { //readOnly inputs are always valid: validationStatus.put(textField, Boolean.TRUE); textField.setEnabled(false); return; } validationStatus.put(textField, Boolean.FALSE); final Label errorImageLabel = new Label(this, SWT.NONE); errorImageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR)); errorImageLabel.setLayoutData(new GridData()); errorImageLabel.setVisible(false); final Label errorLabel = new Label(this, SWT.NONE); errorLabel.setLayoutData(new GridData()); final Color defaultColor = textField.getBackground(); Listener listener = new Listener() { @SuppressWarnings("unchecked") public void checkField() { String newName = textField.getText(); boolean isEmpty = (newName.length() == 0); boolean isNameAlreadyInUse = nameAlreadyInUse(textField, newName); boolean isValid = validator.isValidInput(newName); boolean isKeyword = NameHelper.isKeyword(newName); boolean isValidName = NameHelper.isValidLocalVariableName(newName); boolean isOk = isValid && !isNameAlreadyInUse && !isEmpty && !isKeyword && isValidName; if (isOk) { setErrorStatus(EMPTY_STRING); } else if (isEmpty) { setErrorStatus(validator.errorMessageForEmptyField()); } else if (!isValid || !isValidName) { setErrorStatus(validator.errorMessageForInvalidInput()); } else if (isKeyword) { setErrorStatus(validator.errorIsKeywordMessage()); } else if (isNameAlreadyInUse) { setErrorStatus(validator.errorMessageForDuplicateValues()); } validationStatus.put(textField, isOk); if (validationStatus.values().contains(Boolean.FALSE) || isEmpty || isNameAlreadyInUse || isKeyword || !isValidName) { validator.hasErrors(); } else { validator.hasNoErrors(); } layout(); // recheck all other listeners in case duplicate names have been resolved, // but remove this first to avoid an infinite loop inputTextListeners.remove(this); for (Listener listener : (ArrayList<Listener>) inputTextListeners.clone()) { listener.handleEvent(null); } inputTextListeners.add(this); } private boolean nameAlreadyInUse(final Text textField, String newName) { for (Text text : validationStatus.keySet()) { if (text != textField && text.getText().equals(newName)) { return true; } } return false; } private void setErrorStatus(String errorMessage) { if (EMPTY_STRING.equals(errorMessage)) { textField.setBackground(defaultColor); errorLabel.setText(EMPTY_STRING); errorImageLabel.setVisible(false); } else { textField.setBackground(errorColor); errorLabel.setText(errorMessage); errorImageLabel.setVisible(true); } } @Override public void handleEvent(Event event) { checkField(); } }; //we need to keep a list of all listeners so we get access from other textfields to resolve duplicate names inputTextListeners.add(listener); listener.handleEvent(null); textField.addListener(SWT.Modify, listener); }
From source file:org.eclipse.contribution.visualiser.internal.preference.VisualiserPreferencesDialog.java
License:Open Source License
/** * Creates the dialog's title area./* ww w .j a va 2 s.co m*/ * * @param parent the SWT parent for the title area composite * @return the created title area composite */ private Composite createTitleArea(Composite parent) { // Create the title area which will contain // a title, message, and image. titleArea = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 2; layout.marginWidth = 2; layout.verticalSpacing = 0; layout.horizontalSpacing = 0; layout.numColumns = 2; // Get the background color for the title area Display display = parent.getDisplay(); Color background = JFaceColors.getBannerBackground(display); final Color foreground = JFaceColors.getBannerForeground(display); GridData layoutData = new GridData(GridData.FILL_BOTH); titleArea.setLayout(layout); titleArea.setLayoutData(layoutData); titleArea.setBackground(background); RGB rgb = new RGB(171, 168, 165); final Color borderColor = new Color(titleArea.getDisplay(), rgb); titleArea.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.setForeground(borderColor); Rectangle bounds = titleArea.getClientArea(); bounds.height = bounds.height - 2; bounds.width = bounds.width - 1; e.gc.drawRectangle(bounds); } }); // Add a dispose listener titleArea.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (titleAreaColor != null) titleAreaColor.dispose(); if (errorMsgAreaBackground != null) errorMsgAreaBackground.dispose(); borderColor.dispose(); } }); // Message label messageLabel = new CLabel(titleArea, SWT.LEFT); JFaceColors.setColors(messageLabel, foreground, background); messageLabel.setText(" "); //$NON-NLS-1$ messageLabel.setFont(JFaceResources.getBannerFont()); GridData gd = new GridData(GridData.FILL_BOTH); messageLabel.setLayoutData(gd); // Title image titleImage = new Label(titleArea, SWT.LEFT); titleImage.setBackground(background); titleImage.setImage(JFaceResources.getImage(PREF_DLG_TITLE_IMG)); gd = new GridData(); gd.horizontalAlignment = GridData.END; titleImage.setLayoutData(gd); return titleArea; }
From source file:org.eclipse.contribution.visualiser.internal.preference.VisualiserPreferencesDialog.java
License:Open Source License
/** * Display the given error message. The currently displayed message * is saved and will be redisplayed when the error message is set * to <code>null</code>./*from w ww . j a v a 2s .co m*/ * * @param newErrorMessage the errorMessage to display or <code>null</code> */ public void setErrorMessage(String newErrorMessage) { // Any change? if (errorMessage == null ? newErrorMessage == null : errorMessage.equals(newErrorMessage)) return; errorMessage = newErrorMessage; if (errorMessage == null) { if (showingError) { // we were previously showing an error showingError = false; messageLabel.setBackground(normalMsgAreaBackground); messageLabel.setImage(null); titleImage.setImage(JFaceResources.getImage(PREF_DLG_TITLE_IMG)); } // avoid calling setMessage in case it is overridden to call setErrorMessage, // which would result in a recursive infinite loop if (message == null) //this should probably never happen since setMessage does this conversion.... message = ""; //$NON-NLS-1$ messageLabel.setText(message); messageLabel.setImage(messageImage); messageLabel.setToolTipText(message); } else { messageLabel.setText(errorMessage); messageLabel.setToolTipText(errorMessage); if (!showingError) { // we were not previously showing an error showingError = true; // lazy initialize the error background color and image if (errorMsgAreaBackground == null) { errorMsgAreaBackground = JFaceColors.getErrorBackground(messageLabel.getDisplay()); errorMsgImage = JFaceResources.getImage(PREF_DLG_IMG_TITLE_ERROR); } // show the error normalMsgAreaBackground = messageLabel.getBackground(); messageLabel.setBackground(errorMsgAreaBackground); messageLabel.setImage(errorMsgImage); titleImage.setImage(null); } } titleArea.layout(true); }
From source file:org.eclipse.contribution.visualiser.internal.preference.VisualiserPreferencesDialog.java
License:Open Source License
/** * Sets the message for this dialog with an indication of what type * of message it is./*from ww w. ja v a2 s .co m*/ * <p> * The valid message types are one of <code>NONE</code>, * <code>INFORMATION</code>, <code>WARNING</code>, or <code>ERROR</code>. * </p> * <p> * Note that for backward compatibility, a message of type <code>ERROR</code> * is different than an error message (set using <code>setErrorMessage</code>). * An error message overrides the current message until the error message is * cleared. This method replaces the current message and does not affect the * error message. * </p> * * @param newMessage the message, or <code>null</code> to clear * the message * @param newType the message type */ public void setMessage(String newMessage, int newType) { Image newImage = null; if (newMessage != null) { switch (newType) { case IMessageProvider.NONE: break; case IMessageProvider.INFORMATION: newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_INFO); break; case IMessageProvider.WARNING: newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_WARNING); break; case IMessageProvider.ERROR: newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_ERROR); break; } } showMessage(newMessage, newImage); }
From source file:org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationTabGroupViewer.java
License:Open Source License
/** * Shows the link for either multiple launch delegates or bad launch mode combinations * //from w ww . ja v a 2s .c om * @since 3.3 */ private void showLink() { String text = null; if (!canLaunchWithModes()) { text = LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_13; } else if (hasMultipleDelegates()) { ILaunchDelegate delegate = getPreferredDelegate(); if (delegate != null) { String name = delegate.getName(); if (name == null) { text = LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_15; } else { text = MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_16, new String[] { name }); } } else { text = LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_17; } } if (text != null) { fOptionsLink.setText(text); } fOptionsLink.setVisible(!canLaunchWithModes() || hasMultipleDelegates()); if (hasDuplicateDelegates()) { fOptionsErrorLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR)); } else { fOptionsErrorLabel.setImage(null); } fViewform.layout(true, true); }
From source file:org.eclipse.dirigible.ide.common.status.StatusLineManagerUtil.java
License:Open Source License
public static void setInfoMessage(String message) { getDefaultStatusLineManager().removeAll(); getDefaultStatusLineManager().setMessage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO), message); clearMessages();/* w ww .j a v a 2s.c o m*/ }