List of usage examples for org.eclipse.jface.resource FontDescriptor setHeight
public final FontDescriptor setHeight(int height)
Returns a new FontDescriptor that is equivalent to the receiver, but has the given height.
Does not modify the receiver.
From source file:com.google.devtools.depan.remap_doc.eclipse.ui.editors.MigrationTaskView.java
License:Apache License
/** * Construct the GUI under the given parent. * * @param parent the parent Composite./* w w w . j a va 2 s . c o m*/ * @return the top level widget. */ private Composite setupComposite(Composite parent) { // widgets Composite topLevel = new Composite(parent, SWT.NONE); Label labelId = new Label(topLevel, SWT.NONE); id = new Label(topLevel, SWT.NONE); Label labelName = new Label(topLevel, SWT.NONE); name = new Label(topLevel, SWT.NONE); Label labelDescription = new Label(topLevel, SWT.NONE); description = new Label(topLevel, SWT.NONE); Label labelQuarter = new Label(topLevel, SWT.NONE); quarter = new Label(topLevel, SWT.NONE); Label labelUpdatedBy = new Label(topLevel, SWT.NONE); updatedBy = new Label(topLevel, SWT.NONE); // content labelId.setText("ID"); labelName.setText("Name"); labelDescription.setText("Description"); labelQuarter.setText("Quarter"); labelUpdatedBy.setText("Updated by"); // layout GridLayout layout = new GridLayout(2, false); layout.horizontalSpacing = 22; layout.verticalSpacing = 9; topLevel.setLayout(layout); id.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); name.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); description.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); quarter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); updatedBy.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); Font font = name.getFont(); FontDescriptor bold = FontDescriptor.createFrom(font); bold = bold.setStyle(SWT.BOLD); FontDescriptor big = bold.setHeight(18); Font boldFont = bold.createFont(font.getDevice()); name.setFont(big.createFont(font.getDevice())); id.setFont(boldFont); description.setFont(boldFont); quarter.setFont(boldFont); updatedBy.setFont(boldFont); return topLevel; }
From source file:org.eclipse.tcf.internal.debug.ui.model.TCFDetailPane.java
License:Open Source License
private Font getMonospacedFont() { if (mono_font == null) { FontData[] fd = source_viewer.getControl().getFont().getFontData(); FontDescriptor d = JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_DETAIL_PANE_FONT); if (fd != null && fd.length > 0) d = d.setHeight(fd[0].getHeight()); mono_font = d.createFont(display); }/*from ww w . java 2 s . com*/ return mono_font; }
From source file:org.ejs.gui.properties.ListPropertyEditor.java
License:Open Source License
/** * @param composite/*w w w. j a v a 2 s. co m*/ */ private void createList(Composite parent) { Composite composite = new Composite(parent, SWT.BORDER_DOT); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite); //GridDataFactory.fillDefaults().grab(true, true).minSize(100,-1).applyTo(composite); GridDataFactory.fillDefaults().grab(true, true).minSize(50, -1).applyTo(composite); viewer = new ListViewer(composite); GridDataFactory.fillDefaults().grab(true, true).span(1, 4).applyTo(viewer.getControl()); //GridDataFactory.swtDefaults().span(1, 4).applyTo(viewer.getControl()); if (property.getElementClassFactory() != null) { FontDescriptor desc = FontUtils.getFontDescriptor(JFaceResources.getTextFont()); desc = desc.setHeight(8); final Font smallFont = desc.createFont(parent.getShell().getDisplay()); parent.addDisposeListener(new DisposeListener() { /* (non-Javadoc) * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) */ public void widgetDisposed(DisposeEvent e) { smallFont.dispose(); } }); final Button addButton = new Button(composite, SWT.PUSH); addButton.setFont(smallFont); GridDataFactory.swtDefaults().minSize(50, -1).applyTo(addButton); addButton.setText("+"); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { addNewElement(addButton, property.getElementClassFactory()); } }); final Button removeButton = new Button(composite, SWT.PUSH); removeButton.setFont(smallFont); GridDataFactory.swtDefaults().minSize(50, -1).applyTo(removeButton); removeButton.setText("-"); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (currentElement != null) { property.getList().remove(currentElement); viewer.remove(currentElement); updateList(); } } }); final Button upButton = new Button(composite, SWT.PUSH); upButton.setFont(smallFont); GridDataFactory.swtDefaults().minSize(50, -1).applyTo(upButton); upButton.setText(""); upButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (currentElement != null) { List<Object> list = property.getList(); int index = list.indexOf(currentElement); if (index > 0) { Object el = list.remove(index - 1); list.add(index, el); } viewer.refresh(); updateList(); } } }); final Button downButton = new Button(composite, SWT.PUSH); downButton.setFont(smallFont); GridDataFactory.swtDefaults().minSize(50, -1).applyTo(downButton); downButton.setText(""); downButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (currentElement != null) { List<Object> list = property.getList(); int index = list.indexOf(currentElement); if (index < list.size()) { Object el = list.remove(index + 1); list.add(index, el); } viewer.refresh(); updateList(); } } }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { Object el = ((IStructuredSelection) event.getSelection()).getFirstElement(); removeButton.setEnabled(el != null); } }); } viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { Object el = ((IStructuredSelection) event.getSelection()).getFirstElement(); currentElement = el; updateEditor(); } }); viewer.setLabelProvider(new LabelProvider() { /* (non-Javadoc) * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) */ @Override public String getText(Object element) { if (element instanceof IPropertyEditorProvider) return ((IPropertyEditorProvider) element).getLabel(property); return super.getText(element); } }); viewer.setContentProvider(new ArrayContentProvider()); List<Object> list = property.getList(); viewer.setInput(list); if (list != null && list.size() > 0) { Object el = list.get(0); viewer.setSelection(new StructuredSelection(el)); } }
From source file:org.lamport.tla.toolbox.ui.intro.ToolboxIntroPart.java
License:Open Source License
public static void createControl(Composite container) { Composite outerContainer = new Composite(container, SWT.NONE); // The local resource manager takes care of disposing images, fonts and // colors when // the outerContainer Composite is disposed. final LocalResourceManager localResourceManager = new LocalResourceManager(JFaceResources.getResources(), outerContainer);/*from w ww. ja v a 2 s . c om*/ final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; outerContainer.setLayout(gridLayout); final Color backgroundColor = localResourceManager .createColor(ColorDescriptor.createFrom(new RGB(255, 255, 228))); outerContainer.setBackground(backgroundColor); /* Logo */ final Label lblImage = new Label(outerContainer, SWT.NONE); lblImage.setText("Invisible text"); final Bundle bundle = FrameworkUtil.getBundle(ToolboxIntroPart.class); final URL url = FileLocator.find(bundle, new Path("images/splash_small.bmp"), null); final ImageDescriptor logoImage = ImageDescriptor.createFromURL(url); lblImage.setImage(localResourceManager.createImage(logoImage)); /* Welcome header */ final Label lblHeader = new Label(outerContainer, SWT.WRAP); // Double its font size final FontDescriptor headerFontDescriptor = JFaceResources.getHeaderFontDescriptor(); final FontData fontData = headerFontDescriptor.getFontData()[0]; lblHeader .setFont(localResourceManager.createFont(headerFontDescriptor.setHeight(fontData.getHeight() * 2))); // Color value (taken from old style.css) lblHeader.setForeground(localResourceManager.createColor(new RGB(0, 0, 192))); lblHeader.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 1, 1)); lblHeader.setText("Welcome to the TLA\u207A Toolbox"); lblHeader.setBackground(backgroundColor); /* What is next section */ Label lblSeparator = new Label(outerContainer, SWT.NONE); lblSeparator.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); final StyledText styledWhatIsNext = new StyledText(outerContainer, SWT.WRAP | SWT.CENTER); styledWhatIsNext.setBackground(backgroundColor); final String whatIsnext = "There is no specification open. Click on Help if you're not sure what you should do next."; styledWhatIsNext.setText(whatIsnext); GridData gd_styledWhatIsNext = new GridData(GridData.FILL_HORIZONTAL); gd_styledWhatIsNext.horizontalAlignment = SWT.LEFT; gd_styledWhatIsNext.horizontalSpan = 2; styledWhatIsNext.setLayoutData(gd_styledWhatIsNext); StyleRange winStyle = new StyleRange(); winStyle.underline = true; winStyle.underlineStyle = SWT.UNDERLINE_LINK; int[] winRange = { whatIsnext.indexOf("Help"), "Help".length() }; StyleRange[] winStyles = { winStyle }; styledWhatIsNext.setStyleRanges(winRange, winStyles); // link styled text to getting started guide styledWhatIsNext.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); helpSystem.displayHelpResource("/org.lamport.tla.toolbox.doc/html/contents.html"); } }); /* Getting started text */ final StyledText styledGettingStarted = new StyledText(outerContainer, SWT.WRAP | SWT.CENTER); styledGettingStarted.setBackground(backgroundColor); final String lblString = "If this is the first time you have used the Toolbox, please read the Getting Started guide."; styledGettingStarted.setText(lblString); GridData gd_styledGettingStarted = new GridData(GridData.FILL_HORIZONTAL); gd_styledGettingStarted.horizontalAlignment = SWT.LEFT; gd_styledGettingStarted.horizontalSpan = 2; styledGettingStarted.setLayoutData(gd_styledGettingStarted); new Label(outerContainer, SWT.NONE); new Label(outerContainer, SWT.NONE); StyleRange style = new StyleRange(); style.underline = true; style.underlineStyle = SWT.UNDERLINE_LINK; int[] range = { lblString.indexOf("Getting Started"), "Getting Started".length() }; StyleRange[] styles = { style }; styledGettingStarted.setStyleRanges(range, styles); // link styled text to getting started guide styledGettingStarted.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); helpSystem.displayHelpResource( "/org.lamport.tla.toolbox.doc/html/gettingstarted/gettingstarted.html"); } }); /* Toolbox version */ final Label verticalFillUp = new Label(outerContainer, SWT.NONE); verticalFillUp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 2, 1)); verticalFillUp.setBackground(backgroundColor); final Label horizontalLine = new Label(outerContainer, SWT.SEPARATOR | SWT.HORIZONTAL); horizontalLine.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); final Label lblVersion = new Label(outerContainer, SWT.WRAP); lblVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); lblVersion.setText("Version 1.5.4 of 06 October 2017"); lblVersion.setBackground(backgroundColor); }
From source file:org.lamport.tla.toolbox.ui.view.ToolboxWelcomeView.java
License:Open Source License
public static void createControl(Composite container) { Composite outerContainer = new Composite(container, SWT.NONE); // The local resource manager takes care of disposing images, fonts and colors when // the outerContainer Composite is disposed. final LocalResourceManager localResourceManager = new LocalResourceManager(JFaceResources.getResources(), outerContainer);//from w ww . j a v a 2 s . c om final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; outerContainer.setLayout(gridLayout); final Color backgroundColor = localResourceManager .createColor(ColorDescriptor.createFrom(new RGB(255, 255, 228))); outerContainer.setBackground(backgroundColor); /* Logo */ final Label lblImage = new Label(outerContainer, SWT.NONE); lblImage.setText("Invisible text"); final Bundle bundle = FrameworkUtil.getBundle(ToolboxWelcomeView.class); final URL url = FileLocator.find(bundle, new Path("images/splash_small.bmp"), null); final ImageDescriptor logoImage = ImageDescriptor.createFromURL(url); lblImage.setImage(localResourceManager.createImage(logoImage)); /* Welcome header */ final Label lblHeader = new Label(outerContainer, SWT.WRAP); // Double its font size final FontDescriptor headerFontDescriptor = JFaceResources.getHeaderFontDescriptor(); final FontData fontData = headerFontDescriptor.getFontData()[0]; lblHeader .setFont(localResourceManager.createFont(headerFontDescriptor.setHeight(fontData.getHeight() * 2))); // Color value (taken from old style.css) lblHeader.setForeground(localResourceManager.createColor(new RGB(0, 0, 192))); lblHeader.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 1, 1)); lblHeader.setText("Welcome to the TLA\u207A Toolbox"); lblHeader.setBackground(backgroundColor); /* What is next section */ Label lblSeparator = new Label(outerContainer, SWT.NONE); lblSeparator.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); final StyledText styledWhatIsNext = new StyledText(outerContainer, SWT.WRAP | SWT.CENTER); styledWhatIsNext.setBackground(backgroundColor); final String whatIsnext = "There is no specification open. Click on Help if you're not sure what you should do next."; styledWhatIsNext.setText(whatIsnext); GridData gd_styledWhatIsNext = new GridData(GridData.FILL_HORIZONTAL); gd_styledWhatIsNext.horizontalAlignment = SWT.LEFT; gd_styledWhatIsNext.horizontalSpan = 2; styledWhatIsNext.setLayoutData(gd_styledWhatIsNext); StyleRange winStyle = new StyleRange(); winStyle.underline = true; winStyle.underlineStyle = SWT.UNDERLINE_LINK; int[] winRange = { whatIsnext.indexOf("Help"), "Help".length() }; StyleRange[] winStyles = { winStyle }; styledWhatIsNext.setStyleRanges(winRange, winStyles); // link styled text to getting started guide styledWhatIsNext.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); helpSystem.displayHelpResource("/org.lamport.tla.toolbox.doc/html/contents.html"); } }); // Composite composite = new Composite(outerContainer, SWT.NONE); // composite.setLayout(new GridLayout(2, false)); // composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 2, 1)); //SWT.FILL, SWT.CENTER, false, false, 2, 1)); /* Getting started text */ final StyledText styledGettingStarted = new StyledText(outerContainer, SWT.WRAP | SWT.CENTER); styledGettingStarted.setBackground(backgroundColor); final String lblString = "If this is the first time you have used the Toolbox, please read the Getting Started guide."; styledGettingStarted.setText(lblString); GridData gd_styledGettingStarted = new GridData(GridData.FILL_HORIZONTAL); gd_styledGettingStarted.horizontalAlignment = SWT.LEFT; gd_styledGettingStarted.horizontalSpan = 2; styledGettingStarted.setLayoutData(gd_styledGettingStarted); new Label(outerContainer, SWT.NONE); new Label(outerContainer, SWT.NONE); StyleRange style = new StyleRange(); style.underline = true; style.underlineStyle = SWT.UNDERLINE_LINK; int[] range = { lblString.indexOf("Getting Started"), "Getting Started".length() }; StyleRange[] styles = { style }; styledGettingStarted.setStyleRanges(range, styles); // link styled text to getting started guide styledGettingStarted.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); helpSystem.displayHelpResource( "/org.lamport.tla.toolbox.doc/html/gettingstarted/gettingstarted.html"); } }); // This shows a help button next to the styled text // final Button helpButton = new Button(composite, SWT.PUSH); // helpButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); // helpButton.setSize(36, 36); // helpButton.setText (""); // helpButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_LCL_LINKTO_HELP)); // helpButton.addListener (SWT.Selection, new Listener () { // public void handleEvent (Event event) { // IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); //// helpSystem.displayHelp("org.lamport.tla.toolbox.GettingStarted"); //// helpSystem.displayHelpResource("/org.lamport.tla.toolbox.doc/html/contents.html"); // helpSystem.displayHelpResource("/org.lamport.tla.toolbox.doc/html/gettingstarted/gettingstarted.html"); // } // }); /* Toolbox version */ final Label verticalFillUp = new Label(outerContainer, SWT.NONE); verticalFillUp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 2, 1)); verticalFillUp.setBackground(backgroundColor); final Label horizontalLine = new Label(outerContainer, SWT.SEPARATOR | SWT.HORIZONTAL); horizontalLine.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); final Label lblVersion = new Label(outerContainer, SWT.WRAP); lblVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); lblVersion.setText("Version 1.5.1 of UNRELEASED"); lblVersion.setBackground(backgroundColor); }