List of usage examples for org.eclipse.jface.viewers IStructuredSelection isEmpty
public boolean isEmpty();
From source file:com.bb.extensions.plugin.unittests.internal.actions.CodeCoverageOpenAction.java
License:Open Source License
@Override protected boolean updateSelection(IStructuredSelection selection) { boolean result = false; _selectedElement = null;//from w w w . ja v a 2 s.c o m if (!selection.isEmpty()) { Object selected = selection.getFirstElement(); if (selected instanceof CodeCoverageUnitTestsNavigatorElement) { _selectedElement = (CodeCoverageUnitTestsNavigatorElement) selected; result = true; } } _openAction.selectionChanged(selection); result = result || _openAction.isEnabled(); return result; }
From source file:com.bb.extensions.plugin.unittests.internal.actions.TestFileOpenAction.java
License:Open Source License
@Override protected boolean updateSelection(IStructuredSelection selection) { boolean result = false; _selectedElement = null;/*from w w w . ja v a 2s . c o m*/ if (!selection.isEmpty()) { Object selected = selection.getFirstElement(); if (selected instanceof TestFileUnitTestsNavigatorElement) { _selectedElement = (TestFileUnitTestsNavigatorElement) selected; result = true; } } _openAction.selectionChanged(selection); result = result || _openAction.isEnabled(); return result; }
From source file:com.bb.extensions.plugin.unittests.internal.actions.UpdateMocksAction.java
License:Open Source License
@Override protected boolean updateSelection(IStructuredSelection selection) { boolean result = false; this.selectedElement = null; if (!selection.isEmpty()) { Object selected = selection.getFirstElement(); if (selected instanceof MocksUnitTestsNavigatorElement) { this.selectedElement = (MocksUnitTestsNavigatorElement) selected; result = true;// w w w . j a v a 2 s . c om } } return result; }
From source file:com.bdaum.juploadr.uploadapi.smugrest.ui.AlbumPolicyDialog.java
License:Open Source License
@Override protected void okPressed() { saveValues();//from w w w.j a v a 2 s. c om session.setAlbumPolicy(albumGroup.getSelection() == 0 ? SmugmugRestApi.SELECT : SmugmugRestApi.USEDEFAULT); IStructuredSelection selection = viewer.getStructuredSelection(); if (!selection.isEmpty()) session.setDefaultAlbum(((PhotoSet) selection.getFirstElement())); super.okPressed(); }
From source file:com.bdaum.juploadr.uploadapi.smugrest.ui.AlbumPolicyDialog.java
License:Open Source License
private void saveValues() { CommunityAccount account = session.getAccount(); account.setAlbumPolicy(albumGroup.getSelection() == 0 ? SmugmugRestApi.SELECT : SmugmugRestApi.USEDEFAULT); IStructuredSelection selection = viewer.getStructuredSelection(); if (!selection.isEmpty()) account.setDefaultAlbum(((PhotoSet) selection.getFirstElement()).getTitle()); account.save();/*from ww w. j av a2s . c o m*/ }
From source file:com.bdaum.zoom.gps.internal.views.MapView.java
License:Open Source License
public void setMaptype(String maptype) { IStructuredSelection sel = comboContributionItem.getSelection(); if (!sel.isEmpty()) GpsActivator.setCurrentMapType((IConfigurationElement) sel.getFirstElement(), maptype); }
From source file:com.bdaum.zoom.net.communities.ui.ExportToCommunityPage.java
License:Open Source License
@Override protected void updateFields() { super.updateFields(); IStructuredSelection sel = accountViewer.getStructuredSelection(); if (!sel.isEmpty()) { CommunityAccount account = (CommunityAccount) sel.getFirstElement(); boolean noOrigs = !account.isSupportsRaw() && hasRawImaages; if (noOrigs) { exportModeGroup.setOriginalsEnabled(false); setMessage(msg + Messages.ExportToCommunityPage_cannot_send_orginals); } else/* w w w . j ava 2s. c o m*/ setMessage(msg); } validatePage(); }
From source file:com.bdaum.zoom.ui.internal.dialogs.AbstractSelectExhibitDialog.java
License:Open Source License
protected void processSelection() { IStructuredSelection sel = viewer.getStructuredSelection(); if (sel.isEmpty()) cancelPressed();/* ww w .j a va2 s . co m*/ else { selection = sel.getFirstElement(); okPressed(); } }
From source file:com.bdaum.zoom.ui.internal.dialogs.AutoRuleComponent.java
License:Open Source License
@SuppressWarnings("unused") public AutoRuleComponent(Composite parent, int style, IAdaptable info) { this.info = info; composite = new Composite(parent, SWT.NONE); Layout layout = parent.getLayout();/*from www . ja v a2 s . c om*/ if (layout instanceof GridLayout) { GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.horizontalSpan = ((GridLayout) layout).numColumns; composite.setLayoutData(layoutData); } composite.setLayout(new GridLayout()); new Label(composite, SWT.NONE).setText(Messages.AutoRuleComponent_collections_expl); CGroup autoGroup = UiUtilities.createGroup(composite, 2, Messages.AutoRuleComponent_title); ruleViewer = new TableViewer(autoGroup, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL); TableViewerColumn col0 = new TableViewerColumn(ruleViewer, SWT.NONE); col0.getColumn().setText(Messages.AutoRuleComponent_name); col0.getColumn().setWidth(100); col0.setLabelProvider(new ZColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof AutoRule) return ((AutoRule) element).getName(); return element.toString(); } }); TableViewerColumn col1 = new TableViewerColumn(ruleViewer, SWT.NONE); col1.getColumn().setText(Messages.AutoRuleComponent_group); col1.getColumn().setWidth(180); col1.setLabelProvider(new ZColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof AutoRule) return ((AutoRule) element).getQfield().getCategory().toString(); return element.toString(); } }); TableViewerColumn col2 = new TableViewerColumn(ruleViewer, SWT.NONE); col2.getColumn().setText(Messages.AutoRuleComponent_field); col2.getColumn().setWidth(220); col2.setLabelProvider(new ZColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof AutoRule) return ((AutoRule) element).getQfield().getLabel(); return element.toString(); } }); TableViewerColumn col3 = new TableViewerColumn(ruleViewer, SWT.NONE); col3.getColumn().setText(Messages.AutoRuleComponent_type); col3.getColumn().setWidth(160); col3.setLabelProvider(new ZColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof AutoRule) { AutoRule rule = (AutoRule) element; if (rule.hasCustomIntervals()) return Messages.AutoRuleComponent_custom; QueryField qfield = rule.getQfield(); switch (qfield.getAutoPolicy()) { case QueryField.AUTO_DISCRETE: if (qfield.getEnumeration() != null) return Messages.AutoRuleComponent_enum; if (qfield.getType() == QueryField.T_BOOLEAN) return Messages.AutoRuleComponent_bool; return Messages.AutoRuleComponent_discrete; case QueryField.AUTO_LINEAR: return Messages.AutoRuleComponent_linear; case QueryField.AUTO_LOG: return Messages.AutoRuleComponent_exp; case QueryField.AUTO_CONTAINS: return Messages.AutoRuleComponent_arbitrary; case QueryField.AUTO_SELECT: return Messages.AutoRuleComponent_multiple; } } return element.toString(); } }); TableViewerColumn col4 = new TableViewerColumn(ruleViewer, SWT.NONE); col4.getColumn().setText(Messages.AutoRuleComponent_parms); col4.getColumn().setWidth(220); col4.setLabelProvider(new ZColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof AutoRule) { AutoRule rule = (AutoRule) element; QueryField qfield = rule.getQfield(); switch (qfield.getAutoPolicy()) { case QueryField.AUTO_CONTAINS: case QueryField.AUTO_SELECT: return rule.getValueSpec(); case QueryField.AUTO_DISCRETE: if (qfield.getEnumeration() != null) return rule.getEnumerationSpec(); if (qfield.getType() == QueryField.T_BOOLEAN) return Format.booleanFormatter.toString(Boolean.parseBoolean(rule.getBooleanSpec())); //$FALL-THROUGH$ default: return rule.getIntervalSpec(); } } return element.toString(); } }); ruleViewer.getTable().setHeaderVisible(true); ruleViewer.getTable().setLinesVisible(true); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.heightHint = (style & SWT.SHORT) != 0 ? 150 : 300; ruleViewer.getTable().setLayoutData(layoutData); ruleViewer.setContentProvider(ArrayContentProvider.getInstance()); new SortColumnManager(ruleViewer, new int[] { SWT.UP, SWT.UP, SWT.UP, SWT.NONE, SWT.NONE }, 0); ruleViewer.setComparator(ZViewerComparator.INSTANCE); ruleViewer.getControl().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.CTRL) cntrlDwn = true; } @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.CTRL) cntrlDwn = false; } }); ruleViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateButtons(); if (cntrlDwn) { if (editAutoButton.isEnabled()) editRule(); cntrlDwn = false; } } }); ruleViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { if (!cntrlDwn && editAutoButton.isEnabled()) editRule(); } }); ruleViewer.setInput(autoRules); Composite autoButtonBar = new Composite(autoGroup, SWT.NONE); autoButtonBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); autoButtonBar.setLayout(new GridLayout(1, false)); addAutoButton = new Button(autoButtonBar, SWT.PUSH); addAutoButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); addAutoButton.setText(Messages.AutoRuleComponent_add); addAutoButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { AutoRuleDialog dialog = new AutoRuleDialog(parent.getShell(), null, autoRules); if (dialog.open() == AutoRuleDialog.OK) { AutoRule rule = dialog.getRule(); autoRules.add(rule); ruleViewer.add(rule); ruleViewer.setSelection(new StructuredSelection(rule)); fillAccelViewer(); updateButtons(); } } }); editAutoButton = new Button(autoButtonBar, SWT.PUSH); editAutoButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); editAutoButton.setText(Messages.AutoRuleComponent_edit); editAutoButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { editRule(); } }); removeAutoButton = new Button(autoButtonBar, SWT.PUSH); removeAutoButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); removeAutoButton.setText(Messages.AutoRuleComponent_remove); removeAutoButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @SuppressWarnings("unchecked") Iterator<AutoRule> it = ruleViewer.getStructuredSelection().iterator(); while (it.hasNext()) { AutoRule rule = it.next(); int index = autoRules.indexOf(rule); autoRules.remove(rule); if (index >= autoRules.size()) --index; ruleViewer.remove(rule); if (index >= 0) ruleViewer.setSelection(new StructuredSelection(autoRules.get(index))); } fillAccelViewer(); updateButtons(); } }); new Label(autoButtonBar, SWT.SEPARATOR | SWT.HORIZONTAL) .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); applyButton = new Button(autoButtonBar, SWT.PUSH); applyButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); applyButton.setText(Messages.AutoRuleComponent_apply); applyButton.setToolTipText(Messages.AutoRuleComponent_apply_tooltip); applyButton.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("unchecked") @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection sel = ruleViewer.getStructuredSelection(); if (!sel.isEmpty()) OperationJob.executeSlaveOperation( new AutoRuleOperation(new ArrayList<AutoRule>(sel.toList()), null, null), info, false); } }); CGroup accelGroup = UiUtilities.createGroup(composite, 1, Messages.AutoRuleComponent_accel_candidates); new Label(accelGroup, SWT.WRAP).setText(Messages.AutoRuleComponent_accel_msg); accelViewer = CheckboxTableViewer.newCheckList(accelGroup, SWT.V_SCROLL | SWT.BORDER); accelViewer.getTable().setLayoutData(new GridData(400, (style & SWT.SHORT) != 0 ? 50 : 80)); accelViewer.setContentProvider(ArrayContentProvider.getInstance()); accelViewer.setLabelProvider(new ZColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof QueryField) return ((QueryField) element).getLabel(); return element.toString(); } }); accelViewer.setComparator(ZViewerComparator.INSTANCE); updateButtons(); }
From source file:com.bdaum.zoom.ui.internal.dialogs.AutoRuleComponent.java
License:Open Source License
protected void updateButtons() { if (ruleViewer.getControl().isEnabled()) { IStructuredSelection selection = ruleViewer.getStructuredSelection(); editAutoButton.setEnabled(selection.size() == 1); removeAutoButton.setEnabled(!selection.isEmpty()); applyButton.setEnabled(!selection.isEmpty()); addAutoButton.setEnabled(true);/*from ww w . j ava 2 s . com*/ } else { editAutoButton.setEnabled(false); removeAutoButton.setEnabled(false); applyButton.setEnabled(false); addAutoButton.setEnabled(false); } }