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.iw.plugins.spindle.editors.AbstractPropertySheetEditorSection.java

License:Mozilla Public License

protected void handleEdit() {
    IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
    if (!selection.isEmpty()) {
        Object object = ((IStructuredSelection) selection).getFirstElement();
        fireSelectionNotification(object);
        setPageSelection();//  w  w  w.  j a  v  a2  s  . co  m
        pAction.run();
    }
}

From source file:com.iw.plugins.spindle.editors.AbstractPropertySheetEditorSection.java

License:Mozilla Public License

public boolean isSelected(Object object) {
    IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
    if (selection == null || selection.isEmpty()) {
        return false;
    }// w w w  .j  a v a 2 s.c  o m
    return object == selection.getFirstElement();
}

From source file:com.iw.plugins.spindle.editors.spec.outline.TapestryOutlinePage.java

License:Mozilla Public License

public void createControl(Composite parent) {
    fTree = new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    treeViewer = new TreeViewer(fTree);
    treeViewer.addSelectionChangedListener(this);
    treeViewer.setContentProvider(createContentProvider());
    treeViewer.setLabelProvider(createLabelProvider());
    treeViewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
    treeViewer.setUseHashlookup(false);//from  w ww .  j a v  a2  s  .c o m
    treeViewer.setSorter(fCurrentSorter);
    treeViewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
            if (!selection.isEmpty())
                fireSelectionChanged(new DoubleClickSelection(selection.getFirstElement()));
        }
    });
    UIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            adaptToPreferenceChange(event);
        }
    });
    setInput(fSavedInput);
}

From source file:com.iw.plugins.spindle.editors.spec.outline.XMLOutlinePage.java

License:Mozilla Public License

public void createControl(Composite parent) {
    fTree = new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    treeViewer = new TreeViewer(fTree);
    treeViewer.addSelectionChangedListener(this);
    treeViewer.setContentProvider(createContentProvider());
    treeViewer.setLabelProvider(createLabelProvider());
    treeViewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
    treeViewer.setUseHashlookup(true);/*w  w w  .  j av  a  2 s . co  m*/
    treeViewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
            if (!selection.isEmpty())
                fireSelectionChanged(new DoubleClickSelection(selection.getFirstElement()));
        }
    });
    setInput(fRoot);
}

From source file:com.iw.plugins.spindle.editors.SpindleFormOutlinePage.java

License:Mozilla Public License

/**
 * Method fillContextMenu.//from   w w  w .  ja  v  a 2 s  .com
 * @param mng
 */
private void fillContextMenu(IMenuManager mng) {

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

    if (!selection.isEmpty()) {

        Object item = selection.getFirstElement();
        if (item instanceof Holder) {
            SpindleFormPage page = (SpindleFormPage) getParentPage(item);
            if (page != null) {

                page.fillContextMenu(mng);

            }
        }
    }

}

From source file:com.iw.plugins.spindle.html.HTMLContentOutlinePage.java

License:Mozilla Public License

private void fillContextMenu(IMenuManager manager) {
    TreeViewer viewer = (TreeViewer) getTreeViewer();
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();

    IFile file = Utils.findRelatedComponent(documentFile);

    IStructuredSelection canCreateSelection = filterSelection(file, selection);

    if (canCreateSelection.isEmpty() && selection.size() == 1) {

        ILabelProvider provider = (ILabelProvider) getTreeViewer().getLabelProvider();

        openAction.configure(file, provider.getText(selection.getFirstElement()));
        manager.add(openAction);//from www .j a v  a  2  s.co  m

    } else {

        createAction.configure(file, canCreateSelection);
        manager.add(createAction);
    }

}

From source file:com.iw.plugins.spindle.html.HTMLContentOutlinePage.java

License:Mozilla Public License

private IStructuredSelection filterSelection(IFile file, IStructuredSelection selection) {

    if (selection == null || selection.isEmpty()) {
        return selection;
    }//from ww w.  j  av  a2s.co  m

    if (file == null) {

        return StructuredSelection.EMPTY;
    }

    TapestryComponentModel model = editor.getComponentModel(file);

    if (model == null || !model.isLoaded()) {

        return StructuredSelection.EMPTY;

    }

    ILabelProvider provider = (ILabelProvider) getTreeViewer().getLabelProvider();

    List collected = new ArrayList();

    for (Iterator iter = selection.iterator(); iter.hasNext();) {
        ITypedRegion element = (ITypedRegion) iter.next();
        String jwcId = provider.getText(element);
        if (jwcId.startsWith("$")) {
            continue;
        }

        if (editor.alreadyHasJWCID(jwcId, model)) {
            continue;
        }
        collected.add(jwcId);

    }

    return new StructuredSelection(collected);

}

From source file:com.iw.plugins.spindle.refactor.components.RefactorComponentAliasWizard.java

License:Mozilla Public License

public void selectionChanged(SelectionChangedEvent event) {

    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    canFinish = !selection.isEmpty() && !oldName.equals(firstPage.getNewName());

    getContainer().updateButtons();/*from  www .jav  a  2s . c  om*/

}

From source file:com.iw.plugins.spindle.ui.ChooseFromNamespaceWidget.java

License:Mozilla Public License

public ISelection getSelection() {

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

    if (selection == null || selection.isEmpty()) {

        return selection;

    }//  w  w w  . ja  v  a2 s  . c o  m

    Object[] selectionData = selection.toArray();

    resultString = (String) selectionData[0];
    Object dataNamespace = selectionData[1];

    if (dataNamespace instanceof INamespaceFragment) {

        resultNamespace = (INamespaceFragment) selectionData[1];

    } else {

        resultNamespace = null;
    }

    if (resultString == null) {

        return new StructuredSelection();

    }

    return new StructuredSelection(getResultPath());
}

From source file:com.iw.plugins.spindle.ui.ChooseWorkspaceModelWidget.java

License:Mozilla Public License

public ISelection getSelection() {

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

    if (selection == null || selection.isEmpty()) {

        return selection;

    }/*from www . j  a v a 2s. co m*/

    Object[] selectionData = selection.toArray();

    IStorage selectedStorage = (IStorage) selectionData[0];
    IPackageFragment selectedPackage = (IPackageFragment) selectionData[1];

    resultString = null;
    resultPackage = null;

    if (selectedStorage != null) {

        resultString = selectedStorage.getName();
    }

    if (selectedPackage != null) {

        resultPackage = selectedPackage;

    }

    if (resultString == null) {

        return new StructuredSelection();

    }

    return new StructuredSelection(resultString);
}