List of usage examples for org.eclipse.jface.viewers IStructuredSelection size
public int size();
From source file:com.microsoft.tfs.client.common.ui.views.ChangesetDetailsView.java
License:Open Source License
@Override protected String getStatusLineMessage(final IStructuredSelection selection) { if (changeset == null) { return null; }//ww w.j a va 2 s . c o m final int id = changeset.getChangesetID(); final String owner = changeset.getOwnerDisplayName(); final String date = dateFormat.format(changeset.getDate().getTime()); Change change = null; if (selection.size() >= 1) { final Object element = selection.getFirstElement(); if (element instanceof Change) { change = (Change) element; } } if (change == null) { final String messageFormat = Messages.getString("ChangesetDetailsView.ChangesetStatusFormat"); //$NON-NLS-1$ return MessageFormat.format(messageFormat, Integer.toString(id), owner, date); } else if (selection.size() == 1) { final String status = getStatusLineMessageForChange(change); final String messageFormat = Messages .getString("ChangesetDetailsView.SingleSelectChangesetStatusFormat"); //$NON-NLS-1$ return MessageFormat.format(messageFormat, Integer.toString(id), owner, date, status); } else { final int size = selection.size(); final String messageFormat = Messages .getString("ChangesetDetailsView.MultiSelectChangesetStatusFormat"); //$NON-NLS-1$ return MessageFormat.format(messageFormat, Integer.toString(id), owner, date, size); } }
From source file:com.microsoft.tfs.client.common.ui.views.PendingChangesView.java
License:Open Source License
@Override protected String getStatusLineMessage(final IStructuredSelection selection) { if (selection.size() >= 1) { final Object element = selection.getFirstElement(); if (element instanceof ChangeItem) { if (selection.size() == 1) { return getStatusLineMessageForPendingChange(((ChangeItem) element).getPendingChange()); }//w w w. ja va2s. c o m final String messageFormat = Messages.getString("PendingChangesView.SelectedPendingChangesFormat"); //$NON-NLS-1$ return MessageFormat.format(messageFormat, selection.size()); } else if (element instanceof WorkItemCheckinInfo) { if (selection.size() == 1) { return getStatusLineMessageForWorkItemCheckinInfo((WorkItemCheckinInfo) element); } final String messageFormat = Messages.getString("PendingChangesView.SelectedWorkItemsFormat"); //$NON-NLS-1$ return MessageFormat.format(messageFormat, selection.size()); } else if (element instanceof PolicyFailureData) { if (selection.size() == 1) { return getStatusLineMessageForPolicyFailureData((PolicyFailureData) element); } final String messageFormat = Messages.getString("PendingChangesView.SelectedPolicyFailuresFormat"); //$NON-NLS-1$ return MessageFormat.format(messageFormat, selection.size()); } // TODO: work items, etc return null; } return null; }
From source file:com.microsoft.tfs.client.common.ui.views.ShelvesetDetailsView.java
License:Open Source License
@Override protected String getStatusLineMessage(final IStructuredSelection selection) { if (shelveset == null) { return null; }/*w ww. j a v a 2s. c om*/ final String shelveName = shelveset.getName(); final String date = dateFormat.format(shelveset.getCreationDate().getTime()); final String userName = shelveset.getOwnerDisplayName(); PendingChange change = null; if (selection.size() >= 1) { final Object element = selection.getFirstElement(); if (element instanceof PendingChange) { change = (PendingChange) element; } } if (change == null) { final String messageFormat = Messages.getString("ShelvesetDetailsView.ShelveStatusFormat"); //$NON-NLS-1$ return MessageFormat.format(messageFormat, shelveName, userName, date); } else if (selection.size() == 1) { final String status = getStatusLineMessageForShelvedChange(change); final String messageFormat = Messages.getString("ShelvesetDetailsView.SingleSelectShelveStatusFormat"); //$NON-NLS-1$ return MessageFormat.format(messageFormat, shelveName, userName, date, status); } else { final int size = selection.size(); final String messageFormat = Messages.getString("ShelvesetDetailsView.MultiSelectShelveStatusFormat"); //$NON-NLS-1$ return MessageFormat.format(messageFormat, shelveName, userName, date, size); } }
From source file:com.microsoft.tfs.client.common.ui.wit.qe.BaseResultOptionsControl.java
License:Open Source License
protected void setEnablement(final IStructuredSelection availableColumnsSelection, final IStructuredSelection selectedColumnsSelection, final int[] selectedColumnsSelectionIndices, final int selectedColumnsSize) { selectButton.setEnabled(availableColumnsSelection.size() > 0); deselectButton.setEnabled(selectedColumnsSelection.size() > 0); if (selectedColumnsSelectionIndices.length != 1) { moveUpButton.setEnabled(false);// w w w. ja v a 2s. c o m moveDownButton.setEnabled(false); } else { moveUpButton.setEnabled(selectedColumnsSelectionIndices[0] != 0); moveDownButton.setEnabled(selectedColumnsSelectionIndices[0] != (selectedColumnsSize - 1)); } }
From source file:com.microsoft.tfs.client.common.ui.wit.qe.DisplayFieldsResultOptionsControl.java
License:Open Source License
@Override protected void setEnablement(final IStructuredSelection availableColumnsSelection, final IStructuredSelection selectedColumnsSelection, final int[] selectedColumnsSelectionIndices, final int selectedColumnsSize) { super.setEnablement(availableColumnsSelection, selectedColumnsSelection, selectedColumnsSelectionIndices, selectedColumnsSize);/*from w ww . j a v a 2 s .c om*/ if (selectedColumnsSelection.size() != 1) { selectedDisplayField = null; widthLabel.setEnabled(false); widthText.setEnabled(false); widthText.setText(""); //$NON-NLS-1$ } else { selectedDisplayField = (DisplayField) selectedColumnsSelection.getFirstElement(); widthLabel.setEnabled(true); widthText.setEnabled(true); widthText.setText(String.valueOf(selectedDisplayField.getWidth())); } }
From source file:com.microsoft.tfs.client.common.ui.wit.qe.SortFieldsResultOptionsControl.java
License:Open Source License
@Override protected void setEnablement(final IStructuredSelection availableColumnsSelection, final IStructuredSelection selectedColumnsSelection, final int[] selectedColumnsSelectionIndices, final int selectedColumnsSize) { super.setEnablement(availableColumnsSelection, selectedColumnsSelection, selectedColumnsSelectionIndices, selectedColumnsSize);//from w ww .ja v a 2 s. com if (selectedColumnsSelection.size() != 1) { ascendingButton.setEnabled(false); descendingButton.setEnabled(false); } else { selectedSortField = (SortField) selectedColumnsSelection.getFirstElement(); ascendingButton.setEnabled(!selectedSortField.isAscending()); descendingButton.setEnabled(selectedSortField.isAscending()); } }
From source file:com.microsoft.tfs.client.eclipse.ui.actions.sync.ExternalCompareAction.java
License:Open Source License
protected ExternalTool getExternalToolForSelection() { final IStructuredSelection selection = getStructuredSelection(); if (selection.size() != 1) { return null; }/* w ww . jav a 2 s . c o m*/ final IResource element = (IResource) selection.getFirstElement(); final ExternalToolset compareToolset = ExternalToolset.loadFromMemento( new MementoRepository(DefaultPersistenceStoreProvider.INSTANCE.getConfigurationPersistenceStore()) .load(ExternalToolPreferenceKey.COMPARE_KEY)); return compareToolset.findTool(element.getName()); }
From source file:com.microsoft.tfs.client.eclipse.ui.actions.sync.SynchronizeActionGroup.java
License:Open Source License
public IResource[] getSelection() { final ISelection baseSelection = site.getSelectionProvider().getSelection(); if (!(baseSelection instanceof IStructuredSelection)) { return null; }//from w w w. j av a 2 s .c o m final IStructuredSelection selection = (IStructuredSelection) baseSelection; // exactly one file must be selected for this functionality to exist if (selection == null || selection.size() == 0 || !(selection instanceof IStructuredSelection)) { return null; } final Object[] elements = selection.toArray(); final IResource resources[] = Utils.getResources(elements); return resources; }
From source file:com.mindquarry.desktop.preferences.dialog.FilteredPreferenceDialog.java
License:Open Source License
/** * Save the currently selected node./*from ww w . ja v a 2 s. co m*/ */ private void setSelectedNode() { String storeValue = null; IStructuredSelection selection = (IStructuredSelection) getTreeViewer().getSelection(); if (selection.size() == 1) { IPreferenceNode node = (IPreferenceNode) selection.getFirstElement(); storeValue = node.getId(); } setSelectedNodePreference(storeValue); }
From source file:com.minres.scviewer.e4.application.handlers.AddWaveformHandler.java
License:Open Source License
@CanExecute public boolean canExecute(@Named(PARAM_WHERE_ID) String where, @Named(PARAM_ALL_ID) String all, EPartService partService,/*from w w w . j a v a2 s . co m*/ @Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection) { if (designBrowser == null) designBrowser = getListPart(partService); if (designBrowser == null || designBrowser.getActiveWaveformViewerPart() == null) return false; Boolean before = "before".equalsIgnoreCase(where); if ("true".equalsIgnoreCase(all)) return designBrowser.getFilteredChildren().length > 0 && (!before || ((IStructuredSelection) designBrowser.getActiveWaveformViewerPart().getSelection()) .size() > 0); else return selection.size() > 0 && (!before || ((IStructuredSelection) designBrowser.getActiveWaveformViewerPart().getSelection()) .size() > 0); }