List of usage examples for org.eclipse.jface.resource ImageDescriptor createImage
public Image createImage()
From source file:eu.geclipse.jsdl.ui.providers.DataStageOutLabelProvider.java
License:Open Source License
void loadImages() { URL stageOutURL = Activator.getDefault().getBundle().getEntry("icons/stage-out.gif"); //$NON-NLS-1$ URL stageInOutURL = Activator.getDefault().getBundle().getEntry("icons/stage-in-out.gif"); //$NON-NLS-1$ ImageDescriptor stageOutDesc = ImageDescriptor.createFromURL(stageOutURL); ImageDescriptor stageInOutDesc = ImageDescriptor.createFromURL(stageInOutURL); this.stageOutImage = stageOutDesc.createImage(); this.stageInOutImage = stageInOutDesc.createImage(); }
From source file:eu.geclipse.jsdl.ui.providers.FeatureLabelProvider.java
License:Open Source License
void loadImages() { URL argsURL = Activator.getDefault().getBundle().getEntry("icons/args.gif"); //$NON-NLS-1$ URL candHostsURL = Activator.getDefault().getBundle().getEntry("icons/computing_obj.gif"); //$NON-NLS-1$ URL projectsURL = Activator.getDefault().getBundle().getEntry("icons/gridprojects.gif"); //$NON-NLS-1$ URL annotationURL = Activator.getDefault().getBundle().getEntry("icons/annotation_obj.gif"); //$NON-NLS-1$ ImageDescriptor argsDesc = ImageDescriptor.createFromURL(argsURL); ImageDescriptor candHostsDesc = ImageDescriptor.createFromURL(candHostsURL); ImageDescriptor projectsDesc = ImageDescriptor.createFromURL(projectsURL); ImageDescriptor annotDesc = ImageDescriptor.createFromURL(annotationURL); this.argsImage = argsDesc.createImage(); this.candHostsImage = candHostsDesc.createImage(); this.projectsImage = projectsDesc.createImage(); this.annotationImage = annotDesc.createImage(); }
From source file:eu.geclipse.terminal.internal.Terminal.java
License:Open Source License
private void initMenu() { ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); Menu popUpMenu = new Menu(getShell(), SWT.POP_UP); final MenuItem copyItem = new MenuItem(popUpMenu, SWT.PUSH); copyItem.setText(Messages.getString("Terminal.copy")); //$NON-NLS-1$ // TODO disable menu if selection is empty ImageDescriptor copyImage = sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY); copyItem.setImage(copyImage.createImage()); copyItem.addSelectionListener(new SelectionAdapter() { @Override/*from ww w.j a v a 2 s .co m*/ public void widgetSelected(final SelectionEvent event) { copy(); } }); MenuItem pasteItem = new MenuItem(popUpMenu, SWT.PUSH); pasteItem.setText(Messages.getString("Terminal.paste")); //$NON-NLS-1$ ImageDescriptor pasteImage = sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE); pasteItem.setImage(pasteImage.createImage()); pasteItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { paste(); } }); popUpMenu.addMenuListener(new MenuAdapter() { @Override public void menuShown(final MenuEvent event) { copyItem.setEnabled(!getSelection().isEmpty()); } }); setMenu(popUpMenu); }
From source file:eu.geclipse.ui.dialogs.GridFileDialog.java
License:Open Source License
/** * Create a new dialog with the specified style constant. * * @param parent The dialog's parent {@link Shell}. * @param style The dialog's style, i.e. a bitwise or of style * constants./*from w w w .j a v a2s . c o m*/ */ public GridFileDialog(final Shell parent, final int style) { super(parent); this.style = style; assertStyle(); setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE); URL imgURL = Activator.getDefault().getBundle().getResource("icons/wizban/newconn_wiz.gif"); //$NON-NLS-1$ ImageDescriptor imgDesc = ImageDescriptor.createFromURL(imgURL); setTitleImage(imgDesc.createImage()); }
From source file:eu.geclipse.ui.dialogs.GridFileDialog.java
License:Open Source License
@Override protected Control createDialogArea(final Composite parent) { this.modeManager = new ModeManager(); this.modeManager.addModeChangeListener(new IModeChangeListener() { public void modeChanged(final int mode) { setMode(mode);/* www . j a va 2 s .c om*/ } }); GridData gData; Label topRule = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR); topRule.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite mainComp = new Composite(parent, SWT.NONE); mainComp.setLayout(new GridLayout(2, false)); gData = new GridData(GridData.FILL_BOTH); gData.grabExcessHorizontalSpace = true; gData.grabExcessVerticalSpace = true; gData.widthHint = 500; gData.heightHint = 400; mainComp.setLayoutData(gData); Label bottomRule = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR); bottomRule.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); if (!hasStyle(STYLE_MULTI_SELECTION)) { Composite uriComp = new Composite(mainComp, SWT.NONE); uriComp.setLayout(new GridLayout(2, false)); gData = new GridData(GridData.FILL_HORIZONTAL); gData.grabExcessHorizontalSpace = true; gData.horizontalSpan = 2; uriComp.setLayoutData(gData); Label uriLabel = new Label(uriComp, SWT.NONE); uriLabel.setText(Messages.getString("GridFileDialog.label_URI")); //$NON-NLS-1$ gData = new GridData(); uriLabel.setLayoutData(gData); this.uriCombo = new StoredCombo(uriComp, SWT.NONE); gData = new GridData(GridData.FILL_HORIZONTAL); gData.grabExcessHorizontalSpace = true; this.uriCombo.setLayoutData(gData); this.uriCombo.setEnabled(!hasStyle(STYLE_ALLOW_ONLY_EXISTING)); } if (!hasStyle(STYLE_ALLOW_ONLY_CONNECTIONS | STYLE_ALLOW_ONLY_REMOTE_CONNECTIONS)) { ToolBar modeBar = new ToolBar(mainComp, SWT.VERTICAL | SWT.BORDER); modeBar.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); gData = new GridData(GridData.FILL_VERTICAL); gData.grabExcessVerticalSpace = true; modeBar.setLayoutData(gData); if (!hasStyle(STYLE_ALLOW_ONLY_LOCAL)) { URL connURL = Activator.getDefault().getBundle() .getResource("icons/extras/grid_file_dialog_conn_mode.gif"); //$NON-NLS-1$ ImageDescriptor connDesc = ImageDescriptor.createFromURL(connURL); ToolItem connItem = new ToolItem(modeBar, SWT.CHECK); connItem.setImage(connDesc.createImage()); connItem.setToolTipText(Messages.getString("GridFileDialog.switch_to_connections")); //$NON-NLS-1$ this.modeManager.addModeItem(connItem, ModeManager.CONNECTION_MODE); } if (!hasStyle(STYLE_ALLOW_ONLY_CONNECTIONS | STYLE_ALLOW_ONLY_REMOTE_CONNECTIONS)) { URL wsURL = Activator.getDefault().getBundle() .getResource("icons/extras/grid_file_dialog_ws_mode.gif"); //$NON-NLS-1$ ImageDescriptor wsDesc = ImageDescriptor.createFromURL(wsURL); ToolItem wsItem = new ToolItem(modeBar, SWT.CHECK); wsItem.setImage(wsDesc.createImage()); wsItem.setToolTipText(Messages.getString("GridFileDialog.switch_to_workspace")); //$NON-NLS-1$ this.modeManager.addModeItem(wsItem, ModeManager.WS_MODE); URL homeURL = Activator.getDefault().getBundle() .getResource("icons/extras/grid_file_dialog_home_mode.gif"); //$NON-NLS-1$ ImageDescriptor homeDesc = ImageDescriptor.createFromURL(homeURL); ToolItem homeItem = new ToolItem(modeBar, SWT.CHECK); homeItem.setImage(homeDesc.createImage()); homeItem.setToolTipText(Messages.getString("GridFileDialog.switch_to_home")); //$NON-NLS-1$ this.modeManager.addModeItem(homeItem, ModeManager.HOME_MODE); URL rootURL = Activator.getDefault().getBundle() .getResource("icons/extras/grid_file_dialog_root_mode.gif"); //$NON-NLS-1$ ImageDescriptor rootDesc = ImageDescriptor.createFromURL(rootURL); ToolItem rootItem = new ToolItem(modeBar, SWT.CHECK); rootItem.setImage(rootDesc.createImage()); rootItem.setToolTipText(Messages.getString("GridFileDialog.switch_to_root")); //$NON-NLS-1$ this.modeManager.addModeItem(rootItem, ModeManager.ROOT_MODE); } } Composite browserComp = new Composite(mainComp, SWT.NONE); GridLayout browserLayout = new GridLayout(1, false); browserLayout.marginWidth = 0; browserLayout.marginHeight = 0; browserComp.setLayout(browserLayout); gData = new GridData(GridData.FILL_BOTH); gData.grabExcessHorizontalSpace = true; gData.grabExcessVerticalSpace = true; browserComp.setLayoutData(gData); int treeStyle = SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER; if (hasStyle(STYLE_MULTI_SELECTION)) { treeStyle |= SWT.MULTI; } else { treeStyle |= SWT.SINGLE; } this.treeViewer = new TreeViewer(browserComp, treeStyle); this.treeViewer.setContentProvider(new GridFileDialogContentProvider()); NewGridModelLabelProvider lProvider = new NewGridModelLabelProvider(); lProvider.addColumn(0, FileStoreLabelProvider.COLUMN_TYPE_NAME); lProvider.addColumn(1, FileStoreLabelProvider.COLUMN_TYPE_SIZE); lProvider.addColumn(2, FileStoreLabelProvider.COLUMN_TYPE_MOD_DATE); ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(); DecoratingGridModelLabelProvider dProvider = new DecoratingGridModelLabelProvider(lProvider, decorator); this.treeViewer.setLabelProvider(dProvider); Tree tree = this.treeViewer.getTree(); tree.setHeaderVisible(true); gData = new GridData(GridData.FILL_BOTH); gData.grabExcessHorizontalSpace = true; gData.grabExcessVerticalSpace = true; tree.setLayoutData(gData); TreeColumn nameColumn = new TreeColumn(tree, SWT.NONE); nameColumn.setText(Messages.getString("GridFileDialog.column_title_name")); //$NON-NLS-1$ nameColumn.setAlignment(SWT.LEFT); nameColumn.setWidth(300); TreeColumn sizeColumn = new TreeColumn(tree, SWT.NONE); sizeColumn.setText(Messages.getString("GridFileDialog.column_title_size")); //$NON-NLS-1$ sizeColumn.setAlignment(SWT.RIGHT); sizeColumn.setWidth(100); TreeColumn modColumn = new TreeColumn(tree, SWT.NONE); modColumn.setText(Messages.getString("GridFileDialog.column_title_last_modification")); //$NON-NLS-1$ modColumn.setAlignment(SWT.CENTER); modColumn.setWidth(200); TreeColumnListener columnListener = new TreeColumnListener(this.treeViewer); for (TreeColumn column : tree.getColumns()) { column.addSelectionListener(columnListener); } tree.setSortColumn(nameColumn); tree.setSortDirection(SWT.UP); this.treeViewer.setComparator(new TreeColumnComparator(nameColumn)); Composite fileComp = new Composite(browserComp, SWT.NONE); fileComp.setLayout(new GridLayout(2, false)); gData = new GridData(GridData.FILL_HORIZONTAL); gData.grabExcessHorizontalSpace = true; fileComp.setLayoutData(gData); if (!hasStyle(STYLE_MULTI_SELECTION)) { Label filenameLabel = new Label(fileComp, SWT.NONE); filenameLabel.setText( hasStyle(STYLE_ALLOW_ONLY_FOLDERS) ? Messages.getString("GridFileDialog.label_foldername") //$NON-NLS-1$ : hasStyle(STYLE_ALLOW_ONLY_FILES) ? Messages.getString("GridFileDialog.label_filename") //$NON-NLS-1$ : Messages.getString("GridFileDialog.label_name") //$NON-NLS-1$ ); gData = new GridData(); gData.horizontalAlignment = GridData.BEGINNING; filenameLabel.setLayoutData(gData); this.filenameCombo = new StoredCombo(fileComp, SWT.BORDER); gData = new GridData(GridData.FILL_HORIZONTAL); gData.grabExcessHorizontalSpace = true; this.filenameCombo.setLayoutData(gData); this.filenameCombo.setEnabled(!hasStyle(STYLE_ALLOW_ONLY_EXISTING)); } if (!hasStyle(STYLE_ALLOW_ONLY_FOLDERS)) { Label filetypeLabel = new Label(fileComp, SWT.NONE); filetypeLabel.setText(Messages.getString("GridFileDialog.label_filetype")); //$NON-NLS-1$ gData = new GridData(); gData.horizontalAlignment = GridData.BEGINNING; filetypeLabel.setLayoutData(gData); this.filetypeCombo = new Combo(fileComp, SWT.BORDER | SWT.READ_ONLY); gData = new GridData(GridData.FILL_HORIZONTAL); gData.grabExcessHorizontalSpace = true; this.filetypeCombo.setLayoutData(gData); } int mode = !hasStyle(STYLE_ALLOW_ONLY_LOCAL) ? ModeManager.CONNECTION_MODE : ModeManager.WS_MODE; this.modeManager.setMode(mode); setMode(mode); this.treeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(final DoubleClickEvent event) { handleDoubleClick(); } }); this.selectionListener = new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { setNotificationEnabled(false); handleSelectionChanged(); setNotificationEnabled(true); } }; this.treeViewer.addSelectionChangedListener(this.selectionListener); if (this.uriCombo != null) { this.uriListener = new ModifyListener() { public void modifyText(final ModifyEvent e) { setNotificationEnabled(false); handleUriChanged(); setNotificationEnabled(true); } }; this.uriCombo.addModifyListener(this.uriListener); } if (this.filenameCombo != null) { this.filenameListener = new VerifyListener() { public void verifyText(final VerifyEvent e) { setNotificationEnabled(false); handleFilenameChanged(e); setNotificationEnabled(true); } }; this.filenameCombo.addVerifyListener(this.filenameListener); } if (this.filetypeCombo != null) { this.filetypeCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { configureViewerFilters(); } }); } this.modelListener = new IGridModelListener() { public void gridModelChanged(final IGridModelEvent event) { if ((event.getType() == IGridModelEvent.ELEMENTS_ADDED) || (event.getType() == IGridModelEvent.ELEMENTS_REMOVED)) { refreshViewer(event.getSource()); } } }; GridModel.getRoot().addGridModelListener(this.modelListener); Shell shell = getShell(); if (hasStyle(STYLE_ALLOW_ONLY_FILES)) { if (hasStyle(STYLE_MULTI_SELECTION)) { shell.setText(Messages.getString("GridFileDialog.shell_title_files")); //$NON-NLS-1$ } else { shell.setText(Messages.getString("GridFileDialog.shell_title_file")); //$NON-NLS-1$ } } else if (hasStyle(STYLE_ALLOW_ONLY_FOLDERS)) { if (hasStyle(STYLE_MULTI_SELECTION)) { shell.setText(Messages.getString("GridFileDialog.shell_title_folders")); //$NON-NLS-1$ } else { shell.setText(Messages.getString("GridFileDialog.shell_title_folder")); //$NON-NLS-1$ } } else { if (hasStyle(STYLE_MULTI_SELECTION)) { shell.setText(Messages.getString("GridFileDialog.shell_title_files_folders")); //$NON-NLS-1$ } else { shell.setText(Messages.getString("GridFileDialog.shell_title_file_folder")); //$NON-NLS-1$ } } setTitle(Messages.getString("GridFileDialog.title")); //$NON-NLS-1$ if (hasStyle(STYLE_ALLOW_ONLY_FILES)) { if (hasStyle(STYLE_MULTI_SELECTION)) { setMessage(Messages.getString("GridFileDialog.title_files")); //$NON-NLS-1$ } else { setMessage(Messages.getString("GridFileDialog.title_file")); //$NON-NLS-1$ } } else if (hasStyle(STYLE_ALLOW_ONLY_FOLDERS)) { if (hasStyle(STYLE_MULTI_SELECTION)) { setMessage(Messages.getString("GridFileDialog.title_folders")); //$NON-NLS-1$ } else { setMessage(Messages.getString("GridFileDialog.title_folder")); //$NON-NLS-1$ } } else { if (hasStyle(STYLE_MULTI_SELECTION)) { setMessage(Messages.getString("GridFileDialog.title_files_folders")); //$NON-NLS-1$ } else { setMessage(Messages.getString("GridFileDialog.title_file_folder")); //$NON-NLS-1$ } } addFileTypeFilter(new FileTypeFilter(), Messages.getString("GridFileDialog.label_all_files")); //$NON-NLS-1$ if (this.filenameCombo != null && this.filenameCombo.getItemCount() != 0) { this.filetypeCombo.select(0); } return mainComp; }
From source file:eu.geclipse.ui.internal.dialogs.ProblemReportDialog.java
License:Open Source License
/** * Create a new problem report dialog for the specified problem. * /*from www . j a va2s. c om*/ * @param parentShell The dialog's parent {@link Shell}. * @param throwable The {@link Throwable} to be reported. */ public ProblemReportDialog(final Shell parentShell, final Throwable throwable) { super(parentShell); this.exc = throwable; if (this.exc instanceof ProblemException) { this.problem = ((ProblemException) this.exc).getProblem(); } else { this.problem = null; } setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE); URL imgURL = Activator.getDefault().getBundle().getResource("icons/extras/problem_report_dlg.gif"); //$NON-NLS-1$ ImageDescriptor imgDesc = ImageDescriptor.createFromURL(imgURL); setTitleImage(imgDesc.createImage()); }
From source file:eu.geclipse.ui.internal.preference.PerspectivePreferencePage.java
License:Open Source License
@Override protected void createFieldEditors() { ImageDescriptor userPerspectiveImage = null; ImageDescriptor operatorPerspectiveImage = null; ImageDescriptor developerPerspectiveImage = null; RadioGroupFieldEditor editor = new RadioGroupFieldEditor(KEY_REMEMBER_SWITCHING, "Open a g-Eclipse perspective after creating a Cloud/Grid Project", 3, new String[][] { { "Always", MessageDialogWithToggle.ALWAYS }, { "Never", MessageDialogWithToggle.NEVER }, { "Prompt", MessageDialogWithToggle.PROMPT }, }, getFieldEditorParent(), true); addField(editor);/*from w ww . ja v a 2 s. co m*/ IPerspectiveRegistry reg = PlatformUI.getWorkbench().getPerspectiveRegistry(); String[][] labels = new String[][] { { "Grid User Perspective", Activator.ID_USER_PERSPECTIVE }, { "Grid Operator Perspective", Activator.ID_OPERATOR_PERSPECTIVE }, { "Grid Developer Perspective", Activator.ID_DEVELOPER_PERSPECTIVE } }; IPerspectiveDescriptor p; p = reg.findPerspectiveWithId(Activator.ID_USER_PERSPECTIVE); if (p != null) { labels[0][0] = p.getLabel(); userPerspectiveImage = p.getImageDescriptor(); } p = reg.findPerspectiveWithId(Activator.ID_OPERATOR_PERSPECTIVE); if (p != null) { labels[1][0] = p.getLabel(); operatorPerspectiveImage = p.getImageDescriptor(); } p = reg.findPerspectiveWithId(Activator.ID_DEVELOPER_PERSPECTIVE); if (p != null) { labels[2][0] = p.getLabel(); developerPerspectiveImage = p.getImageDescriptor(); } editor = new RadioGroupFieldEditor(KEY_DEFAULT_PERSPECTIVE, "Choose perspective to open for new Cloud/Grid Projects", 1, labels, getFieldEditorParent(), true); addField(editor); //add perspective images Control[] children = editor.getRadioBoxControl(getFieldEditorParent()).getChildren(); if (userPerspectiveImage != null && children[0] != null && children[0] instanceof Button) { ((Button) children[0]).setImage(userPerspectiveImage.createImage()); } if (operatorPerspectiveImage != null && children[1] != null && children[1] instanceof Button) { ((Button) children[1]).setImage(operatorPerspectiveImage.createImage()); } if (developerPerspectiveImage != null && children[2] != null && children[2] instanceof Button) { ((Button) children[2]).setImage(developerPerspectiveImage.createImage()); } BooleanFieldEditor bfe = new BooleanFieldEditor(KEY_NOT_SWITCH_FROM_GECLIPSE_PERSPECTIVE, "Do not switch from other g-Eclipse perspectives (User, Operator or Developer)", getFieldEditorParent()); addField(bfe); }
From source file:eu.geclipse.ui.providers.FileStoreLabelProvider.java
License:Open Source License
/** * Load the image from the specified path. * /*from ww w . j a va 2s . co m*/ * @param path The path of the image. * @return The image or <code>null</code> if no image could be found * at the specified path. */ protected static Image loadImage(final String path) { URL url = Activator.getDefault().getBundle().getEntry(path); ImageDescriptor descriptor = ImageDescriptor.createFromURL(url); return descriptor.createImage(); }
From source file:eu.geclipse.ui.providers.GridModelLabelProvider.java
License:Open Source License
private static Image loadImage(final String path) { URL url = Activator.getDefault().getBundle().getEntry(path); ImageDescriptor descriptor = ImageDescriptor.createFromURL(url); return descriptor.createImage(); }
From source file:eu.geclipse.ui.views.jobdetails.JobComplexDetail.java
License:Open Source License
private Image getButtonImage() { if (image == null) { ImageDescriptor imageDescriptor = Activator.getDefault().getImageRegistry() .getDescriptor(Activator.IMG_SEE); image = imageDescriptor.createImage(); }/*from w ww . j a v a 2 s.c o m*/ return image; }