List of usage examples for org.eclipse.jface.resource JFaceResources getImageRegistry
public static ImageRegistry getImageRegistry()
From source file:org.eclipse.e4.ui.workbench.swt.internal.copy.FilteredTree.java
License:Open Source License
/** * Create the button that clears the text. * /*from w ww.j a v a 2 s. c o m*/ * @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(WorkbenchSWTMessages.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.e4.ui.workbench.swt.internal.copy.FilteredTree.java
License:Open Source License
/** * Create the button that clears the text. * //from w w w.j ava2 s . c o m * @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(WorkbenchSWTMessages.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 = WorkbenchSWTMessages.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.e4.ui.workbench.swt.internal.copy.ViewLabelProvider.java
License:Open Source License
public Image getImage(Object element) { if (element instanceof MPartDescriptor) { String iconURI = ((MPartDescriptor) element).getIconURI(); if (iconURI != null && iconURI.length() > 0) { Image image = imageMap.get(iconURI); if (image == null) { ISWTResourceUtilities resUtils = (ISWTResourceUtilities) context .get(IResourceUtilities.class.getName()); image = resUtils.imageDescriptorFromURI(URI.createURI(iconURI)).createImage(); imageMap.put(iconURI, image); }// w w w.j a v a 2 s . co m return image; } return null; } else if (element instanceof String) { Image image = imageMap.get(FOLDER_ICON); if (image == null) { image = JFaceResources.getImageRegistry().getDescriptor(FOLDER_ICON).createImage(); imageMap.put(FOLDER_ICON, image); } return image; } return null; }
From source file:org.eclipse.e4.xwt.tools.ui.designer.resources.ImageShop.java
License:Open Source License
public static ImageRegistry getImageRegistry() { return JFaceResources.getImageRegistry(); }
From source file:org.eclipse.e4.xwt.ui.utils.ImageManager.java
License:Open Source License
private static ImageDescriptor createManaged(String prefix, String name, String key) { ImageDescriptor result = create(prefix, name, true); JFaceResources.getImageRegistry().put(key, result); return result; }
From source file:org.eclipse.e4.xwt.ui.utils.ImageManager.java
License:Open Source License
/** * Returns the image managed under the given key in this registry. * //from w ww . j a v a 2s.co m * @param key * the image's key * @return the image managed under the given key */ public static Image get(String key) { return JFaceResources.getImageRegistry().get(key); }
From source file:org.eclipse.equinox.internal.p2.ui.discovery.util.TextSearchControl.java
License:Open Source License
@SuppressWarnings("restriction") public TextSearchControl(Composite parent, boolean automaticFind) { super(parent, getCompositeStyle(automaticFind, parent)); this.automaticFind = automaticFind; int textStyle = SWT.SINGLE; int numColumns = 1; if (useNativeSearchField(automaticFind, parent)) { if (automaticFind) { textStyle |= SWT.SEARCH | ICON_CANCEL; } else {/*from ww w.ja v a2 s. co m*/ textStyle |= SWT.SEARCH | ICON_SEARCH | ICON_CANCEL; } } else { super.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); super.setFont(parent.getFont()); numColumns = 2; if (!automaticFind) { numColumns += 1; } } GridLayoutFactory.swtDefaults().margins(0, 0).extendedMargins(0, 0, 0, 0).spacing(0, 1) .numColumns(numColumns).applyTo(this); textControl = new Text(this, textStyle); GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); textControl.setLayoutData(gridData); if (useNativeSearchField == null || !useNativeSearchField) { findControl = createLabelButtonControl(this, textControl, JFaceResources.getImageRegistry().getDescriptor(FIND_ICON), "Find", "Find", ICON_SEARCH); clearControl = createLabelButtonControl(this, textControl, JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON), WorkbenchMessages.FilteredTree_ClearToolTip, //FilteredTree_AccessibleListenerClearButton, WorkbenchMessages.FilteredTree_ClearToolTip, ICON_CANCEL); addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { updateButtonVisibilityAndEnablement(); } }); updateButtonVisibilityAndEnablement(); } registerListeners(); }
From source file:org.eclipse.equinox.internal.p2.ui.model.ProvElement.java
License:Open Source License
public ImageDescriptor getImageDescriptor(Object object) { String id = getImageId(object); if (id == null) { return null; }//from w w w. j a v a2 s .c o m ImageDescriptor desc = ProvUIImages.getImageDescriptor(id); if (desc == null) desc = JFaceResources.getImageRegistry().getDescriptor(id); return desc; }
From source file:org.eclipse.equinox.internal.p2.ui.model.ProvElement.java
License:Open Source License
/** * Return the image that should be used to show the specfied object. The * image is managed by an image registry and should not be freed. * //from w ww . j a v a 2s . c o m * @param object * the object whose image id is requested * @return the string id of the image in the provisioning image registry * */ public Image getImage(Object object) { String id = getImageId(object); if (id == null) { return null; } Image img = ProvUIImages.getImage(id); if (img == null) img = JFaceResources.getImageRegistry().get(id); return img; }
From source file:org.eclipse.fx.ide.ui.preview.LivePreviewPart.java
License:Open Source License
@Override public void createPartControl(final Composite parent) { final Composite container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout(3, false)); folder = new CTabFolder(container, SWT.BOTTOM | SWT.BORDER); folder.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 3, 1)); document = new Document(); // parent.getDisplay().syncExec(new Runnable() { ///* www . j ava 2 s .c o m*/ // @Override // public void run() { { CTabItem item = new CTabItem(folder, SWT.NONE); item.setText("Preview"); item.setImage(JFaceResources.getImage(IMAGE_PREVIEW)); swtFXContainer = new FXCanvas(folder, SWT.NONE); swtFXContainer.setEnabled(false); item.setControl(swtFXContainer); rootPane_new = new BorderPane(); BorderPane pane = new BorderPane(); pane.setCenter(rootPane_new); defaultScene = new Scene(pane, -1, -1, Platform.isSupported(ConditionalFeature.SCENE3D)); currentScene = defaultScene; swtFXContainer.setScene(defaultScene); } { logItem = new CTabItem(folder, SWT.NONE); logItem.setText("Error log"); logItem.setImage(JFaceResources.getImage(IMAGE_OK)); logStatement = new Text(folder, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); logStatement.setEditable(false); logItem.setControl(logStatement); Menu m = new Menu(logStatement); logStatement.setMenu(m); MenuItem clearItem = new MenuItem(m, SWT.PUSH); clearItem.setText("Clear Log"); clearItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { logStatement.setText(""); } }); } { CTabItem fxmlContent = new CTabItem(folder, SWT.NONE); fxmlContent.setText("FXML-Source"); fxmlContent.setImage(JFaceResources.getImage(IMAGE_FXML_CONTENT)); final AnnotationModel model = new AnnotationModel(); VerticalRuler verticalRuler = new VerticalRuler(VERTICAL_RULER_WIDTH, new AnnotationAccess()); int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; SourceViewer sourceViewer = new SourceViewer(folder, verticalRuler, styles); sourceViewer.configure(new XMLConfiguration(new ColorManager())); sourceViewer.setEditable(false); sourceViewer.getTextWidget().setFont(JFaceResources.getTextFont()); IDocumentPartitioner partitioner = new FastPartitioner(new XMLPartitionScanner(), new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT }); partitioner.connect(document); document.setDocumentPartitioner(partitioner); sourceViewer.setDocument(document); verticalRuler.setModel(model); fxmlContent.setControl(sourceViewer.getControl()); } folder.setSelection(0); statusLabelIcon = new Label(container, SWT.NONE); statusLabelIcon.setImage(JFaceResources.getImage(IMAGE_STATUS_NOPREVIEW)); statusLabelText = new Label(container, SWT.NONE); statusLabelText.setText(NO_PREVIEW_TEXT); statusLabelText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite scaleControl = new Composite(container, SWT.NONE); scaleControl.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); scaleControl.setLayout(new GridLayout(2, false)); Label l = new Label(scaleControl, SWT.NONE); l.setText("Zoom"); scale = new Spinner(scaleControl, SWT.BORDER); scale.setMinimum(10); scale.setMaximum(500); scale.setIncrement(10); scale.setSelection(100); scale.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { rootPane_new.getTransforms() .setAll(Transform.scale(scale.getSelection() / 100.0, scale.getSelection() / 100.0)); if (currentFile != null) { scaleMap.put(currentFile, scale.getSelection()); } } }); parent.layout(true, true); if (currentData != null) { refreshContent(currentData); } // } // }); parent.layout(true, true); Action loadController = new Action("", IAction.AS_CHECK_BOX) { @Override public void run() { preference.putBoolean(PREF_LOAD_CONTROLLER, !preference.getBoolean(PREF_LOAD_CONTROLLER, false)); try { preference.flush(); synchronizer.refreshPreview(); } catch (BackingStoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; loadController.setChecked(preference.getBoolean(PREF_LOAD_CONTROLLER, false)); loadController.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(IMAGE_LOAD_CONTROLLER)); loadController.setToolTipText("Load the controller"); Action refresh = new Action("", JFaceResources.getImageRegistry().getDescriptor(IMAGE_REFRESH)) { @Override public void run() { synchronizer.refreshPreview(); } }; refresh.setToolTipText("Force a refresh"); MenuManager mgr = new MenuManager(); for (SCREEN_SIZE s : SCREEN_SIZE.values()) { mgr.add(new ScreenAction(s)); } final Menu m = mgr.createContextMenu(parent); screenSize = new Action("ScreenSize", IAction.AS_DROP_DOWN_MENU) { @Override public void runWithEvent(Event event) { if (event.detail == SWT.DROP_DOWN) { ToolItem i = (ToolItem) event.widget; m.setLocation(i.getParent().toDisplay(event.x, event.y)); m.setVisible(true); } } }; getViewSite().getActionBars().getToolBarManager().add(screenSize); getViewSite().getActionBars().getToolBarManager().add(new Action("Horizontal", Action.AS_CHECK_BOX) { @Override public void run() { updateResolution(currentSize, isChecked()); } }); getViewSite().getActionBars().getToolBarManager().add(refresh); getViewSite().getActionBars().getToolBarManager().add(loadController); }