List of usage examples for org.eclipse.jface.resource JFaceResources getDefaultFont
public static Font getDefaultFont()
From source file:gov.redhawk.ui.util.SWTUtil.java
License:Open Source License
/** * Returns a width hint for a button control. * /*w w w .j a va 2s .co m*/ * @param button the button * @return the button width hint */ public static int getButtonWidthHint(final Button button) { if (button.getFont().equals(JFaceResources.getDefaultFont())) { button.setFont(JFaceResources.getDialogFont()); } final PixelConverter converter = new PixelConverter(button); final int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:io.usethesource.impulse.preferences.fields.FontFieldEditor.java
License:Open Source License
/** * Returns the change button for this field editor. * * @param parent The Composite to create the button in if required. * @return the change button/*from w w w.ja va2s. co m*/ */ public Button getChangeControl() { if (changeFontButton == null) { changeFontButton = new Button(parent, SWT.PUSH); if (changeButtonText != null) { changeFontButton.setText(changeButtonText); } changeFontButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { FontDialog fontDialog = new FontDialog(changeFontButton.getShell()); if (chosenFont != null) { fontDialog.setFontList(chosenFont); } FontData font = fontDialog.open(); if (font != null) { FontData[] oldFont = chosenFont; if (oldFont == null) { oldFont = JFaceResources.getDefaultFont().getFontData(); } setPresentsDefaultValue(false); FontData[] newData = new FontData[1]; newData[0] = font; updateFont(newData); fireValueChanged(VALUE, oldFont[0], font); } } }); changeFontButton.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { changeFontButton = null; } }); changeFontButton.setFont(parent.getFont()); setButtonLayoutData(changeFontButton); } else { checkParent(changeFontButton, parent); } return changeFontButton; }
From source file:net.mldonkey.g2gui.view.pref.PreferenceLoader.java
License:Open Source License
/** * @param preferenceStore// ww w.j a va 2s . c o m * @return */ static IPreferenceStore setDefaults( IPreferenceStore preferenceStore ) { Display display = Display.getDefault(); preferenceStore.setDefault( "initialized", false ); preferenceStore.setDefault( "windowMaximized", false ); preferenceStore.setDefault( "coolbarLocked", true ); preferenceStore.setDefault( "toolbarSmallButtons", false ); preferenceStore.setDefault( "flatInterface", false ); preferenceStore.setDefault( "useGraident", true ); preferenceStore.setDefault( "allClients", false); preferenceStore.setDefault( "splashScreen", true ); PreferenceConverter.setDefault( preferenceStore, "windowBounds", new Rectangle(0,0,640,480) ); PreferenceConverter.setDefault( preferenceStore, "consoleBackground", display.getSystemColor( SWT.COLOR_LIST_BACKGROUND ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "consoleForeground", display.getSystemColor( SWT.COLOR_LIST_FOREGROUND ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "consoleHighlight", display.getSystemColor( SWT.COLOR_LIST_SELECTION ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "consoleInputBackground", display.getSystemColor( SWT.COLOR_LIST_BACKGROUND ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "consoleInputForeground", display.getSystemColor( SWT.COLOR_LIST_FOREGROUND ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "consoleFontData", JFaceResources.getTextFont().getFontData() ); PreferenceConverter.setDefault( preferenceStore, "downloadsBackgroundColor", display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "downloadsAvailableFileColor", display.getSystemColor( SWT.COLOR_BLACK ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "downloadsUnAvailableFileColor", new RGB(128,128,128) ); PreferenceConverter.setDefault( preferenceStore, "downloadsDownloadedFileColor", display.getSystemColor( SWT.COLOR_BLUE ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "downloadsQueuedFileColor", display.getSystemColor( SWT.COLOR_GRAY ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "downloadsPausedFileColor", display.getSystemColor( SWT.COLOR_DARK_RED ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "downloadsRateAbove20FileColor", new RGB(0,160,0) ); PreferenceConverter.setDefault( preferenceStore, "downloadsRateAbove10FileColor", new RGB(0,140,0) ); PreferenceConverter.setDefault( preferenceStore, "downloadsRateAbove0FileColor", new RGB(0,110,0) ); PreferenceConverter.setDefault( preferenceStore, "graphUploadsColor1", display.getSystemColor( SWT.COLOR_BLUE ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "graphUploadsColor2", new RGB(0,0,125) ); PreferenceConverter.setDefault( preferenceStore, "graphDownloadsColor1", display.getSystemColor( SWT.COLOR_GREEN ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "graphDownloadsColor2", new RGB(0,125,0) ); PreferenceConverter.setDefault( preferenceStore, "graphBackgroundColor", display.getSystemColor( SWT.COLOR_BLACK ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "graphGridColor", new RGB(0,128,64) ); PreferenceConverter.setDefault( preferenceStore, "graphTextColor", display.getSystemColor( SWT.COLOR_WHITE ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "graphLabelBackgroundColor", display.getSystemColor( SWT.COLOR_WHITE ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "graphLabelLineColor", display.getSystemColor( SWT.COLOR_YELLOW ).getRGB() ); PreferenceConverter.setDefault( preferenceStore, "graphLabelTextColor", display.getSystemColor( SWT.COLOR_BLACK ).getRGB() ); preferenceStore.setDefault( "defaultWebBrowser", ""); preferenceStore.setDefault( "hostname", "localhost" ); preferenceStore.setDefault( "username", "admin" ); preferenceStore.setDefault( "password", "" ); preferenceStore.setDefault( "port", "4001" ); preferenceStore.setDefault( "advancedMode", false ); preferenceStore.setDefault( "searchFilterPornography", false ); preferenceStore.setDefault( "searchFilterProfanity", false ); preferenceStore.setDefault( "maintainSortOrder", false ); preferenceStore.setDefault( "updateDelay", 0 ); preferenceStore.setDefault( "useGradient", true ); preferenceStore.setDefault( "displayNodes", false ); preferenceStore.setDefault( "displayChunkGraphs", false ); preferenceStore.setDefault( "displayGridLines", true ); preferenceStore.setDefault( "tableCellEditors", false ); preferenceStore.setDefault( "displayTableColors" , true ); preferenceStore.setDefault( "displayFontAA" , false ); preferenceStore.setDefault( "coreExecutable", "" ); preferenceStore.setDefault( "useCombo", false ); preferenceStore.setDefault( "minimizeOnClose", false ); preferenceStore.setDefault( "dragAndDrop", true ); preferenceStore.setDefault( "pollUpStats", true ); preferenceStore.setDefault( "running", false ); preferenceStore.setDefault( "allowMultipleInstances", false ); preferenceStore.setDefault( "downloadsFilterQueued", false ); preferenceStore.setDefault( "downloadsFilterPaused", false ); preferenceStore.setDefault( "graphSashOrientation", SWT.HORIZONTAL ); preferenceStore.setDefault( "graphSashMaximized", -1 ); preferenceStore.setDefault( "clientSashOrientation", SWT.HORIZONTAL ); preferenceStore.setDefault( "clientSashMaximized", 0 ); preferenceStore.setDefault( "transferSashOrientation", SWT.VERTICAL ); preferenceStore.setDefault( "transferSashMaximized", -1 ); preferenceStore.setDefault( "uploadsSashOrientation", SWT.HORIZONTAL ); preferenceStore.setDefault( "uploadsSashMaximized", -1 ); PreferenceConverter.setDefault( preferenceStore, "viewerFontData", JFaceResources.getDefaultFont().getFontData() ); preferenceStore.setDefault( G2GuiResources.getString( "ENS_NOT_CONNECTED" ), false ); preferenceStore.setDefault( G2GuiResources.getString( "ENS_CONNECTING" ), false ); preferenceStore.setDefault( G2GuiResources.getString( "ENS_CONNECTED_INITIATING" ), false ); preferenceStore.setDefault( G2GuiResources.getString( "ENS_CONNECTED_DOWNLOADING" ), false ); preferenceStore.setDefault( G2GuiResources.getString( "ENS_CONNECTED" ), false ); preferenceStore.setDefault( G2GuiResources.getString( "ENS_CONNECTED_AND_QUEUED" ), false ); preferenceStore.setDefault( G2GuiResources.getString( "ENS_NEW_HOST" ), false ); preferenceStore.setDefault( G2GuiResources.getString( "ENS_REMOVE_HOST" ), false ); preferenceStore.setDefault( G2GuiResources.getString( "ENS_BLACK_LISTED" ), false ); preferenceStore.setDefault( G2GuiResources.getString( "ENS_NOT_CONNECTED_WAS_QUEUED" ), false ); // set the default filter for server tab to connected, connecting and connection initiated preferenceStore.setDefault( Enum.getPrefName( EnumState.CONNECTED, ServerPaneListener.class ), true ); preferenceStore.setDefault( Enum.getPrefName( EnumState.CONNECTING, ServerPaneListener.class ), true ); preferenceStore.setDefault( Enum.getPrefName( EnumState.CONNECTED_INITIATING, ServerPaneListener.class ), true ); preferenceStore.setDefault( "searchSashWeights", "1,5" ); preferenceStore.setDefault( "UploadersPaneListenerBestFit", "-1" ); preferenceStore.setDefault( "ClientPaneListenerBestFit", "-1" ); preferenceStore.setDefault( "UploadPaneListenerBestFit", "-1" ); preferenceStore.setDefault( "DownloadPaneListenerBestFit", "-1" ); preferenceStore.setDefault( "ServerPaneListenerBestFit", "-1" ); // we want this in the g2gui.pref file without a frontend in the gui preferenceStore.setDefault( "WEBSERVICE.URL.BITZI", "http://bitzi.com/lookup/" ); preferenceStore.setDefault( "WEBSERVICE.URL.FILEDONKEY", "http://www.filedonkey.com/file.html?md4=" ); preferenceStore.setDefault( "WEBSERVICE.URL.DONKEYFAKES", "http://donkeyfakes.gambri.net/index.php?action=search&ed2k=" ); return preferenceStore; }
From source file:net.sourceforge.veditor.actions.OpenDeclarationAction.java
License:Open Source License
private void showPopUp(Vector<OutlineElement> definitionList, HdlEditor editor, Point position) { IEditorSite control = editor.getEditorSite(); if (m_ProposalShell == null) { m_ProposalShell = new Shell(control.getShell(), SWT.ON_TOP); m_ProposalShell.setFont(JFaceResources.getDefaultFont()); GridLayout layout = new GridLayout(); layout.marginWidth = 0;// w w w . j av a 2s . c o m layout.marginHeight = 0; layout.verticalSpacing = 1; m_ProposalShell.setLayout(layout); m_ProposalTable = new Table(m_ProposalShell, SWT.H_SCROLL | SWT.V_SCROLL); m_ProposalTable.setLocation(0, 0); GridData data = new GridData(GridData.FILL_BOTH); m_ProposalTable.setLayoutData(data); Point size = new Point(600, 200); m_ProposalShell.setSize(size); m_ProposalTable.setSize(size); m_ProposalTable.addFocusListener(new focusListener()); m_ProposalTable.addSelectionListener(new selectionListener()); } m_ProposalTable.setItemCount(definitionList.size()); TableItem[] tableItem = m_ProposalTable.getItems(); for (int i = 0; i < tableItem.length; i++) { tableItem[i].setText(definitionList.get(i).getLongName() + " @ " + definitionList.get(i).getFile().getFullPath().toString()); String imageName = definitionList.get(i).GetImageName(); if (imageName != null) { tableItem[i].setImage(VerilogPlugin.getPlugin().getImage(imageName)); } tableItem[i].setData(definitionList.get(i)); } m_ProposalShell.setLocation(position); m_ProposalShell.setVisible(true); m_ProposalTable.setFocus(); }
From source file:net.tourbook.common.font.FontFieldEditorExtended.java
License:Open Source License
private void fireFontChanged(final FontData font) { FontData[] oldFont = chosenFont;/*w ww . j ava 2 s . c om*/ if (oldFont == null) { oldFont = JFaceResources.getDefaultFont().getFontData(); } setPresentsDefaultValue(false); final FontData[] newFontData = new FontData[1]; newFontData[0] = font; updateFont(newFontData); fireValueChanged(VALUE, oldFont[0], font); }
From source file:org.codehaus.groovy.eclipse.debug.ui.EnsureJUnitFont.java
License:Apache License
private void internalSetMonospaceFont(boolean isMonospace, TestRunnerViewPart view) { FailureTrace trace = view.getFailureTrace(); Composite widget = (Composite) ReflectionUtils.getPrivateField(FailureTrace.class, "fTable", trace); if (isMonospace) { widget.setFont(JFaceResources.getTextFont()); } else {/*w ww .j av a2 s . com*/ widget.setFont(JFaceResources.getDefaultFont()); } }
From source file:org.dadacoalition.yedit.preferences.tasktag.SWTUtil.java
License:Open Source License
/** * Returns a height hint for a button control. * @deprecated//w w w . java 2 s . co m * @see IDialogConstants#BUTTON_HEIGHT */ @Deprecated public static int getButtonHeigthHint(Button button) { if (button.getFont().equals(JFaceResources.getDefaultFont())) button.setFont(JFaceResources.getDialogFont()); PixelConverter converter = new PixelConverter(button); return converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); }
From source file:org.dafoe.application.presentations.sideWinder.PartItem.java
License:Open Source License
public void paintControl(PaintEvent e) { Rectangle titleRect = getClientArea(); int x = titleRect.x + VERT_SPACING; //int y = titleRect.y + HORIZ_SPACING; GC gc = e.gc;//from w ww .j ava 2 s . c om setBackground(getParent().getBackground()); fill(gc, titleRect.x, titleRect.y, titleRect.width - 1, titleRect.height); Image image = getImage(); if (image != null && showImage) { Rectangle imageBounds = image.getBounds(); int imageX = x; int imageHeight = imageBounds.height; int imageY = (titleRect.height - imageHeight) / 2; int imageWidth = imageBounds.width * imageHeight / imageBounds.height; gc.drawImage(image, imageBounds.x, imageBounds.y, imageBounds.width, imageBounds.height, imageX, imageY, imageWidth, imageHeight); x += imageWidth + VERT_SPACING; } int textWidth = titleRect.width - 1; if (textWidth > 0 && text != null && showText) { gc.setFont(getFont()); Point extent = gc.textExtent(text, SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC); int textY = titleRect.y + (titleRect.height - extent.y) / 2; if (selected) gc.setForeground(e.display.getSystemColor(SWT.COLOR_WHITE)); else gc.setForeground(e.display.getSystemColor(SWT.COLOR_BLACK)); gc.setFont(JFaceResources.getDefaultFont()); gc.drawText(text, x, textY, SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC); } }
From source file:org.eclipse.birt.report.designer.util.CSSUtil.java
License:Open Source License
/** * Converts object 's units to inch, with baseSize to compute the relative * unit.//from w w w . j a va2 s . c o m * * @param object * The origine object, may be DimensionValue or DimensionHandle. * @param baseSize * The given baseSize used to compute relative unit. * @return The inch value. */ public static double convertToInch(Object object, int baseSize) { double inchValue = 0; double measure = 0; String units = ""; //$NON-NLS-1$ if (object instanceof DimensionValue) { DimensionValue dimension = (DimensionValue) object; measure = dimension.getMeasure(); units = dimension.getUnits(); } else if (object instanceof DimensionHandle) { DimensionHandle dimension = (DimensionHandle) object; measure = dimension.getMeasure(); units = dimension.getUnits(); } else { // assert false; } if ("".equalsIgnoreCase(units))//$NON-NLS-1$ { units = SessionHandleAdapter.getInstance().creatReportDesign().getDefaultUnits(); } if (DesignChoiceConstants.UNITS_IN.equals(units)) { return measure; } // sets default baseSize to JFace Resources 's default font data 's // height. if (baseSize == 0) { Font defaultFont = JFaceResources.getDefaultFont(); FontData[] fontData = defaultFont.getFontData(); baseSize = fontData[0].getHeight(); } // converts relative units to inch. if (DesignChoiceConstants.UNITS_EM.equals(units)) { inchValue = DimensionUtil .convertTo(measure * baseSize, DesignChoiceConstants.UNITS_PT, DesignChoiceConstants.UNITS_IN) .getMeasure(); } else if (DesignChoiceConstants.UNITS_EX.equals(units)) { inchValue = DimensionUtil.convertTo(measure * baseSize / 3, DesignChoiceConstants.UNITS_PT, DesignChoiceConstants.UNITS_IN).getMeasure(); } else if (DesignChoiceConstants.UNITS_PERCENTAGE.equals(units)) { inchValue = DimensionUtil.convertTo(measure * baseSize / 100, DesignChoiceConstants.UNITS_PT, DesignChoiceConstants.UNITS_IN).getMeasure(); } else if (DesignChoiceConstants.UNITS_PX.equals(units)) { inchValue = pixelToInch(measure); } else { // converts absolute units to inch. inchValue = DimensionUtil.convertTo(measure, units, DesignChoiceConstants.UNITS_IN).getMeasure(); } return inchValue; }
From source file:org.eclipse.birt.report.designer.util.DEUtil.java
License:Open Source License
/** * Transform other units to pixel./*from ww w . ja v a2 s . c om*/ * * @param object * model to keep the measure and units. * @param fontSize * the parent font size. * @return The pixel value. */ public static double convertToPixel(Object object, int fontSize) { double px = 0; double measure = 0; String units = ""; //$NON-NLS-1$ if (object instanceof DimensionValue) { DimensionValue dimension = (DimensionValue) object; measure = dimension.getMeasure(); units = dimension.getUnits(); } else if (object instanceof DimensionHandle) { DimensionHandle dimension = (DimensionHandle) object; measure = dimension.getMeasure(); units = dimension.getUnits(); } if (DesignChoiceConstants.UNITS_PX.equals(units)) { return measure; } // Default value is DesignChoiceConstants.UNITS_IN if ("".equalsIgnoreCase(units)) //$NON-NLS-1$ { px = measure; } if (fontSize == 0) { Font defaultFont = JFaceResources.getDefaultFont(); FontData[] fontData = defaultFont.getFontData(); fontSize = fontData[0].getHeight(); } if (DesignChoiceConstants.UNITS_EM.equals(units)) { px = DimensionUtil .convertTo(measure * fontSize, DesignChoiceConstants.UNITS_PT, DesignChoiceConstants.UNITS_IN) .getMeasure(); } else if (DesignChoiceConstants.UNITS_EX.equals(units)) { px = DimensionUtil.convertTo(measure * fontSize / 3, DesignChoiceConstants.UNITS_PT, DesignChoiceConstants.UNITS_IN).getMeasure(); } else if (DesignChoiceConstants.UNITS_PERCENTAGE.equals(units)) { px = DimensionUtil.convertTo(measure * fontSize / 100, DesignChoiceConstants.UNITS_PT, DesignChoiceConstants.UNITS_IN).getMeasure(); } // added by gao if unit is "", set the unit is Design default unit else if ("".equals(units))//$NON-NLS-1$ { units = SessionHandleAdapter.getInstance().getReportDesignHandle().getDefaultUnits(); px = DimensionUtil.convertTo(measure, units, DesignChoiceConstants.UNITS_IN).getMeasure(); } else if (units == null) { px = 0.0; } else { px = DimensionUtil.convertTo(measure, units, DesignChoiceConstants.UNITS_IN).getMeasure(); } return MetricUtility.inchToPixel(px); }