Example usage for org.eclipse.jface.viewers IStructuredSelection isEmpty

List of usage examples for org.eclipse.jface.viewers IStructuredSelection isEmpty

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IStructuredSelection isEmpty.

Prototype

public boolean isEmpty();

Source Link

Document

Returns whether this selection is empty.

Usage

From source file:com.hydra.project.myplugin_nebula.xviewer.customize.dialog.CustomizationDataSelectionDialog.java

License:Open Source License

private CustomizeData getSelectedCustomizeData() {
    IStructuredSelection selection = (IStructuredSelection) getTableViewer().getSelection();
    if (selection.isEmpty()) {
        return null;
    }//from  w w w .  jav  a  2  s .  c  o  m
    Iterator<?> i = selection.iterator();
    return (CustomizeData) i.next();
}

From source file:com.hydra.project.myplugin_nebula.xviewer.customize.dialog.XViewerCustomizeDialog.java

License:Open Source License

public void performVisibleTableDragOver(DropTargetEvent event) {
    if (!TextTransfer.getInstance().isSupportedType(event.currentDataType)) {
        event.detail = DND.DROP_NONE;//from  w w w.ja  v  a2s  .c  o  m
        return;
    }

    Tree tree = visibleColTable.getViewer().getTree();
    TreeItem dragOverTreeItem = tree.getItem(visibleColTable.getViewer().getTree().toControl(event.x, event.y));
    if (dragOverTreeItem == null) {
        return;
    }

    event.feedback = DND.FEEDBACK_EXPAND;
    event.detail = DND.DROP_NONE;

    IStructuredSelection selectedItem = (IStructuredSelection) visibleColTable.getViewer().getSelection();
    if (selectedItem == null || selectedItem.isEmpty()) {
        selectedItem = (IStructuredSelection) hiddenColTable.getViewer().getSelection();
    }
    if (selectedItem == null) {
        return;
    }
    Object obj = selectedItem.getFirstElement();
    if (obj instanceof XViewerColumn) {
        if (isFeedbackAfter) {
            event.feedback = DND.FEEDBACK_INSERT_AFTER;
        } else {
            event.feedback = DND.FEEDBACK_INSERT_BEFORE;
        }
        event.detail = DND.DROP_MOVE;
    }
}

From source file:com.hydra.project.myplugin_nebula.xviewer.customize.dialog.XViewerCustomizeDialog.java

License:Open Source License

private CustomizeData getCustTableSelection() {
    IStructuredSelection selection = (IStructuredSelection) custTable.getViewer().getSelection();
    if (selection.isEmpty()) {
        return null;
    }//from www  . j a  v  a  2  s.c  om
    Iterator<?> i = selection.iterator();
    return (CustomizeData) i.next();
}

From source file:com.hydra.project.myplugin_nebula.xviewer.customize.dialog.XViewerCustomizeDialog.java

License:Open Source License

private List<XViewerColumn> getTableSelection(TreeViewer xColTableViewer) {
    List<XViewerColumn> xCols = new ArrayList<XViewerColumn>();
    IStructuredSelection selection = (IStructuredSelection) xColTableViewer.getSelection();
    if (selection.isEmpty()) {
        return null;
    }//from  w  w w. j av a2  s.  c  o  m
    Iterator<?> i = selection.iterator();
    while (i.hasNext()) {
        xCols.add((XViewerColumn) i.next());
    }
    return xCols;
}

From source file:com.ibm.etools.mft.conversion.esb.extension.render.CompleteToDo.java

License:Open Source License

@Override
public void selectionChanged(IAction action, ISelection selection) {
    IStructuredSelection s = (IStructuredSelection) selection;
    if (!s.isEmpty() && s.size() == 1 && (s.getFirstElement() instanceof TodoEntry)) {
        selected = (TodoEntry) s.getFirstElement();
        action.setEnabled(!selected.isCompleted());
    } else {//from   ww  w. j a  v  a 2 s.  c  o  m
        action.setEnabled(false);
    }
}

From source file:com.ibm.etools.mft.conversion.esb.extension.render.ReopenToDo.java

License:Open Source License

@Override
public void selectionChanged(IAction action, ISelection selection) {
    IStructuredSelection s = (IStructuredSelection) selection;
    if (!s.isEmpty() && s.size() == 1 && (s.getFirstElement() instanceof TodoEntry)) {
        selected = (TodoEntry) s.getFirstElement();
        action.setEnabled(selected.isCompleted());
    } else {//from w  w  w .ja va  2  s .  c om
        action.setEnabled(false);
    }
}

From source file:com.ibm.research.tours.actions.TourElementActionDelegate.java

License:Open Source License

public void selectionChanged(IAction action, ISelection selection) {
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    fSelectedElements = new ArrayList<ITourElement>();

    if (!structuredSelection.isEmpty()) {
        Object[] selectionArray = structuredSelection.toArray();

        for (Object o : selectionArray) {
            if (o instanceof ITourElement)
                fSelectedElements.add((ITourElement) o);
        }/*from   w  w  w .  ja v a  2 s .  c om*/
    }
}

From source file:com.ibm.research.tours.dnd.PaletteDragListener.java

License:Open Source License

public void dragStart(DragSourceEvent event) {
    fEntries = new ArrayList<IPaletteEntry>();

    IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();

    if (!selection.isEmpty()) {
        for (Object o : selection.toArray())
            if (o instanceof IPaletteEntry)
                fEntries.add((IPaletteEntry) o);
    } else {//from  w w  w .  jav  a 2 s . c o  m
        event.doit = false;
    }
}

From source file:com.ibm.research.tours.editors.TourTreeSelectionChangedListener.java

License:Open Source License

public void selectionChanged(SelectionChangedEvent event) {
    IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();

    performSave();/*from  www .  ja v a 2 s  .com*/
    flastSelectedElement = null;

    if (!structuredSelection.isEmpty()) {
        Object[] selected = structuredSelection.toArray();

        if (selected.length == 1 && selected[0] instanceof ITourElement) {
            flastSelectedElement = (ITourElement) selected[0];
            fEditor.getNotesText().setText(flastSelectedElement.getNotes());
            fEditor.getNotesText().setEditable(true);
            return;
        }
    }

    fEditor.getNotesText().setText("");
    fEditor.getNotesText().setEditable(false);
    flastSelectedElement = null;
}

From source file:com.ibm.research.tours.fx.dialogs.SelectPerspectiveDialog.java

License:Open Source License

/**
 * Update the selection object./* w  w  w  .  ja v  a 2s  .  c  o m*/
 */
protected void updateSelection(SelectionChangedEvent event) {
    perspDesc = null;
    IStructuredSelection sel = (IStructuredSelection) event.getSelection();
    if (!sel.isEmpty()) {
        Object obj = sel.getFirstElement();
        if (obj instanceof IPerspectiveDescriptor) {
            perspDesc = (IPerspectiveDescriptor) obj;
        }
    }
}