List of usage examples for org.eclipse.jface.resource JFaceResources getImage
public static Image getImage(String key)
null
if none. From source file:org.bonitasoft.studio.migration.ui.view.MigrationStatusView.java
License:Open Source License
private void createHelpButton(Composite bottomComposite) { ToolBar helpToolbar = new ToolBar(bottomComposite, SWT.NONE); helpToolbar.setLayoutData(/*from www.j ava 2 s .c om*/ GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).grab(false, false).create()); ToolItem helpItem = new ToolItem(helpToolbar, SWT.PUSH); helpItem.setImage(JFaceResources.getImage(Dialog.DLG_IMG_HELP)); helpItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { new WizardDialog(Display.getDefault().getActiveShell(), new MigrationWarningWizard()).open(); } }); }
From source file:org.caleydo.core.gui.OpenOnlineHelpAction.java
License:Open Source License
public OpenOnlineHelpAction(String url, boolean useSmallIcon) { this.url = url; setText(LABEL);//from ww w . j a v a2s.c o m setToolTipText(LABEL); setImageDescriptor(ImageDescriptor.createFromImage(useSmallIcon ? GeneralManager.get().getResourceLoader().getImage(PlatformUI.getWorkbench().getDisplay(), ICON) : JFaceResources.getImage(Dialog.DLG_IMG_HELP))); setChecked(false); }
From source file:org.caleydo.core.gui.util.AHelpButtonDialog.java
License:Open Source License
@Override protected Control createHelpControl(Composite parent) { Image helpImage = JFaceResources.getImage(DLG_IMG_HELP); if (helpImage != null) { return createHelpImageButton(parent, helpImage); }/*w ww .ja v a 2 s .com*/ return super.createHelpControl(parent); }
From source file:org.caleydo.core.gui.util.HelpButtonWizardDialog.java
License:Open Source License
@Override protected Control createHelpControl(Composite parent) { Image helpImage = JFaceResources.getImage(DLG_IMG_HELP); if (helpImage != null) { return createHelpImageButton(parent, helpImage); }/*from w ww .jav a2 s .c om*/ return super.createHelpControl(parent); }
From source file:org.caleydo.core.io.gui.dataimport.widget.DataTranspositionWidget.java
License:Open Source License
protected Label createWarningIconLabel(Composite parent) { Label warningLabel = new Label(parent, SWT.NONE); warningLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); return warningLabel; }
From source file:org.caleydo.core.io.gui.dataimport.widget.IDParsingRulesWidget.java
License:Open Source License
/** * @param parent//from w ww . j a v a 2 s .c om * @param templateIdTypeParsingRules * Template that is used to fill the widgets. May be null. * @param showEnableButton * Determines, whether a checkbox is displayed that enables/disables all widgets. * @param idSample * Sample id that shall be used to preview effects of regular expressions. * @param validRegExCallback * Called when the inserted regular expression is valid or not valid. This can be used to disable buttons * external to this widget when the inserted regex is not valid. */ public IDParsingRulesWidget(Composite parent, IDTypeParsingRules templateIdTypeParsingRules, boolean showEnableButton, String idSample, ICallback<Boolean> validRegExCallback) { this.idSample = idSample; this.validRegExCallback = validRegExCallback; if (showEnableButton) { useRegExButton = new Button(parent, SWT.CHECK); useRegExButton.setText("Convert IDs"); useRegExButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setEnabled(useRegExButton.getSelection()); } }); } Label conversionLabel = new Label(parent, SWT.WRAP); conversionLabel.setText( "You can convert IDs using the follwing methods. They are applied in the order shown here."); conversionLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); caseGroup = new Group(parent, SWT.SHADOW_ETCHED_IN); caseGroup.setText("Change Case"); caseGroup.setLayout(new GridLayout(1, false)); caseGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); caseExplanationLabel = new Label(caseGroup, SWT.WRAP); caseExplanationLabel.setText( "Choose whether to keep the case of the IDs, convert all to lower, or convert all to upper case."); caseExplanationLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); keepCaseButton = new Button(caseGroup, SWT.RADIO); keepCaseButton.setText("Keep case unchanged"); keepCaseButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); keepCaseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { updatePreview(); } }); toUpperCaseButton = new Button(caseGroup, SWT.RADIO); toUpperCaseButton.setText("Make upper case"); toUpperCaseButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); toUpperCaseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { updatePreview(); } }); toLowerCaseButton = new Button(caseGroup, SWT.RADIO); toLowerCaseButton.setText("Make lower case"); toLowerCaseButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); toUpperCaseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { updatePreview(); } }); replaceGroup = new Group(parent, SWT.SHADOW_ETCHED_IN); replaceGroup.setText("Replace parts of IDs"); replaceGroup.setLayout(new GridLayout(4, false)); replaceGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); Composite useRegExComposite = new Composite(replaceGroup, SWT.NONE); useRegExComposite.setLayout(new RowLayout(SWT.HORIZONTAL)); useRegExComposite.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false, 4, 1)); ModifyListener regexModifyListener = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { updatePreview(); } }; replacementExplanationLabel = new Label(replaceGroup, SWT.WRAP); replacementExplanationLabel.setText("Replace certain expressions within an ID by a specified " + "string. For example, applying the regular expression '\\.' and the replacement string '-' on the ID " + "'abc.000.yz' results in 'abc-000-yz'."); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1); gridData.widthHint = 500; replacementExplanationLabel.setLayoutData(gridData); replacementRegExLabel = new Label(replaceGroup, SWT.NONE); replacementRegExLabel.setText("Replace"); replacementRegExLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, true)); replacementRegExTextField = new Text(replaceGroup, SWT.BORDER); GridData replacementTextFieldsGridData = new GridData(SWT.FILL, SWT.FILL, true, true); replacementTextFieldsGridData.widthHint = 150; replacementRegExTextField.setLayoutData(replacementTextFieldsGridData); replacementRegExTextField.addModifyListener(regexModifyListener); replacementStringLabel = new Label(replaceGroup, SWT.NONE); replacementStringLabel.setText("with"); replacementStringTextField = new Text(replaceGroup, SWT.BORDER); replacementStringTextField.setLayoutData(replacementTextFieldsGridData); replacementStringTextField.addModifyListener(regexModifyListener); substringGroup = new Group(parent, SWT.SHADOW_ETCHED_IN); substringGroup.setText("Split IDs"); substringGroup.setLayout(new GridLayout(4, false)); substringGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); substringExplanationLabel = new Label(substringGroup, SWT.WRAP); substringExplanationLabel .setText("Splits an ID into substrings around matches of the specified regular expression. " + "The first non-empty substring of this operation will be the resulting ID. For example, a leading string " + "'abc' can be removed from an ID 'abc-001' using the expression 'abc-'. In this case the split operation " + "results in ['','001']. Using, for example, '\\-' as expression would result in ['abc','001'] and 'abc' " + "would be used as the result."); gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1); gridData.widthHint = 500; substringExplanationLabel.setLayoutData(gridData); substringRegExLabel = new Label(substringGroup, SWT.NONE); substringRegExLabel.setText("Substring specification"); substringRegExTextField = new Text(substringGroup, SWT.BORDER); substringRegExTextField.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); substringRegExTextField.addModifyListener(regexModifyListener); if (idSample != null) { gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1); previewLabel = new Label(substringGroup, SWT.NONE); previewLabel.setText("Preview: "); previewLabel.setLayoutData(gridData); FontData fontData = previewLabel.getFont().getFontData()[0]; Font font = new Font(previewLabel.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD)); previewLabel.setFont(font); gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1); originalIDLabel = new Label(substringGroup, SWT.NONE); originalIDLabel.setText("Original ID: " + idSample); originalIDLabel.setLayoutData(gridData); gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1); convertedIDLabel = new Label(substringGroup, SWT.NONE); convertedIDLabel.setLayoutData(gridData); } errorImage = new Label(parent, SWT.NONE); errorImage.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR)); errorImage.setVisible(false); errorLabel = new Label(parent, SWT.NONE); errorLabel.setText("Invalid regular expression."); errorLabel.setVisible(false); regexLink = new Link(parent, SWT.WRAP); regexLink.setText( " <a href=\"http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html\">Regular Expression Reference</a>"); regexLink.addSelectionListener(BrowserUtils.LINK_LISTENER); fillWidgets(templateIdTypeParsingRules); }
From source file:org.csstudio.alarm.beast.ui.actions.EditAAItemDialog.java
License:Open Source License
@SuppressWarnings("nls") @Override/*w ww. ja va2 s.c om*/ protected void okPressed() { rowData[0] = titleText == null ? "" : titleText.getText().trim(); rowData[1] = detailsText == null ? "" : detailsText.getText().trim(); rowData[2] = delayText == null ? "" : delayText.getText().trim(); try { if (rowData[1] != null && !rowData[1].isEmpty()) { NotifierUtils.performValidation(rowData[1]); } showingError = false; super.okPressed(); } catch (Exception e) { if (!showingError) { // Message image @ left final Label messageImageLabel = new Label(header, SWT.NONE); messageImageLabel.setImage(JFaceResources.getImage(DLG_IMG_MESSAGE_ERROR)); GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false); gridData.widthHint = 30; messageImageLabel.setLayoutData(gridData); messageImageLabel.pack(); // Message label @ right messageLabel = new Text(header, SWT.WRAP); messageLabel.setBackground(header.getBackground()); messageLabel.setForeground(parent_composite.getDisplay().getSystemColor(SWT.COLOR_RED)); messageLabel.setFont(JFaceResources.getDialogFont()); header.setVisible(true); showingError = true; } String message = e.getMessage(); // Cut long messages GC gc = new GC(messageLabel); int charWidth = gc.getFontMetrics().getAverageCharWidth(); int parentWidth = parent_composite.getSize().x; int msgLength = message.length(); int parentMaxLength = (parentWidth - 70) / charWidth; if (msgLength > parentMaxLength) { int nbLines = (msgLength / parentMaxLength) + 1; StringBuilder sb = new StringBuilder(); int index = 0; while (index < nbLines) { int beginIndex = index * parentMaxLength; int endIndex = (index + 1) * parentMaxLength; if (endIndex > msgLength) endIndex = msgLength; sb.append(message.substring(beginIndex, endIndex)); if (index < nbLines - 1) sb.append("\n"); index++; } message = sb.toString(); } messageLabel.setText(message); messageLabel.pack(); header.pack(); parent_composite.layout(); getShell().layout(); } }
From source file:org.eclipse.birt.chart.ui.swt.wizard.format.popup.AbstractPopupSheet.java
License:Open Source License
/** * Creates a new help control that provides access to context help. * <p>//w w w . j ava 2s .com * The <code>TrayDialog</code> implementation of this method creates the * control, registers it for selection events including selection, Note that * the parent's layout is assumed to be a <code>GridLayout</code> and the * number of columns in this layout is incremented. Subclasses may override. * </p> * * @param parent * the parent composite * @return the help control */ private Control createHelpControl(Composite parent) { Image helpImage = JFaceResources.getImage(Dialog.DLG_IMG_HELP); if (helpImage != null) { return createHelpImageButton(parent, helpImage); } return createHelpLink(parent); }
From source file:org.eclipse.birt.report.designer.data.ui.property.AbstractTitlePropertyDialog.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 ww .j av a2s . c om*/ titleArea = new Composite(contents, SWT.NONE); initializeDialogUnits(titleArea); FormData titleAreaData = new FormData(); titleAreaData.top = new FormAttachment(0, 0); titleAreaData.left = new FormAttachment(0, 0); titleAreaData.right = new FormAttachment(100, 0); titleArea.setLayoutData(titleAreaData); layout = new FormLayout(); titleArea.setLayout(layout); // add a dispose listener titleArea.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (titleAreaColor != null) { titleAreaColor.dispose(); } } }); // Determine the background color of the title bar Display display = titleArea.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); } int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); titleArea.setBackground(background); // Dialog image @ right titleImageLabel = new Label(titleArea, SWT.CENTER); titleImageLabel.setBackground(background); if (titleImage == null || titleImage.isDisposed()) { titleImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER)); } else { titleImageLabel.setImage(titleImage); } 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(titleArea, 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); messageImageLabel = new Label(titleArea, SWT.CENTER); messageImageLabel.setBackground(background); messageLabel = new Text(titleArea, 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; leftFillerLabel = new Label(titleArea, SWT.CENTER); leftFillerLabel.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.data.ui.property.AbstractTitlePropertyDialog.java
License:Open Source License
public void setErrorMessage(String newErrorMessage) { // Any change? if (errorMessage == null ? newErrorMessage == null : errorMessage.equals(newErrorMessage)) return;/*from w ww . j a v a 2 s. c o m*/ errorMessage = newErrorMessage; // Clear or set error message. if (errorMessage == null) { if (showingError) { // we were previously showing an error showingError = false; } // show the message // 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$ updateMessage(message); messageImageLabel.setImage(messageImage); setImageLabelVisible(messageImage != null); } else { // Add in a space for layout purposes but do not // change the instance variable String displayedErrorMessage = " " + errorMessage; //$NON-NLS-1$ updateMessage(displayedErrorMessage); if (!showingError) { // we were not previously showing an error showingError = true; messageImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_ERROR)); setImageLabelVisible(true); } } layoutForNewMessage(); }