本文整理汇总了Java中org.eclipse.jface.viewers.IStructuredSelection.size方法的典型用法代码示例。如果您正苦于以下问题:Java IStructuredSelection.size方法的具体用法?Java IStructuredSelection.size怎么用?Java IStructuredSelection.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.viewers.IStructuredSelection
的用法示例。
在下文中一共展示了IStructuredSelection.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateButtonAvailability
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
/**
* Updates the modify buttons' enabled state based on the current selection.
*/
private void updateButtonAvailability() {
final IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
final boolean hasSelection = !selection.isEmpty();
final boolean hasSingleSelection = selection.size() == 1;
if (manager instanceof MutableWorkingSetManager) {
removeButton.setEnabled(hasSelection && containsNoBuiltInWorkingSets(selection));
editButton.setEnabled(hasSingleSelection && containsNoBuiltInWorkingSets(selection));
}
if (upButton != null) {
upButton.setEnabled(canMoveUp());
}
if (downButton != null) {
downButton.setEnabled(canMoveDown());
}
}
示例2: isEnabled
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
@Override
public boolean isEnabled() {
ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
if(selection instanceof IStructuredSelection) {
IStructuredSelection s = (IStructuredSelection) selection;
if(s.size() == 1) {
Object e = s.getFirstElement();
try {
return e instanceof IProject && ((IProject) e).hasNature("org.eclipse.jdt.internal.core.JavaProject");
} catch (CoreException e1) {
return false;
}
}
}
return false;
}
示例3: drop
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
@Override
public void drop(DropTargetEvent event) {
IStructuredSelection structuredSelection = (IStructuredSelection) LocalSelectionTransfer
.getTransfer().getSelection();
if (structuredSelection.size() == 1) {
AvroNode sourceNode = (AvroNode) structuredSelection.getFirstElement();
TreeItem item = (TreeItem) event.item;
if (item != null) {
AvroNode targetNode = nodeConverter.convertToAvroNode(item.getData());
dropPolicy.drop(sourceNode, targetNode, position);
}
}
}
示例4: isMultiApplyAttempt
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
/**
* Returns true iff the user is trying to apply quick fixes to multiple issues / markers at once.
* <p>
* Implementation note: this method assumes that the entire code of class MarkerResolutionGenerator is only invoked
* if quick fixes are initiated via the Problems view (not if they are initiated from within the editor). Therefore,
* this method simply checks whether the Problems view contains a selection of multiple, i.e. two or more, elements.
*/
private boolean isMultiApplyAttempt() {
if (workbench == null)
return false;
try {
// get the current selection in the problems view
final ISelectionService service = workbench.getActiveWorkbenchWindow().getSelectionService();
final IStructuredSelection sel = (IStructuredSelection) service.getSelection(IPageLayout.ID_PROBLEM_VIEW);
return sel != null && sel.size() >= 2;
} catch (Exception e) {
return false;
}
}
示例5: canEnable
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
private boolean canEnable(final IStructuredSelection sel) {
if (sel.size() == 0) {
return true;
}
final List<?> list = sel.toList();
for (final Iterator<?> iterator = list.iterator(); iterator.hasNext(); /**/) {
if (!isNewTarget(iterator.next())) {
return false;
}
}
return true;
}
示例6: getSingleSelectedEntry
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
protected ListEntry getSingleSelectedEntry() {
final IStructuredSelection sel = (IStructuredSelection) listViewer.getSelection();
final Object obj = sel.size() == 1 ? sel.getFirstElement() : null;
if (obj instanceof ListEntry)
return (ListEntry) obj;
return null;
}
示例7: getSingleSelectedEntry
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
/** returns currently selected entry or null */
protected VisualisationSnapshot getSingleSelectedEntry() {
final IStructuredSelection sel = (IStructuredSelection) listViewer.getSelection();
final Object obj = sel.size() == 1 ? sel.getFirstElement() : null;
if (obj instanceof VisualisationSnapshot)
return (VisualisationSnapshot) obj;
return null;
}
示例8: 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;
}
示例9: getObject
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private Object getObject(Object objects, boolean multiple[]) {
Object object = null;
if (objects instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) objects;
object = selection.getFirstElement();
if (selection.size() == 1) {
multiple[0] = false;
return object;
}
multiple[0] = true;
Class firstClass = typeMapper.mapType(object);
if (selection.size() > 1) {
for (Iterator i = selection.iterator(); i.hasNext();) {
Object next = i.next();
Class nextClass = typeMapper.mapType(next);
if (!nextClass.equals(firstClass)) {
multiple[0] = false;
object = null;
break;
}
}
}
} else {
multiple[0] = false;
object = objects;
}
return object;
}
示例10: initialize
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
/**
* Tests if the current workbench selection is a suitable container to use.
*/
private void initialize() {
if (selection != null && selection.isEmpty() == false
&& selection instanceof IStructuredSelection) {
IStructuredSelection ssel = (IStructuredSelection) selection;
if (ssel.size() > 1)
return;
Object obj = ssel.getFirstElement();
}
fileText.setText("Example.java");
fileText.setSelection(0, "Example.java".length()-".java".length());
}
示例11: initialize
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
/**
* Tests if the current workbench selection is a suitable container to use.
*/
private void initialize() {
if (selection != null && selection.isEmpty() == false
&& selection instanceof IStructuredSelection) {
IStructuredSelection ssel = (IStructuredSelection) selection;
if (ssel.size() > 1)
return;
Object obj = ssel.getFirstElement();
}
fileText.setText("pack");
fileText.setSelection(0, "pack".length());
}
示例12: getSelectedSchemaNode
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
protected SchemaNode getSelectedSchemaNode(SchemaViewer viewer, AvroContext context) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (!selection.isEmpty() && selection.size() == 1) {
AvroNode node = (AvroNode) selection.getFirstElement();
SchemaNodeRegistry schemaNodeRegistry = context.getSchemaNodeRegistry();
SchemaViewerNodeConverter converter = new SchemaViewerNodeConverter(schemaNodeRegistry);
return converter.convertToSchemaNode(node);
}
return null;
}
示例13: doExecute
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
@Override
protected void doExecute(ExecutionEvent event, AvroSchemaEditor schemaEditor, AvroContext context) {
SchemaViewer schemaViewer = schemaEditor.getContentPart().getSchemaViewer(context.getKind());
IStructuredSelection selection = (IStructuredSelection) schemaViewer.getSelection();
if (!selection.isEmpty() && selection.size() == 1) {
AvroNode node = (AvroNode) selection.getFirstElement();
if (isNavigableNode(node)) {
schemaViewer.setContent(node);
}
}
}
示例14: getSelectionList
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
private List<?> getSelectionList(IStructuredSelection selection) {
return (selection != null && selection.size() > 1) ? selection.toList()
: Collections.emptyList();
}
示例15: test
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
@Override
protected boolean test(Object receiver, String property, Object[] args, Object expectedValue, AvroSchemaEditor editor) {
if (PROPERTY.equals(property)) {
if (receiver instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) receiver;
if (selection.size() == 1) {
AvroNode node = (AvroNode) selection.getFirstElement();
NodeType[] types = EditUtils.getAddableNodeTypes(node, editor.getServiceProvider().getService(AvroSchemaController.class));
return types.length > 0;
}
}
}
return false;
}