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

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

Introduction

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

Prototype

StructuredSelection EMPTY

To view the source code for org.eclipse.jface.viewers StructuredSelection EMPTY.

Click Source Link

Document

The canonical empty selection.

Usage

From source file:com.aptana.explorer.internal.ui.SingleProjectView.java

License:Open Source License

protected void openImportWizard() {
    ImportExportWizard wizard = new ImportExportWizard(ImportExportWizard.IMPORT);
    wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);

    IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
    IDialogSettings wizardSettings = workbenchSettings.getSection("ImportExportAction"); //$NON-NLS-1$
    if (wizardSettings == null) {
        wizardSettings = workbenchSettings.addNewSection("ImportExportAction"); //$NON-NLS-1$
    }/*w ww.  j av  a  2  s  .c  o  m*/
    wizard.setDialogSettings(wizardSettings);
    wizard.setForcePreviousAndNextButtons(true);

    WizardDialog dialog = new WizardDialog(UIUtils.getActiveShell(), wizard);
    dialog.open();
}

From source file:com.aptana.ide.debug.internal.ui.preferences.JSDetailFormattersPreferencePage.java

License:Open Source License

private void removeDetailFormatters(Object[] detailFormatters) {
    for (int i = 0; i < detailFormatters.length; ++i) {
        formatters.remove(detailFormatters[i]);
        types.remove(((DetailFormatter) detailFormatters[i]).getTypeName());
    }/* w  w  w. java2  s.  c o  m*/
    listViewer.refresh();
    listViewer.setSelection(StructuredSelection.EMPTY);
    updatePage(StructuredSelection.EMPTY);
}

From source file:com.aptana.ide.syncing.ui.views.FTPManagerComposite.java

License:Open Source License

public void setSelectedSite(ISiteConnection siteConnection) {
    if (siteConnection == fSelectedSite) {
        return;//from w ww. j  a va2  s .  co  m
    }
    fSelectedSite = siteConnection;
    if (siteConnection == null) {
        fSitesViewer.setSelection(StructuredSelection.EMPTY);
        fSource.setConnectionPoint(null);
        fTarget.setConnectionPoint(null);
    } else {
        if (siteConnection == DefaultSiteConnection.getInstance()) {
            fSitesViewer.setInput(new ISiteConnection[] { siteConnection });
        } else {
            fSitesViewer.setInput(SyncingPlugin.getSiteConnectionManager().getSiteConnections());
        }
        fSitesViewer.setSelection(new StructuredSelection(siteConnection));
        fSource.setConnectionPoint(siteConnection.getSource());
        fTarget.setConnectionPoint(siteConnection.getDestination());
    }
    fireSiteConnectionChanged(fSelectedSite);
}

From source file:com.aptana.ide.ui.io.navigator.actions.NewFileTemplateMenuContributor.java

License:Open Source License

private static IStructuredSelection getActiveSelection() {
    IStructuredSelection selection = null;
    IEvaluationService evaluationService = (IEvaluationService) PlatformUI.getWorkbench()
            .getService(IEvaluationService.class);
    if (evaluationService != null) {
        IEvaluationContext currentState = evaluationService.getCurrentState();
        Object variable = currentState.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
        if (variable instanceof IStructuredSelection) {
            selection = (IStructuredSelection) variable;
        }//  w  ww  .j  av a2s.  c  om
    }
    return (selection == null) ? StructuredSelection.EMPTY : selection;
}

From source file:com.aptana.ide.ui.io.navigator.actions.WizardNewExternalFilePage.java

License:Open Source License

public WizardNewExternalFilePage(String pageName, String initialName, boolean collectTemplates) {
    super(pageName, StructuredSelection.EMPTY);
    initialFilename = initialName;//  w w  w.jav  a2 s  .  c  om
    this.collectTemplates = collectTemplates;
    setPageComplete(true);
}

From source file:com.aptana.ide.ui.io.navigator.FilesystemLinkHelper.java

License:Open Source License

public IStructuredSelection findSelection(IEditorInput anInput) {
    IFileStore fileStore = (IFileStore) anInput.getAdapter(IFileStore.class);
    IFileInfo fileInfo = (IFileInfo) anInput.getAdapter(IFileInfo.class);
    if (fileStore == null || fileInfo == null) {
        return StructuredSelection.EMPTY;
    }/*from w ww.j a v a 2 s .  com*/
    return new StructuredSelection(new FileSystemObject(fileStore, fileInfo));
}

From source file:com.aptana.js.debug.ui.internal.preferences.JSDetailFormattersPreferencePage.java

License:Open Source License

private void removeDetailFormatters(DetailFormatter[] detailFormatters) {
    for (DetailFormatter detailFormatter : detailFormatters) {
        formatters.remove(detailFormatter);
    }//from  ww w  .  j  ava  2  s. c  om
    listViewer.refresh();
    listViewer.setSelection(StructuredSelection.EMPTY);
    updatePage(StructuredSelection.EMPTY);
}

From source file:com.aptana.webserver.ui.preferences.ServersPreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setFont(parent.getFont());
    composite.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).create());

    viewer = new ListViewer(composite, SWT.SINGLE | SWT.BORDER);
    viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewer.setContentProvider(new ArrayContentProvider() {
        @Override/* w  ww .j av  a2s  .co  m*/
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof IServerManager) {
                inputElement = ((IServerManager) inputElement).getServers(); // $codepro.audit.disable
                // questionableAssignment
            }
            return super.getElements(inputElement);
        }

    });
    viewer.setLabelProvider(new LabelProvider() {
        @Override
        public Image getImage(Object element) {
            return null; // TODO: use ImageAssociations
        }

        @Override
        public String getText(Object element) {
            if (element instanceof IServer) {
                return ((IServer) element).getName();
            }
            return super.getText(element);
        }

    });
    viewer.setInput(WebServerCorePlugin.getDefault().getServerManager());

    Composite buttonContainer = new Composite(composite, SWT.NONE);
    buttonContainer.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());
    buttonContainer.setLayout(GridLayoutFactory.swtDefaults().create());

    Button newButton = new Button(buttonContainer, SWT.PUSH);
    newButton.setText(StringUtil.ellipsify(CoreStrings.NEW));
    newButton
            .setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER)
                    .hint(Math.max(newButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x,
                            convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH)), SWT.DEFAULT)
                    .create());

    final Button editButton = new Button(buttonContainer, SWT.PUSH);
    editButton.setText(StringUtil.ellipsify(CoreStrings.EDIT));
    editButton.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).create());

    final Button deleteButton = new Button(buttonContainer, SWT.PUSH);
    deleteButton.setText(CoreStrings.DELETE);
    deleteButton.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).create());

    newButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            ListDialog dlg = new ListDialog(getShell());
            dlg.setContentProvider(ArrayContentProvider.getInstance());
            dlg.setLabelProvider(new LabelProvider() {
                @Override
                public Image getImage(Object element) {
                    return null; // TODO: use ImageAssociations
                }

                @Override
                public String getText(Object element) {
                    if (element instanceof IServerType) {
                        return ((IServerType) element).getName();
                    }
                    return super.getText(element);
                }
            });
            dlg.setInput(WebServerCorePlugin.getDefault().getServerManager().getServerTypes());
            dlg.setTitle(Messages.ServersPreferencePage_Title);
            Object[] result;
            if (dlg.open() == Window.OK && (result = dlg.getResult()) != null && result.length == 1) { // $codepro.audit.disable assignmentInCondition
                String typeId = ((IServerType) result[0]).getId();
                try {
                    IServer newConfiguration = WebServerCorePlugin.getDefault().getServerManager()
                            .createServer(typeId);
                    if (newConfiguration != null) {
                        if (editServerConfiguration(newConfiguration)) {
                            WebServerCorePlugin.getDefault().getServerManager().add(newConfiguration);
                            viewer.refresh();
                        }
                    }
                } catch (CoreException e) {
                    IdeLog.logError(WebServerUIPlugin.getDefault(), e);
                }
            }
        }

    });
    editButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IServer selection = (IServer) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            if (selection != null && editServerConfiguration(selection)) {
                viewer.refresh();
            }
        }

    });
    deleteButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IServer selection = (IServer) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            if (selection != null
                    && MessageDialog.openQuestion(getShell(), Messages.ServersPreferencePage_DeletePrompt_Title,
                            Messages.ServersPreferencePage_DeletePrompt_Message)) {
                WebServerCorePlugin.getDefault().getServerManager().remove(selection);
                viewer.refresh();
            }
        }

    });

    viewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            IServer selection = (IServer) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            if (selection != null && editServerConfiguration(selection)) {
                viewer.refresh();
            }
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            boolean hasSelection = !event.getSelection().isEmpty();
            editButton.setEnabled(hasSelection);
            deleteButton.setEnabled(hasSelection);
        }
    });
    viewer.setSelection(StructuredSelection.EMPTY);

    return composite;
}

From source file:com.arc.cdt.debug.seecode.internal.ui.action.AbstractDebugActionDelegate.java

License:Open Source License

protected void update(IAction action, ISelection s) {
    if (s instanceof IStructuredSelection) {
        IStructuredSelection ss = (IStructuredSelection) s;
        action.setEnabled(getEnableStateForSelection(ss));
        setSelection(ss);//from  w ww  .jav a2s. c o m
    } else {
        action.setEnabled(false);
        setSelection(StructuredSelection.EMPTY);
    }
}

From source file:com.archimatetool.editor.diagram.ArchimateDiagramEditor.java

License:Open Source License

@Override
public void selectElements(IArchimateElement[] elements) {
    List<EditPart> editParts = new ArrayList<EditPart>();

    for (IArchimateElement element : elements) {
        // Find Diagram Components
        for (IDiagramModelComponent dc : DiagramModelUtils.findDiagramModelComponentsForElement(getModel(),
                element)) {/*  w  ww . java  2 s . co m*/
            EditPart editPart = (EditPart) getGraphicalViewer().getEditPartRegistry().get(dc);
            if (editPart != null && editPart.isSelectable() && !editParts.contains(editPart)) {
                editParts.add(editPart);
            }
        }

        // Find Components from nested connections
        if (ConnectionPreferences.useNestedConnections() && element instanceof IRelationship) {
            for (IDiagramModelArchimateObject[] list : DiagramModelUtils
                    .findNestedComponentsForRelationship(getModel(), (IRelationship) element)) {
                EditPart editPart1 = (EditPart) getGraphicalViewer().getEditPartRegistry().get(list[0]);
                EditPart editPart2 = (EditPart) getGraphicalViewer().getEditPartRegistry().get(list[1]);
                if (editPart1 != null && editPart1.isSelectable() && !editParts.contains(editPart1)) {
                    editParts.add(editPart1);
                }
                if (editPart2 != null && editPart2.isSelectable() && !editParts.contains(editPart2)) {
                    editParts.add(editPart2);
                }
            }
        }
    }

    if (!editParts.isEmpty()) {
        getGraphicalViewer().setSelection(new StructuredSelection(editParts));
        getGraphicalViewer().reveal(editParts.get(0));
    } else {
        getGraphicalViewer().setSelection(StructuredSelection.EMPTY);
    }
}