Search in sources :

Example 1 with DBTreeProvider

use of org.talend.sqlbuilder.dbstructure.DBTreeProvider in project tdi-studio-se by Talend.

the class OpenNewEditorAction method run.

@Override
public void run() {
    IStructuredSelection selection = (IStructuredSelection) selectionProvider.getSelection();
    RepositoryNode firstNode = (RepositoryNode) selection.getFirstElement();
    if (firstNode.getProperties(EProperties.CONTENT_TYPE) == RepositoryNodeType.FOLDER) {
        firstNode = repositoryNodeManager.getRepositoryNodebyName(connParam.getRepositoryName());
    }
    List<String> repositoryNames = repositoryNodeManager.getALLReposotoryNodeNames();
    IRepositoryViewObject object = SQLBuilderRepositoryNodeManager.getRoot(firstNode).getObject();
    connParam.setRepositoryName(object.getLabel());
    connParam.setRepositoryId(object.getId());
    connParam.setFirstOpenSqlBuilder(false);
    if (isQuery) {
        DBTreeProvider provider = (DBTreeProvider) selectionProvider.getContentProvider();
        selectReveal(provider.getSelectedExtReposiotryNode());
        isQuery = false;
    } else {
        connParam.setEditorTitle(TextUtil.getNewQueryLabel());
    }
    dialog.openEditor(firstNode, repositoryNames, connParam, false);
}
Also used : DBTreeProvider(org.talend.sqlbuilder.dbstructure.DBTreeProvider) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 2 with DBTreeProvider

use of org.talend.sqlbuilder.dbstructure.DBTreeProvider in project tdi-studio-se by Talend.

the class DBStructureComposite method createDBTree.

/**
     * Create contents of the dialog.
     */
protected void createDBTree() {
    treeViewer = new TreeViewer(this, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    //
    treeViewer.getControl().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));
    treeViewer.setUseHashlookup(true);
    Tree tree = treeViewer.getTree();
    TreeColumn database = new TreeColumn(tree, SWT.LEFT);
    //$NON-NLS-1$
    database.setText(Messages.getString("DBStructureComposite.Databases"));
    database.setWidth(COLUMN_DATABASE_WIDTH);
    TreeColumn repository = new TreeColumn(tree, SWT.LEFT);
    //$NON-NLS-1$
    repository.setText(Messages.getString("DBStructureComposite.Repository"));
    repository.setWidth(COLUMN_REPOSITORY_WIDTH);
    TreeColumn diff = new TreeColumn(tree, SWT.LEFT);
    //$NON-NLS-1$
    diff.setText("Diff");
    diff.setWidth(30);
    tree.setHeaderVisible(true);
    treeLabelProvider = new DBTreeProvider(this, builderDialog.getConnParameters());
    treeViewer.setContentProvider(treeLabelProvider);
    treeViewer.setLabelProvider(treeLabelProvider);
    treeViewer.addFilter(filter);
    treeViewer.setInput(new RepositoryNode(null, null, ENodeType.SYSTEM_FOLDER));
    doExpand();
    treeViewer.setSorter(new DBTreeViewerSorter());
    treeViewer.addTreeListener(new ITreeViewerListener() {

        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
        // doSetColorOrNot(event);
        }

        @Override
        public void treeExpanded(TreeExpansionEvent event) {
        // doSetColorOrNot(event);
        }
    });
    hookDoubleClickAction();
    addContextMenu();
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeColumn(org.eclipse.swt.widgets.TreeColumn) DBTreeProvider(org.talend.sqlbuilder.dbstructure.DBTreeProvider) GridData(org.eclipse.swt.layout.GridData) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) Tree(org.eclipse.swt.widgets.Tree) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Example 3 with DBTreeProvider

use of org.talend.sqlbuilder.dbstructure.DBTreeProvider in project tdi-studio-se by Talend.

the class DBStructureComposite method updateStructureView.

/**
     * Updates the structure view to reflect the change of Repository View.
     * 
     * @see SQLBuilderDialog.repositoryChanged(RepositoryChangedEvent event)
     * @param event
     */
protected void updateStructureView(RepositoryChangedEvent event) {
    if (!isShowAllConnections) {
        DatabaseConnectionItem originalConnection = getDisplayedConnection();
        IRepositoryViewObject repositoryObject = event.getDelta().getRepositoryObject();
        if (repositoryObject != null) {
            DatabaseConnectionItem newConnection = (DatabaseConnectionItem) repositoryObject.getProperty().getItem();
            if (!originalConnection.getProperty().getId().equals(newConnection.getProperty().getId())) {
                return;
            }
            if (!originalConnection.getProperty().getLabel().equals(newConnection.getProperty().getLabel())) {
                String newRepositoryName = newConnection.getProperty().getLabel();
                this.builderDialog.getConnParameters().setRepositoryName(newRepositoryName);
                this.builderDialog.getConnParameters().setRepositoryId(newConnection.getProperty().getId());
            }
        }
    }
    ((DBTreeProvider) treeViewer.getContentProvider()).setInitialized(false);
    treeViewer.setInput(new RepositoryNode(null, null, ENodeType.SYSTEM_FOLDER));
    doExpand();
}
Also used : DBTreeProvider(org.talend.sqlbuilder.dbstructure.DBTreeProvider) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Aggregations

RepositoryNode (org.talend.repository.model.RepositoryNode)3 DBTreeProvider (org.talend.sqlbuilder.dbstructure.DBTreeProvider)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 IRepositoryNode (org.talend.repository.model.IRepositoryNode)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ITreeViewerListener (org.eclipse.jface.viewers.ITreeViewerListener)1 TreeExpansionEvent (org.eclipse.jface.viewers.TreeExpansionEvent)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 GridData (org.eclipse.swt.layout.GridData)1 Tree (org.eclipse.swt.widgets.Tree)1 TreeColumn (org.eclipse.swt.widgets.TreeColumn)1 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)1