Search in sources :

Example 56 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.

the class DeleteQueryAction method selectionChanged.

@Override
public void selectionChanged(IStructuredSelection selection) {
    boolean enabled = true;
    if (selection.size() != 1) {
        enabled = false;
    } else {
        RepositoryNode node = (RepositoryNode) selection.getFirstElement();
        RepositoryNodeType type = (RepositoryNodeType) node.getProperties(EProperties.CONTENT_TYPE);
        if (type != RepositoryNodeType.QUERY) {
            enabled = false;
        }
    }
    enabled = enabled && !dialog.getConnParameters().isNodeReadOnly();
    setEnabled(enabled);
}
Also used : RepositoryNodeType(org.talend.sqlbuilder.dbstructure.RepositoryNodeType) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 57 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.

the class SQLEditorSessionSwitcher method createControl.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.ControlContribution#createControl(org.eclipse.swt.widgets.Composite)
     */
protected Control createControl(Composite parent) {
    sessionCombo = new Combo(parent, SWT.READ_ONLY);
    //$NON-NLS-1$
    sessionCombo.setToolTipText(Messages.getString("SQLEditor.Actions.ChooseSession.ToolTip"));
    List<String> repositoryNameList = nodeManager.getALLReposotoryNodeNames();
    sessionCombo.setItems(repositoryNameList.toArray(new String[repositoryNameList.size()]));
    sessionCombo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            String repoName = sessionCombo.getText();
            RepositoryNode node = nodeManager.getRepositoryNodebyName(repoName);
            if (!repoName.equals(DBTreeProvider.BUILT_IN)) {
                MultiPageSqlBuilderEditor multiPageEditor = editor.getMultiPageEditor();
                multiPageEditor.setRepositoryNode(node);
            }
        // editor.refresh(true);
        }
    });
    return sessionCombo;
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Combo(org.eclipse.swt.widgets.Combo) MultiPageSqlBuilderEditor(org.talend.sqlbuilder.editors.MultiPageSqlBuilderEditor) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 58 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.

the class ShowQueryPropertyAction method run.

@Override
public void run() {
    RepositoryNode node = (RepositoryNode) getStructuredSelection().getFirstElement();
    QueryRepositoryObject object = (QueryRepositoryObject) node.getObject();
    Query query = object.getQuery();
    String oldQuery = query.getLabel();
    // Finds the root
    node = SQLBuilderRepositoryNodeManager.getRoot(node);
    List<String> existingName = repositoryNodeManager.getALLQueryLabels(node);
    SQLPropertyDialog saveSQLDialog = new SQLPropertyDialog(dialog.getShell(), true);
    saveSQLDialog.setQuery(query);
    if (Window.OK == saveSQLDialog.open()) {
        query = saveSQLDialog.getQuery();
        repositoryNodeManager.saveQuery(node, query, oldQuery);
        dialog.refreshNode(node);
        dialog.notifySQLBuilder(node.getObject());
    }
}
Also used : QueryRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.QueryRepositoryObject) Query(org.talend.core.model.metadata.builder.connection.Query) RepositoryNode(org.talend.repository.model.RepositoryNode) SQLPropertyDialog(org.talend.sqlbuilder.ui.SQLPropertyDialog)

Example 59 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.

the class GenerateSelectSQLAction method init.

//$NON-NLS-1$
@SuppressWarnings("unchecked")
public void init() {
    selectedNodes.clear();
    IStructuredSelection structuredSelection = (IStructuredSelection) provider.getSelection();
    for (int i = 0; i < structuredSelection.toList().size(); i++) {
        RepositoryNode repositoryNode = (RepositoryNode) structuredSelection.toList().get(i);
        if (SQLBuilderRepositoryNodeManager.getRepositoryType(repositoryNode) == RepositoryNodeType.FOLDER) {
            this.setEnabled(false);
            return;
        }
        RepositoryNode rootNode = SQLBuilderRepositoryNodeManager.getRoot(repositoryNode);
        if (!selectedNodes.isEmpty() && selectedNodes.get(0) != null && !rootNode.equals(SQLBuilderRepositoryNodeManager.getRoot((RepositoryNode) selectedNodes.get(0)))) {
            setEnabled(false);
            return;
        }
        selectedNodes.add(repositoryNode);
    }
    if (selectedNodes.isEmpty()) {
        this.setEnabled(false);
        return;
    }
    this.setEnabled(true);
    for (IRepositoryNode node : selectedNodes) {
        Object type = node.getProperties(EProperties.CONTENT_TYPE);
        if (type != RepositoryNodeType.COLUMN && type != RepositoryNodeType.TABLE && type != RepositoryNodeType.DATABASE) {
            setEnabled(false);
            break;
        }
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) MetadataTableRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject) SqlBuilderRepositoryObject(org.talend.sqlbuilder.dbstructure.SqlBuilderRepositoryObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 60 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.

the class GenerateSelectSQLAction method getTablePrefix.

private String getTablePrefix(IRepositoryNode node) {
    RepositoryNode root = SQLBuilderRepositoryNodeManager.getRoot((RepositoryNode) node);
    DatabaseConnection connection = (DatabaseConnection) ((ConnectionItem) root.getObject().getProperty().getItem()).getConnection();
    if (connection.getUiSchema() != null && !connection.getUiSchema().trim().equals("")) {
        //$NON-NLS-1$
        return connection.getUiSchema();
    } else {
        //$NON-NLS-1$
        return "";
    }
}
Also used : DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Aggregations

RepositoryNode (org.talend.repository.model.RepositoryNode)250 IRepositoryNode (org.talend.repository.model.IRepositoryNode)94 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)74 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)44 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)44 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)42 Item (org.talend.core.model.properties.Item)38 ArrayList (java.util.ArrayList)33 PersistenceException (org.talend.commons.exception.PersistenceException)27 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)27 ProcessItem (org.talend.core.model.properties.ProcessItem)23 RepositoryObject (org.talend.core.model.repository.RepositoryObject)22 ISelection (org.eclipse.jface.viewers.ISelection)20 ConnectionItem (org.talend.core.model.properties.ConnectionItem)20 IProjectRepositoryNode (org.talend.repository.model.nodes.IProjectRepositoryNode)20 List (java.util.List)18 Property (org.talend.core.model.properties.Property)18 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)17 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)16 WizardDialog (org.eclipse.jface.wizard.WizardDialog)13