org.eclipse.jface.resource.DeviceResourceException Java Examples
The following examples show how to use
org.eclipse.jface.resource.DeviceResourceException.
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: XtextDirectEditManager.java From statecharts with Eclipse Public License 1.0 | 6 votes |
/** * Given a label figure object, this will calculate the correct Font needed * to display into screen coordinates, taking into account the current * mapmode. This will typically be used by direct edit cell editors that * need to display independent of the zoom or any coordinate mapping that is * taking place on the drawing surface. * * @param label * the label to use for the font calculation * @return the <code>Font</code> that is scaled to the screen coordinates. * Note: the returned <code>Font</code> should not be disposed since * it is cached by a common resource manager. */ protected Font getScaledFont(IFigure label) { Font scaledFont = label.getFont(); FontData data = scaledFont.getFontData()[0]; Dimension fontSize = new Dimension(0, MapModeUtil.getMapMode(label).DPtoLP(data.getHeight())); label.translateToAbsolute(fontSize); if (Math.abs(data.getHeight() - fontSize.height) < 2) fontSize.height = data.getHeight(); try { FontDescriptor fontDescriptor = FontDescriptor.createFrom(data); cachedFontDescriptors.add(fontDescriptor); return getResourceManager().createFont(fontDescriptor); } catch (DeviceResourceException e) { Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), "getScaledFont", e); //$NON-NLS-1$ Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "getScaledFont", e); //$NON-NLS-1$ } return JFaceResources.getDefaultFont(); }
Example #2
Source File: KeysPreferencePage.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public Image getColumnImage(Object element, int index) { BindingElement be = (BindingElement) element; switch (index) { case COMMAND_NAME_COLUMN: final String commandId = be.getId(); final ImageDescriptor imageDescriptor = commandImageService.getImageDescriptor(commandId); if (imageDescriptor == null) { return null; } try { return localResourceManager.createImage(imageDescriptor); } catch (final DeviceResourceException e) { final String message = "Problem retrieving image for a command '" //$NON-NLS-1$ + commandId + '\''; final IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, message, e); WorkbenchPlugin.log(message, status); } return null; } return null; }
Example #3
Source File: KeysPreferencePage.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public Image getColumnImage(Object element, int index) { BindingElement be = (BindingElement) element; switch (index) { case COMMAND_NAME_COLUMN: final String commandId = be.getId(); final ImageDescriptor imageDescriptor = commandImageService.getImageDescriptor(commandId); if (imageDescriptor == null) { return null; } try { return localResourceManager.createImage(imageDescriptor); } catch (final DeviceResourceException e) { final String message = "Problem retrieving image for a command '" //$NON-NLS-1$ + commandId + '\''; final IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, message, e); WorkbenchPlugin.log(message, status); } return null; } return null; }
Example #4
Source File: KeysPreferencePage.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public Image getColumnImage(Object element, int index) { BindingElement be = (BindingElement) element; switch (index) { case COMMAND_NAME_COLUMN: final String commandId = be.getId(); final ImageDescriptor imageDescriptor = commandImageService.getImageDescriptor(commandId); if (imageDescriptor == null) { return null; } try { return localResourceManager.createImage(imageDescriptor); } catch (final DeviceResourceException e) { final String message = "Problem retrieving image for a command '" //$NON-NLS-1$ + commandId + '\''; final IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, message, e); WorkbenchPlugin.log(message, status); } return null; } return null; }
Example #5
Source File: XtextDirectEditManager.java From statecharts with Eclipse Public License 1.0 | 5 votes |
/** * This method obtains the fonts that are being used by the figure at its * zoom level. * * @param gep * the associated <code>GraphicalEditPart</code> of the figure * @param actualFont * font being used by the figure * @param display * @return <code>actualFont</code> if zoom level is 1.0 (or when there's an * error), new Font otherwise. */ private Font getZoomLevelFont(Font actualFont, Display display) { Object zoom = getEditPart().getViewer().getProperty(ZoomManager.class.toString()); if (zoom != null) { double zoomLevel = ((ZoomManager) zoom).getZoom(); if (zoomLevel == 1.0f) return actualFont; FontData[] fd = new FontData[actualFont.getFontData().length]; FontData tempFD = null; for (int i = 0; i < fd.length; i++) { tempFD = actualFont.getFontData()[i]; fd[i] = new FontData(tempFD.getName(), (int) (zoomLevel * tempFD.getHeight()), tempFD.getStyle()); } try { FontDescriptor fontDescriptor = FontDescriptor.createFrom(fd); cachedFontDescriptors.add(fontDescriptor); return getResourceManager().createFont(fontDescriptor); } catch (DeviceResourceException e) { Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), "getZoomLevelFonts", e); //$NON-NLS-1$ Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "getZoomLevelFonts", e); //$NON-NLS-1$ return actualFont; } } else return actualFont; }
Example #6
Source File: CommitCommentArea.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private Color getSpellingErrorColor(Composite composite) { AnnotationPreference pref = EditorsUI .getAnnotationPreferenceLookup().getAnnotationPreference( "org.eclipse.ui.workbench.texteditor.spelling"); // $NON-NLS-1$ String preferenceKey = pref.getColorPreferenceKey(); try { return fResources.createColor(PreferenceConverter.getColor(EditorsUI.getPreferenceStore(), preferenceKey)); } catch (DeviceResourceException e) { SVNUIPlugin.log(IStatus.ERROR, Policy.bind("internal"), e); //$NON-NLS-1$ return JFaceColors.getErrorText(composite.getDisplay()); } }
Example #7
Source File: PyEdit.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Used in the script pyedit_list_bindings.py */ public Font getFont(FontData descriptor) throws DeviceResourceException { Font font = getResourceManager().createFont(FontDescriptor.createFrom(descriptor)); // Old implementation (for Eclipse 3.3) // Font font = (Font) SWTResourceUtil.getFontTable().get(descriptor); // if (font == null) { // font = new Font(Display.getCurrent(), descriptor); // SWTResourceUtil.getFontTable().put(descriptor, font); // } return font; }