List of usage examples for org.eclipse.jface.resource JFaceResources getImageRegistry
public static ImageRegistry getImageRegistry()
From source file:org.eclipse.sirius.ext.e3.ui.dialogs.FilteredTree.java
License:Open Source License
/** * Create the button that clears the text. * * @param parent parent <code>Composite</code> of toolbar button *///from w w w. ja v a 2 s .com private void createClearTextNew(Composite parent) { // only create the button if the text widget doesn't support one // natively if ((filterText.getStyle() & SWT.ICON_CANCEL) == 0) { final Image inactiveImage = JFaceResources.getImageRegistry().getDescriptor(DISABLED_CLEAR_ICON) .createImage(); final Image activeImage = JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON).createImage(); final Image pressedImage = new Image(getDisplay(), activeImage, SWT.IMAGE_GRAY); final Label clearButton = new Label(parent, SWT.NONE); clearButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); clearButton.setImage(inactiveImage); clearButton.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); clearButton.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip); clearButton.addMouseListener(new MouseAdapter() { private MouseMoveListener fMoveListener; @Override public void mouseDown(MouseEvent e) { clearButton.setImage(pressedImage); fMoveListener = new MouseMoveListener() { private boolean fMouseInButton = true; @Override public void mouseMove(MouseEvent e) { boolean mouseInButton = isMouseInButton(e); if (mouseInButton != fMouseInButton) { fMouseInButton = mouseInButton; clearButton.setImage(mouseInButton ? pressedImage : inactiveImage); } } }; clearButton.addMouseMoveListener(fMoveListener); } @Override public void mouseUp(MouseEvent e) { if (fMoveListener != null) { clearButton.removeMouseMoveListener(fMoveListener); fMoveListener = null; boolean mouseInButton = isMouseInButton(e); clearButton.setImage(mouseInButton ? activeImage : inactiveImage); if (mouseInButton) { clearText(); filterText.setFocus(); } } } private boolean isMouseInButton(MouseEvent e) { Point buttonSize = clearButton.getSize(); return 0 <= e.x && e.x < buttonSize.x && 0 <= e.y && e.y < buttonSize.y; } }); clearButton.addMouseTrackListener(new MouseTrackListener() { @Override public void mouseEnter(MouseEvent e) { clearButton.setImage(activeImage); } @Override public void mouseExit(MouseEvent e) { clearButton.setImage(inactiveImage); } @Override public void mouseHover(MouseEvent e) { } }); clearButton.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { inactiveImage.dispose(); activeImage.dispose(); pressedImage.dispose(); } }); clearButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { e.result = WorkbenchMessages.FilteredTree_AccessibleListenerClearButton; } }); clearButton.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() { @Override public void getRole(AccessibleControlEvent e) { e.detail = ACC.ROLE_PUSHBUTTON; } }); this.clearButtonControl = clearButton; } }
From source file:org.eclipse.sirius.ui.tools.internal.views.common.navigator.filter.FilteredCommonTree.java
License:Open Source License
/** * Create the button that clears the text. * /* w ww . j a v a 2 s .co m*/ * @param aParent * parent <code>Composite</code> of toolbar button */ private void createClearTextOld(Composite aParent) { // only create the button if the text widget doesn't support one // natively if ((filterText.getStyle() & SWT.ICON_CANCEL) == 0) { filterToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL); filterToolBar.createControl(aParent); IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) { //$NON-NLS-1$ /* * (non-Javadoc) * * @see org.eclipse.jface.action.Action#run() */ public void run() { clearText(); } }; clearTextAction.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip); clearTextAction.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON)); clearTextAction.setDisabledImageDescriptor( JFaceResources.getImageRegistry().getDescriptor(DISABLED_CLEAR_ICON)); filterToolBar.add(clearTextAction); } }
From source file:org.eclipse.sirius.ui.tools.internal.views.common.navigator.filter.FilteredCommonTree.java
License:Open Source License
/** * Create the button that clears the text. * // w ww . j a va 2s . c om * @param aParent * parent <code>Composite</code> of toolbar button */ private void createClearTextNew(Composite aParent) { // only create the button if the text widget doesn't support one // natively if ((filterText.getStyle() & SWT.ICON_CANCEL) == 0) { final Image inactiveImage = JFaceResources.getImageRegistry().getDescriptor(DISABLED_CLEAR_ICON) .createImage(); final Image activeImage = JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON).createImage(); final Image pressedImage = new Image(getDisplay(), activeImage, SWT.IMAGE_GRAY); final Label clearButton = new Label(aParent, SWT.NONE); clearButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); clearButton.setImage(inactiveImage); clearButton.setBackground(aParent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); clearButton.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip); clearButton.addMouseListener(new MouseAdapter() { private MouseMoveListener fMoveListener; public void mouseDown(MouseEvent e) { clearButton.setImage(pressedImage); fMoveListener = new MouseMoveListener() { private boolean fMouseInButton = true; public void mouseMove(MouseEvent e) { boolean mouseInButton = isMouseInButton(e); if (mouseInButton != fMouseInButton) { fMouseInButton = mouseInButton; clearButton.setImage(mouseInButton ? pressedImage : inactiveImage); } } }; clearButton.addMouseMoveListener(fMoveListener); } public void mouseUp(MouseEvent e) { if (fMoveListener != null) { clearButton.removeMouseMoveListener(fMoveListener); fMoveListener = null; boolean mouseInButton = isMouseInButton(e); clearButton.setImage(mouseInButton ? activeImage : inactiveImage); if (mouseInButton) { clearText(); filterText.setFocus(); } } } private boolean isMouseInButton(MouseEvent e) { Point buttonSize = clearButton.getSize(); return 0 <= e.x && e.x < buttonSize.x && 0 <= e.y && e.y < buttonSize.y; } }); clearButton.addMouseTrackListener(new MouseTrackListener() { public void mouseEnter(MouseEvent e) { clearButton.setImage(activeImage); } public void mouseExit(MouseEvent e) { clearButton.setImage(inactiveImage); } public void mouseHover(MouseEvent e) { } }); clearButton.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { inactiveImage.dispose(); activeImage.dispose(); pressedImage.dispose(); } }); clearButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { e.result = WorkbenchMessages.FilteredTree_AccessibleListenerClearButton; } }); clearButton.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() { public void getRole(AccessibleControlEvent e) { e.detail = ACC.ROLE_PUSHBUTTON; } }); this.clearButtonControl = clearButton; } }
From source file:org.eclipse.swtbot.forms.finder.test.FormView.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and * initialize it./*w ww. j ava 2 s.com*/ */ public void createPartControl(Composite parent) { toolkit = new FormToolkit(parent.getDisplay()); form = toolkit.createScrolledForm(parent); form.setText("Hello, Eclipse Forms"); TableWrapLayout layout = new TableWrapLayout(); form.getBody().setLayout(layout); Hyperlink link = toolkit.createHyperlink(form.getBody(), "Click here.", SWT.WRAP); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println("Link activated!"); } }); link.setText("This is an example of a form that is much longer and will need to wrap."); layout.numColumns = 2; TableWrapData td = new TableWrapData(); td.colspan = 2; link.setLayoutData(td); toolkit.createLabel(form.getBody(), "Text field label:"); Text text = toolkit.createText(form.getBody(), ""); td = new TableWrapData(TableWrapData.FILL_GRAB); text.setLayoutData(td); Button button = toolkit.createButton(form.getBody(), "An example of a checkbox in a form", SWT.CHECK); td = new TableWrapData(); td.colspan = 2; button.setLayoutData(td); ImageHyperlink ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL); ih.setText("Image link with no image"); ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL); ih.setImage(JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_MESSAGE_ERROR)); ih.setText("Link with image and text"); ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT); ImageHyperlink eci = toolkit.createImageHyperlink(ec, SWT.NULL); eci.setImage(JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_MESSAGE_ERROR)); ec.setTextClient(eci); ec.setText("Expandable Composite title"); String ctext = "We will now create a somewhat long text so that " + "we can use it as content for the expandable composite. " + "Expandable composite is used to hide or show the text using the " + "toggle control"; Label client = toolkit.createLabel(ec, ctext, SWT.WRAP); ec.setClient(client); td = new TableWrapData(); td.colspan = 2; ec.setLayoutData(td); ec.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TWISTIE | Section.EXPANDED); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; section.setLayoutData(td); section.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); section.setText("Section title"); toolkit.createCompositeSeparator(section); section.setDescription("This is the description that goes below the title"); Composite sectionClient = toolkit.createComposite(section); sectionClient.setLayout(new GridLayout()); button = toolkit.createButton(sectionClient, "Radio 1", SWT.RADIO); button = toolkit.createButton(sectionClient, "Radio 2", SWT.RADIO); section.setClient(sectionClient); StringBuffer buf = new StringBuffer(); buf.append("<form>"); buf.append("<p>"); buf.append("Here is some plain text for the text to render; "); buf.append( "this text is at <a href=\"http://www.eclipse.org\" nowrap=\"true\">http://www.eclipse.org</a> web site."); buf.append("</p>"); buf.append("<p>"); buf.append("<span color=\"header\" font=\"header\">This text is in header font and color.</span>"); buf.append("</p>"); buf.append("<p>This line will contain some <b>bold</b> and some <span font=\"code\">source</span> text. "); buf.append("We can also add <img href=\"image\"/> an image. "); buf.append("</p>"); buf.append("<li>A default (bulleted) list item.</li>"); buf.append("<li>Another bullet list item.</li>"); buf.append("<li style=\"text\" value=\"1.\">A list item with text.</li>"); buf.append("<li style=\"text\" value=\"2.\">Another list item with text</li>"); buf.append("<li style=\"image\" value=\"image\">List item with an image bullet</li>"); buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"3.\">A list item with text.</li>"); buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"4.\">A list item with text.</li>"); buf.append( "<p> leading blanks; more white \n\n new lines <br/><br/><br/> \n more <b> bb </b> white . </p>"); buf.append("</form>"); FormText rtext = toolkit.createFormText(form.getBody(), false); //rtext.setWhitespaceNormalized(false); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; rtext.setLayoutData(td); rtext.setImage("image", JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_MESSAGE_ERROR)); rtext.setColor("header", toolkit.getColors().getColor(IFormColors.TITLE)); rtext.setFont("header", JFaceResources.getHeaderFont()); rtext.setFont("code", JFaceResources.getTextFont()); rtext.setText(buf.toString(), true, false); rtext.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println("Link active: " + e.getHref()); } }); /* layout.numColumns = 3; Label label; TableWrapData td; label = toolkit.createLabel(form.getBody(), "Some text to put in the first column", SWT.WRAP); label = toolkit.createLabel(form.getBody() ,"Some text to put in the second column and make it a bit longer so that we can see what happens with column distribution. This text must be the longest so that it can get more space allocated to the columns it belongs to.", SWT.WRAP); td = new TableWrapData(); td.colspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text will span two rows and should not grow the column.", SWT.WRAP); td = new TableWrapData(); td.rowspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); form.getBody().setBackground(form.getBody().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));*/ toolkit.paintBordersFor(form.getBody()); }
From source file:org.eclipse.tcf.te.ui.swt.SWTControlUtil.java
License:Open Source License
public static synchronized Image getCheckBoxImage(boolean checked, boolean grayed, boolean enabled) { String key = (SWTControlUtil.class.getName() + "_" + //$NON-NLS-1$ ((checked || grayed) ? CHECKED : UNCHECKED) + "_" + //$NON-NLS-1$ (grayed ? GRAYED + "_" : "") + //$NON-NLS-1$ //$NON-NLS-2$ (enabled ? ENABLED : DISABLED)); Image image = JFaceResources.getImageRegistry().get(key); try {//from w w w .j a va 2 s . co m if (image == null || image.getImageData().data == null) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); image = makeShot(shell, checked || grayed, grayed, enabled); if (image.getImageData().data != null) { JFaceResources.getImageRegistry().put(key, image); } } } catch (Exception e) { } return image; }
From source file:org.eclipse.team.internal.ui.dialogs.DetailsDialog.java
License:Open Source License
final protected Control createDialogArea(Composite parent) { applyDialogFont(parent);//from w ww . ja v a2s . c o m initializeDialogUnits(parent); // create composite Composite composite = (Composite) super.createDialogArea(parent); if (!isMainGrabVertical()) { composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); } String helpContextId = getHelpContextId(); if (helpContextId != null) { PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, helpContextId); } // create image String key = getImageKey(); Image image = null; if (key != null) { image = JFaceResources.getImageRegistry().get(key); } if (image != null) { // create a composite to split the dialog area in two Composite top = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); layout.numColumns = 2; top.setLayout(layout); top.setLayoutData(new GridData(GridData.FILL_BOTH)); // add the image to the left of the composite Label label = new Label(top, 0); image.setBackground(label.getBackground()); label.setImage(image); label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING)); // add a composite to the right to contain the custom components Composite right = new Composite(top, SWT.NONE); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); right.setLayout(layout); right.setLayoutData(new GridData(GridData.FILL_BOTH)); createMainDialogArea(right); } else { createMainDialogArea(composite); } if (includeErrorMessage()) { errorMessageLabel = new Label(composite, SWT.NONE); errorMessageLabel .setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); errorMessageLabel.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_RED)); } Dialog.applyDialogFont(parent); return composite; }
From source file:org.eclipse.thym.ui.PlatformImage.java
License:Open Source License
/** * Returns the image for attribute and platform id. Image is cached by {@link JFaceResources} * {@link ImageRegistry}/*from ww w . j av a 2 s. com*/ * * @param attribute * @param id * @return */ public static Image getImageFor(String attribute, String id) { String key = IMAGE_REG_BASE + attribute + id; ImageRegistry imageRegistry = JFaceResources.getImageRegistry(); Image image = imageRegistry.get(key); if (image == null) { ImageDescriptor desc = getIconFor(attribute, id); if (desc == null) return null; imageRegistry.put(key, getIconFor(attribute, id)); image = imageRegistry.get(key); } return image; }
From source file:org.eclipse.tm.te.ui.swt.SWTControlUtil.java
License:Open Source License
public static synchronized Image getCheckBoxImage(boolean checked, boolean grayed, boolean enabled) { String key = (SWTControlUtil.class.getName() + "_" + //$NON-NLS-1$ ((checked || grayed) ? CHECKED : UNCHECKED) + "_" + //$NON-NLS-1$ (grayed ? GRAYED + "_" : "") + //$NON-NLS-1$ //$NON-NLS-2$ (enabled ? ENABLED : DISABLED)); Image image = JFaceResources.getImageRegistry().get(key); try {/* w ww.j a v a 2 s. co m*/ if (image == null || image.getImageData().data == null) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); image = makeShot(shell, checked || grayed, grayed, enabled); if (image != null && image.getImageData().data != null) { JFaceResources.getImageRegistry().put(key, image); } } } catch (Exception e) { } return image; }
From source file:org.eclipse.ui.dialogs.FilteredTree.java
License:Open Source License
/** * Create the button that clears the text. * /*from w ww. j a v a2 s. c om*/ * @param parent * parent <code>Composite</code> of toolbar button */ private void createClearTextOld(Composite parent) { // only create the button if the text widget doesn't support one // natively if ((filterText.getStyle() & SWT.ICON_CANCEL) == 0) { filterToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL); filterToolBar.createControl(parent); IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$ /* * (non-Javadoc) * * @see org.eclipse.jface.action.Action#run() */ public void run() { clearText(); } }; clearTextAction.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip); clearTextAction.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON)); clearTextAction.setDisabledImageDescriptor( JFaceResources.getImageRegistry().getDescriptor(DISABLED_CLEAR_ICON)); filterToolBar.add(clearTextAction); } }
From source file:org.eclipse.ui.dialogs.FilteredTree.java
License:Open Source License
/** * Create the button that clears the text. * //from ww w. j a va 2s .com * @param parent parent <code>Composite</code> of toolbar button */ private void createClearTextNew(Composite parent) { // only create the button if the text widget doesn't support one // natively if ((filterText.getStyle() & SWT.ICON_CANCEL) == 0) { final Image inactiveImage = JFaceResources.getImageRegistry().getDescriptor(DISABLED_CLEAR_ICON) .createImage(); final Image activeImage = JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON).createImage(); final Image pressedImage = new Image(getDisplay(), activeImage, SWT.IMAGE_GRAY); final Label clearButton = new Label(parent, SWT.NONE); clearButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); clearButton.setImage(inactiveImage); clearButton.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); clearButton.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip); clearButton.addMouseListener(new MouseAdapter() { private MouseMoveListener fMoveListener; public void mouseDown(MouseEvent e) { clearButton.setImage(pressedImage); fMoveListener = new MouseMoveListener() { private boolean fMouseInButton = true; public void mouseMove(MouseEvent e) { boolean mouseInButton = isMouseInButton(e); if (mouseInButton != fMouseInButton) { fMouseInButton = mouseInButton; clearButton.setImage(mouseInButton ? pressedImage : inactiveImage); } } }; clearButton.addMouseMoveListener(fMoveListener); } public void mouseUp(MouseEvent e) { if (fMoveListener != null) { clearButton.removeMouseMoveListener(fMoveListener); fMoveListener = null; boolean mouseInButton = isMouseInButton(e); clearButton.setImage(mouseInButton ? activeImage : inactiveImage); if (mouseInButton) { clearText(); filterText.setFocus(); } } } private boolean isMouseInButton(MouseEvent e) { Point buttonSize = clearButton.getSize(); return 0 <= e.x && e.x < buttonSize.x && 0 <= e.y && e.y < buttonSize.y; } }); clearButton.addMouseTrackListener(new MouseTrackListener() { public void mouseEnter(MouseEvent e) { clearButton.setImage(activeImage); } public void mouseExit(MouseEvent e) { clearButton.setImage(inactiveImage); } public void mouseHover(MouseEvent e) { } }); clearButton.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { inactiveImage.dispose(); activeImage.dispose(); pressedImage.dispose(); } }); clearButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { e.result = WorkbenchMessages.FilteredTree_AccessibleListenerClearButton; } }); clearButton.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() { public void getRole(AccessibleControlEvent e) { e.detail = ACC.ROLE_PUSHBUTTON; } }); this.clearButtonControl = clearButton; } }