List of usage examples for org.eclipse.jface.resource ImageDescriptor createFromURL
public static ImageDescriptor createFromURL(URL url)
From source file:eu.geclipse.ui.adapters.GridJobAdapter.java
License:Open Source License
@Override public ImageDescriptor getImageDescriptor(final Object resource) { URL imgUrl = Activator.getDefault().getBundle().getEntry("icons/obj16/job_folder.gif"); //$NON-NLS-1$ return ImageDescriptor.createFromURL(imgUrl); // return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( // ISharedImages.IMG_OPEN_MARKER); }
From source file:eu.geclipse.ui.decorators.GridJobDecorator.java
License:Open Source License
private ImageDescriptor getIcon(final int type) { ImageDescriptor decorator = null;//from w w w . j a va 2 s. c o m String fileName = imageNames.get(Integer.valueOf(type)); if (fileName == null) { fileName = imageNames.get(Integer.valueOf(STATUS_UNKNOWN_IMG)); } URL imgUrl = Activator.getDefault().getBundle().getEntry("icons/ovr16/" + fileName); //$NON-NLS-1$ decorator = ImageDescriptor.createFromURL(imgUrl); return decorator; }
From source file:eu.geclipse.ui.decorators.GridProjectFolderDecorator.java
License:Open Source License
public GridProjectFolderDecorator() { ImageDescriptor standardImage = null; ImageDescriptor image = null;/*www. j a va2s . c om*/ ExtensionManager extm = new ExtensionManager(); List<IConfigurationElement> configurationElements = extm .getConfigurationElements(Extensions.PROJECT_FOLDER_POINT, Extensions.PROJECT_FOLDER_ELEMENT); for (IConfigurationElement element : configurationElements) { String id = element.getAttribute(Extensions.PROJECT_FOLDER_ID_ATTRIBUTE); String icon = element.getAttribute(Extensions.PROJECT_FOLDER_ICON_ATTRIBUTE); if (icon != null) { IExtension extension = element.getDeclaringExtension(); IContributor contributor = extension.getContributor(); String name = contributor.getName(); Bundle bundle = Platform.getBundle(name); URL url = FileLocator.find(bundle, new Path(icon), null); image = ImageDescriptor.createFromURL(url); } else { if (standardImage == null) { URL url = Activator.getDefault().getBundle().getEntry("icons/ovr16/project_ovr.gif"); //$NON-NLS-1$ standardImage = ImageDescriptor.createFromURL(url); } image = standardImage; } this.images.put(id, image); } }
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 . ja v a2 s. 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);/*from ww w . ja v a 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.actions.CollapseAllAction.java
License:Open Source License
/** * Construct a new collapse all action for the specified tree viewer. * /*from w w w. j a v a 2s . co m*/ * @param viewer The tree viewer that is the target of this action. */ public CollapseAllAction(final TreeViewer viewer) { super(Messages.getString("CollapseAllAction.collapse_all_action_text")); //$NON-NLS-1$ this.viewer = viewer; URL imgUrl = Activator.getDefault().getBundle().getEntry("icons/elcl16/collapseall.gif"); //$NON-NLS-1$ setImageDescriptor(ImageDescriptor.createFromURL(imgUrl)); }
From source file:eu.geclipse.ui.internal.actions.LinkWithEditorAction.java
License:Open Source License
protected LinkWithEditorAction(final GridModelViewPart view) { super(Messages.getString("LinkWithEditorAction.link_with_editor_action_text"), IAction.AS_CHECK_BOX); //$NON-NLS-1$ this.view = view; URL imgUrl = Activator.getDefault().getBundle().getEntry("icons/elcl16/synced.gif"); //$NON-NLS-1$ setImageDescriptor(ImageDescriptor.createFromURL(imgUrl)); }
From source file:eu.geclipse.ui.internal.actions.NewConnectionAction.java
License:Open Source License
/** * Construct this action for the specified workbench window. * /* w w w . j a v a2 s .c o m*/ * @param workbenchWindow The {@link IWorkbenchWindow} for which to * create this action. */ public NewConnectionAction(final IWorkbenchWindow workbenchWindow) { super(Messages.getString("NewConnectionAction.new_connection_action_text")); //$NON-NLS-1$ this.workbenchWindow = workbenchWindow; URL imgUrl = Activator.getDefault().getBundle().getEntry("icons/etool16/newconn_wiz.gif"); //$NON-NLS-1$ setImageDescriptor(ImageDescriptor.createFromURL(imgUrl)); }
From source file:eu.geclipse.ui.internal.actions.ToggleUpdateJobsAction.java
License:Open Source License
protected ToggleUpdateJobsAction() { super(Messages.getString("ToggleJobsUpdatesAction.toggle_jobs_updates_action_active_text"), //$NON-NLS-1$ IAction.AS_CHECK_BOX);/* w w w.jav a 2 s . co m*/ URL imgUrl = Activator.getDefault().getBundle().getEntry("icons/job.gif"); //$NON-NLS-1$ setImageDescriptor(ImageDescriptor.createFromURL(imgUrl)); setChecked(eu.geclipse.core.Preferences.getUpdateJobsStatus()); }
From source file:eu.geclipse.ui.internal.actions.ViewModeAction.java
License:Open Source License
/** * Create a new view mode action for the specified view. * /*from ww w . j a va2s. c o m*/ * @param name The name of the action. * @param viewMode The view mode this action stands for, i.e. either * {@link ConfigurableContentProvider#MODE_FLAT} or * {@link ConfigurableContentProvider#MODE_HIERARCHICAL}. * @param view The view for which to set the view mode. */ protected ViewModeAction(final String name, final int viewMode, final ElementManagerViewPart view) { super(name); this.view = view; this.viewMode = viewMode; updateActionState(); URL imgURL = null; if (viewMode == ConfigurableContentProvider.MODE_FLAT) { imgURL = Activator.getDefault().getBundle().getEntry(ViewModeAction.VIEW_FLAT_IMAGE); } else if (viewMode == ConfigurableContentProvider.MODE_HIERARCHICAL) { imgURL = Activator.getDefault().getBundle().getEntry(ViewModeAction.VIEW_HIERARCHICAL_IMAGE); } if (imgURL != null) { ImageDescriptor descriptor = ImageDescriptor.createFromURL(imgURL); setImageDescriptor(descriptor); } }