Search in sources :

Example 1 with CreateDatabaseWizard

use of org.pentaho.di.ui.core.database.wizard.CreateDatabaseWizard in project pentaho-kettle by pentaho.

the class BaseStepDialog method addConnectionLine.

/**
 * Adds the connection line.
 *
 * @param parent        the parent UI component
 * @param previous      the previous UI component
 * @param middle        the middle
 * @param margin        the margin
 * @param wlConnection  the connection label
 * @param wbnConnection the "new connection" button
 * @param wbeConnection the "edit connection" button
 * @param databaseType  the database type
 * @return the Combo Box component for the given parameters
 */
public CCombo addConnectionLine(Composite parent, Control previous, int middle, int margin, final Label wlConnection, final Button wbwConnection, final Button wbnConnection, final Button wbeConnection, final Class<? extends DatabaseInterface> databaseType) {
    final CCombo wConnection;
    final FormData fdlConnection, fdbConnection, fdeConnection, fdConnection, fdbwConnection;
    wConnection = new CCombo(parent, SWT.BORDER | SWT.READ_ONLY);
    props.setLook(wConnection);
    addDatabases(wConnection);
    wlConnection.setText(BaseMessages.getString(PKG, "BaseStepDialog.Connection.Label"));
    props.setLook(wlConnection);
    fdlConnection = new FormData();
    fdlConnection.left = new FormAttachment(0, 0);
    fdlConnection.right = new FormAttachment(middle, -margin);
    if (previous != null) {
        fdlConnection.top = new FormAttachment(previous, margin);
    } else {
        fdlConnection.top = new FormAttachment(0, 0);
    }
    wlConnection.setLayoutData(fdlConnection);
    // 
    // Wizard button
    // 
    wbwConnection.setText(BaseMessages.getString(PKG, "BaseStepDialog.WizardConnectionButton.Label"));
    wbwConnection.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            CreateDatabaseWizard cdw = new CreateDatabaseWizard();
            DatabaseMeta newDBInfo = cdw.createAndRunDatabaseWizard(shell, props, transMeta.getDatabases());
            if (newDBInfo != null) {
                transMeta.addDatabase(newDBInfo);
                reinitConnectionDropDown(wConnection, newDBInfo.getName());
            }
        }
    });
    fdbwConnection = new FormData();
    fdbwConnection.right = new FormAttachment(100, 0);
    if (previous != null) {
        fdbwConnection.top = new FormAttachment(previous, margin);
    } else {
        fdbwConnection.top = new FormAttachment(0, 0);
    }
    wbwConnection.setLayoutData(fdbwConnection);
    // 
    // NEW button
    // 
    wbnConnection.setText(BaseMessages.getString(PKG, "BaseStepDialog.NewConnectionButton.Label"));
    wbnConnection.addSelectionListener(new AddConnectionListener(wConnection));
    fdbConnection = new FormData();
    fdbConnection.right = new FormAttachment(wbwConnection, -margin);
    if (previous != null) {
        fdbConnection.top = new FormAttachment(previous, margin);
    } else {
        fdbConnection.top = new FormAttachment(0, 0);
    }
    wbnConnection.setLayoutData(fdbConnection);
    // 
    // Edit button
    // 
    wbeConnection.setText(BaseMessages.getString(PKG, "BaseStepDialog.EditConnectionButton.Label"));
    wbeConnection.addSelectionListener(new EditConnectionListener(wConnection));
    fdeConnection = new FormData();
    fdeConnection.right = new FormAttachment(wbnConnection, -margin);
    if (previous != null) {
        fdeConnection.top = new FormAttachment(previous, margin);
    } else {
        fdeConnection.top = new FormAttachment(0, 0);
    }
    wbeConnection.setLayoutData(fdeConnection);
    // 
    // what's left of the line: combo box
    // 
    fdConnection = new FormData();
    fdConnection.left = new FormAttachment(middle, 0);
    if (previous != null) {
        fdConnection.top = new FormAttachment(previous, margin);
    } else {
        fdConnection.top = new FormAttachment(0, 0);
    }
    fdConnection.right = new FormAttachment(wbeConnection, -margin);
    wConnection.setLayoutData(fdConnection);
    return wConnection;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CreateDatabaseWizard(org.pentaho.di.ui.core.database.wizard.CreateDatabaseWizard) CCombo(org.eclipse.swt.custom.CCombo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 2 with CreateDatabaseWizard

use of org.pentaho.di.ui.core.database.wizard.CreateDatabaseWizard in project pentaho-kettle by pentaho.

the class Spoon method createDatabaseWizard.

/**
 * Shows a wizard that creates a new database connection...
 */
public void createDatabaseWizard() {
    HasDatabasesInterface hasDatabasesInterface = getActiveHasDatabasesInterface();
    if (hasDatabasesInterface == null) {
        // nowhere to put the new database
        return;
    }
    CreateDatabaseWizard cdw = new CreateDatabaseWizard();
    DatabaseMeta newDBInfo = cdw.createAndRunDatabaseWizard(shell, props, hasDatabasesInterface.getDatabases());
    if (newDBInfo != null) {
        // finished
        hasDatabasesInterface.addDatabase(newDBInfo);
        refreshTree();
        refreshGraph();
    }
}
Also used : CreateDatabaseWizard(org.pentaho.di.ui.core.database.wizard.CreateDatabaseWizard) HasDatabasesInterface(org.pentaho.di.trans.HasDatabasesInterface) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 3 with CreateDatabaseWizard

use of org.pentaho.di.ui.core.database.wizard.CreateDatabaseWizard in project pentaho-kettle by pentaho.

the class JobEntryDialog method addConnectionLine.

/**
 * Adds the connection line for the given parent and previous control, and returns a combo box UI component
 *
 * @param parent
 *          the parent composite object
 * @param previous
 *          the previous control
 * @param middle
 *          the middle
 * @param margin
 *          the margin
 * @param wlConnection
 *          the connection label
 * @param wbnConnection
 *          the "new connection" button
 * @param wbeConnection
 *          the "edit connection" button
 * @return the combo box UI component
 */
public CCombo addConnectionLine(Composite parent, Control previous, int middle, int margin, final Label wlConnection, final Button wbwConnection, final Button wbnConnection, final Button wbeConnection) {
    final CCombo wConnection;
    final FormData fdlConnection, fdbConnection, fdeConnection, fdConnection, fdbwConnection;
    wConnection = new CCombo(parent, SWT.BORDER | SWT.READ_ONLY);
    props.setLook(wConnection);
    addDatabases(wConnection);
    wlConnection.setText(BaseMessages.getString(PKG, "BaseStepDialog.Connection.Label"));
    props.setLook(wlConnection);
    fdlConnection = new FormData();
    fdlConnection.left = new FormAttachment(0, 0);
    fdlConnection.right = new FormAttachment(middle, -margin);
    if (previous != null) {
        fdlConnection.top = new FormAttachment(previous, margin);
    } else {
        fdlConnection.top = new FormAttachment(0, 0);
    }
    wlConnection.setLayoutData(fdlConnection);
    // 
    // Wizard button
    // 
    wbwConnection.setText(BaseMessages.getString(PKG, "BaseStepDialog.WizardConnectionButton.Label"));
    wbwConnection.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            CreateDatabaseWizard cdw = new CreateDatabaseWizard();
            DatabaseMeta newDBInfo = cdw.createAndRunDatabaseWizard(shell, props, jobMeta.getDatabases());
            if (newDBInfo != null) {
                jobMeta.addDatabase(newDBInfo);
                reinitConnectionDropDown(wConnection, newDBInfo.getName());
            }
        }
    });
    fdbwConnection = new FormData();
    fdbwConnection.right = new FormAttachment(100, 0);
    if (previous != null) {
        fdbwConnection.top = new FormAttachment(previous, margin);
    } else {
        fdbwConnection.top = new FormAttachment(0, 0);
    }
    wbwConnection.setLayoutData(fdbwConnection);
    // 
    // NEW button
    // 
    wbnConnection.setText(BaseMessages.getString(PKG, "BaseStepDialog.NewConnectionButton.Label"));
    wbnConnection.addSelectionListener(new AddConnectionListener(wConnection));
    fdbConnection = new FormData();
    fdbConnection.right = new FormAttachment(wbwConnection, -margin);
    if (previous != null) {
        fdbConnection.top = new FormAttachment(previous, margin);
    } else {
        fdbConnection.top = new FormAttachment(0, 0);
    }
    wbnConnection.setLayoutData(fdbConnection);
    // 
    // Edit button
    // 
    wbeConnection.setText(BaseMessages.getString(PKG, "BaseStepDialog.EditConnectionButton.Label"));
    wbeConnection.addSelectionListener(new EditConnectionListener(wConnection));
    fdeConnection = new FormData();
    fdeConnection.right = new FormAttachment(wbnConnection, -margin);
    if (previous != null) {
        fdeConnection.top = new FormAttachment(previous, margin);
    } else {
        fdeConnection.top = new FormAttachment(0, 0);
    }
    wbeConnection.setLayoutData(fdeConnection);
    // 
    // what's left of the line: combo box
    // 
    fdConnection = new FormData();
    fdConnection.left = new FormAttachment(middle, 0);
    if (previous != null) {
        fdConnection.top = new FormAttachment(previous, margin);
    } else {
        fdConnection.top = new FormAttachment(0, 0);
    }
    fdConnection.right = new FormAttachment(wbeConnection, -margin);
    wConnection.setLayoutData(fdConnection);
    return wConnection;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CreateDatabaseWizard(org.pentaho.di.ui.core.database.wizard.CreateDatabaseWizard) CCombo(org.eclipse.swt.custom.CCombo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)3 CreateDatabaseWizard (org.pentaho.di.ui.core.database.wizard.CreateDatabaseWizard)3 CCombo (org.eclipse.swt.custom.CCombo)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2 HasDatabasesInterface (org.pentaho.di.trans.HasDatabasesInterface)1