List of usage examples for org.eclipse.jface.viewers IStructuredSelection isEmpty
public boolean isEmpty();
From source file:com.ibm.research.tours.fx.wizards.FontPreferenceWizardPage.java
License:Open Source License
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.verticalSpacing = 6;/*w w w . j a v a 2s . c o m*/ composite.setLayout(layout); Label label = new Label(composite, SWT.WRAP); label.setText("Configure font for this element"); GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); label.setData(data); ITableLabelProvider labelProvider = new TableLabelProviderAdapter() { public String getColumnText(Object element, int columnIndex) { if (element instanceof FontDefinition) { FontDefinition defn = (FontDefinition) element; if (columnIndex == 0) return defn.getName(); else if (columnIndex == 1) return defn.getDescription(); } return null; } }; IContentProvider contentProvider = new StructuredContentProviderAdapter() { public Object[] getElements(Object inputElement) { IThemeRegistry registry = WorkbenchPlugin.getDefault().getThemeRegistry(); FontDefinition[] fontDefinitions = registry.getFonts(); return fontDefinitions; } }; fFontPrefRegistry = new FilteredTable(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL, new NQueryTablePatternFilter()); fFontPrefRegistry.getViewer().setContentProvider(contentProvider); fFontPrefRegistry.getViewer().setSorter(new ViewerSorter()); fFontPrefRegistry.getViewer().setLabelProvider(labelProvider); fFontPrefRegistry.getViewer().setInput(new Object()); fFontPrefRegistry.getViewer().addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selected = (IStructuredSelection) event.getSelection(); if (selected.isEmpty()) { FontPreferenceWizardPage.this.setPageComplete(false); } else { FontDefinition defn = (FontDefinition) selected.getFirstElement(); FontPreferenceWizardPage.this.setId(defn.getId()); FontPreferenceWizardPage.this.setLabel(defn.getName()); FontPreferenceWizardPage.this.setPageComplete(getFontData() != null); } } }); Table table = fFontPrefRegistry.getViewer().getTable(); table.setHeaderVisible(false); table.setLinesVisible(true); TableColumn nameColumn = new TableColumn(table, SWT.LEFT, 0); nameColumn.setWidth(240); TableColumn descColumn = new TableColumn(table, SWT.LEFT, 1); descColumn.setWidth(640); GridData registryListData = new GridData(GridData.FILL_HORIZONTAL); registryListData.heightHint = 120; registryListData.horizontalSpan = 2; fFontPrefRegistry.setLayoutData(registryListData); if (id != null) { IThemeRegistry registry = WorkbenchPlugin.getDefault().getThemeRegistry(); FontDefinition[] fontDefinitions = registry.getFonts(); for (FontDefinition defn : fontDefinitions) { if (id.equals(defn.getId())) { IStructuredSelection selection = new StructuredSelection(defn); fFontPrefRegistry.getViewer().setSelection(selection, true); break; } } } fFontGroup = new FontGroup(fFontData); GridData fontGroupData = new GridData(GridData.FILL_HORIZONTAL); fontGroupData.heightHint = 80; fontGroupData.widthHint = 300; fFontGroup.createComposite(composite, fontGroupData); fResetButton = new Button(composite, SWT.CHECK); fResetButton.setText("Reset font after transition"); fResetButton.setSelection(fReset); fResetButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { fReset = fResetButton.getSelection(); } public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); setPageComplete(id != null && getFontData() != null); setControl(composite); }
From source file:com.ibm.research.tours.fx.wizards.ResetFontPreferenceWizardPage.java
License:Open Source License
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.verticalSpacing = 6;/*from w w w . ja v a2 s .c o m*/ composite.setLayout(layout); Label label = new Label(composite, SWT.WRAP); label.setText("Configure font for this element"); GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); label.setData(data); ITableLabelProvider labelProvider = new TableLabelProviderAdapter() { public String getColumnText(Object element, int columnIndex) { if (element instanceof FontDefinition) { FontDefinition defn = (FontDefinition) element; if (columnIndex == 0) return defn.getName(); else if (columnIndex == 1) return defn.getDescription(); } return null; } }; IContentProvider contentProvider = new StructuredContentProviderAdapter() { public Object[] getElements(Object inputElement) { IThemeRegistry registry = WorkbenchPlugin.getDefault().getThemeRegistry(); FontDefinition[] fontDefinitions = registry.getFonts(); return fontDefinitions; } }; fFontPrefRegistry = new FilteredTable(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL, new NQueryTablePatternFilter()); fFontPrefRegistry.getViewer().setContentProvider(contentProvider); fFontPrefRegistry.getViewer().setSorter(new ViewerSorter()); fFontPrefRegistry.getViewer().setLabelProvider(labelProvider); fFontPrefRegistry.getViewer().setInput(new Object()); fFontPrefRegistry.getViewer().addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selected = (IStructuredSelection) event.getSelection(); if (selected.isEmpty()) { ResetFontPreferenceWizardPage.this.setPageComplete(false); } else { FontDefinition defn = (FontDefinition) selected.getFirstElement(); ResetFontPreferenceWizardPage.this.setId(defn.getId()); ResetFontPreferenceWizardPage.this.setLabel(defn.getName()); ResetFontPreferenceWizardPage.this.setPageComplete(id != null); } } }); Table table = fFontPrefRegistry.getViewer().getTable(); table.setHeaderVisible(false); table.setLinesVisible(true); TableColumn nameColumn = new TableColumn(table, SWT.LEFT, 0); nameColumn.setWidth(240); TableColumn descColumn = new TableColumn(table, SWT.LEFT, 1); descColumn.setWidth(640); GridData registryListData = new GridData(GridData.FILL_HORIZONTAL); registryListData.heightHint = 120; registryListData.horizontalSpan = 2; fFontPrefRegistry.setLayoutData(registryListData); if (id != null) { IThemeRegistry registry = WorkbenchPlugin.getDefault().getThemeRegistry(); FontDefinition[] fontDefinitions = registry.getFonts(); for (FontDefinition defn : fontDefinitions) { if (id.equals(defn.getId())) { IStructuredSelection selection = new StructuredSelection(defn); fFontPrefRegistry.getViewer().setSelection(selection, true); break; } } } setPageComplete(id != null); setControl(composite); }
From source file:com.itsolut.mantis.ui.action.MantisDeleteAttachmentAction.java
License:Open Source License
public void selectionChanged(IAction action, ISelection selection) { attachments.clear();/*from w w w . j a va2 s . com*/ action.setEnabled(false); IStructuredSelection structuredSelection = null; if (selection instanceof IStructuredSelection) structuredSelection = (IStructuredSelection) selection; if (structuredSelection == null || structuredSelection.isEmpty()) return; for (Object selectionItem : structuredSelection.toList()) { if (selectionItem instanceof ITaskAttachment) { attachments.add((ITaskAttachment) selectionItem); } } action.setEnabled(attachments.size() > 0); }
From source file:com.itsolut.mantis.ui.wizard.NewMantisTaskWizard.java
License:Open Source License
@Override public void addPages() { IStructuredSelection selection = MantisUIUtil.getCurrentSelection(); if (selection != null && !selection.isEmpty()) { Object selectedElement = selection.getFirstElement(); String projectName = null; if (selectedElement instanceof ITask) { ITask task = (ITask) selectedElement; projectName = task.getAttribute(PROJECT.getKey()); } else if (selectedElement instanceof IRepositoryQuery) { IRepositoryQuery query = (IRepositoryQuery) selectedElement; projectName = query.getAttribute(IMantisClient.PROJECT_NAME); } else if (selectedElement instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) selectedElement; ITask task = (ITask) adaptable.getAdapter(ITask.class); if (task != null) projectName = task.getAttribute(PROJECT.getKey()); }//from w w w . ja v a 2 s. co m if (projectName != null && !MantisProject.ALL_PROJECTS.getName().equals(projectName)) { try { MantisCacheData cacheData = clientManager.getRepository(taskRepository).getCacheData(); for (MantisProject project : cacheData.getProjects()) { if (project.getName().equals(projectName)) { mapping = new ProductOnlyTaskMapping(projectName); return; } } } catch (MantisException e) { // ignore the attempt and fall back to using a project page } } } newTaskPage = new MantisProjectPage(taskRepository, clientManager); addPage(newTaskPage); }
From source file:com.iw.plugins.spindle.actions.AbstractTapestryProjectAction.java
License:Mozilla Public License
/** * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) *//*from w w w . ja v a2 s . com*/ public void selectionChanged(IAction action, ISelection sel) { boolean enable = false; this.selection = null; IStructuredSelection selection = null; if (sel instanceof IStructuredSelection) { selection = (IStructuredSelection) sel; if (selection != null && !selection.isEmpty() && selection.size() == 1) { if (checkProjectIsOpenAndHasJavaNature(selection)) { enable = checkSelection(selection); } } } if (enable) { this.selection = selection; } action.setEnabled(enable); }
From source file:com.iw.plugins.spindle.actions.AbstractTapestryResourceAction.java
License:Mozilla Public License
/** * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) *//*from w ww. j a v a 2 s . co m*/ public void selectionChanged(IAction action, ISelection sel) { boolean enable = false; this.fSelection = null; IStructuredSelection selection = null; if (sel instanceof IStructuredSelection) { selection = (IStructuredSelection) sel; if (!selection.isEmpty()) enable = checkSelection(selection); } if (enable) this.fSelection = selection; action.setEnabled(enable); }
From source file:com.iw.plugins.spindle.actions.AbstractTapestryResourceAction.java
License:Mozilla Public License
/** * Method checkMultiSelection./* www .j av a 2 s . com*/ * * @param selection * @return boolean */ private boolean checkSelection(IStructuredSelection selection) { boolean result = true; if (selection == null || selection.isEmpty()) { result = false; } else { for (Iterator iter = selection.iterator(); iter.hasNext();) { IFile candidateFile = (IFile) iter.next(); IProject project = candidateFile.getProject(); try { if (!project.isOpen() || !project.hasNature(TapestryCore.NATURE_ID)) return false; if (project.findMarkers(ITapestryMarker.TAPESTRY_BUILDBROKEN_MARKER, false, IResource.DEPTH_ZERO).length > 0) return false; } catch (CoreException e) { return false; } if (checkSpecificationExists(candidateFile)) result = false; } } return result; }
From source file:com.iw.plugins.spindle.editorjwc.beans.BeanSelectionSection.java
License:Mozilla Public License
public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.isEmpty()) { fireSelectionNotification(null); }// ww w .ja v a 2 s. co m PluginBeanSpecification bean = (PluginBeanSpecification) getSelected(); if (bean != null) { fireSelectionNotification(bean); if (hasFocus || updateSelection) { setPageSelection(); } } }
From source file:com.iw.plugins.spindle.editorjwc.beans.ChooseBeanInitializerDialog.java
License:Mozilla Public License
protected void okPressed() { if (viewer != null) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); if (!selection.isEmpty()) { chosenProperties = new ArrayList(); for (Iterator iter = selection.toList().iterator(); iter.hasNext();) { PropertyDescriptor element = (PropertyDescriptor) iter.next(); chosenProperties.add(element.getName()); }// w ww .j a v a 2s . c om } } super.okPressed(); }
From source file:com.iw.plugins.spindle.editorjwc.components.ChooseBindingTypeDialog.java
License:Mozilla Public License
protected void okPressed() { if (viewer != null) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); if (!selection.isEmpty()) { chosenParameters = selection.toList(); }// w w w . j a v a2s.com } super.okPressed(); }