List of usage examples for org.eclipse.jface.resource JFaceResources getDefaultFont
public static Font getDefaultFont()
From source file:org.netxms.ui.eclipse.market.views.helpers.RepositoryLabelProvider.java
License:Open Source License
/** * Constructor/*from ww w . ja va 2s . c om*/ */ public RepositoryLabelProvider() { FontData fd = JFaceResources.getDefaultFont().getFontData()[0]; fd.setStyle(SWT.BOLD); markFont = new Font(Display.getCurrent(), fd); markColor = new Color(Display.getCurrent(), 0, 148, 255); }
From source file:org.netxms.ui.eclipse.networkmaps.views.helpers.ObjectFigureLargeLabel.java
License:Open Source License
/** * @param element/*from w w w . ja v a 2s .c o m*/ * @param labelProvider */ public ObjectFigureLargeLabel(NetworkMapObject element, MapLabelProvider labelProvider) { super(element, labelProvider); setOpaque(true); setBorder(new MarginBorder(3)); GridLayout layout = new GridLayout(2, false); layout.horizontalSpacing = 10; layout.numColumns = 2; setLayoutManager(layout); icon = new Label(labelProvider.getImage(element)); icon.setFont(JFaceResources.getDefaultFont()); add(icon); GridData gd = new GridData(); gd.horizontalAlignment = SWT.LEFT; gd.verticalAlignment = SWT.TOP; gd.verticalSpan = 3; setConstraint(icon, gd); name = new Label(object.getObjectName()); name.setFont(JFaceResources.getDefaultFont()); name.setLabelAlignment(PositionConstants.LEFT); add(name); gd = new GridData(); gd.horizontalAlignment = SWT.FILL; gd.verticalAlignment = SWT.TOP; gd.grabExcessHorizontalSpace = true; setConstraint(name, gd); additionalInfo = new Label(object.getObjectName()); additionalInfo.setLabelAlignment(PositionConstants.LEFT); additionalInfo.setFont(labelProvider.getLabelFont()); add(additionalInfo); gd = new GridData(); gd.horizontalAlignment = SWT.FILL; gd.verticalAlignment = SWT.TOP; gd.grabExcessHorizontalSpace = true; setConstraint(additionalInfo, gd); StringBuilder sb = new StringBuilder(); if ((object instanceof Node) && ((Node) object).getPrimaryIP().isValidAddress() && !((Node) object).getPrimaryIP().getAddress().isAnyLocalAddress()) { sb.append(((Node) object).getPrimaryIP().getHostAddress()); MacAddress mac = ((Node) object).getPrimaryMAC(); if (mac != null) { sb.append(" ("); //$NON-NLS-1$ sb.append(mac.toString()); sb.append(')'); } } additionalInfo.setText(sb.toString()); if (object instanceof Node) { DciValue[] values = labelProvider.getNodeLastValues(object.getObjectId()); if ((values != null) && (values.length > 0)) { lastValuesFigure = new NodeLastValuesFigure(values); gd = new GridData(); gd.horizontalAlignment = SWT.FILL; gd.verticalAlignment = SWT.TOP; gd.grabExcessHorizontalSpace = true; add(lastValuesFigure, gd); } } Dimension ls = getPreferredSize(-1, -1); setSize(ls.width, ls.height); }
From source file:org.netxms.ui.eclipse.objectview.widgets.RackWidget.java
License:Open Source License
/** * Draw tooltip for current object//from w w w. ja va 2 s. com * * @param gc */ private void drawObjectToolTip(GC gc) { gc.setFont(objectToolTipHeaderFont); Point titleSize = gc.textExtent(tooltipObject.getObjectName()); gc.setFont(JFaceResources.getDefaultFont()); // Calculate width and height int width = Math.max(titleSize.x + 12, 128); int height = OBJECT_TOOLTIP_Y_MARGIN * 2 + titleSize.y + 2 + OBJECT_TOOLTIP_SPACING; List<String> texts = new ArrayList<String>(); if (tooltipObject instanceof AbstractNode) { texts.add(((AbstractNode) tooltipObject).getPrimaryIP().getHostAddress()); texts.add(((AbstractNode) tooltipObject).getPlatformName()); String sd = ((AbstractNode) tooltipObject).getSystemDescription(); if (sd.length() > 127) sd = sd.substring(0, 127) + "..."; texts.add(sd); texts.add(((AbstractNode) tooltipObject).getSnmpSysName()); texts.add(((AbstractNode) tooltipObject).getSnmpSysContact()); } for (String s : texts) { if ((s == null) || s.isEmpty()) continue; Point pt = gc.textExtent(s); if (width < pt.x) width = pt.x; height += pt.y; } List<DciValue> values = ((DataCollectionTarget) tooltipObject).getTooltipDciData(); if (!values.isEmpty()) { for (DciValue v : values) { Point pt = gc.textExtent(v.getName() + " " + v.getValue()); if (width < pt.x) width = pt.x; height += pt.y; } height += OBJECT_TOOLTIP_SPACING * 2 + 1; } if ((tooltipObject.getComments() != null) && !tooltipObject.getComments().isEmpty()) { Point pt = gc.textExtent(tooltipObject.getComments()); if (width < pt.x) width = pt.x; height += pt.y + OBJECT_TOOLTIP_SPACING * 2 + 1; } width += OBJECT_TOOLTIP_X_MARGIN * 2; Rectangle ca = getClientArea(); Rectangle rect = new Rectangle(objectToolTipLocation.x - width / 2, objectToolTipLocation.y - height / 2, width, height); if (rect.x < 0) rect.x = 0; else if (rect.x + rect.width >= ca.width) rect.x = ca.width - rect.width - 1; if (rect.y < 0) rect.y = 0; else if (rect.y + rect.height >= ca.height) rect.y = ca.height - rect.height - 1; gc.setBackground(colorCache.create(239, 225, 160)); gc.setAlpha(240); gc.fillRoundRectangle(rect.x, rect.y, rect.width, rect.height, 3, 3); gc.setForeground(colorCache.create(92, 92, 92)); gc.setAlpha(255); gc.setLineWidth(3); gc.drawRoundRectangle(rect.x, rect.y, rect.width, rect.height, 3, 3); gc.setLineWidth(1); int y = rect.y + OBJECT_TOOLTIP_Y_MARGIN + titleSize.y + 2; gc.drawLine(rect.x + 1, y, rect.x + rect.width - 1, y); gc.setBackground(StatusDisplayInfo.getStatusColor(tooltipObject.getStatus())); gc.fillOval(rect.x + OBJECT_TOOLTIP_X_MARGIN, rect.y + OBJECT_TOOLTIP_Y_MARGIN + titleSize.y / 2 - 4, 8, 8); gc.setForeground(colorCache.create(0, 0, 0)); gc.setFont(objectToolTipHeaderFont); gc.drawText(tooltipObject.getObjectName(), rect.x + OBJECT_TOOLTIP_X_MARGIN + 12, rect.y + OBJECT_TOOLTIP_Y_MARGIN, true); gc.setFont(JFaceResources.getDefaultFont()); int textLineHeight = gc.textExtent("M").y; //$NON-NLS-1$ y = rect.y + OBJECT_TOOLTIP_Y_MARGIN + titleSize.y + OBJECT_TOOLTIP_SPACING + 2 - textLineHeight; for (String s : texts) { if ((s == null) || s.isEmpty()) continue; y += textLineHeight; gc.drawText(s, rect.x + OBJECT_TOOLTIP_X_MARGIN, y, true); } if (!values.isEmpty()) { y += textLineHeight + OBJECT_TOOLTIP_SPACING; gc.setForeground(colorCache.create(92, 92, 92)); gc.drawLine(rect.x + 1, y, rect.x + rect.width - 1, y); y += OBJECT_TOOLTIP_SPACING; gc.setForeground(colorCache.create(0, 0, 0)); for (DciValue v : values) { gc.drawText(v.getName(), rect.x + OBJECT_TOOLTIP_X_MARGIN, y, true); Point pt = gc.textExtent(v.getValue()); gc.drawText(v.getValue(), rect.x + rect.width - OBJECT_TOOLTIP_X_MARGIN - pt.x, y, true); y += textLineHeight; } y -= textLineHeight; } if ((tooltipObject.getComments() != null) && !tooltipObject.getComments().isEmpty()) { y += textLineHeight + OBJECT_TOOLTIP_SPACING; gc.setForeground(colorCache.create(92, 92, 92)); gc.drawLine(rect.x + 1, y, rect.x + rect.width - 1, y); y += OBJECT_TOOLTIP_SPACING; gc.setForeground(colorCache.create(0, 0, 0)); gc.drawText(tooltipObject.getComments(), rect.x + OBJECT_TOOLTIP_X_MARGIN, y, true); } objectTooltipRectangle = rect; }
From source file:org.netxms.ui.eclipse.osm.widgets.ObjectGeoLocationViewer.java
License:Open Source License
/** * Draw tooltip for current object/*from w w w . ja v a 2 s .com*/ * * @param gc */ private void drawObjectToolTip(GC gc) { gc.setFont(objectToolTipHeaderFont); Point titleSize = gc.textExtent(currentObject.getObjectName()); gc.setFont(JFaceResources.getDefaultFont()); // Calculate width and height int width = Math.max(titleSize.x + 12, 128); int height = OBJECT_TOOLTIP_Y_MARGIN * 2 + titleSize.y + 2 + OBJECT_TOOLTIP_SPACING; final String location = currentObject.getGeolocation().toString(); Point pt = gc.textExtent(location); if (width < pt.x) width = pt.x; height += pt.y; String locationDetails; if ((currentObject.getGeolocation().getTimestamp().getTime() > 0) && currentObject.getGeolocation().isAutomatic()) { locationDetails = String.format(Messages.get().ObjectGeoLocationViewer_ObtainedFrom, RegionalSettings.getDateTimeFormat().format(currentObject.getGeolocation().getTimestamp()), (currentObject.getGeolocation().getType() == GeoLocation.GPS) ? Messages.get().ObjectGeoLocationViewer_GPS : Messages.get().ObjectGeoLocationViewer_Network); pt = gc.textExtent(locationDetails); if (width < pt.x) width = pt.x; height += pt.y; } else { locationDetails = null; } final String postalAddress = currentObject.getPostalAddress().getAddressLine(); if (!postalAddress.isEmpty()) { pt = gc.textExtent(postalAddress); if (width < pt.x) width = pt.x; height += pt.y + OBJECT_TOOLTIP_SPACING; } String lastReport, batteryLevel; if (currentObject instanceof MobileDevice) { lastReport = String.format(Messages.get().ObjectGeoLocationViewer_LastReport, ((MobileDevice) currentObject).getLastReportTime().getTime() > 0 ? RegionalSettings.getDateTimeFormat() .format(((MobileDevice) currentObject).getLastReportTime()) : Messages.get().ObjectGeoLocationViewer_Never); pt = gc.textExtent(lastReport); if (width < pt.x) width = pt.x; height += pt.y + OBJECT_TOOLTIP_SPACING * 2 + 1; if (((MobileDevice) currentObject).getBatteryLevel() >= 0) { batteryLevel = String.format(Messages.get().ObjectGeoLocationViewer_BatteryLevel, ((MobileDevice) currentObject).getBatteryLevel()); pt = gc.textExtent(batteryLevel); if (width < pt.x) width = pt.x; height += pt.y; } else { batteryLevel = null; } } else { lastReport = null; batteryLevel = null; } if ((currentObject.getComments() != null) && !currentObject.getComments().isEmpty()) { pt = gc.textExtent(currentObject.getComments()); if (width < pt.x) width = pt.x; height += pt.y + OBJECT_TOOLTIP_SPACING * 2 + 1; } width += OBJECT_TOOLTIP_X_MARGIN * 2; Rectangle ca = getClientArea(); Rectangle rect = new Rectangle(objectToolTipLocation.x - width / 2, objectToolTipLocation.y - height / 2, width, height); if (rect.x < 0) rect.x = 0; else if (rect.x + rect.width >= ca.width) rect.x = ca.width - rect.width - 1; if (rect.y < 0) rect.y = 0; else if (rect.y + rect.height >= ca.height) rect.y = ca.height - rect.height - 1; gc.setBackground(colorCache.create(224, 224, 224)); gc.setAlpha(192); gc.fillRoundRectangle(rect.x, rect.y, rect.width, rect.height, 3, 3); gc.setForeground(colorCache.create(92, 92, 92)); gc.setAlpha(255); gc.setLineWidth(3); gc.drawRoundRectangle(rect.x, rect.y, rect.width, rect.height, 3, 3); gc.setLineWidth(1); int y = rect.y + OBJECT_TOOLTIP_Y_MARGIN + titleSize.y + 2; gc.drawLine(rect.x + 1, y, rect.x + rect.width - 1, y); gc.setBackground(StatusDisplayInfo.getStatusColor(currentObject.getStatus())); gc.fillOval(rect.x + OBJECT_TOOLTIP_X_MARGIN, rect.y + OBJECT_TOOLTIP_Y_MARGIN + titleSize.y / 2 - 4, 8, 8); gc.setForeground(colorCache.create(0, 0, 0)); gc.setFont(objectToolTipHeaderFont); gc.drawText(currentObject.getObjectName(), rect.x + OBJECT_TOOLTIP_X_MARGIN + 12, rect.y + OBJECT_TOOLTIP_Y_MARGIN, true); gc.setFont(JFaceResources.getDefaultFont()); int textLineHeight = gc.textExtent("M").y; //$NON-NLS-1$ y = rect.y + OBJECT_TOOLTIP_Y_MARGIN + titleSize.y + OBJECT_TOOLTIP_SPACING + 2; gc.drawText(location, rect.x + OBJECT_TOOLTIP_X_MARGIN, y, true); if (locationDetails != null) { y += textLineHeight; gc.drawText(locationDetails, rect.x + OBJECT_TOOLTIP_X_MARGIN, y, true); } if (!postalAddress.isEmpty()) { y += textLineHeight; gc.drawText(postalAddress, rect.x + OBJECT_TOOLTIP_X_MARGIN, y, true); } if (lastReport != null) { y += textLineHeight + OBJECT_TOOLTIP_SPACING; gc.setForeground(colorCache.create(92, 92, 92)); gc.drawLine(rect.x + 1, y, rect.x + rect.width - 1, y); y += OBJECT_TOOLTIP_SPACING; gc.setForeground(colorCache.create(0, 0, 0)); gc.drawText(lastReport, rect.x + OBJECT_TOOLTIP_X_MARGIN, y, true); if (batteryLevel != null) { y += textLineHeight; gc.drawText(batteryLevel, rect.x + OBJECT_TOOLTIP_X_MARGIN, y, true); } } if ((currentObject.getComments() != null) && !currentObject.getComments().isEmpty()) { y += textLineHeight + OBJECT_TOOLTIP_SPACING; gc.setForeground(colorCache.create(92, 92, 92)); gc.drawLine(rect.x + 1, y, rect.x + rect.width - 1, y); y += OBJECT_TOOLTIP_SPACING; gc.setForeground(colorCache.create(0, 0, 0)); gc.drawText(currentObject.getComments(), rect.x + OBJECT_TOOLTIP_X_MARGIN, y, true); } objectTooltipRectangle = rect; }
From source file:org.netxms.ui.eclipse.perfview.widgets.helpers.TableLabelProvider.java
License:Open Source License
/** * /*from w w w . jav a2s. c o m*/ */ public TableLabelProvider() { FontData fd = JFaceResources.getDefaultFont().getFontData()[0]; fd.setStyle(SWT.BOLD); keyColumnFont = new Font(Display.getCurrent(), fd); }
From source file:org.netxms.ui.eclipse.tools.FontTools.java
License:Open Source License
/** * Create first available font from given list with adjusted height * /*from w w w. j a v a 2 s. com*/ * @param names * @param height * @param style * @return */ public static Font createFont(String[] names, int heightAdjustment, int style) { String name = findFirstAvailableFont(names); if (name == null) return null; return new Font(Display.getCurrent(), name, JFaceResources.getDefaultFont().getFontData()[0].getHeight() + heightAdjustment, style); }
From source file:org.netxms.ui.eclipse.widgets.CGroup.java
License:Open Source License
/** * @param parent//from ww w. j a v a 2s .c om * @param style */ public CGroup(Composite parent, String text) { super(parent, SWT.NONE); this.text = text; setBackground(getParent().getBackground()); borderColor = SharedColors.getColor(SharedColors.CGROUP_BORDER, getDisplay()); titleColor = SharedColors.getColor(SharedColors.CGROUP_TITLE, getDisplay()); FontData fd = JFaceResources.getDefaultFont().getFontData()[0]; fd.setStyle(SWT.BOLD); titleFont = new Font(getDisplay(), fd); setFont(titleFont); headerSize = WidgetHelper.getTextExtent(this, text); headerSize.y += 5; addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { titleFont.dispose(); } }); GridLayout layout = new GridLayout(); layout.marginWidth = BORDER_WIDTH; layout.marginHeight = BORDER_WIDTH; layout.verticalSpacing = 3; layout.marginTop = headerSize.y + 2; layout.marginBottom = 2; setLayout(layout); clientArea = createClientAreaInternal(); addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { doPaint(e.gc); } }); addMouseListener(new MouseListener() { @Override public void mouseUp(MouseEvent e) { } @Override public void mouseDown(MouseEvent e) { } @Override public void mouseDoubleClick(MouseEvent e) { if (doubleClickAction != null) doubleClickAction.run(); } }); addControlListener(new ControlListener() { @Override public void controlResized(ControlEvent e) { layoutButtons(); } @Override public void controlMoved(ControlEvent e) { } }); }
From source file:org.opentravel.schemas.stl2Developer.editor.parts.ConnectionEditPart.java
License:Apache License
@Override protected ConnectionAnchor getTargetConnectionAnchor() { if (getTarget() != null) { int topOffset = -1; if (Features.fixedTargetAnchor()) { topOffset = TextUtilities.INSTANCE.getStringExtents("A", JFaceResources.getDefaultFont()).height / 2;//from ww w.ja va 2 s . c o m } return new MyAnchor(((GraphicalEditPart) getTarget()).getFigure(), topOffset); } return super.getTargetConnectionAnchor(); }
From source file:org.opentravel.schemas.stl2Developer.editor.ui.figures.FlowTextFigure.java
License:Apache License
public FlowTextFigure() { fp = new FlowPage(); fp.setFont(JFaceResources.getDefaultFont()); fp.setOpaque(true);/*from w ww.j a va2s . c om*/ add(fp); fp.setBorder(new LineBorder(ColorConstants.black, 1)); }
From source file:org.robotframework.ide.eclipse.main.plugin.views.documentation.DocumentationView.java
License:Apache License
@PostConstruct public void postConstruct(final Composite parent, final IViewPart part) { parent.setLayout(new FillLayout()); styledText = new StyledText(parent, SWT.H_SCROLL | SWT.V_SCROLL); styledText.setMargins(5, 5, 5, 5);//w w w . j a v a 2s . c om styledText.setBackground(ColorsManager.getColor(SWT.COLOR_INFO_BACKGROUND)); styledText.setFont(JFaceResources.getDefaultFont()); styledText.setEditable(false); createToolbarActions(part.getViewSite().getActionBars().getToolBarManager()); documentationViewPartListener = new DocumentationViewPartListener(this); PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .addPartListener(documentationViewPartListener); }