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

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

Introduction

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

Prototype

@Override
    public boolean isEmpty() 

Source Link

Usage

From source file:org2.eclipse.php.internal.debug.ui.views.DebugViewHelper.java

License:Open Source License

public IPHPDebugTarget getSelectionElement(ISelection selection) {
    IDebugElement element = getAdaptableElement();
    if (element == null) {
        if (selection != null) {
            if (selection instanceof StructuredSelection) {
                StructuredSelection sSelection = (StructuredSelection) selection;
                if (!sSelection.isEmpty()) {
                    Object first = sSelection.getFirstElement();
                    if (first instanceof IDebugElement)
                        element = (IDebugElement) first;
                }/*from   w  w  w.j ava  2s  .  c o m*/
            }
        }
    }
    IPHPDebugTarget target = getDebugTarget(element);
    // If target is null try to get target from the last debug process to run
    if (target == null) {
        IProcess process = DebugUITools.getCurrentProcess();
        if (process != null) {
            if (process instanceof PHPProcess) {
                target = (IPHPDebugTarget) ((PHPProcess) process).getDebugTarget();
            }
        }
    }

    return target;
}

From source file:rocks.inspectit.ui.rcp.preferences.page.CmrRepositoryPreferencePage.java

/**
 * Updates the state of the remove and license info buttons depending on the current table
 * selection./*w ww  . ja  v  a  2  s  .c o  m*/
 */
private void updateButtonsState() {
    StructuredSelection structuredSelection = (StructuredSelection) tableViewer.getSelection();
    if (structuredSelection.isEmpty()) {
        removeButton.setEnabled(false);
        manageLabelsButton.setEnabled(false);
    } else {
        removeButton.setEnabled(true);
        if ((structuredSelection.size() == 1)
                && (((CmrRepositoryDefinition) structuredSelection.getFirstElement())
                        .getOnlineStatus() == OnlineStatus.ONLINE)) {
            manageLabelsButton.setEnabled(true);
        } else {
            manageLabelsButton.setEnabled(false);
        }
    }
}

From source file:sernet.gs.ui.rcp.main.bsi.dialogs.AccessControlEditDialog.java

License:Open Source License

protected Set<Permission> getSelectedPermissions() {
    Set<Permission> selectedPermission = new HashSet<Permission>();
    StructuredSelection selection = (StructuredSelection) viewer.getSelection();
    if (selection != null && !selection.isEmpty()) {
        for (Iterator<Permission> iterator = selection.iterator(); iterator.hasNext();) {
            selectedPermission.add(iterator.next());
        }//from w w w  . jav  a2 s  .  c o m
    }
    return selectedPermission;
}

From source file:sernet.verinice.iso27k.rcp.LdapImportDialog.java

License:Open Source License

@SuppressWarnings("unchecked")
protected void removePerson() {
    StructuredSelection selection = (StructuredSelection) viewer.getSelection();
    if (selection != null && !selection.isEmpty()) {
        for (Iterator<PersonInfo> iterator = selection.iterator(); iterator.hasNext();) {
            PersonInfo permission = iterator.next();
            this.personSet.remove(permission);
        }// w w  w  . j a  v  a  2  s  .co m
        try {
            refreshTable();
        } catch (Exception t) {
            LOG.error("Error while setting table data", t); //$NON-NLS-1$
        }
    }
}

From source file:sernet.verinice.rcp.search.SearchView.java

License:Open Source License

private void doCsvExport() throws CsvExportException {
    StructuredSelection selection = ((StructuredSelection) resultsByTypeCombo.getSelection());
    if (selection != null && !selection.isEmpty()) {
        VeriniceSearchResultTable result = (VeriniceSearchResultTable) selection.getFirstElement();
        CsvExportHandler handler = new CsvExportHandler(result, getShell());
        handler.run();/*from w  ww  .jav a  2s  .c o m*/
    }
}

From source file:ummisco.gama.ui.navigator.GamaNavigator.java

@Override
public void selectReveal(final ISelection selection) {
    VirtualContent<?> current;/*from  www  .  j  a v  a2s  .  com*/
    final Object o1 = getCommonViewer().getStructuredSelection().getFirstElement();
    if (o1 instanceof IResource) {
        current = NavigatorRoot.getInstance().getManager().findWrappedInstanceOf(o1);
    } else {
        current = (VirtualContent<?>) getCommonViewer().getStructuredSelection().getFirstElement();
    }
    StructuredSelection newSelection = new StructuredSelection();
    if (selection instanceof StructuredSelection) {
        newSelection = (StructuredSelection) selection;
        Object o = ((StructuredSelection) selection).getFirstElement();
        if (o instanceof IResource) {
            o = NavigatorRoot.getInstance().getManager().findWrappedInstanceOf(o);
            if (o != null) {
                newSelection = new StructuredSelection(o);
            }
        }
    }
    if (current instanceof WrappedSyntacticContent) {
        final Object o = newSelection.getFirstElement();
        if (o instanceof WrappedFile) {
            if (((VirtualContent<?>) current).isContainedIn((VirtualContent<?>) o)) {
                getCommonViewer().setSelection(new StructuredSelection(current));
            }
            return;
        }
    }
    if (!newSelection.isEmpty()) {
        super.selectReveal(newSelection);
    }
}