本文整理汇总了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();
}
}