List of usage examples for org.eclipse.jface.resource JFaceResources getResources
public static ResourceManager getResources()
From source file:org.jcryptool.games.numbershark.dialogs.NewGameDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { setTitle(Messages.NewGameDialog_0);/*from www .j a v a 2 s .c o m*/ setMessage(Messages.NewGameDialog_1); LocalResourceManager resources = new LocalResourceManager(JFaceResources.getResources(), getShell()); setTitleImage(resources.createImage(NumberSharkPlugin.getImageDescriptor("/icons/new_game.png"))); //$NON-NLS-1$ Composite area = (Composite) super.createDialogArea(parent); Group maximumNumberGroup = new Group(area, SWT.NONE); maximumNumberGroup.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false)); maximumNumberGroup.setLayout(new GridLayout(2, false)); maximumNumberGroup.setText(Messages.NewGameDialog_2); final Slider numSlider = new Slider(maximumNumberGroup, SWT.NONE); numSlider.setValues(numberOfFields, 1, 1024, 7, 1, 10); numSlider.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); final Spinner numSpinner = new Spinner(maximumNumberGroup, SWT.BORDER); numSpinner.setValues(numberOfFields, 1, 1024, 0, 1, 10); numSpinner.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { numSlider.setSelection(numSpinner.getSelection()); numberOfFields = numSlider.getSelection(); } }); numSlider.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { numSpinner.setSelection(numSlider.getSelection()); numberOfFields = numSlider.getSelection(); } }); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, NumberSharkPlugin.PLUGIN_ID + ".newGameDialog"); //$NON-NLS-1$ return area; }
From source file:org.jcryptool.games.numbershark.strategies.AbstractResultDialog.java
License:Open Source License
public void createTable(Composite parent) { sequences = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION); sequences.setHeaderVisible(true);//from w ww. jav a 2 s. com GridData gd_sequences = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd_sequences.widthHint = 304; sequences.setLayoutData(gd_sequences); sequences.setLinesVisible(true); sequences.addListener(SWT.MouseDown, new Listener() { @Override public void handleEvent(Event event) { if (event.button == 3) { Table table = (Table) event.widget; Menu popupmenu = new Menu(table.getShell(), SWT.POP_UP); Point zeroPointShell = table.getShell().getLocation(); Point zeroPointTable = table.getLocation(); Point point = new Point(zeroPointTable.x + zeroPointShell.x + event.x + 5, 104 + zeroPointShell.y + event.y); popupmenu.setLocation(point); popupmenu.setVisible(true); MenuItem play = new MenuItem(popupmenu, SWT.PUSH); play.setText(Messages.OptStratDialog_9); play.addSelectionListener(playSelection); LocalResourceManager resources = new LocalResourceManager(JFaceResources.getResources(), getShell()); Image image = resources .createImage(NumberSharkPlugin.getImageDescriptor("icons/play_icon.png")); //$NON-NLS-1$ play.setImage(image); MenuItem copy = new MenuItem(popupmenu, SWT.PUSH); copy.setText(Messages.OptStratDialog_10); image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_COPY); copy.setImage(image); copy.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Clipboard cb = new Clipboard(sequences.getDisplay()); TextTransfer textTransfer = TextTransfer.getInstance(); StringBuffer sb = new StringBuffer(sequences.getSelection()[0].getText(0)); for (int i = 1; i < 5; i++) { sb.append("|" + sequences.getSelection()[0].getText(i)); } cb.setContents(new Object[] { sb.toString() }, new Transfer[] { textTransfer }); } }); while (!popupmenu.isDisposed() && popupmenu.isVisible()) { if (!table.getDisplay().readAndDispatch()) table.getDisplay().sleep(); } popupmenu.dispose(); } } }); sequences.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (sequences.getSelection().length > 0) { playSelected.setEnabled(true); } } }); }
From source file:org.kalypso.contribs.eclipse.ui.actions.DropDownToolbarItem.java
License:Open Source License
private void updateIcons(final ImageDescriptor icon, final ImageDescriptor disabledIcon, final ImageDescriptor hoverIcon) { final LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources()); final Image imageIcon = icon == null ? null : m.createImage(icon); final Image disabledImageIcon = disabledIcon == null ? null : m.createImage(disabledIcon); // If the command is currently not enabled, show a disabled icon as the default image Image imageIcon2;/*from w ww . j a v a 2 s . c om*/ if (m_currentCommand.isEnabled() || imageIcon == null) imageIcon2 = imageIcon; else if (disabledImageIcon != null) imageIcon2 = disabledImageIcon; else { final ImageDescriptor disabledDescriptor = new DisabledImageDescriptor(imageIcon); imageIcon2 = m.createImage(disabledDescriptor); } if (widget instanceof MenuItem) { final MenuItem item = (MenuItem) widget; item.setImage(imageIcon2); } else if (widget instanceof ToolItem) { final Image hoverImageIcon = hoverIcon == null ? null : m.createImage(hoverIcon); final ToolItem item = (ToolItem) widget; item.setDisabledImage(disabledImageIcon); item.setHotImage(hoverImageIcon); item.setImage(imageIcon2); } disposeOldImages(); localResourceManager = m; }
From source file:org.kalypso.core.status.StatusComposite.java
License:Open Source License
public static Image getIDEImage(final String constantName) { return JFaceResources.getResources() .createImageWithDefault(IDEInternalWorkbenchImages.getImageDescriptor(constantName)); }
From source file:org.kalypso.ogc.gml.outline.nodes.ThemeNodeLabelProvider.java
License:Open Source License
/** * Lazy load the resource manager//from w w w . j a v a2s .c o m * * @return The resource manager, create one if necessary */ private ResourceManager getResourceManager() { if (m_resourceManager == null) m_resourceManager = new LocalResourceManager(JFaceResources.getResources()); return m_resourceManager; }
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 w w.j a va 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 w w . j a v a2s .co m*/ 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); }
From source file:org.loezto.e.dialog.AboutDialog.java
License:Open Source License
@Override /**//from ww w. j av a2 s . c o m * @wbp.parser.entryPoint */ public Control createDialogArea(Composite parent) { Composite container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout(1, false)); Label label = new Label(container, SWT.BORDER | SWT.CENTER); label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); label.setAlignment(SWT.CENTER); LocalResourceManager lrm = new LocalResourceManager(JFaceResources.getResources(), parent); ImageDescriptor desc = ImageDescriptor.createFromURL( FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path("img/e128.png"), null)); Image eh = lrm.createImage(desc); label.setImage(eh); Label lblInfo = new Label(container, SWT.CENTER); lblInfo.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1)); lblInfo.setText( "\n\n - a personal information manager - v0.2\n\n\nReleased under the Eclipse Public License 1.0\n\n\n"); label.pack(); lblInfo.pack(); Link link = new Link(container, SWT.NONE); link.setText( "Uses icons from <a href=\"http://www.famfamfam.com/lab/icons/silk/\">Famfamfam's Silk icon set</a>."); return super.createDialogArea(parent); }
From source file:org.marketcetera.photon.strategy.engine.ui.StrategyEnginesLabelProvider.java
/** * Constructor. Must be called from the UI thread. * //from w w w . j av a 2 s .co m * @throws IllegalStateException * if called from a non UI thread, i.e. a thread where * Display.getCurrent() is null */ public StrategyEnginesLabelProvider() { SWTUtils.checkThread(); mResourceManager = new LocalResourceManager(JFaceResources.getResources()); }
From source file:org.marketcetera.photon.test.JFaceAsserts.java
/** * Asserts that the provided "actual" image is equal to the image described * by the "expected" image descriptor./*from w w w . ja v a2s .c o m*/ * * @param actual * the actual image * @param expected * the expected image descriptor */ public static void assertImage(Image actual, ImageDescriptor expected) { Image expectedImage = createImageAndAssertNotMissing(expected); try { assertThat(actual, is(expectedImage)); } finally { JFaceResources.getResources().destroyImage(expected); } }