Java Code Examples for org.eclipse.swt.widgets.Button#setImage()
The following examples show how to use
org.eclipse.swt.widgets.Button#setImage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnterOptionsDialog.java From hop with Apache License 2.0 | 6 votes |
/** * Setting the layout of a <i>Reset</i> option button. Either a button image is set - if existing - or a text. * * @param button The button */ private FormData layoutResetOptionButton( Button button ) { FormData fd = new FormData(); Image editButton = GuiResource.getInstance().getResetOptionButton(); if ( editButton != null ) { button.setImage( editButton ); button.setBackground( GuiResource.getInstance().getColorWhite() ); fd.width = editButton.getBounds().width + 20; fd.height = editButton.getBounds().height; } else { button.setText( BaseMessages.getString( PKG, "EnterOptionsDialog.Button.Reset" ) ); } button.setToolTipText( BaseMessages.getString( PKG, "EnterOptionsDialog.Button.Reset.Tooltip" ) ); return fd; }
Example 2
Source File: SWTFactory.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Creates a check box button using the parents' font * * @param parent * the parent to add the button to * @param label * the label for the button * @param image * the image for the button * @param checked * the initial checked state of the button * @param hspan * the horizontal span to take up in the parent composite * @return a new checked button set to the initial checked state */ public static Button createCheckButton(Composite parent, String label, Image image, boolean checked, int hspan) { Button button = new Button(parent, SWT.CHECK); button.setFont(parent.getFont()); button.setSelection(checked); if (image != null) { button.setImage(image); } if (label != null) { button.setText(label); } GridData gd = new GridData(); gd.horizontalSpan = hspan; button.setLayoutData(gd); setButtonDimensionHint(button); return button; }
Example 3
Source File: ScriptSWTFactory.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Create the push button * * @param parent * @param label * @param image * @return */ public static Button createPushButton( Composite parent, String label, Image image ) { Button button = new Button( parent, SWT.PUSH ); button.setFont( parent.getFont( ) ); if ( image != null ) { button.setImage( image ); } if ( label != null ) { button.setText( label ); } GridData gd = new GridData( ); button.setLayoutData( gd ); setButtonDimensionHint( button ); return button; }
Example 4
Source File: AbstractPTWidget.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * @param parent parent composite * @param showAsCategory if <code>true</code>, the "show as category" button is * pushed */ private void buildCategoryButton(final Composite parent, final boolean showAsCategory) { final Button categoryButton = new Button(parent, SWT.FLAT | SWT.TOGGLE); categoryButton.setImage(SWTGraphicUtil.createImageFromFile("images/category.png")); categoryButton.setSelection(showAsCategory); categoryButton.setToolTipText(ResourceManager.getLabel(ResourceManager.CATEGORY_SHORT_DESCRIPTION)); categoryButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 1, 1)); categoryButton.addListener(SWT.Selection, event -> { if (getParentPropertyTable().styleOfView == PropertyTable.VIEW_AS_CATEGORIES) { getParentPropertyTable().viewAsFlatList(); } else { getParentPropertyTable().viewAsCategories(); } }); }
Example 5
Source File: EnterOptionsDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Setting the layout of an <i>Edit</i> option button. Either a button image is set - if existing - or a text. * * @param button * The button */ private FormData layoutEditOptionButton( Button button ) { FormData fd = new FormData(); Image editButton = GUIResource.getInstance().getEditOptionButton(); if ( editButton != null ) { button.setImage( editButton ); button.setBackground( GUIResource.getInstance().getColorWhite() ); fd.width = editButton.getBounds().width + 20; fd.height = editButton.getBounds().height; } else { button.setText( BaseMessages.getString( PKG, "EnterOptionsDialog.Button.Edit" ) ); } button.setToolTipText( BaseMessages.getString( PKG, "EnterOptionsDialog.Button.Edit.Tooltip" ) ); return fd; }
Example 6
Source File: SourceInfoPage.java From olca-app with Mozilla Public License 2.0 | 6 votes |
protected void additionalInfo(Composite body) { Composite comp = UI.formSection(body, tk, M.AdditionalInformation, 3); UI.gridLayout(comp, 4); text(comp, M.URL, "url"); Button urlButton = tk.createButton(comp, M.Open, SWT.NONE); urlButton.setImage(Icon.MAP.get()); Controls.onSelect(urlButton, e -> { String url = getModel().url; if (Strings.isNullOrEmpty(url)) return; Desktop.browse(url); }); text(comp, M.TextReference, "textReference"); UI.filler(comp, tk); shortText(comp, M.Year, "year"); UI.filler(comp, tk); fileSection(comp); UI.filler(comp, tk); UI.filler(comp, tk); image = new ImageView(comp, () -> getDatabaseFile()); }
Example 7
Source File: ProductSystemInfoPage.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void addCalculationButton(Composite comp, FormToolkit tk) { tk.createLabel(comp, ""); Button button = tk.createButton(comp, M.Calculate, SWT.NONE); button.setImage(Icon.RUN.get()); Controls.onSelect(button, e -> { CalculationWizard.open(getModel()); inventoryInfo.setVisible(!getModel().inventory.isEmpty()); }); tk.createLabel(comp, ""); }
Example 8
Source File: HelpUtils.java From hop with Apache License 2.0 | 5 votes |
private static Button newButton( final Composite parent ) { Button button = new Button( parent, SWT.PUSH ); button.setImage( GuiResource.getInstance().getImageHelpWeb() ); button.setText( BaseMessages.getString( PKG, "System.Button.Help" ) ); button.setToolTipText( BaseMessages.getString( PKG, "System.Tooltip.Help" ) ); FormData fdButton = new FormData(); fdButton.left = new FormAttachment( 0, 0 ); fdButton.bottom = new FormAttachment( 100, 0 ); button.setLayoutData( fdButton ); return button; }
Example 9
Source File: ViewFilterDialog.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private Button createCloseButton(Composite composite) { Button closeButton = new Button(composite, SWT.NONE); closeButton.setToolTipText(Messages.TimeEventFilterDialog_CloseButton); closeButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); closeButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE)); closeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { clearFilter(); close(); } }); return closeButton; }
Example 10
Source File: SWTFactory.java From goclipse with Eclipse Public License 1.0 | 5 votes |
/** * Creates and returns a new push button with the given * label and/or image. * * @param parent parent control * @param label button label or <code>null</code> * @param image image of <code>null</code> * @param fill the alignment for the new button * * @return a new push button * @since 3.4 */ public static Button createPushButton(Composite parent, String label, Image image, int fill) { Button button = new Button(parent, SWT.PUSH); button.setFont(parent.getFont()); if (image != null) { button.setImage(image); } if (label != null) { button.setText(label); } GridData gd = new GridData(fill); button.setLayoutData(gd); setButtonDimensionHint(button); return button; }
Example 11
Source File: HelpButton.java From tlaplus with MIT License | 5 votes |
/** * * @param parent Where the button should be added. * @param helpFile The suffix of the URL of the help page, which follows * .../org.lamport.tla.toolbox.doc/html/ -- for example, * "model/overview-page.html#what-to-check" . * @return A Button that has been added to the Composite that, when clicked * raises a browser window on the specified help page URL. */ public static Button helpButton(final Composite parent, final String helpFile) { final Button button = new Button(parent, SWT.NONE); final HelpButtonListener listener = new HelpButtonListener(parent, helpFile); button.addSelectionListener(listener); button.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_LCL_LINKTO_HELP)); final GridData gridData = new GridData(); gridData.verticalAlignment = SWT.TOP; button.setLayoutData(gridData); button.setEnabled(true); return button; }
Example 12
Source File: SWTFactory.java From goclipse with Eclipse Public License 1.0 | 5 votes |
public static Button createButton(Composite parent, int style, String label, Image image) { Button button = new Button(parent, style); if(image != null) { button.setImage(image); } if(label != null) { button.setText(label); } return button; }
Example 13
Source File: ExternalizedTextEditorComposite.java From birt with Eclipse Public License 1.0 | 5 votes |
private void placeComponents() { GridLayout glContent = new GridLayout(); glContent.numColumns = 2; glContent.horizontalSpacing = 1; glContent.marginHeight = 0; glContent.marginWidth = 0; this.setLayout(glContent); txtSelection = new TextEditorComposite(this, iStyle); GridData gdTXTSelection = new GridData(GridData.FILL_HORIZONTAL); if (iHeightHint > 0) { gdTXTSelection.heightHint = iHeightHint - 10; } if (iWidthHint > 0) { gdTXTSelection.widthHint = iWidthHint; } txtSelection.setLayoutData(gdTXTSelection); txtSelection.addListener(this); btnDown = new Button(this, SWT.PUSH); GridData gdBTNDown = new GridData(GridData.VERTICAL_ALIGN_END); ChartUIUtil.setChartImageButtonSizeByPlatform( gdBTNDown ); btnDown.setImage( UIHelper.getImage( "icons/obj16/externalizetext.gif" ) ); //$NON-NLS-1$ btnDown.setToolTipText(Messages.getString("ExternalizedTextEditorComposite.Lbl.EditText")); //$NON-NLS-1$ btnDown.setLayoutData(gdBTNDown); btnDown.addSelectionListener(this); ChartUIUtil.addScreenReaderAccessbility( btnDown, btnDown.getToolTipText( ) ); }
Example 14
Source File: ProjectSetupPage.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void createButton(Composite comp) { toolkit.createLabel(comp, ""); Composite c = toolkit.createComposite(comp); UI.gridLayout(c, 2).marginHeight = 5; Button b = toolkit.createButton(c, M.Report, SWT.NONE); UI.gridData(b, false, false).widthHint = 100; b.setImage(Images.get(ModelType.PROJECT)); Controls.onSelect(b, e -> ProjectEditorActions.calculate( project, editor.getReport())); }
Example 15
Source File: Snippet7.java From nebula with Eclipse Public License 2.0 | 5 votes |
private Button createIconButton(Composite parent, String imageFilename, String toolTipText, Listener selectionListener) { Button button = createButton(parent, toolTipText, selectionListener); button.setImage(createImage(imageFilename)); return button; }
Example 16
Source File: RecentPanel.java From Rel with Apache License 2.0 | 5 votes |
private void createItem(Composite parent, String prompt, String iconName, String dbURL, Listener action) { boolean enabled = true; if (dbURL != null) enabled = Core.databaseMayExist(dbURL); Composite panel = new Composite(parent, SWT.TRANSPARENT); panel.setLayout(new RowLayout(SWT.VERTICAL)); Composite topPanel = new Composite(panel, SWT.TRANSPARENT); topPanel.setLayout(new RowLayout(SWT.HORIZONTAL)); Button icon = new Button(topPanel, SWT.FLAT); icon.setImage(IconLoader.loadIcon(iconName)); icon.addListener(SWT.Selection, action); icon.setEnabled(enabled); if (dbURL != null) { Button removeButton = new Button(topPanel, SWT.NONE); removeButton.setText("X"); removeButton.setToolTipText("Remove this entry from this list of recently-used databases." + ((enabled) ? " The database will not be deleted." : "")); removeButton.addListener(SWT.Selection, e -> { Core.removeFromRecentlyUsedDatabaseList(dbURL); ((DbTabContentRecent)getParent()).redisplayed(); }); } Label urlButton = new Label(panel, SWT.NONE); urlButton.setText(prompt); urlButton.addListener(SWT.MouseUp, action); if (!enabled) urlButton.setForeground(getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND)); }
Example 17
Source File: SwtXYChartViewer.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Constructor for the chart. Any final class that derives this class must * call the {@link #populate()} method to create the rest of the chart. * * @param parent * A parent composite * @param data * A configured data series for the chart * @param model * A chart model to use */ public SwtXYChartViewer(Composite parent, ChartData data, ChartModel model) { fParent = parent; fData = data; fModel = model; fSeriesMap = new HashMap<>(data.getChartSeries().size()); fObjectMap = new HashMap<>(data.getChartSeries().size()); fXInformation = DescriptorsInformation.create(getXDescriptors()); fYInformation = DescriptorsInformation.create(getYDescriptors()); validateChartData(); fChart = new Chart(parent, SWT.NONE); /* * Temporarily generate titles, they may be modified once the data has * been parsed (with formatting information, units, etc) */ fXTitle = generateTitle(getXDescriptors(), getChart().getAxisSet().getXAxis(0)); fYTitle = generateTitle(getYDescriptors(), getChart().getAxisSet().getYAxis(0)); /* Set all titles and labels font color to black */ fChart.getTitle().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fChart.getAxisSet().getXAxis(0).getTitle().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fChart.getAxisSet().getYAxis(0).getTitle().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fChart.getAxisSet().getXAxis(0).getTick().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fChart.getAxisSet().getYAxis(0).getTick().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); /* Set X label 90 degrees */ fChart.getAxisSet().getXAxis(0).getTick().setTickLabelAngle(90); /* Set the legend position if necessary */ if (getData().getChartSeries().size() > 1) { fChart.getLegend().setPosition(SWT.BOTTOM); } else { fChart.getLegend().setVisible(false); } /* Refresh the titles to fit the current chart size */ refreshDisplayTitles(); /* Create the close button */ Image close = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_REMOVE); fCloseButton = new Button(fChart, SWT.PUSH); fCloseButton.setSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE); fCloseButton.setLocation(fChart.getSize().x - fCloseButton.getSize().x - CLOSE_BUTTON_MARGIN, CLOSE_BUTTON_MARGIN); fCloseButton.setImage(close); fCloseButton.addSelectionListener(new CloseButtonEvent()); /* Add listeners for the visibility of the close button and resizing */ Listener mouseEnter = new MouseEnterEvent(); Listener mouseExit = new MouseExitEvent(); fChart.getDisplay().addFilter(SWT.MouseEnter, mouseEnter); fChart.getDisplay().addFilter(SWT.MouseExit, mouseExit); fChart.addDisposeListener(event -> { fChart.getDisplay().removeFilter(SWT.MouseEnter, mouseEnter); fChart.getDisplay().removeFilter(SWT.MouseExit, mouseExit); }); fChart.addControlListener(new ResizeEvent()); }
Example 18
Source File: ConfigOptionController.java From tesb-studio-se with Apache License 2.0 | 4 votes |
@Override public Control createControl(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) { Button theBtn = getWidgetFactory().createButton(subComposite, "", SWT.PUSH); //$NON-NLS-1$ theBtn.setBackground(subComposite.getBackground()); if (param.getDisplayName().equals("")) { //$NON-NLS-1$ theBtn.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON))); } else { theBtn.setText(param.getDisplayName()); } FormData data = new FormData(); if (isInWizard()) { if (lastControl != null) { data.right = new FormAttachment(lastControl, 0); } else { data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE); } } else { if (lastControl != null) { data.left = new FormAttachment(lastControl, 0); } else { data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0); } } data.top = new FormAttachment(0, top); theBtn.setLayoutData(data); theBtn.setEnabled(!param.isReadOnly()); theBtn.setData(param); hashCurControls.put(param.getName(), theBtn); theBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Command cmd = createCommand((Button) e.getSource()); executeCommand(cmd); } }); Point initialSize = theBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT); dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE); if (nexusServerBean == null) { theBtn.setVisible(false); } Display.getDefault().asyncExec(new Runnable() { @Override public void run() { refresh(param, true); } }); return theBtn; }
Example 19
Source File: TableView.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void editButton( TableItem row, int rownr, int colnr ) { beforeEdit = getItemText( row ); fieldChanged = false; ColumnInfo colinfo = columns[colnr - 1]; if ( colinfo.isReadOnly() ) { return; } if ( colinfo.getDisabledListener() != null ) { boolean disabled = colinfo.getDisabledListener().isFieldDisabled( rownr ); if ( disabled ) { return; } } button = new Button( table, SWT.PUSH ); props.setLook( button, Props.WIDGET_STYLE_TABLE ); String buttonText = columns[colnr - 1].getButtonText(); if ( buttonText != null ) { button.setText( buttonText ); } button.setImage( GUIResource.getInstance().getImage( "ui/images/edittext.svg" ) ); SelectionListener selAdpt = colinfo.getSelectionAdapter(); if ( selAdpt != null ) { button.addSelectionListener( selAdpt ); } buttonRownr = rownr; buttonColnr = colnr; // button.addTraverseListener(lsTraverse); buttonContent = row.getText( colnr ); String tooltip = columns[colnr - 1].getToolTip(); if ( tooltip != null ) { button.setToolTipText( tooltip ); } else { button.setToolTipText( "" ); } button.addTraverseListener( lsTraverse ); // hop to next field button.addTraverseListener( new TraverseListener() { @Override public void keyTraversed( TraverseEvent arg0 ) { closeActiveButton(); } } ); editor.horizontalAlignment = SWT.LEFT; editor.verticalAlignment = SWT.TOP; editor.grabHorizontal = false; editor.grabVertical = false; Point size = button.computeSize( SWT.DEFAULT, SWT.DEFAULT ); editor.minimumWidth = size.x; editor.minimumHeight = size.y - 2; // setRowNums(); editor.layout(); // Open the text editor in the correct column of the selected row. editor.setEditor( button ); button.setFocus(); // if the button loses focus, destroy it... /* * button.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { button.dispose(); } } ); */ }
Example 20
Source File: DualList.java From nebula with Eclipse Public License 2.0 | 3 votes |
/** * Create a button * * @param fileName file name of the icon * @param verticalExpand if <code>true</code>, the button will take all the * available space vertically * @param alignment button alignment * @return a new button */ private Button createButton(final String fileName, final boolean verticalExpand, final int alignment) { final Button button = new Button(this, SWT.PUSH); final Image image = SWTGraphicUtil.createImageFromFile("images/" + fileName); button.setImage(image); button.setLayoutData(new GridData(GridData.CENTER, alignment, false, verticalExpand)); SWTGraphicUtil.addDisposer(button, image); return button; }