List of usage examples for org.eclipse.jface.resource JFaceResources getImage
public static Image getImage(String key)
null
if none. From source file:com.google.dart.tools.ui.omni.BasePopupDialog.java
License:Open Source License
/** * Create the dialog's menu for the move and resize actions. * /*from w w w . jav a 2 s .com*/ * @param parent The parent composite. */ private void createDialogMenu(Composite parent) { toolBar = new ToolBar(parent, SWT.FLAT); ToolItem viewMenuButton = new ToolItem(toolBar, SWT.PUSH, 0); GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(toolBar); viewMenuButton.setImage(JFaceResources.getImage(POPUP_IMG_MENU)); viewMenuButton.setDisabledImage(JFaceResources.getImage(POPUP_IMG_MENU_DISABLED)); viewMenuButton.setToolTipText(JFaceResources.getString("BasePopupDialog.menuTooltip")); //$NON-NLS-1$ viewMenuButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { showDialogMenu(); } }); // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=177183 toolBar.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { showDialogMenu(); } }); }
From source file:com.google.gdt.eclipse.gph.wizards.ShowErrorPage.java
License:Open Source License
@Override protected Control createPageContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayoutFactory.swtDefaults().margins(10, 10).numColumns(2).applyTo(composite); Label iconLabel = new Label(composite, SWT.NONE); iconLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR)); Label titleLabel = new Label(composite, SWT.NONE); titleLabel.setText(status.getMessage()); titleLabel.setFont(getBoldFont(titleLabel.getFont())); GridDataFactory.fillDefaults().grab(true, false).applyTo(titleLabel); // spacer/*from ww w. java 2s.c o m*/ new Label(composite, SWT.NONE); if (status.isMultiStatus() || status.getException() != null) { final Link link = new Link(composite, SWT.NONE); link.setText("<a>show details...</a>"); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { replaceWithDetails(link); } }); GridDataFactory.fillDefaults().grab(true, true).applyTo(link); } return composite; }
From source file:com.gorillalogic.monkeyconsole.editors.utils.TitleAreaDialogStyledTextMessage.java
License:Open Source License
/** * Creates the dialog's title area./* w w w .jav a 2 s.c o m*/ * * @param parent * the SWT parent for the title area widgets * @return Control with the highest x axis value. */ private Control createTitleArea(Composite parent) { // add a dispose listener parent.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (titleAreaColor != null) { titleAreaColor.dispose(); } } }); // Determine the background color of the title bar Display display = parent.getDisplay(); Color background; Color foreground; if (titleAreaRGB != null) { titleAreaColor = new Color(display, titleAreaRGB); background = titleAreaColor; foreground = null; } else { background = JFaceColors.getBannerBackground(display); foreground = JFaceColors.getBannerForeground(display); } parent.setBackground(background); int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); // Dialog image @ right titleImageLabel = new Label(parent, SWT.CENTER); titleImageLabel.setBackground(background); if (titleAreaImage == null) titleImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER)); else titleImageLabel.setImage(titleAreaImage); FormData imageData = new FormData(); imageData.top = new FormAttachment(0, 0); // Note: do not use horizontalSpacing on the right as that would be a // regression from // the R2.x style where there was no margin on the right and images are // flush to the right // hand side. see reopened comments in 41172 imageData.right = new FormAttachment(100, 0); // horizontalSpacing titleImageLabel.setLayoutData(imageData); // Title label @ top, left titleLabel = new Label(parent, SWT.LEFT); JFaceColors.setColors(titleLabel, foreground, background); titleLabel.setFont(JFaceResources.getBannerFont()); titleLabel.setText(" ");//$NON-NLS-1$ FormData titleData = new FormData(); titleData.top = new FormAttachment(0, verticalSpacing); titleData.right = new FormAttachment(titleImageLabel); titleData.left = new FormAttachment(0, horizontalSpacing); titleLabel.setLayoutData(titleData); // Message image @ bottom, left messageImageLabel = new Label(parent, SWT.CENTER); messageImageLabel.setBackground(background); // Message label @ bottom, center messageLabel = new Link(parent, SWT.WRAP | SWT.READ_ONLY); JFaceColors.setColors(messageLabel, foreground, background); messageLabel.setText(" \n "); // two lines//$NON-NLS-1$ messageLabel.setFont(JFaceResources.getDialogFont()); messageLabelHeight = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; // Filler labels leftFillerLabel = new Label(parent, SWT.CENTER); leftFillerLabel.setBackground(background); bottomFillerLabel = new Label(parent, SWT.CENTER); bottomFillerLabel.setBackground(background); setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing); determineTitleImageLargest(); if (titleImageLargest) return titleImageLabel; return messageLabel; }
From source file:com.gorillalogic.monkeyconsole.editors.utils.TitleAreaDialogStyledTextMessage.java
License:Open Source License
/** * Display the given error message. The currently displayed message is saved * and will be redisplayed when the error message is set to * <code>null</code>./*from w ww .j a v a 2s .co m*/ * * @param newErrorMessage * the newErrorMessage to display or <code>null</code> */ public void setErrorMessage(String newErrorMessage) { // Any change? if (errorMessage == null ? newErrorMessage == null : errorMessage.equals(newErrorMessage)) return; errorMessage = newErrorMessage; // Clear or set error message. if (errorMessage == null) { if (showingError) { // we were previously showing an error showingError = false; } // show the message // avoid calling setMessage in case it is overridden to call // setErrorMessage, // which would result in a recursive infinite loop if (message == null) // this should probably never happen since // setMessage does this conversion.... message = ""; //$NON-NLS-1$ updateMessage(message); messageImageLabel.setImage(messageImage); setImageLabelVisible(messageImage != null); } else { // Add in a space for layout purposes but do not // change the instance variable String displayedErrorMessage = " " + errorMessage; //$NON-NLS-1$ updateMessage(displayedErrorMessage); if (!showingError) { // we were not previously showing an error showingError = true; messageImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_ERROR)); setImageLabelVisible(true); } } layoutForNewMessage(); }
From source file:com.gorillalogic.monkeyconsole.editors.utils.TitleAreaDialogStyledTextMessage.java
License:Open Source License
/** * Sets the message for this dialog with an indication of what type of * message it is.// w ww . j av a 2s . co m * <p> * The valid message types are one of <code>NONE</code>, * <code>INFORMATION</code>,<code>WARNING</code>, or * <code>ERROR</code>. * </p> * <p> * Note that for backward compatibility, a message of type * <code>ERROR</code> is different than an error message (set using * <code>setErrorMessage</code>). An error message overrides the current * message until the error message is cleared. This method replaces the * current message and does not affect the error message. * </p> * * @param newMessage * the message, or <code>null</code> to clear the message * @param newType * the message type * @since 2.0 */ public void setMessage(String newMessage, int newType) { Image newImage = null; if (newMessage != null) { switch (newType) { case IMessageProvider.NONE: break; case IMessageProvider.INFORMATION: newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_INFO); break; case IMessageProvider.WARNING: newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_WARNING); break; case IMessageProvider.ERROR: newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_ERROR); break; } } showMessage(newMessage, newImage); }
From source file:com.liferay.ide.project.ui.upgrade.animated.BuildPage.java
License:Open Source License
private void createImages() { imageProject = PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OBJ_PROJECT); if (imageProject.isDisposed()) { imageProject = PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(SharedImages.IMG_OBJ_PROJECT).createImage(); }// w w w . ja v a 2 s. c om URL greenTickUrl = ProjectUI.getDefault().getBundle().getEntry("/images/greentick.png"); imageSuccess = ImageDescriptor.createFromURL(greenTickUrl).createImage(); imageSuccess.getImageData().scaledTo(16, 16); imageFail = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); }
From source file:com.liferay.ide.project.ui.upgrade.animated.GearControl.java
License:Open Source License
protected void init() { super.init(); display = getDisplay();// w w w .jav a 2 s . c om errorImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); warningImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); WHITE = display.getSystemColor(SWT.COLOR_WHITE); GRAY = display.getSystemColor(SWT.COLOR_GRAY); DARK_GRAY = display.getSystemColor(SWT.COLOR_DARK_GRAY); Font initialFont = getFont(); FontData[] fontData = initialFont.getFontData(); for (int i = 0; i < fontData.length; i++) { fontData[i].setHeight(16); fontData[i].setStyle(SWT.BOLD); } baseFont = new Font(display, fontData); numberFont = createFont(24); tooltipFont = createFont(24); radius = 32; setSize((int) (gearMaxNumber * 2 * radius), (int) (2 * radius)); // Not selected. gearBackground[0] = createColor(169, 171, 202); gearForeground[0] = createColor(140, 132, 171); // Selected. gearBackground[1] = createColor(247, 148, 30); gearForeground[1] = createColor(207, 108, 0); tooltipColor = createColor(253, 232, 206); }
From source file:com.liferay.ide.ui.form.IDEFormPage.java
License:Open Source License
protected void createFormErrorContent(IManagedForm managedForm, String errorTitle, String errorMessage, Exception e) {/*from w ww . j a v a 2 s . c o m*/ ScrolledForm form = managedForm.getForm(); FormToolkit toolkit = managedForm.getToolkit(); toolkit.decorateFormHeading(form.getForm()); Composite parent = form.getBody(); GridLayout layout = new GridLayout(); GridData data2 = new GridData(GridData.FILL_BOTH); layout.marginWidth = 7; layout.marginHeight = 7; parent.setLayout(layout); parent.setLayoutData(data2); // Set the title and image of the form form.setText(errorTitle); form.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR)); int sectionStyle = Section.DESCRIPTION | ExpandableComposite.TITLE_BAR; // Create the message section Section messageSection = createUISection(parent, Msgs.message, errorMessage, sectionStyle); Composite messageClient = createUISectionContainer(messageSection, 1); // Bind the widgets toolkit.paintBordersFor(messageClient); messageSection.setClient(messageClient); // Ensure the exception was defined if (e == null) { return; } // Create the details section Section detailsSection = createUISection(parent, Msgs.details, e.getMessage(), sectionStyle); Composite detailsClient = createUISectionContainer(detailsSection, 1); // Create text widget holding the exception trace int style = SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY; Text text = toolkit.createText(detailsClient, getStackTrace(e), style); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = 160; data.widthHint = 200; text.setLayoutData(data); // Bind the widgets toolkit.paintBordersFor(detailsClient); detailsSection.setClient(detailsClient); // Note: The veritical scrollbar fails to appear when text widget is // not entirely shown }
From source file:com.mindquarry.desktop.client.MindClient.java
License:Open Source License
protected Control createContents(Composite parent) { initRegistries();/*from w w w.ja v a 2 s .c om*/ sashForm = new SashForm(parent, SWT.HORIZONTAL); sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); teamList = new TeamlistWidget(sashForm, SWT.NONE, this); createCategoryWidget(sashForm); ((UpdateWorkspacesAction) getAction(UpdateWorkspacesAction.class.getName())).setTeamList(teamList); ((SynchronizeTasksAction) getAction(SynchronizeTasksAction.class.getName())).setTeamList(teamList); // initialize window shell Window.setDefaultImage(JFaceResources.getImage(CLIENT_IMG_KEY)); getShell().addListener(SWT.Show, new Listener() { private boolean first = true; public void handleEvent(Event event) { if (first) { first = false; // TODO: send start event refreshOnStartup(); } getShell().setActive(); } }); getShell().addShellListener(new IconifyingShellListener()); getShell().addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { saveOptions(); } }); getShell().setImage(JFaceResources.getImage(CLIENT_IMG_KEY)); getShell().setText(APPLICATION_NAME); getShell().setSize(800, 600); createTrayIconAndMenu(Display.getDefault()); if (storedEvent != null) { EventBus.send(storedEvent); } return parent; }
From source file:com.mindquarry.desktop.client.MindClient.java
License:Open Source License
private void createTrayIconAndMenu(Display display) { // create tray item Tray tray = display.getSystemTray(); Shell shell = new Shell(display); trayItem = new TrayItem(tray, SWT.NONE); trayItem.setImage(JFaceResources.getImage(CLIENT_TRAY_IMG_KEY)); // show tooltip that indicates successful startup of the client // TODO: tooltip placement is buggy under both Linux and Mac (SWT 3.3), // so disable it for now: if (SVNFileUtil.isWindows) { final ToolTip tip = new ToolTip(shell, SWT.BALLOON | SWT.ICON_INFORMATION); tip.setText(I18N.getString("Mindquarry Desktop Client")); tip.setMessage(I18N.getString("Select this icon to open the Mindquarry Desktop Client")); trayItem.setToolTip(tip);/*from w w w . ja va 2 s . c o m*/ tip.setVisible(true); } // create tray item menu trayMenu = new Menu(shell, SWT.POP_UP); if (SVNFileUtil.isOSX) { // no right click on tray icons in OSX, do the menu on left click trayItem.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // double click: nothing to do here } public void widgetSelected(SelectionEvent e) { // single left click => show menu trayMenu.setVisible(true); } }); } else { // left-click trayItem.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // double click: nothing to do here } public void widgetSelected(SelectionEvent e) { // single left click => show window if (getShell().isVisible()) { // get all child shells and block minimizing if // necessary Shell[] shells = getShell().getShells(); if (0 < shells.length) { for (Shell shell : shells) { shell.forceActive(); } } else { getShell().setVisible(false); } } else { getShell().open(); getShell().forceActive(); } } }); // right-click / context menu => show menu trayItem.addListener(SWT.MenuDetect, new Listener() { public void handleEvent(Event event) { trayMenu.setVisible(true); } }); } ActionContributionItem showMainWindowAction = new ActionContributionItem(new ShowMainWindowAction(this)); showMainWindowAction.fill(trayMenu, trayMenu.getItemCount()); ActionContributionItem aboutAction = new ActionContributionItem(new AboutAction(this)); aboutAction.fill(trayMenu, trayMenu.getItemCount()); MenuItem menuItem = new MenuItem(trayMenu, SWT.SEPARATOR); // profiles sub menu menuItem = new MenuItem(trayMenu, SWT.CASCADE); menuItem.setText(I18N.getString("Server Profiles")); //$NON-NLS-1$ profilesMenu = new Menu(shell, SWT.DROP_DOWN); profilesMenu.addListener(SWT.Show, new Listener() { public void handleEvent(Event event) { updateProfileSelector(); } }); updateProfileSelector(); menuItem.setMenu(profilesMenu); // open web page action menuItem = new MenuItem(trayMenu, SWT.SEPARATOR); ActionContributionItem webpageAction = new ActionContributionItem( getAction(OpenWebpageAction.class.getName())); webpageAction.fill(trayMenu, trayMenu.getItemCount()); // options dialog ActionContributionItem preferencesAction = new ActionContributionItem( getAction(PreferencesAction.class.getName())); preferencesAction.fill(trayMenu, trayMenu.getItemCount()); // exit action menuItem = new MenuItem(trayMenu, SWT.SEPARATOR); ActionContributionItem closeAction = new ActionContributionItem(getAction(CloseAction.class.getName())); closeAction.fill(trayMenu, trayMenu.getItemCount()); iconAction = new IconActionThread(trayItem, getShell()); iconAction.setDaemon(true); iconAction.start(); }