Search in sources :

Example 1 with CouchVariablesDialog

use of com.twinsoft.convertigo.eclipse.dialogs.CouchVariablesDialog in project convertigo by convertigo.

the class CouchAddVariables method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        TreeObject parentTreeObject = null;
        AbstractCouchDbTransaction databaseObject = null;
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            parentTreeObject = explorerView.getFirstSelectedTreeObject();
            if (parentTreeObject.getObject() instanceof AbstractCouchDbTransaction) {
                databaseObject = (AbstractCouchDbTransaction) parentTreeObject.getObject();
                PropertyDescriptor[] props = CachedIntrospector.getBeanInfo(databaseObject).getPropertyDescriptors();
                props = cleanProps(databaseObject, props);
                if (props.length > 0) {
                    CouchVariablesDialog couchVariablesDialog = new CouchVariablesDialog(shell, databaseObject, props);
                    couchVariablesDialog.open();
                    explorerView.reloadTreeObject(parentTreeObject);
                } else {
                    MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK);
                    messageBox.setMessage("No parameters are available for this transaction.");
                    messageBox.setText("No availables parameters");
                    messageBox.open();
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to create a new database object '" + databaseObjectClassName + "'!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) PropertyDescriptor(java.beans.PropertyDescriptor) CouchVariablesDialog(com.twinsoft.convertigo.eclipse.dialogs.CouchVariablesDialog) AbstractCouchDbTransaction(com.twinsoft.convertigo.beans.transactions.couchdb.AbstractCouchDbTransaction) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) Cursor(org.eclipse.swt.graphics.Cursor) Display(org.eclipse.swt.widgets.Display) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

AbstractCouchDbTransaction (com.twinsoft.convertigo.beans.transactions.couchdb.AbstractCouchDbTransaction)1 CouchVariablesDialog (com.twinsoft.convertigo.eclipse.dialogs.CouchVariablesDialog)1 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)1 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 Cursor (org.eclipse.swt.graphics.Cursor)1 Display (org.eclipse.swt.widgets.Display)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 Shell (org.eclipse.swt.widgets.Shell)1