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

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

Introduction

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

Prototype

public StructuredSelection(List elements) 

Source Link

Document

Creates a structured selection from the given List.

Usage

From source file:com.amalto.workbench.dialogs.DataModelSelectDialog.java

License:Open Source License

private void selectDefaultDataModel(TreeObject[] children) {
    for (TreeObject treeObj : children) {
        if (treeObj.getType() == TreeObject.DATA_MODEL && clusterName.equals(treeObj.getName())) {
            domViewer.setSelection(new StructuredSelection(treeObj));
            break;
        }//from w w  w.j a v  a  2s.co m
    }
}

From source file:com.amalto.workbench.editors.DataClusterDialog.java

License:Open Source License

private void selectDefaultServer() {
    for (MDMServerDef serverDef : getAllServerDefs()) {
        if (serverDef.getName().equals(oldServerDef.getName())) {
            serverComboViewer.setSelection(new StructuredSelection(serverDef), true);
            break;
        }//from w w  w .  j  a va  2  s .  co m
    }
}

From source file:com.amalto.workbench.editors.DataClusterDialog.java

License:Open Source License

private void selectDefaultContainer() {
    for (TreeObject treeObj : dataContainers) {
        if (treeObj.getName().equals("UpdateReport")) { //$NON-NLS-1$
            containerComboViewer.setSelection(new StructuredSelection(treeObj));
            break;
        }/*from w w  w .  ja  v a  2s.co m*/
    }
}

From source file:com.amalto.workbench.editors.xsdeditor.XSDEditor.java

License:Open Source License

private void resetTreeSelection(int newPageIndex) {
    DataModelMainPage dataModelEditorPage = getDataModelEditorPage();
    if (dataModelEditorPage != null) {
        TreeViewer treeViewer = dataModelEditorPage.getTreeViewer();
        if (newPageIndex == MODEL_PAGE_INDEX) {
            treeViewer.setSelection(null);
        } else if (newPageIndex == SOURCE_PAGE_INDEX) {
            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
            if (!selection.isEmpty()) {
                Object firstElement = selection.getFirstElement();
                if ((firstElement instanceof XSDIdentityConstraintDefinition)) {
                    XSDIdentityConstraintDefinition cdf = (XSDIdentityConstraintDefinition) firstElement;
                    XSDConcreteComponent container = cdf.getContainer();
                    treeViewer.setSelection(new StructuredSelection(container));
                } else if ((firstElement instanceof XSDXPathDefinition)) {
                    XSDXPathDefinition pathdef = (XSDXPathDefinition) firstElement;
                    XSDConcreteComponent container = pathdef.getContainer().getContainer();
                    treeViewer.setSelection(new StructuredSelection(container));
                } else if (firstElement instanceof XSDAnnotation) {
                    XSDAnnotation annotation = (XSDAnnotation) firstElement;
                    XSDConcreteComponent container = annotation.getContainer();
                    treeViewer.setSelection(new StructuredSelection(container));
                }// w ww . j  ava2s.  c o  m
            }
        }
    }
}

From source file:com.amalto.workbench.editors.xsdeditor.XSDSelectionListener.java

License:Open Source License

public void selectionChanged(SelectionChangedEvent event) {
    // do not fire selection in source editor if the current active page is the InternalXSDMultiPageEditor (source)
    // We only want to make source selections if the active page is either the outline or properties (a modify
    // has been done via the outline or properties and not the source view). We don't want to be selecting
    // and unselecting things in the source when editing in the source!!
    boolean makeSelection = true;
    if (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null) {
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        if (page.getActivePart() instanceof XSDEditor) {
            if (editor.getActivePage() == editor.SOURCE_PAGE_INDEX) {
                makeSelection = false;/*from ww w.  ja  v  a 2 s  . c  om*/
            }
        }
    }

    // do not fire selection in source editor if selection event came
    // from source editor
    if (event.getSource() != editor.getTextEditor().getSelectionProvider() && makeSelection) {
        ISelection selection = event.getSelection();
        if (selection instanceof StructuredSelection) {

            Object selectedElement = ((StructuredSelection) selection).getFirstElement();
            XSDElementDeclaration element = getElement(selectedElement);
            if (element == null)
                return;

            editor.getSelectionManager().setSelection(new StructuredSelection(selectedElement));
        }
    }
}

From source file:com.amalto.workbench.utils.CompositeSelectionProvider.java

License:Open Source License

public ISelection getSelection() {
    if (selection == null && repositoryViewObj != null) {
        StructuredSelection sel = new StructuredSelection(repositoryViewObj);
        selection = sel;/*from   w ww.jav  a  2  s . co m*/
    }
    return selection;
}

From source file:com.amazonaws.eclipse.core.ui.preferences.AwsAccountPreferencePageTab.java

License:Apache License

/**
 * Set the input data for the account selector combo and also set the
 * selection to the specified AccountInfo object.
 *///from w w w. j  a  v a 2  s  .c  o m
private void setUpAccountSelectorItems(Collection<AccountInfo> allAccounts, AccountInfo selectedAccount) {
    accountSelector.setInput(allAccounts);

    // If the given account is not found, then select the first element
    if (!allAccounts.contains(selectedAccount)) {
        selectedAccount = allAccounts.iterator().next();
    }

    accountSelector.setSelection(new StructuredSelection(selectedAccount), true); // visible=true

    // TODO: copied from the existing code, not sure why it's necessary
    accountSelector.getCombo().getParent().getParent().layout();
}

From source file:com.amazonaws.eclipse.datatools.sqltools.tablewizard.simpledb.ui.popup.actions.DeleteAttributeWizardAction.java

License:Apache License

/**
 * @param info/*  w  ww .  jav  a  2s  . com*/
 * @param column
 */
private void deleteColumn(final ConnectionInfo info, final Column column) throws Exception {
    final Table table = column.getTable();

    WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
        @Override
        protected void execute(final IProgressMonitor monitor) {
            try {
                Connection conn = info.getSharedConnection();
                conn.prepareStatement(
                        "alter table " + JdbcStatement.DELIMITED_IDENTIFIER_QUOTE + table.getName() //$NON-NLS-1$
                                + JdbcStatement.DELIMITED_IDENTIFIER_QUOTE + " drop " //$NON-NLS-1$
                                + JdbcStatement.DELIMITED_IDENTIFIER_QUOTE + column.getName() + JdbcStatement.DELIMITED_IDENTIFIER_QUOTE)
                        .executeUpdate();

                CommonViewer cViewer = (CommonViewer) DeleteAttributeWizardAction.this.event.getSource();
                TreePath[] expanded = cViewer.getExpandedTreePaths();

                ((ICatalogObject) table).refresh();

                for (TreePath path : expanded) {
                    cViewer.expandToLevel(path, 0);
                }
                cViewer.setSelection(new StructuredSelection(table), true);

            } catch (Exception e) {
                UIPlugin.logMessage(e.getMessage(), e, IStatus.ERROR);
            } finally {
                monitor.done();
            }
        }
    };

    UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().run(false, true, operation);
}

From source file:com.amazonaws.eclipse.datatools.sqltools.tablewizard.simpledb.ui.popup.actions.DeleteDomainWizardAction.java

License:Apache License

/**
 * @param profile//from  ww  w.ja va 2s .  co m
 * @param table
 */
private void deleteTable(final ConnectionInfo info, final PersistentTable table) throws Exception {
    final Database db = table.getSchema().getDatabase() != null ? table.getSchema().getDatabase()
            : table.getSchema().getCatalog().getDatabase();
    //    final DatabaseDefinition databaseDefinition = RDBCorePlugin.getDefault().getDatabaseDefinitionRegistry()
    //        .getDefinition(db);

    WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
        @Override
        protected void execute(final IProgressMonitor monitor) {
            try {
                //          SQLDevToolsConfiguration f = SQLToolsFacade.getConfigurationByProfileName(info.getConnectionProfile().getName());
                //          ConnectionService conService = f.getConnectionService();
                //          DatabaseIdentifier databaseIdentifier = new DatabaseIdentifier(info.getConnectionProfile().getName(), info.getDatabaseName());
                //Connection conn = conService.createConnection(databaseIdentifier, true);
                //          String profileName = profile.getName();
                //          DatabaseVendorDefinitionId dbVendorId = ProfileUtil.getDatabaseVendorDefinitionId(profileName);
                //          ISQLEditorConnectionInfo ci = new SQLEditorConnectionInfo(dbVendorId, profileName, db.getName());
                Connection conn = info.getSharedConnection();
                conn.prepareStatement(
                        "delete domain " + JdbcStatement.DELIMITED_IDENTIFIER_QUOTE + table.getName() //$NON-NLS-1$
                                + JdbcStatement.DELIMITED_IDENTIFIER_QUOTE)
                        .executeUpdate();

                CommonViewer cViewer = (CommonViewer) DeleteDomainWizardAction.this.event.getSource();

                TreePath[] expanded = cViewer.getExpandedTreePaths();
                //          Object selected = ((IStructuredSelection) DeleteDomainWizardAction.this.event.getSelection())
                //              .getFirstElement();

                ((ICatalogObject) db).refresh();

                for (TreePath path : expanded) {
                    cViewer.expandToLevel(path, 0);
                }
                cViewer.setSelection(new StructuredSelection(db), true);

            } catch (Exception e) {
                UIPlugin.logMessage(e.getMessage(), e, IStatus.ERROR);
            } finally {
                monitor.done();
            }
        }
    };

    UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().run(false, true, operation);
}

From source file:com.amazonaws.eclipse.datatools.sqltools.tablewizard.simpledb.ui.popup.actions.ExportDBUDataSetAction.java

License:Apache License

public ISelection getSelection() {
    return new StructuredSelection(this.mSelectedObject);
}