本文整理汇总了Java中org.eclipse.jface.viewers.IStructuredSelection.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java IStructuredSelection.isEmpty方法的具体用法?Java IStructuredSelection.isEmpty怎么用?Java IStructuredSelection.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.viewers.IStructuredSelection
的用法示例。
在下文中一共展示了IStructuredSelection.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
@Override
protected Object execute(SchemaRegistryView registryView, AvroSchemaEditor editor, ExecutionEvent event) {
IStructuredSelection selection = (IStructuredSelection) registryView.getSelection();
if (!selection.isEmpty()) {
Object element = selection.getFirstElement();
if (element instanceof AvroNode) {
AvroNode node = (AvroNode) element;
SchemaViewer masterViewer = editor.getContentPart().getSchemaViewer(AvroContext.Kind.MASTER);
masterViewer.setSelection(new StructuredSelection(node));
masterViewer.reveal(node);
}
}
return null;
}
示例2: 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());
}
}
示例3: 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;
}
}
示例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: updateToolbarOnSelectionChanged
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
protected void updateToolbarOnSelectionChanged(ISelection selection) {
IStructuredSelection sel = (IStructuredSelection) selection;
NSNode selectedNode = null;
if (sel.isEmpty()) {
selectedNode = schemaRegistry.getNameSpaceTree();
} else {
Object element = sel.getFirstElement();
if (element instanceof NSNode) {
selectedNode = (NSNode) element;
}
}
for (NameSpaceAction action : actions) {
action.setNSNode(selectedNode);
}
toolbarMgr.update(true);
}
示例6: getItems
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
/**
* Get all items from the selection
*
* @return a data of all selected items
*/
protected Collection<Item> getItems ()
{
final Collection<Item> result = new LinkedList<Item> ();
final IStructuredSelection sel = getSelection ();
if ( sel != null && !sel.isEmpty () )
{
for ( final Iterator<?> i = sel.iterator (); i.hasNext (); )
{
final Object o = i.next ();
final Item holder = AdapterHelper.adapt ( o, Item.class );
if ( holder != null )
{
result.add ( holder );
}
}
}
return result;
}
示例7: getItems
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
protected Collection<ItemWrapper> getItems ()
{
final Collection<ItemWrapper> result = new LinkedList<ItemWrapper> ();
final IStructuredSelection sel = getSelection ();
if ( sel != null && !sel.isEmpty () )
{
for ( final Iterator<?> i = sel.iterator (); i.hasNext (); )
{
final Object o = i.next ();
final ItemWrapper item = AdapterHelper.adapt ( o, ItemWrapper.class );
if ( item != null )
{
result.add ( item );
}
}
}
return result;
}
示例8: getQueries
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
protected Collection<QueryBuffer> getQueries ()
{
final Collection<QueryBuffer> result = new LinkedList<QueryBuffer> ();
final IStructuredSelection sel = getSelection ();
if ( sel != null && !sel.isEmpty () )
{
for ( final Iterator<?> i = sel.iterator (); i.hasNext (); )
{
final Object o = i.next ();
final QueryBuffer item = AdapterHelper.adapt ( o, QueryBuffer.class );
if ( item != null )
{
result.add ( item );
}
}
}
return result;
}
示例9: 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;
}
示例10: init
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
@Override
public void init(final IWorkbench workbench, final IStructuredSelection selection) {
if (selection != null && !selection.isEmpty()) {
final Object firstElement = selection.getFirstElement();
if (firstElement instanceof WorkingSet) {
editedWorkingSet = (WorkingSet) firstElement;
}
}
}
示例11: 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);
}
}
}
示例12: fillContextMenu
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
private void fillContextMenu(IMenuManager manager) {
IStructuredSelection structuredSelection = (IStructuredSelection) _TreeViewer.getSelection();
boolean emptySelection = structuredSelection == null || structuredSelection.isEmpty();
manager.add(_NewJmxConnectionAction);
if (emptySelection) {
return;
}
manager.add(new Separator());
manager.add(_OpenAction);
manager.add(new Separator());
if (_DeleteAction.isEnabled()) {
manager.add(_DeleteAction);
manager.add(new Separator());
}
manager.add(_RefreshAction);
manager.add(new Separator());
_DrillDownAdapter.addNavigationActions(manager);
// Other plug-ins can contribute there actions here
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
示例13: dragStart
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
@Override
public void dragStart ( final DragSourceEvent event )
{
event.doit = false;
if ( ! ( this.viewer.getSelection () instanceof IStructuredSelection ) )
{
return;
}
final IStructuredSelection selection = (IStructuredSelection)this.viewer.getSelection ();
if ( selection.isEmpty () )
{
return;
}
for ( final Iterator<?> i = selection.iterator (); i.hasNext (); )
{
final Object o = i.next ();
if ( ! ( o instanceof ListEntry ) )
{
return;
}
}
LocalSelectionTransfer.getTransfer ().setSelection ( this.viewer.getSelection () );
event.doit = true;
}
示例14: selectionChanged
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) cmbDbNames.getSelection();
if (sel.isEmpty()) {
return;
}
Object selected = sel.getFirstElement();
boolean revertSelection;
if (selected instanceof DbInfo || selected instanceof File) {
previous = sel;
revertSelection = false;
} else if (selected instanceof LoadFileElement) {
LoadFileElement loadEl = (LoadFileElement) selected;
File dumpFile = chooseDbSource(getShell(), prefStore, loadEl.loadDir);
if (dumpFile != null) {
loadStore(new StructuredSelection(dumpFile));
revertSelection = false;
} else {
revertSelection = true;
}
} else {
// string or some other "unselectable" selection
revertSelection = true;
}
if (revertSelection) {
cmbDbNames.setSelection(previous);
}
}
示例15: getCurrentNodeConfig
import org.eclipse.jface.viewers.IStructuredSelection; //导入方法依赖的package包/类
private NodeImageConfig getCurrentNodeConfig(){
IStructuredSelection selection=(IStructuredSelection)tableViewer.getSelection();
if(selection.isEmpty()){
MessageDialog.openError(getShell(), "操作错误", "请先选中一个要操作的节点!");
return null;
}
return (NodeImageConfig)selection.getFirstElement();
}