List of usage examples for org.eclipse.jface.viewers DecoratingLabelProvider DecoratingLabelProvider
public DecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator)
From source file:ts.eclipse.ide.json.ui.internal.tsconfig.FilesPage.java
License:Open Source License
private void createIncludeSection(Composite parent) { final IFile tsconfigFile = getTsconfigFile(); FormToolkit toolkit = super.getToolkit(); Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR); section.setDescription(TsconfigEditorMessages.FilesPage_IncludeSection_desc); section.setText(TsconfigEditorMessages.FilesPage_IncludeSection_title); Composite client = toolkit.createComposite(section); GridLayout layout = new GridLayout(); layout.numColumns = 2;/*from www.ja v a2 s . com*/ layout.marginWidth = 2; layout.marginHeight = 2; client.setLayout(layout); Table table = toolkit.createTable(client, SWT.MULTI); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 20; gd.widthHint = 100; table.setLayoutData(gd); Composite buttonsComposite = toolkit.createComposite(client); buttonsComposite.setLayout(new GridLayout()); buttonsComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL)); if (tsconfigFile != null) { final Button addButton = toolkit.createButton(buttonsComposite, TsconfigEditorMessages.Button_add, SWT.PUSH); gd = new GridData(GridData.FILL_HORIZONTAL); addButton.setLayoutData(gd); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Object[] resources = DialogUtils.openResourcesDialog(tsconfigFile.getProject(), addButton.getShell()); if (resources != null && resources.length > 0) { IPath path = null; Collection<String> elements = new ArrayList<String>(resources.length); for (int i = 0; i < resources.length; i++) { path = WorkbenchResourceUtil.getRelativePath((IResource) resources[i], tsconfigFile.getParent()); elements.add(path.toString()); } IObservableList list = ((IObservableList) includeViewer.getInput()); list.addAll(elements); } } }); } final Button addGlobButton = toolkit.createButton(buttonsComposite, TsconfigEditorMessages.Button_add_pattern, SWT.PUSH); gd = new GridData(GridData.FILL_HORIZONTAL); addGlobButton.setLayoutData(gd); addGlobButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { InputDialog dialog = new InputDialog(addGlobButton.getShell(), TsconfigEditorMessages.AddPatternDialog_title, TsconfigEditorMessages.AddPatternDialog_message, "src/**/*", null); if (dialog.open() == Window.OK) { IObservableList list = ((IObservableList) includeViewer.getInput()); list.add(dialog.getValue()); } } }); includeRemoveButton = toolkit.createButton(buttonsComposite, TsconfigEditorMessages.Button_remove, SWT.PUSH); gd = new GridData(GridData.FILL_HORIZONTAL); includeRemoveButton.setLayoutData(gd); includeRemoveButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { removeSelectedItems(includeViewer); } }); includeViewer = new TableViewer(table); includeViewer.setLabelProvider(new DecoratingLabelProvider(filesLabelProvider, filesLabelProvider)); // update enable/disable of buttons when selection changed includeViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { includeRemoveButton.setEnabled(!event.getSelection().isEmpty()); } }); includeViewer.getTable().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { removeSelectedItems(includeViewer); } } }); toolkit.paintBordersFor(client); section.setClient(client); section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); section.setLayoutData(new GridData(GridData.FILL_BOTH)); IObservableList include = JSONProperties.list(new ExtendedJSONPath("include[*]")) .observe(getEditor().getDocument()); includeViewer.setContentProvider(new ObservableListContentProvider()); includeViewer.setInput(include); }
From source file:ts.eclipse.ide.json.ui.internal.tsconfig.PluginsPage.java
License:Open Source License
/** * Create Files section.//from w w w . j a v a2 s . co m * * @param parent */ private void createPluginsSection(Composite parent) { final IFile tsconfigFile = getTsconfigFile(); FormToolkit toolkit = super.getToolkit(); Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR); section.setDescription(TsconfigEditorMessages.FilesPage_FilesSection_desc); section.setText(TsconfigEditorMessages.FilesPage_FilesSection_title); Composite client = toolkit.createComposite(section); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 2; layout.marginHeight = 2; client.setLayout(layout); Table table = toolkit.createTable(client, SWT.MULTI); GridData gd = new GridData(GridData.FILL_BOTH); gd.minimumHeight = 100; gd.widthHint = 100; table.setLayoutData(gd); // Buttons Composite buttonsComposite = toolkit.createComposite(client); buttonsComposite.setLayout(new GridLayout()); buttonsComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL)); final Button pluginsAddButton = toolkit.createButton(buttonsComposite, TsconfigEditorMessages.Button_add, SWT.PUSH); gd = new GridData(GridData.FILL_HORIZONTAL); pluginsAddButton.setLayoutData(gd); pluginsRemoveButton = toolkit.createButton(buttonsComposite, TsconfigEditorMessages.Button_remove, SWT.PUSH); gd = new GridData(GridData.FILL_HORIZONTAL); pluginsRemoveButton.setLayoutData(gd); pluginsRemoveButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // removeSelectedItems(filesViewer); } }); // Files table pluginsViewer = new TableViewer(table); pluginsViewer.setLabelProvider(new DecoratingLabelProvider(PluginsLabelProvider.getInstance(), PluginsLabelProvider.getInstance())); // open file when row is double clicked // pluginsViewer.addDoubleClickListener(new IDoubleClickListener() { // // @Override // public void doubleClick(DoubleClickEvent e) { // openFile(pluginsViewer.getSelection()); // } // }); // // update enable/disable of buttons when selection changed // pluginsViewer.addSelectionChangedListener(new ISelectionChangedListener() { // // @Override // public void selectionChanged(SelectionChangedEvent event) { // updateFilesOpenButton(event.getSelection()); // filesRemoveButton.setEnabled(!event.getSelection().isEmpty()); // } // }); // pluginsViewer.getTable().addKeyListener(new KeyAdapter() { // @Override // public void keyPressed(KeyEvent e) { // if (e.keyCode == SWT.DEL) { // removeSelectedItems(pluginsViewer); // } // } // }); toolkit.paintBordersFor(client); section.setClient(client); section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); section.setLayoutData(new GridData(GridData.FILL_BOTH)); IObservableList files = JSONProperties.list(new ExtendedJSONPath("compilerOptions.plugins[*]")) .observe(getEditor().getDocument()); pluginsViewer.setContentProvider(new ObservableListContentProvider()); pluginsViewer.setInput(files); }
From source file:uk.ac.gda.client.experimentdefinition.components.ExperimentProviderUtils.java
License:Open Source License
/** * Creates a label provider on the file viewer for showing any exafs file. * /*from w w w. j a v a 2 s .com*/ * @param fileViewer */ public static void createExafsLabelProvider(final TableViewer fileViewer) { ColumnViewerToolTipSupport.enableFor(fileViewer, ToolTip.NO_RECREATE); final TableViewerColumn name = new TableViewerColumn(fileViewer, SWT.NONE); name.getColumn().setText("File"); name.getColumn().setWidth(500); fileViewer.setLabelProvider(new DecoratingLabelProvider(new LabelProvider(), CommonRCPActivator.getDefault().getWorkbench().getDecoratorManager().getLabelDecorator())); }