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

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

Introduction

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

Prototype

public int size();

Source Link

Document

Returns the number of elements selected in this selection.

Usage

From source file:com.siteview.mde.internal.ui.editor.product.FeatureSection.java

License:Open Source License

protected void fillContextMenu(IMenuManager manager) {
    IStructuredSelection ssel = (IStructuredSelection) fFeatureTable.getSelection();
    if (ssel == null)
        return;/*from  ww  w  .java2s.com*/

    Action openAction = new Action(MDEUIMessages.Product_FeatureSection_open) {
        public void run() {
            handleDoubleClick((IStructuredSelection) fFeatureTable.getSelection());
        }
    };
    openAction.setEnabled(isEditable() && ssel.size() == 1);
    manager.add(openAction);

    manager.add(new Separator());

    Action removeAction = new Action(MDEUIMessages.Product_FeatureSection_remove) {
        public void run() {
            handleDelete();
        }
    };
    removeAction.setEnabled(isEditable() && ssel.size() > 0);
    manager.add(removeAction);

    Action removeAll = new Action(MDEUIMessages.FeatureSection_removeAll) {
        public void run() {
            handleRemoveAll();
        }
    };
    removeAll.setEnabled(isEditable());
    manager.add(removeAll);

    manager.add(new Separator());

    getPage().getMDEEditor().getContributor().contextMenuAboutToShow(manager);
}

From source file:com.siteview.mde.internal.ui.editor.product.PluginConfigurationSection.java

License:Open Source License

private void handleRemove() {
    IStructuredSelection ssel = (IStructuredSelection) fConfigurationsTable.getSelection();
    if (ssel.size() > 0) {
        Object[] objects = ssel.toArray();
        IPluginConfiguration[] configurations = new IPluginConfiguration[objects.length];
        System.arraycopy(objects, 0, configurations, 0, objects.length);
        getProduct().removePluginConfigurations(configurations);
    }//from ww  w . j a  v  a  2  s. com
    clearEditors();
}

From source file:com.siteview.mde.internal.ui.editor.product.PluginSection.java

License:Open Source License

private void handleProperties() {
    IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection();
    if (ssel.size() == 1) {
        IProductPlugin plugin = (IProductPlugin) ssel.toArray()[0];
        VersionDialog dialog = new VersionDialog(MDEPlugin.getActiveWorkbenchShell(), isEditable(),
                plugin.getVersion());//  w  ww. j av a  2  s .  c o m
        dialog.create();
        SWTUtil.setDialogSize(dialog, 400, 200);
        if (dialog.open() == Window.OK) {
            plugin.setVersion(dialog.getVersion());
        }
    }
}

From source file:com.siteview.mde.internal.ui.editor.product.PluginSection.java

License:Open Source License

protected void fillContextMenu(IMenuManager manager) {
    IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection();
    if (ssel == null)
        return;//from w w  w  .j ava 2  s.  c  o m

    Action openAction = new Action(MDEUIMessages.PluginSection_open) {
        public void run() {
            handleDoubleClick((IStructuredSelection) fPluginTable.getSelection());
        }
    };
    openAction.setEnabled(isEditable() && ssel.size() == 1);
    manager.add(openAction);

    manager.add(new Separator());

    Action removeAction = new Action(MDEUIMessages.PluginSection_remove) {
        public void run() {
            handleDelete();
        }
    };
    removeAction.setEnabled(isEditable() && ssel.size() > 0);
    manager.add(removeAction);

    Action removeAll = new Action(MDEUIMessages.PluginSection_removeAll) {
        public void run() {
            handleRemoveAll();
        }
    };
    removeAll.setEnabled(isEditable());
    manager.add(removeAll);

    manager.add(new Separator());

    getPage().getMDEEditor().getContributor().contextMenuAboutToShow(manager);
}

From source file:com.siteview.mde.internal.ui.editor.product.PluginSection.java

License:Open Source License

private void handleDelete() {
    IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection();
    if (ssel.size() > 0) {
        Object[] objects = ssel.toArray();
        IProductPlugin[] plugins = new IProductPlugin[objects.length];
        System.arraycopy(objects, 0, plugins, 0, objects.length);
        getProduct().removePlugins(plugins);
    }/*w  w w.  j  a  va  2 s . c om*/
}

From source file:com.siteview.mde.internal.ui.editor.product.PropertiesSection.java

License:Open Source License

private void handleEdit() {
    IStructuredSelection ssel = (IStructuredSelection) fPropertiesTable.getSelection();
    if (ssel.size() > 0 && ssel.getFirstElement() instanceof IConfigurationProperty) {
        IConfigurationProperty propertyToEdit = (IConfigurationProperty) ssel.getFirstElement();
        Set existing = getExistingNames();
        existing.remove(propertyToEdit.getName());
        PropertyDialog dialog = new PropertyDialog(MDEPlugin.getActiveWorkbenchShell(), propertyToEdit,
                existing);//www .java 2  s.co m
        if (dialog.open() == Window.OK) {
            IConfigurationProperty result = dialog.getResult();
            if (result != null) {
                fPropertiesTable.refresh();
                fPropertiesTable.setSelection(new StructuredSelection(result));
                updateButtons();
            }
        }
    }
}

From source file:com.siteview.mde.internal.ui.editor.product.PropertiesSection.java

License:Open Source License

private void handleRemove() {
    IStructuredSelection ssel = (IStructuredSelection) fPropertiesTable.getSelection();
    if (ssel.size() > 0) {
        Object[] objects = ssel.toArray();
        IConfigurationProperty[] properties = new IConfigurationProperty[objects.length];
        System.arraycopy(objects, 0, properties, 0, objects.length);
        getProduct().removeConfigurationProperties(properties);
        fPropertiesTable.refresh(false);
    }//from   w w w .j av  a  2s .com
}

From source file:com.siteview.mde.internal.ui.editor.site.ArchiveSection.java

License:Open Source License

private void createButtons(Composite parent, FormToolkit toolkit) {
    Composite container = toolkit.createComposite(parent);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 10;//from   www  . j a v a2  s  .  co m
    container.setLayout(layout);
    container.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    fAddButton = toolkit.createButton(container, MDEUIMessages.SiteEditor_add, SWT.PUSH);
    fAddButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fAddButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            showDialog(null);
        }
    });
    fAddButton.setEnabled(isEditable());
    fEditButton = toolkit.createButton(container, MDEUIMessages.SiteEditor_edit, SWT.PUSH);
    fEditButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fEditButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection ssel = (IStructuredSelection) fViewer.getSelection();
            if (ssel != null && ssel.size() == 1)
                showDialog((ISiteArchive) ssel.getFirstElement());
        }
    });
    fRemoveButton = toolkit.createButton(container, MDEUIMessages.SiteEditor_remove, SWT.PUSH);
    fRemoveButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fRemoveButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            handleDelete();
        }
    });
    fRemoveButton.setEnabled(false);
    fEditButton.setEnabled(false);
    toolkit.paintBordersFor(container);
}

From source file:com.siteview.mde.internal.ui.editor.site.ArchiveSection.java

License:Open Source License

private void handleSelectionChanged() {
    ISelection selection = fViewer.getSelection();
    getManagedForm().fireSelectionChanged(this, selection);
    getPage().getMDEEditor().setSelection(selection);
    if (!isEditable()) {
        return;/*  w  w w . j a  v a2 s.c  o  m*/
    }
    if (selection != null && selection instanceof IStructuredSelection) {
        IStructuredSelection ssel = (IStructuredSelection) selection;
        fRemoveButton.setEnabled(ssel.size() > 0);
        fEditButton.setEnabled(ssel.size() == 1);
    } else {
        fRemoveButton.setEnabled(false);
        fEditButton.setEnabled(false);
    }
}

From source file:com.siteview.mde.internal.ui.editor.site.ArchiveSection.java

License:Open Source License

private void handleDelete() {
    try {//from   w w w. java  2s  . c o  m
        ISelection selection = fViewer.getSelection();
        if (selection != null && selection instanceof IStructuredSelection) {
            IStructuredSelection ssel = (IStructuredSelection) selection;
            if (ssel.size() > 0) {
                ISiteArchive[] array = (ISiteArchive[]) ssel.toList().toArray(new ISiteArchive[ssel.size()]);
                ISite site = ((ISiteModel) getPage().getModel()).getSite();
                site.removeArchives(array);
            }
        }
    } catch (CoreException e) {
    }
}