本文整理匯總了Java中org.eclipse.jface.viewers.IStructuredSelection.toArray方法的典型用法代碼示例。如果您正苦於以下問題:Java IStructuredSelection.toArray方法的具體用法?Java IStructuredSelection.toArray怎麽用?Java IStructuredSelection.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.viewers.IStructuredSelection
的用法示例。
在下文中一共展示了IStructuredSelection.toArray方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: performSelectionChanged
import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
private void performSelectionChanged(final IStructuredSelection structuredSelection) {
final Object[] array = structuredSelection.toArray();
final ArrayList<IProject> openProjects = new ArrayList<>();
final int selectionStatus = evaluateSelection(array, openProjects);
final StructuredSelection sel = new StructuredSelection(openProjects);
// If only projects are selected, disable this action group, as all of
// the project-related contributions will be provided by default action providers
enableContribution = (selectionStatus & NON_PROJECT_SELECTED) != 0;
openAction.setEnabled(hasClosedProjectsInWorkspace());
enableOpenInContextMenu = (selectionStatus & CLOSED_PROJECTS_SELECTED) != 0
|| (selectionStatus == 0 && array.length == 0 && hasClosedProjectsInWorkspace());
closeAction.selectionChanged(sel);
closeUnrelatedAction.selectionChanged(sel);
}
示例2: updateSelection
import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
@Override
public boolean updateSelection(IStructuredSelection selection) {
if (selection == null || selection.isEmpty()) {
return false;
}
final Object[] selectedElements = selection.toArray();
final IProject[] selectedProjects = Arrays2.filter(selectedElements, IProject.class);
// only enable this action for project-only selections
if (selectedElements.length != selectedProjects.length) {
return false;
}
// also check whether the active manager is {@link ManualAssociationAwareWorkingSetManager}
if (!(broker.getActiveManager() instanceof ManualAssociationAwareWorkingSetManager)) {
return false;
} else {
return true;
}
}
示例3: run
import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
@Override
public void run() {
final IStructuredSelection selection = getStructuredSelection();
final Object[] selectionElements = selection.toArray();
final WorkingSet[] selectedWorkingSets = Arrays2.filter(selectionElements, WorkingSet.class);
final WorkingSetManager manager = selectedWorkingSets[0].getWorkingSetManager();
final WorkingSetDiffBuilder builder = new WorkingSetDiffBuilder(manager);
final WorkingSet[] newAllItems = manager.getAllWorkingSets();
final List<WorkingSet> newItems = newArrayList(manager.getWorkingSets());
for (final WorkingSet toHide : selectedWorkingSets) {
newItems.remove(toHide);
}
final Diff<WorkingSet> diff = builder.build(Iterables.toArray(newItems, WorkingSet.class), newAllItems);
if (!diff.isEmpty()) {
manager.updateState(diff);
manager.saveState(new NullProgressMonitor());
manager.getWorkingSetManagerBroker().refreshNavigator();
}
}
示例4: updateSelection
import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
@Override
@VisibleForTesting
public boolean updateSelection(IStructuredSelection selection) {
if (selection == null || selection.isEmpty()) {
return false;
}
final Object[] selectionElements = selection.toArray();
final WorkingSet[] selectedWorkingSets = Arrays2.filter(selectionElements, WorkingSet.class);
if (selectionElements.length != selectedWorkingSets.length) {
return false;
}
final WorkingSetManager manager = selectedWorkingSets[0].getWorkingSetManager();
// Cannot hide all working sets.
return manager.getWorkingSets().length > selectedWorkingSets.length;
}
示例5: getSelectedTreeObjects
import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
public TreeObject[] getSelectedTreeObjects() {
TreeObject[] treeObjects = null;
ISelection selection = viewer.getSelection();
if (!selection.isEmpty()) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object[] treeArray = structuredSelection.toArray();
treeObjects = new TreeObject[structuredSelection.size()];
for (int i=0; i<treeObjects.length; i++)
treeObjects[i] = (TreeObject)treeArray[i];
}
return treeObjects;
}
示例6: dragSetData
import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
@Override
public void dragSetData(DragSourceEvent event) {
if (schemaViewer.getSelection() instanceof IStructuredSelection) {
LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
IStructuredSelection ss = (IStructuredSelection) schemaViewer.getSelection();
Object[] objects = ss.toArray();
transfer.setSelection(new StructuredSelection(objects));
event.data = transfer.getSelection();
}
}