List of usage examples for org.eclipse.jface.viewers IStructuredSelection size
public int size();
From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.actions.CompareChangeWithWorkspaceVersionAction.java
License:Open Source License
@Override protected boolean computeEnablement(final IStructuredSelection selection) { if (selection.size() != 1) { return false; }/*from ww w .ja v a 2 s .com*/ final Change change = (Change) adaptSelectionFirstElement(Change.class); if (change.getItem().getItemType() != ItemType.FILE || containsSymlinkChange(change)) { return false; } String mappedLocalPath; try { mappedLocalPath = getRepository().getWorkspace().getMappedLocalPath(change.getItem().getServerItem()); } catch (final ServerPathFormatException e) { return false; } if (mappedLocalPath == null || !new File(mappedLocalPath).exists()) { return false; } if (change.getChangeType().contains(ChangeType.DELETE)) { return false; } return true; }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.actions.ComparePendingChangeWithLatestVersionAction.java
License:Open Source License
@Override protected boolean computeEnablement(final IStructuredSelection selection) { if (selection.size() != 1) { return false; }/*from ww w . j a v a 2s . co m*/ final PendingChange pendingChange = (PendingChange) adaptSelectionFirstElement(PendingChange.class); return PendingChangesHelpers.canCompareWithLatestVersion(pendingChange); }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.actions.ComparePendingChangeWithWorkspaceVersionAction.java
License:Open Source License
@Override protected boolean computeEnablement(final IStructuredSelection selection) { if (selection.size() != 1) { return false; }/*from w ww . ja va2 s. c om*/ final PendingChange pendingChange = (PendingChange) adaptSelectionFirstElement(PendingChange.class); return PendingChangesHelpers.canCompareWithWorkspaceVersion(getRepository(), pendingChange); }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.actions.CompareShelvedChangeWithLatestVersionAction.java
License:Open Source License
@Override protected boolean computeEnablement(final IStructuredSelection selection) { if (selection.size() != 1) { return false; }// w ww . j av a 2 s . c o m final PendingChange pendingChange = (PendingChange) adaptSelectionFirstElement(PendingChange.class); if (pendingChange.getItemType() != ItemType.FILE) { return false; } return !(pendingChange.getChangeType().contains(ChangeType.DELETE) || pendingChange.getChangeType().contains(ChangeType.ADD) || pendingChange.getChangeType().contains(ChangeType.BRANCH) || PendingChangesHelpers.containsSymlinkChange(pendingChange)); }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.actions.CompareShelvedChangeWithUnmodifiedVersionAction.java
License:Open Source License
@Override protected boolean computeEnablement(final IStructuredSelection selection) { if (selection.size() != 1) { return false; }// ww w . java2s . c om final PendingChange pendingChange = (PendingChange) adaptSelectionFirstElement(PendingChange.class); if (pendingChange.getItemType() != ItemType.FILE || PendingChangesHelpers.containsSymlinkChange(pendingChange)) { return false; } if (pendingChange.getChangeType().contains(ChangeType.ADD) || pendingChange.getChangeType().contains(ChangeType.BRANCH) || pendingChange.getChangeType().contains(ChangeType.DELETE)) { return false; } if (pendingChange.getChangeType().contains(ChangeType.RENAME) && !pendingChange.getChangeType().contains(ChangeType.EDIT)) { return false; } return true; }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.actions.UndoPendingChangesAction.java
License:Open Source License
@Override protected boolean computeEnablement(final IStructuredSelection selection) { return selection.size() > 0; }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.actions.UndoUnchangedPendingChangesAction.java
License:Open Source License
protected boolean computeEnablement(final IStructuredSelection selection) { return selection.size() > 0; }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.actions.ViewChangeAction.java
License:Open Source License
@Override protected boolean computeEnablement(final IStructuredSelection selection) { if (selection.size() != 1) { return false; }/*from w w w.j a v a 2 s . c om*/ final Change change = (Change) adaptSelectionFirstElement(Change.class); if (change.getItem().getItemType() != ItemType.FILE) { return false; } return true; }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.actions.ViewPendingChangeAction.java
License:Open Source License
private boolean computeEnablementInternal(final IStructuredSelection selection) { if (selection.size() != 1) { return false; }/*from w w w.j a va 2 s . c o m*/ final PendingChange pendingChange = (PendingChange) adaptSelectionFirstElement(PendingChange.class); if (pendingChange.getItemType() != ItemType.FILE) { return false; } if (pendingChange.getChangeType().contains(ChangeType.DELETE) && ViewVersionType.DEFAULT == viewVersionType) { return false; } if (viewVersionType == ViewVersionType.UNMODIFIED) { final String messageFormat = Messages.getString("ViewPendingChangeAction.VersionFormat"); //$NON-NLS-1$ String message = MessageFormat.format(messageFormat, viewVersionType.getText(), Integer.toString(pendingChange.getVersion())); setText(message); message = MessageFormat.format(messageFormat, viewVersionType.getTooltipText(), Integer.toString(pendingChange.getVersion())); setToolTipText(message); } return true; }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.ServerItemTreeControl.java
License:Open Source License
public ServerItemTreeControl(final Composite parent, final int style) { super(parent, style); final FillLayout layout = new FillLayout(); setLayout(layout);//from w ww. j av a2 s . c om viewer = new TreeViewer(this, TREE_STYLES | (style & OPTIONAL_TREE_STYLES)); AutomationIDHelper.setWidgetID(viewer.getTree(), TREE_VIEWER_ID); viewer.setUseHashlookup(true); viewer.setContentProvider(new ContentProvider()); viewer.setLabelProvider(new ServerItemLabelProvider()); viewer.addFilter(new Filter()); viewer.setSorter(new ViewerSorter() { @Override public int compare(final Viewer viewer, final Object e1, final Object e2) { final TypedServerItem node1 = (TypedServerItem) e1; final TypedServerItem node2 = (TypedServerItem) e2; return node1.getName().compareToIgnoreCase(node2.getName()); } }); contextMenu = createContextMenu(); createActions(); contributeActions(); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { final IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.size() == 0) { selectedItems = null; } else { @SuppressWarnings("unchecked") final List<TypedServerItem> l = selection.toList(); selectedItems = l.toArray(new TypedServerItem[l.size()]); } } }); viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(final DoubleClickEvent event) { final TypedServerItem doubleClickedElement = (TypedServerItem) ((IStructuredSelection) event .getSelection()).getFirstElement(); if (ServerItemType.isFolder(doubleClickedElement.getType())) { final boolean expandedState = viewer.getExpandedState(doubleClickedElement); viewer.setExpandedState(doubleClickedElement, !expandedState); } } }); }