List of usage examples for org.eclipse.jface.resource JFaceResources getImageRegistry
public static ImageRegistry getImageRegistry()
From source file:at.bestsolution.efxclipse.tooling.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)); parent.getDisplay().asyncExec(new Runnable() { @Override// ww w.ja va 2 s. co m 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(); Scene scene = new Scene((Parent) rootPane_new, 1000, 1000); currentScene = scene; swtFXContainer.setScene(scene); } { 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()); document = new Document(); 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.setScaleX(scale.getSelection() / 100.0); rootPane_new.setScaleY(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"); getViewSite().getActionBars().getToolBarManager().add(refresh); getViewSite().getActionBars().getToolBarManager().add(loadController); }
From source file:at.medevit.icons.core.Icon.java
License:Open Source License
/** * Returns an image. Clients do not need to dispose the image, it will be * disposed automatically./*w w w .java 2 s . c o m*/ * * @return an {@link Image} */ public Image getImage(IconSize is) { Image image = JFaceResources.getImageRegistry().get(this.name()); if (image == null) { addIconImageDescriptor(this.name(), is); image = JFaceResources.getImageRegistry().get(this.name()); } return image; }
From source file:at.medevit.icons.core.Icon.java
License:Open Source License
/** * @return {@link ImageDescriptor} for the current image *///from w w w .j a v a 2 s . com public ImageDescriptor getImageDescriptor(IconSize is) { ImageDescriptor id = null; id = JFaceResources.getImageRegistry().getDescriptor(this.name()); if (id == null) { addIconImageDescriptor(this.name(), is); id = JFaceResources.getImageRegistry().getDescriptor(this.name()); } return id; }
From source file:at.medevit.icons.core.Icon.java
License:Open Source License
/** * Add an image descriptor for a specific key and {@link IconSize} to the * global {@link ImageRegistry}/*w w w. j av a 2 s.co m*/ * * @param name * @param is * @return <code>true</code> if successfully added, else <code>false</code> */ private static boolean addIconImageDescriptor(String name, IconSize is) { try { ResourceBundle iconsetProperties = ResourceBundle.getBundle("iconset"); String fileName = iconsetProperties.getString(name); URL fileLocation = FileLocator.find(Activator.getDefault().getBundle(), new Path("icons/" + is.name + "/" + fileName), null); ImageDescriptor id = ImageDescriptor.createFromURL(fileLocation); JFaceResources.getImageRegistry().put(name, id); } catch (MissingResourceException | IllegalArgumentException e) { return false; } return true; }
From source file:br.ufes.inf.nemo.ontouml.transformation.onto2info.ui.util.EmulatedNativeCheckBoxLabelProvider.java
License:Open Source License
public EmulatedNativeCheckBoxLabelProvider(ColumnViewer viewer) { if (JFaceResources.getImageRegistry().getDescriptor(CHECKED_KEY) == null) { JFaceResources.getImageRegistry().put(UNCHECK_KEY, makeShot(viewer.getControl(), false)); JFaceResources.getImageRegistry().put(CHECKED_KEY, makeShot(viewer.getControl(), true)); }//from ww w. ja v a 2 s .c o m }
From source file:br.ufes.inf.nemo.ontouml.transformation.onto2info.ui.util.EmulatedNativeCheckBoxLabelProvider.java
License:Open Source License
public Image getImage(Object element) { if (isChecked(element)) { return JFaceResources.getImageRegistry().get(CHECKED_KEY); } else {//from w ww . j a v a2s . c om return JFaceResources.getImageRegistry().get(UNCHECK_KEY); } }
From source file:cc.frz.ecl.filterpackageexplorer.FilterPackageExplorer.java
License:Open Source License
/** * Create the button that clears the text. * //from w ww. j av a 2 s . c om * @param parent * parent <code>Composite</code> of toolbar button */ private void createClearText(Composite parent) { filterToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL); ToolBar control = filterToolBar.createControl(parent); control.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$ /* * (non-Javadoc) * * @see org.eclipse.jface.action.Action#run() */ public void run() { filtertext.setText(""); updateTree(); } }; clearTextAction.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip); clearTextAction.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON)); clearTextAction.setDisabledImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(DCLEAR_ICON)); filterToolBar.add(clearTextAction); filterToolBar.update(false); }
From source file:ch.elexis.core.icons.Images.java
License:Open Source License
/** * Returns an image. Clients do not need to dispose the image, it will be disposed * automatically.//from w w w.ja v a 2 s . c o m * * @return an {@link Image} */ public Image getImage() { Image image = JFaceResources.getImageRegistry().get(this.name()); if (image == null) { addImageDescriptor(this.name()); image = JFaceResources.getImageRegistry().get(this.name()); } return image; }
From source file:ch.elexis.core.icons.Images.java
License:Open Source License
/** * @return {@link ImageDescriptor} for the current image *//*from w w w . j av a2s. co m*/ public ImageDescriptor getImageDescriptor() { ImageDescriptor id = null; id = JFaceResources.getImageRegistry().getDescriptor(this.name()); if (id == null) { addImageDescriptor(this.name()); id = JFaceResources.getImageRegistry().getDescriptor(this.name()); } return id; }
From source file:ch.elexis.core.icons.Images.java
License:Open Source License
/** * Opportunistic lookup for a probably existing key.<br> * There may exist keys within the <code>iconset.properties</code> file which are not managed by * this Enumeration. This method allows an opportunistic lookup of such registered images. * /*w w w . ja va 2 s . c o m*/ * @param iconKey * @return <code>null</code> if no such image is existent */ public static Image lookupImage(String iconKey) { Image image = JFaceResources.getImageRegistry().get(iconKey); if (image == null) { boolean ret = addImageDescriptor(iconKey); if (!ret) return null; image = JFaceResources.getImageRegistry().get(iconKey); } return image; }