本文整理汇总了Java中org.eclipse.jface.resource.DeviceResourceException类的典型用法代码示例。如果您正苦于以下问题:Java DeviceResourceException类的具体用法?Java DeviceResourceException怎么用?Java DeviceResourceException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeviceResourceException类属于org.eclipse.jface.resource包,在下文中一共展示了DeviceResourceException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getScaledFont
import org.eclipse.jface.resource.DeviceResourceException; //导入依赖的package包/类
/**
* 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();
}
开发者ID:Yakindu,项目名称:statecharts,代码行数:34,代码来源:XtextDirectEditManager.java
示例2: put
import org.eclipse.jface.resource.DeviceResourceException; //导入依赖的package包/类
/**
* Adds an image to this registry. This method fails if there is already an
* image or descriptor for the given key.
* <p>
* Note that an image registry owns all of the image objects registered with
* it, and automatically disposes of them when the SWT Display is disposed.
* Because of this, clients must not register an image object that is
* managed by another object.
* </p>
*
* @param key
* the key
* @param image
* the image, should not be <code>null</code>
* @exception IllegalArgumentException
* if the key already exists
*/
public void put(String key, Image image) {
Entry entry = getEntry(key);
if (entry == null) {
entry = new Entry();
putEntry(key, entry);
}
if (entry.image != null || entry.descriptor != null) {
throw new IllegalArgumentException(
"ImageRegistry key already in use: " + key); //$NON-NLS-1$
}
// Should be checking for a null image here.
// Current behavior is that a null image won't be caught until dispose.
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130315
entry.image = image;
entry.descriptor = new OriginalImageDescriptor(image, manager
.getDevice());
try {
manager.create(entry.descriptor);
} catch (DeviceResourceException e) {
}
}
开发者ID:evilwan,项目名称:raptor-chess-interface,代码行数:43,代码来源:RaptorImageRegistry.java
示例3: getColumnImage
import org.eclipse.jface.resource.DeviceResourceException; //导入依赖的package包/类
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;
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:23,代码来源:KeysPreferencePage.java
示例4: getSpellingErrorColor
import org.eclipse.jface.resource.DeviceResourceException; //导入依赖的package包/类
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());
}
}
开发者ID:subclipse,项目名称:subclipse,代码行数:13,代码来源:CommitCommentArea.java
示例5: changeFont
import org.eclipse.jface.resource.DeviceResourceException; //导入依赖的package包/类
/**
* Changes a control's font
* @param control
* @param style
* @throws DeviceResourceException
*/
public static void changeFont(Control control, int style) throws DeviceResourceException {
FontDescriptor boldDescriptor = FontDescriptor.createFrom(control.getFont());
final Font boldFont = boldDescriptor.createFont(control.getDisplay());
control.setFont(boldFont);
control.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent arg0) {
if (boldFont != null && !boldFont.isDisposed()) {
boldFont.dispose();
}
}
});
}
开发者ID:WiednerF,项目名称:ARXPlugin,代码行数:21,代码来源:SWTUtil.java
示例6: getZoomLevelFont
import org.eclipse.jface.resource.DeviceResourceException; //导入依赖的package包/类
/**
* 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;
}
开发者ID:Yakindu,项目名称:statecharts,代码行数:46,代码来源:XtextDirectEditManager.java
示例7: createResource
import org.eclipse.jface.resource.DeviceResourceException; //导入依赖的package包/类
@Override
public Object createResource(Device device)
throws DeviceResourceException {
if (device == originalDisplay) {
refCount++;
return original;
}
return super.createResource(device);
}
开发者ID:evilwan,项目名称:raptor-chess-interface,代码行数:10,代码来源:RaptorImageRegistry.java
示例8: findOrCreateImage
import org.eclipse.jface.resource.DeviceResourceException; //导入依赖的package包/类
private Image findOrCreateImage(final ImageDescriptor imageDescriptor, final ResourceManager resourceManager) {
if (imageDescriptor == null) { return null; }
Image image = (Image) resourceManager.find(imageDescriptor);
if (image == null) {
try {
image = resourceManager.createImage(imageDescriptor);
} catch (final DeviceResourceException e) {
// WorkbenchPlugin.log(e);
}
}
return image;
}
开发者ID:gama-platform,项目名称:gama,代码行数:13,代码来源:GamlAccessEntry.java
示例9: getFont
import org.eclipse.jface.resource.DeviceResourceException; //导入依赖的package包/类
/**
* 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;
}
开发者ID:fabioz,项目名称:Pydev,代码行数:15,代码来源:PyEdit.java
示例10: getColor
import org.eclipse.jface.resource.DeviceResourceException; //导入依赖的package包/类
private Color getColor(ResourceManager manager, RGB rgb) {
try {
return manager.createColor(rgb);
} catch (DeviceResourceException e) {
return manager.getDevice().getSystemColor(SWT.COLOR_BLACK);
}
}
开发者ID:awltech,项目名称:eclipse-mylyn-notifications,代码行数:8,代码来源:NotificationPopupColors.java
示例11: ComponentRiskMonitor
import org.eclipse.jface.resource.DeviceResourceException; //导入依赖的package包/类
/**
* Creates a new instance
* @param parent
* @param controller
* @param text
* @param shortText
*/
public ComponentRiskMonitor(final Composite parent,
final String text,
final String shortText) {
Display.getCurrent().getActiveShell();
// Images
imageLow = Resources.getImage("bullet_green.png"); //$NON-NLS-1$
imageHigh = Resources.getImage("bullet_red.png"); //$NON-NLS-1$
// Layout
GridLayout layout = SWTUtil.createGridLayout(1);
layout.marginHeight = 0;
layout.marginTop = 0;
layout.marginBottom = 0;
layout.verticalSpacing = 0;
// Root
this.root = new Composite(parent, SWT.NONE);
this.root.setLayout(layout);
this.root.setToolTipText(text);
// Caption
this.caption = new CLabel(root, SWT.CENTER);
this.caption.setText(shortText);
this.caption.setLayoutData(SWTUtil.createFillHorizontallyGridData());
this.caption.setToolTipText(text);
this.caption.setImage(imageHigh);
try {
SWTUtil.changeFont(caption, SWT.BOLD);
} catch (DeviceResourceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Content
Composite content = new Composite(root, SWT.NONE);
content.setLayoutData(SWTUtil.createFillGridData());
content.setToolTipText(text);
// Create meter
Canvas canvas = new Canvas(content, SWT.DOUBLE_BUFFERED);
canvas.setToolTipText(text);
this.meter = new ComponentMeterFigure();
this.meter.setNeedleColor(XYGraphMediaFactory.getInstance().getColor(0, 0, 0));
this.meter.setValueLabelVisibility(true);
this.meter.setRange(new Range(0, 100));
this.meter.setLoLevel(0);
this.meter.setLoColor(XYGraphMediaFactory.getInstance().getColor(0, 150, 0));
this.meter.setLoloLevel(25);
this.meter.setLoloColor(XYGraphMediaFactory.getInstance().getColor(255, 255, 0));
this.meter.setHiLevel(50);
this.meter.setHiColor(XYGraphMediaFactory.getInstance().getColor(255, 200, 25));
this.meter.setHihiLevel(100);
this.meter.setHihiColor(XYGraphMediaFactory.getInstance().getColor(255, 0, 0));
this.meter.setMajorTickMarkStepHint(50);
LightweightSystem lws = new LightweightSystem(canvas);
lws.setContents(this.meter);
// Create label
label = new CLabel(content, SWT.CENTER);
label.setLayoutData(SWTUtil.createFillHorizontallyGridData());
label.setToolTipText(text);
// Create responsive layout
new ComponentResponsiveLayout(content, 100, 50, canvas, label);
}
开发者ID:WiednerF,项目名称:ARXPlugin,代码行数:74,代码来源:ComponentRiskMonitor.java
示例12: ComponentRiskThresholds
import org.eclipse.jface.resource.DeviceResourceException; //导入依赖的package包/类
/**
* Creates a new instance
* @param parent
* @param shortText
*/
public ComponentRiskThresholds(final Composite parent) {
// Color profiles
this.defaultColorProfile = KnobColorProfile.createDefaultSystemProfile(parent.getDisplay());
this.focusedColorProfile = KnobColorProfile.createFocusedBlueRedProfile(parent.getDisplay());
this.root = new Composite(parent, SWT.NONE);
this.root.setLayout(SWTUtil.createGridLayout(1));
this.root.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent arg0) {
if (defaultColorProfile != null && !defaultColorProfile.isDisposed()) {
defaultColorProfile.dispose();
}
if (focusedColorProfile != null && !focusedColorProfile.isDisposed()) {
focusedColorProfile.dispose();
}
}
});
// Label
Label label = new Label(root, SWT.CENTER);
label.setText(CAPTION);
GridData labeldata = SWTUtil.createFillHorizontallyGridData();
labeldata.horizontalAlignment = SWT.CENTER;
label.setLayoutData(labeldata);
try {
SWTUtil.changeFont(label, SWT.BOLD);
} catch (DeviceResourceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Base
Composite base = new Composite(root, SWT.NONE);
base.setLayoutData(GridDataFactory.swtDefaults().grab(true, true).align(SWT.CENTER, SWT.CENTER).create());
// Layout
GridLayout layout = SWTUtil.createGridLayout(6, true);
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
base.setLayout(layout);
createSeparator(base, "Main", 2);
createSeparator(base, "Derived", 4);
createLabel(base, LABEL1);
createLabel(base, LABEL2);
createLabel(base, LABEL3);
knob1 = createKnob(base);
label1 = createLabel(base, knob1);
knob2 = createKnob(base);
label2 = createLabel(base, knob2);
knob3 = createKnob(base);
label3 = createLabel(base, knob3);
}
开发者ID:WiednerF,项目名称:ARXPlugin,代码行数:63,代码来源:ComponentRiskThresholds.java
注:本文中的org.eclipse.jface.resource.DeviceResourceException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论