Search in sources :

Example 61 with SashForm

use of org.eclipse.swt.custom.SashForm in project MonjaDB by Kanatoko.

the class MJavaScriptView method init2.

//--------------------------------------------------------------------------------
public void init2() {
    parent.setLayout(new FormLayout());
    sashForm = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL);
    FormData fd_sashForm1 = new FormData();
    fd_sashForm1.top = new FormAttachment(0, 1);
    fd_sashForm1.left = new FormAttachment(0, 1);
    fd_sashForm1.right = new FormAttachment(100, -1);
    fd_sashForm1.bottom = new FormAttachment(100, -1);
    sashForm.setLayoutData(fd_sashForm1);
    text1 = new Text(sashForm, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    text1.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            onSashResize();
        }
    });
    text1.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            executeAction.setEnabled(dataManager.isConnected() && text1.getText().length() > 0);
        }
    });
    FormData fd_text = new FormData();
    fd_text.top = new FormAttachment(0, 1);
    fd_text.left = new FormAttachment(0, 1);
    fd_text.bottom = new FormAttachment(100, -1);
    fd_text.right = new FormAttachment(100, -1);
    text1.setLayoutData(fd_text);
    text2 = new Text(sashForm, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    FormData fd_text2 = new FormData();
    fd_text2.top = new FormAttachment(0, 1);
    fd_text2.left = new FormAttachment(0, 1);
    fd_text2.bottom = new FormAttachment(100, -1);
    fd_text2.right = new FormAttachment(100, -1);
    text2.setLayoutData(fd_text2);
    executeAction = new Action() {

        public void run() {
            //-----------
            onExecute();
        }
    };
    //-----------
    executeAction.setToolTipText("Execute JavaScript 'eval()' on MongoDB Server");
    executeAction.setText("Execute");
    initAction(executeAction, "database_go.png", null);
    executeAction.setEnabled(false);
    clearAction = new Action() {

        public void run() {
            //-----------
            text1.setText("");
            text2.setText("");
        }
    };
    //-----------
    clearAction.setToolTipText("Clear");
    clearAction.setText("Clear");
    initAction(clearAction, "bullet_delete.png", null);
    clearAction.setEnabled(true);
    if (prop.containsKey(JAVASCRIPT_COMPOSITE_WEIGHT)) {
        (new Thread() {

            public void run() {
                MSystemUtil.sleep(0);
                shell.getDisplay().asyncExec(new Runnable() {

                    public void run() {
                        //----
                        sashForm.setWeights(prop.getIntArrayProperty(JAVASCRIPT_COMPOSITE_WEIGHT));
                    }
                });
            //----
            }
        }).start();
    } else {
        sashForm.setWeights(new int[] { 70, 30 });
    }
    initializedTime = System.currentTimeMillis();
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Action(org.eclipse.jface.action.Action) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ModifyListener(org.eclipse.swt.events.ModifyListener) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 62 with SashForm

use of org.eclipse.swt.custom.SashForm in project MonjaDB by Kanatoko.

the class MDocumentEditor method init2.

//--------------------------------------------------------------------------------
public void init2() {
    parent.setLayout(new FormLayout());
    sashForm = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL);
    FormData fd_sashForm1 = new FormData();
    fd_sashForm1.top = new FormAttachment(0, 1);
    fd_sashForm1.left = new FormAttachment(0, 1);
    fd_sashForm1.right = new FormAttachment(100, -1);
    fd_sashForm1.bottom = new FormAttachment(100, -1);
    sashForm.setLayoutData(fd_sashForm1);
    tree = new Tree(sashForm, SWT.BORDER | SWT.FULL_SELECTION);
    tree.setHeaderVisible(true);
    FormData d1 = new FormData();
    d1.top = new FormAttachment(0, 1);
    d1.left = new FormAttachment(0, 1);
    d1.right = new FormAttachment(100, -1);
    d1.bottom = new FormAttachment(100, -1);
    tree.setLayoutData(d1);
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
    column2.setText("Data Type");
    editorComposite = new Composite(sashForm, SWT.BORDER);
    editorComposite.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            onSashResize();
        }
    });
    FormData fd_composite1 = new FormData();
    fd_composite1.top = new FormAttachment(0, 1);
    fd_composite1.bottom = new FormAttachment(0, 35);
    fd_composite1.right = new FormAttachment(100, -1);
    fd_composite1.left = new FormAttachment(0, 1);
    editorComposite.setLayoutData(fd_composite1);
    editorComposite.setLayout(new FormLayout());
    Label nameLabel = new Label(editorComposite, SWT.NONE);
    FormData fd_nameLabel = new FormData();
    fd_nameLabel.right = new FormAttachment(0, 66);
    fd_nameLabel.bottom = new FormAttachment(0, 32);
    fd_nameLabel.top = new FormAttachment(0, 12);
    fd_nameLabel.left = new FormAttachment(0, 10);
    nameLabel.setLayoutData(fd_nameLabel);
    nameLabel.setText("Name :");
    Label valueLabel = new Label(editorComposite, SWT.NONE);
    FormData fd_valueLabel = new FormData();
    fd_valueLabel.top = new FormAttachment(nameLabel, 15);
    fd_valueLabel.left = new FormAttachment(0, 10);
    fd_valueLabel.bottom = new FormAttachment(nameLabel, 34, SWT.BOTTOM);
    fd_valueLabel.right = new FormAttachment(nameLabel, 0, SWT.RIGHT);
    valueLabel.setLayoutData(fd_valueLabel);
    valueLabel.setText("Value :");
    valueText = new Text(editorComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    valueText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            verifyData();
        }
    });
    valueText.setEnabled(false);
    valueText.setEditable(false);
    FormData fd_valueText = new FormData();
    fd_valueText.top = new FormAttachment(nameLabel, 5);
    fd_valueText.bottom = new FormAttachment(100, -80);
    fd_valueText.right = new FormAttachment(100, -20);
    fd_valueText.left = new FormAttachment(valueLabel, 0, SWT.RIGHT);
    valueText.setLayoutData(fd_valueText);
    updateButton = new Button(editorComposite, SWT.NONE);
    updateButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            onUpdateButtonSelect();
        }
    });
    updateButton.setEnabled(false);
    FormData fd_updateButton = new FormData();
    fd_updateButton.left = new FormAttachment(100, -120);
    fd_updateButton.right = new FormAttachment(valueText, 0, SWT.RIGHT);
    updateButton.setLayoutData(fd_updateButton);
    updateButton.setText("Update");
    typeCombo = new Combo(editorComposite, SWT.READ_ONLY);
    fd_updateButton.top = new FormAttachment(typeCombo, 10);
    typeCombo.setEnabled(false);
    FormData fd_typeList = new FormData();
    fd_typeList.left = new FormAttachment(valueText, 0, SWT.LEFT);
    fd_typeList.top = new FormAttachment(valueText, 5, SWT.BOTTOM);
    //fd_typeList.bottom = new FormAttachment(valueText, 30, SWT.BOTTOM);
    fd_typeList.right = new FormAttachment(valueText, 170, SWT.LEFT);
    typeCombo.setLayoutData(fd_typeList);
    typeCombo.add("Double");
    typeCombo.add("Integer");
    typeCombo.add("Long");
    typeCombo.add("String");
    typeCombo.add("List (BasicDBList)");
    typeCombo.add("Map (BasicDBObject)");
    typeCombo.add("Date");
    typeCombo.add("ObjectId");
    typeCombo.add("JavaScript code");
    typeCombo.add("Binary data");
    typeCombo.add("Boolean");
    typeCombo.add("Null");
    typeCombo.add("Regular expression");
    typeCombo.add("Symbol");
    typeCombo.add("JavaScript code with scope");
    typeCombo.add("Timestamp");
    typeCombo.add("Min key");
    typeCombo.add("Max key");
    typeCombo.addListener(SWT.Selection, this);
    typeComboIndexMap.put(Double.class, new Integer(0));
    typeComboIndexMap.put(Integer.class, new Integer(1));
    typeComboIndexMap.put(Long.class, new Integer(2));
    typeComboIndexMap.put(String.class, new Integer(3));
    typeComboIndexMap.put(com.mongodb.BasicDBList.class, new Integer(4));
    typeComboIndexMap.put(com.mongodb.BasicDBObject.class, new Integer(5));
    typeComboIndexMap.put(java.util.Date.class, new Integer(6));
    typeComboIndexMap.put(org.bson.types.ObjectId.class, new Integer(7));
    typeComboIndexMap.put(org.bson.types.Code.class, new Integer(8));
    typeComboIndexMap.put(byte[].class, new Integer(9));
    typeComboIndexMap.put(Boolean.class, new Integer(10));
    typeComboIndexMap.put(java.util.regex.Pattern.class, new Integer(12));
    typeComboIndexMap.put(org.bson.types.Symbol.class, new Integer(13));
    typeComboIndexMap.put(org.bson.types.CodeWScope.class, new Integer(14));
    typeComboIndexMap.put(org.bson.types.BSONTimestamp.class, new Integer(15));
    typeComboIndexMap.put(org.bson.types.MinKey.class, new Integer(16));
    typeComboIndexMap.put(org.bson.types.MaxKey.class, new Integer(17));
    Label typeLabel = new Label(editorComposite, SWT.NONE);
    FormData fd_typeLabel = new FormData();
    fd_typeLabel.top = new FormAttachment(typeCombo, 3, SWT.TOP);
    fd_typeLabel.left = new FormAttachment(nameLabel, 0, SWT.LEFT);
    typeLabel.setLayoutData(fd_typeLabel);
    typeLabel.setText("Type :");
    nameText = new Text(editorComposite, SWT.READ_ONLY);
    nameText.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
    FormData fd_nameText = new FormData();
    fd_nameText.top = new FormAttachment(nameLabel, -2, SWT.TOP);
    fd_nameText.left = new FormAttachment(valueText, 0, SWT.LEFT);
    fd_nameText.right = new FormAttachment(valueText, 0, SWT.RIGHT);
    nameText.setLayoutData(fd_nameText);
    MSwtUtil.getTreeColumnWidthFromProperties("documentTree", tree, prop, new int[] { 150, 150 });
    //listeners
    tree.addListener(SWT.MouseDoubleClick, this);
    tree.addListener(SWT.Selection, this);
    tree.addListener(SWT.KeyDown, this);
    MSwtUtil.addListenerToTreeColumns2(tree, this);
    documentImage = MUtil.getImage(parent.getShell().getDisplay(), "table.png");
    oidImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_star.png");
    intImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_blue.png");
    longImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_red.png");
    doubleImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_orange.png");
    stringImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_green.png");
    dateImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_white.png");
    boolImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_yellow.png");
    listImage = MUtil.getImage(parent.getShell().getDisplay(), "stop_blue.png");
    mapImage = MUtil.getImage(parent.getShell().getDisplay(), "stop_green.png");
    nullImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_black.png");
    jsImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_right.png");
    if (prop.containsKey(DOCUMENT_COMPOSITE_WEIGHT)) {
        (new Thread() {

            public void run() {
                //System.out.println( "e" );
                MSystemUtil.sleep(0);
                //System.out.println( "a" );
                shell.getDisplay().asyncExec(new Runnable() {

                    public void run() {
                        //----
                        //debug( "--" + prop.getIntArrayProperty( DOCUMENT_COMPOSITE_WEIGHT )[ 0 ] );
                        sashForm.setWeights(prop.getIntArrayProperty(DOCUMENT_COMPOSITE_WEIGHT));
                    }
                });
            //----
            }
        }).start();
    } else {
        sashForm.setWeights(new int[] { 70, 30 });
    }
    initializedTime = System.currentTimeMillis();
}
Also used : ControlAdapter(org.eclipse.swt.events.ControlAdapter) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) TreeColumn(org.eclipse.swt.widgets.TreeColumn) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) com.mongodb(com.mongodb) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) SashForm(org.eclipse.swt.custom.SashForm) java.util(java.util) net.jumperz.util(net.jumperz.util) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 63 with SashForm

use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.

the class MultiQueryThread method initialize.

public void initialize() {
    // count column row count and weights
    int columnCount = (int) Math.ceil(Math.sqrt((double) dbList.size()));
    int rowCount = (int) Math.ceil(((double) dbList.size() / (double) columnCount));
    int[] columnWeights = new int[columnCount];
    for (int i = 0; i < columnCount; i++) {
        columnWeights[i] = 100 / columnCount;
    }
    int[] rowWeights = new int[rowCount];
    for (int i = 0; i < rowCount; i++) {
        rowWeights[i] = 100 / rowCount;
    }
    // create row
    SashForm horizontalMainForm = createSashForm(this, SWT.VERTICAL, columnCount);
    List<SashForm> verticalFormList = new ArrayList<SashForm>();
    for (int i = 0; i < rowCount; i++) {
        SashForm verticalForm = createSashForm(horizontalMainForm, SWT.HORIZONTAL, rowCount);
        verticalFormList.add(verticalForm);
    }
    setWeightsToSashForm(horizontalMainForm, rowWeights);
    // create column
    for (int i = 0; i < verticalFormList.size(); i++) {
        SashForm verticalForm = verticalFormList.get(i);
        for (int j = 0; j < columnCount; j++) {
            //String index = editor.getCombinedQueryComposite().getMultiDBQueryComp().getIndex();
            createResultQueryResultComposite(verticalForm, getAssignDB());
        }
        setWeightsToSashForm(verticalForm, columnWeights);
    }
    assignIndex = 0;
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) ArrayList(java.util.ArrayList)

Example 64 with SashForm

use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.

the class MultiQueryThread method createSashForm.

public SashForm createSashForm(Composite parent, int type, int column) {
    SashForm resultSashForm = new SashForm(parent, type);
    resultSashForm.setLayout(new GridLayout(column, true));
    resultSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    return resultSashForm;
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData)

Example 65 with SashForm

use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.

the class MultiSQLQueryResultComposite method createSashForm.

public SashForm createSashForm(Composite parent, int type, int column) {
    SashForm resultSashForm = new SashForm(parent, type);
    resultSashForm.setLayout(new GridLayout(column, true));
    resultSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    return resultSashForm;
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData)

Aggregations

SashForm (org.eclipse.swt.custom.SashForm)96 GridData (org.eclipse.swt.layout.GridData)65 GridLayout (org.eclipse.swt.layout.GridLayout)57 Composite (org.eclipse.swt.widgets.Composite)56 SelectionEvent (org.eclipse.swt.events.SelectionEvent)31 FillLayout (org.eclipse.swt.layout.FillLayout)30 Label (org.eclipse.swt.widgets.Label)26 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)25 CTabItem (org.eclipse.swt.custom.CTabItem)14 Button (org.eclipse.swt.widgets.Button)13 StyledText (org.eclipse.swt.custom.StyledText)12 ToolBar (org.eclipse.swt.widgets.ToolBar)12 ArrayList (java.util.ArrayList)11 Point (org.eclipse.swt.graphics.Point)11 Table (org.eclipse.swt.widgets.Table)11 ToolItem (org.eclipse.swt.widgets.ToolItem)11 TableViewer (org.eclipse.jface.viewers.TableViewer)10 Event (org.eclipse.swt.widgets.Event)10 Listener (org.eclipse.swt.widgets.Listener)9 Tree (org.eclipse.swt.widgets.Tree)9