Example usage for org.eclipse.jface.viewers ComboViewer ComboViewer

List of usage examples for org.eclipse.jface.viewers ComboViewer ComboViewer

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ComboViewer ComboViewer.

Prototype

public ComboViewer(Composite parent, int style) 

Source Link

Document

Creates a combo viewer on a newly-created combo control under the given parent.

Usage

From source file:com.hangum.tadpole.manager.core.editor.resource.ResourceManageEditor.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    GridLayout gl_parent = new GridLayout(1, false);
    gl_parent.verticalSpacing = 1;/*from   ww w . j a  va2 s  .  co  m*/
    gl_parent.marginHeight = 1;
    gl_parent.horizontalSpacing = 1;
    gl_parent.marginWidth = 1;
    parent.setLayout(gl_parent);

    Composite compositeToolbar = new Composite(parent, SWT.NONE);
    compositeToolbar.setLayout(new GridLayout(1, false));
    compositeToolbar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));

    ToolBar toolBar = new ToolBar(compositeToolbar, SWT.FLAT | SWT.RIGHT);
    GridData gd_toolBar = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_toolBar.widthHint = 267;
    toolBar.setLayoutData(gd_toolBar);

    ToolItem tltmRefresh = new ToolItem(toolBar, SWT.NONE);
    tltmRefresh.setToolTipText("Refresh");
    tltmRefresh.setImage(ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/refresh.png")); //$NON-NLS-1$
    tltmRefresh.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            comboViewer.getCombo().clearSelection();
            textTitle.setText("");
            textDescription.setText("");
            textQuery.setText("");

            initUI();
            //reLoadResource();
        }
    });

    SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    columnFilter = new DefaultTableColumnFilter();

    SashForm sashForm_1 = new SashForm(sashForm, SWT.NONE);

    treeViewer = new TreeViewer(sashForm_1, SWT.BORDER);
    Tree treeDatabase = treeViewer.getTree();
    treeDatabase.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);

    Composite composite_1 = new Composite(sashForm_1, SWT.NONE);
    composite_1.setLayout(new GridLayout(1, false));

    Composite composite_2 = new Composite(composite_1, SWT.NONE);
    composite_2.setLayout(new GridLayout(2, false));
    GridData gd_composite_2 = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_composite_2.heightHint = 28;
    composite_2.setLayoutData(gd_composite_2);

    Label lblFilter = new Label(composite_2, SWT.NONE);
    lblFilter.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblFilter.setText("Filter");

    textFilter = new Text(composite_2, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SEARCH | SWT.CANCEL);
    textFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textFilter.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.Selection) {
                columnFilter.setSearchString(textFilter.getText());
                tableViewer.refresh();
            }
        }
    });

    tableViewer = new TableViewer(composite_1, SWT.BORDER | SWT.FULL_SELECTION);
    tableResource = tableViewer.getTable();
    tableResource.setHeaderVisible(true);
    tableResource.setLinesVisible(true);
    tableResource.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    sashForm_1.setWeights(new int[] { 230, 359 });
    tableViewer.addFilter(columnFilter);

    Group grpQuery = new Group(sashForm, SWT.NONE);
    grpQuery.setText("Query");
    GridLayout gl_grpQuery = new GridLayout(1, false);
    gl_grpQuery.verticalSpacing = 1;
    gl_grpQuery.horizontalSpacing = 1;
    gl_grpQuery.marginHeight = 1;
    gl_grpQuery.marginWidth = 1;
    grpQuery.setLayout(gl_grpQuery);

    Composite composite = new Composite(grpQuery, SWT.NONE);
    GridLayout gl_composite = new GridLayout(6, false);
    gl_composite.marginHeight = 2;
    gl_composite.marginWidth = 2;
    gl_composite.verticalSpacing = 2;
    composite.setLayout(gl_composite);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Label lblNewLabel = new Label(composite, SWT.NONE);
    lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel.setText("Share");

    comboViewer = new ComboViewer(composite, SWT.NONE);
    comboShare = comboViewer.getCombo();
    comboShare.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboShare.setItems(new String[] { "PUBLIC", "PRIVATE" });

    Label lblNewLabel_1 = new Label(composite, SWT.NONE);
    lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel_1.setText("Title");

    textTitle = new Text(composite, SWT.BORDER);
    textTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Button btnSave = new Button(composite, SWT.NONE);
    btnSave.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // TODO : SAVE... ?  .
            if (tableViewer.getSelection().isEmpty())
                return;

            StructuredSelection ss = (StructuredSelection) tableViewer.getSelection();
            ResourceManagerDAO dao = (ResourceManagerDAO) ss.getFirstElement();

            try {
                String share_type = comboShare.getText();
                share_type = (share_type == null || "".equals(share_type)) ? "PUBLIC" : share_type;
                dao.setShared_type(share_type);
                dao.setRes_title(textTitle.getText());
                dao.setDescription(textDescription.getText());
                TadpoleSystem_UserDBResource.updateResourceHeader(dao);
                //reLoadResource();
                addUserResouceData();
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });
    btnSave.setText("Save");

    Button btnDelete = new Button(composite, SWT.NONE);
    btnDelete.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // TODO : DELYN SET TO 'YES'
            if (tableViewer.getSelection().isEmpty())
                return;

            StructuredSelection ss = (StructuredSelection) tableViewer.getSelection();
            ResourceManagerDAO dao = (ResourceManagerDAO) ss.getFirstElement();

            // ? ?  (?)?   ? ? dao ?   ?
            // .
            UserDBResourceDAO userDBResource = new UserDBResourceDAO();
            userDBResource.setResource_seq((int) dao.getResource_seq());
            userDBResource.setName(dao.getRes_title());
            userDBResource.setParent(userDB);

            try {
                TadpoleSystem_UserDBResource.delete(userDBResource);
            } catch (Exception e1) {
                logger.error("Resource delete " + dao.toString(), e1);
            }
        }
    });
    btnDelete.setText("Delete");

    Label lblDescription = new Label(composite, SWT.NONE);
    lblDescription.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblDescription.setText("Description");

    textDescription = new Text(composite, SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.CANCEL | SWT.MULTI);
    GridData gd_textDescription = new GridData(SWT.FILL, SWT.CENTER, true, false, 5, 1);
    gd_textDescription.heightHint = 44;
    textDescription.setLayoutData(gd_textDescription);

    textQuery = new Text(composite,
            SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    textQuery.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 6, 1));
    sashForm.setWeights(new int[] { 179, 242 });

    createTableColumn();

    initUI();

}

From source file:com.hangum.tadpole.manager.core.editor.restfulapi.RESTFulAPIManagerEditor.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout(1, false));

    Composite compositeHead = new Composite(parent, SWT.NONE);
    compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    compositeHead.setLayout(new GridLayout(1, false));

    ToolBar toolBar = new ToolBar(compositeHead, SWT.FLAT | SWT.RIGHT);

    ToolItem tltmRefrsh = new ToolItem(toolBar, SWT.NONE);
    tltmRefrsh.setToolTipText(Messages.get().Refresh);
    tltmRefrsh.setImage(ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/refresh.png")); //$NON-NLS-1$
    tltmRefrsh.addSelectionListener(new SelectionAdapter() {
        @Override//  ww w. jav a2s .  co m
        public void widgetSelected(SelectionEvent e) {
            initUI();
        }
    });

    ToolItem tltmAPIExecute = new ToolItem(toolBar, SWT.NONE);
    tltmAPIExecute.setToolTipText(Messages.get().RESTFulAPIManagerEditor_3);
    tltmAPIExecute.setImage(ResourceManager.getPluginImage(com.hangum.tadpole.manager.core.Activator.PLUGIN_ID,
            "resources/icons/restful_api.png")); //$NON-NLS-1$
    tltmAPIExecute.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            UserAPIServiceDialog dialog = new UserAPIServiceDialog(getSite().getShell());
            dialog.open();
        }
    });

    Composite compositeBody = new Composite(parent, SWT.NONE);
    compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    compositeBody.setLayout(new GridLayout(1, false));

    tvAPIList = new TreeViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION);
    tvAPIList.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            if (tvAPIList.getSelection().isEmpty())
                return;

            StructuredSelection ss = (StructuredSelection) tvAPIList.getSelection();
            RESTFulAPIDAO dao = (RESTFulAPIDAO) ss.getFirstElement();
            rmDAO = dao.getResourceManagerDao();

            if (rmDAO == null)
                return;

            try {
                userDB = TadpoleSystem_UserDBQuery.getUserDBInstance(Integer.parseInt("" + rmDAO.getDb_seq())); //$NON-NLS-1$

                SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
                List<String> result = sqlClient.queryForList("userDbResourceData", rmDAO); //$NON-NLS-1$

                comboShare.getCombo().select("PUBLIC".equals(rmDAO.getShared_type()) ? 0 : 1); //$NON-NLS-1$
                textTitle.setText(rmDAO.getName());
                textDescription.setText(rmDAO.getDescription());
                comboSupportAPI.setText(rmDAO.getRestapi_yesno());
                textAPIURL.setText(rmDAO.getRestapi_uri() == null ? "" : rmDAO.getRestapi_uri()); //$NON-NLS-1$
                textAPIKey.setText(rmDAO.getRestapi_key());
                textQuery.setText(""); //$NON-NLS-1$
                for (String data : result) {
                    textQuery.append(data);
                }

            } catch (Exception e) {
                logger.error("Resource detail", e); //$NON-NLS-1$
            }
        }
    });
    tvAPIList.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            if (tvAPIList.getSelection().isEmpty())
                return;

            StructuredSelection ss = (StructuredSelection) tvAPIList.getSelection();
            RESTFulAPIDAO dao = (RESTFulAPIDAO) ss.getFirstElement();
            ResourceManagerDAO rmDAO = dao.getResourceManagerDao();

            if (rmDAO == null)
                return;

            try {

                final UserDBDAO userDB = TadpoleSystem_UserDBQuery
                        .getUserDBInstance(Integer.parseInt("" + rmDAO.getDb_seq())); //$NON-NLS-1$

                // TODO :  ??? ??     DAO   ?  .DAO    ?.
                UserDBResourceDAO ad = new UserDBResourceDAO();
                ad.setResource_seq((int) rmDAO.getResource_seq());
                ad.setName(rmDAO.getName());
                ad.setParent(userDB);

                // db object ?  ? ??.
                if (PublicTadpoleDefine.RESOURCE_TYPE.ERD.toString().equals(rmDAO.getResource_types())) {
                    if (userDB != null && DBDefine.MONGODB_DEFAULT == userDB.getDBDefine()) {
                        MongoDBERDViewAction ea = new MongoDBERDViewAction();
                        ea.run(ad);
                    } else {
                        RDBERDViewAction ea = new RDBERDViewAction();
                        ea.run(ad);
                    }
                } else if (PublicTadpoleDefine.RESOURCE_TYPE.SQL.toString().equals(rmDAO.getResource_types())) {
                    QueryEditorAction qea = new QueryEditorAction();
                    qea.run(ad);
                }
            } catch (Exception e) {
                logger.error("select api", e); //$NON-NLS-1$
            }
        }
    });
    Tree tree = tvAPIList.getTree();
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    TreeViewerColumn treeViewerColumn = new TreeViewerColumn(tvAPIList, SWT.NONE);
    TreeColumn trclmnUrl = treeViewerColumn.getColumn();
    trclmnUrl.setWidth(150);
    trclmnUrl.setText(Messages.get().URL);

    TreeViewerColumn tvcName = new TreeViewerColumn(tvAPIList, SWT.NONE);
    TreeColumn trclmnDBName = tvcName.getColumn();
    trclmnDBName.setWidth(150);
    trclmnDBName.setText(Messages.get().APIName);

    TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(tvAPIList, SWT.NONE);
    TreeColumn trclmnName = treeViewerColumn_1.getColumn();
    trclmnName.setWidth(150);
    trclmnName.setText(Messages.get().DBName);

    TreeViewerColumn treeViewerColumn_2 = new TreeViewerColumn(tvAPIList, SWT.NONE);
    TreeColumn trclmnDescription = treeViewerColumn_2.getColumn();
    trclmnDescription.setWidth(300);
    trclmnDescription.setText(Messages.get().Description);

    tvAPIList.setContentProvider(new APIListContentProvider());
    tvAPIList.setLabelProvider(new APIListLabelProvider());

    /////////////////////////////////////////////////////////////////////////////////////////////
    Group grpQuery = new Group(parent, SWT.NONE);
    grpQuery.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    grpQuery.setText(Messages.get().DetailItem);
    GridLayout gl_grpQuery = new GridLayout(1, false);
    gl_grpQuery.verticalSpacing = 1;
    gl_grpQuery.horizontalSpacing = 1;
    gl_grpQuery.marginHeight = 1;
    gl_grpQuery.marginWidth = 1;
    grpQuery.setLayout(gl_grpQuery);

    Composite compositeDetail = new Composite(grpQuery, SWT.NONE | SWT.READ_ONLY);
    GridLayout gl_compositeDetail = new GridLayout(7, false);
    gl_compositeDetail.marginHeight = 2;
    gl_compositeDetail.marginWidth = 2;
    gl_compositeDetail.verticalSpacing = 2;
    compositeDetail.setLayout(gl_compositeDetail);
    compositeDetail.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Label lblNewLabel = new Label(compositeDetail, SWT.NONE);
    lblNewLabel.setText(Messages.get().Share);

    comboShare = new ComboViewer(compositeDetail, SWT.NONE | SWT.READ_ONLY);
    Combo cShare = comboShare.getCombo();
    cShare.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    cShare.setItems(new String[] { "PUBLIC", "PRIVATE" }); //$NON-NLS-1$ //$NON-NLS-2$

    Label lblNewLabel_1 = new Label(compositeDetail, SWT.NONE);
    lblNewLabel_1.setText(Messages.get().Title);

    textTitle = new Text(compositeDetail, SWT.BORDER);
    textTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));

    Button btnSave = new Button(compositeDetail, SWT.NONE);
    btnSave.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (rmDAO == null)
                return;

            if (!MessageDialog.openConfirm(getSite().getShell(), Messages.get().Confirm,
                    Messages.get().RESTFulAPIManagerEditor_22))
                return;

            try {
                String share_type = comboShare.getCombo().getText();
                share_type = (share_type == null || "".equals(share_type)) ? "PUBLIC" : share_type; //$NON-NLS-1$ //$NON-NLS-2$
                rmDAO.setShared_type(share_type);
                rmDAO.setName(textTitle.getText());
                rmDAO.setDescription(textDescription.getText());
                rmDAO.setRestapi_yesno(comboSupportAPI.getText());
                rmDAO.setRestapi_uri(textAPIURL.getText());

                if (!isValid(rmDAO))
                    return;

                try {
                    TadpoleSystem_UserDBResource.userDBResourceDupUpdate(userDB, rmDAO);
                } catch (Exception ee) {
                    logger.error("Resource validate", ee); //$NON-NLS-1$
                    MessageDialog.openError(null, Messages.get().Error, ee.getMessage()); //$NON-NLS-1$
                    return;
                }

                if (comboSupportAPI.getText().equals(PublicTadpoleDefine.YES_NO.YES.name())
                        && "".equals(rmDAO.getRestapi_key())) { //$NON-NLS-1$
                    rmDAO.setRestapi_key(Utils.getUniqueID());
                }

                TadpoleSystem_UserDBResource.updateResourceHeader(rmDAO);
                tvAPIList.refresh(rmDAO, true);

                MessageDialog.openInformation(getSite().getShell(), Messages.get().Confirm,
                        Messages.get().RESTFulAPIManagerEditor_27);
            } catch (Exception e1) {
                logger.error("save resource", e1); //$NON-NLS-1$
                MessageDialog.openError(getSite().getShell(), Messages.get().Error,
                        Messages.get().RESTFulAPIManagerEditor_30 + e1.getMessage());
            }
        }

        /**
         * is valid
         * @return
         */
        private boolean isValid(ResourceManagerDAO dao) {
            int len = StringUtils.trimToEmpty(textTitle.getText()).length();
            if (len < 3) {
                MessageDialog.openWarning(null, Messages.get().Warning,
                        Messages.get().RESTFulAPIManagerEditor_31); //$NON-NLS-1$
                textTitle.setFocus();
                return false;
            }

            // sql type 
            if (dao.getResource_types().equals(RESOURCE_TYPE.SQL.name())) {
                if (PublicTadpoleDefine.YES_NO.YES.name().equals(comboSupportAPI.getText())) {
                    String strAPIURI = textAPIURL.getText().trim();

                    if (strAPIURI.equals("")) { //$NON-NLS-1$
                        MessageDialog.openWarning(getSite().getShell(), Messages.get().Warning,
                                Messages.get().RESTFulAPIManagerEditor_34);
                        textAPIURL.setFocus();
                        return false;
                    }

                    // check valid url. url pattern is must be /{parent}/{child}
                    if (!RESTfulAPIUtils.validateURL(textAPIURL.getText())) {
                        MessageDialog.openWarning(getSite().getShell(), Messages.get().Warning,
                                Messages.get().RESTFulAPIManagerEditor_36);

                        textAPIURL.setFocus();
                        return false;
                    }
                }
            }

            return true;
        }
    });
    btnSave.setText(Messages.get().Save);

    //      Button btnDelete = new Button(composite, SWT.NONE);
    //      btnDelete.addSelectionListener(new SelectionAdapter() {
    //         @Override
    //         public void widgetSelected(SelectionEvent e) {
    //            if (tableViewer.getSelection().isEmpty()) return;
    //
    //            if(!MessageDialog.openConfirm(getSite().getShell(), Messages.get().Confirm, "Do you wont to delete?")) return;
    //            StructuredSelection ss = (StructuredSelection) tableViewer.getSelection();
    //            ResourceManagerDAO dao = (ResourceManagerDAO) ss.getFirstElement();
    //
    //            // ? ?  (?)?   ? ? dao ?   ?
    //            // .
    //            UserDBResourceDAO userDBResource = new UserDBResourceDAO();
    //            userDBResource.setResource_seq((int) dao.getResource_seq());
    //            userDBResource.setName(dao.getRes_title());
    //            userDBResource.setParent(userDB);
    //
    //            try {
    //               TadpoleSystem_UserDBResource.delete(userDBResource);
    //               addUserResouceData(null);
    //            } catch (Exception e1) {
    //               logger.error("Resource delete " + dao.toString(), e1);
    //            }
    //         }
    //      });
    //      btnDelete.setText("Delete");

    Label lblDescription = new Label(compositeDetail, SWT.NONE);
    lblDescription.setText(Messages.get().Description);

    textDescription = new Text(compositeDetail, SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.CANCEL | SWT.MULTI);
    GridData gd_textDescription = new GridData(SWT.FILL, SWT.CENTER, true, false, 6, 1);
    gd_textDescription.heightHint = 44;
    textDescription.setLayoutData(gd_textDescription);

    Label lblSupportApi = new Label(compositeDetail, SWT.NONE);
    lblSupportApi.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSupportApi.setText(Messages.get().RESTFulAPIManagerEditor_39);

    comboSupportAPI = new Combo(compositeDetail, SWT.READ_ONLY);
    comboSupportAPI.add("YES"); //$NON-NLS-1$
    comboSupportAPI.add("NO"); //$NON-NLS-1$
    comboSupportAPI.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblApiURI = new Label(compositeDetail, SWT.NONE);
    lblApiURI.setText(Messages.get().APIURL);

    textAPIURL = new Text(compositeDetail, SWT.BORDER);
    textAPIURL.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));

    Button btnShowUrl = new Button(compositeDetail, SWT.NONE);
    btnShowUrl.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (!"".equals(textAPIURL.getText())) { //$NON-NLS-1$
                String strURL = RESTfulAPIUtils.makeURL(textQuery.getText(), textAPIURL.getText());

                TadpoleSimpleMessageDialog dialog = new TadpoleSimpleMessageDialog(getSite().getShell(),
                        Messages.get().RESTFulAPIManagerEditor_44, strURL);
                dialog.open();
            }
        }
    });
    btnShowUrl.setText(Messages.get().RESTFulAPIManagerEditor_45);
    new Label(compositeDetail, SWT.NONE);
    new Label(compositeDetail, SWT.NONE);

    Label lblApiKey = new Label(compositeDetail, SWT.NONE);
    lblApiKey.setText(Messages.get().RESTFulAPIManagerEditor_46);

    textAPIKey = new Text(compositeDetail, SWT.BORDER);
    textAPIKey.setEditable(false);
    textAPIKey.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));

    Button btnApiExecute = new Button(compositeDetail, SWT.NONE);
    btnApiExecute.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (!"".equals(textAPIURL.getText())) { //$NON-NLS-1$
                if (userDB != null & rmDAO != null) {
                    APIServiceDialog dialog = new APIServiceDialog(getSite().getShell(), userDB,
                            textQuery.getText(), rmDAO);
                    dialog.open();
                }
            }
        }
    });
    btnApiExecute.setText(Messages.get().RESTFulAPIManagerEditor_48);

    textQuery = new Text(compositeDetail,
            SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    textQuery.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 7, 1));
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    initUI();

}

From source file:com.hydra.project.myplugin_nebula.xviewer.util.internal.dialog.ColumnFilterDialog.java

License:Open Source License

@Override
protected void createExtendedArea(Composite parent) {
    super.createExtendedArea(parent);
    if (column.getSortDataType() == SortDataType.Date) {

        widgetComp = new Composite(parent, SWT.NONE);
        widgetComp.setLayout(new GridLayout(6, false));
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;// w w w . j  a  va  2s. c  om
        widgetComp.setLayoutData(gd);

        Label label = new Label(widgetComp, SWT.NONE);
        label.setText("Date Match: ");

        dateRangeTypeCombo = new ComboViewer(widgetComp, SWT.NONE);
        dateRangeTypeCombo.setContentProvider(new ArrayContentProvider());
        dateRangeTypeCombo.setLabelProvider(new LabelProvider() {

            @Override
            public String getText(Object element) {
                return ((DateRangeType) element).getDisplayName();
            }

        });
        dateRangeTypeCombo.setInput(DateRangeType.values());
        dateRangeTypeCombo.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                String text2 = dateRangeTypeCombo.getCombo().getText();
                dateRangeType = DateRangeType.get(text2);
                updateDate2Composite();
            }

        });

        date1Widget = new DateTime(widgetComp, SWT.CALENDAR);
        date1Widget.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                setDate1Selection();
            }

        });

        // set initial date
        Calendar cal = Calendar.getInstance();
        cal.set(date1Widget.getYear(), date1Widget.getMonth(), date1Widget.getDay(), 0, 0);
        date1 = cal.getTime();

        time1Widget = new DateTime(widgetComp, SWT.TIME);
        time1Widget.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                setDate1Selection();
            }

        });
        time1Widget.setHours(0);
        time1Widget.setMinutes(0);
        time1Widget.setSeconds(0);

    }
}

From source file:com.jaspersoft.studio.data.hive.HiveDataAdapterComposite.java

License:Open Source License

private void initComponents() {
    setLayout(new GridLayout(2, false));

    createLabel(Messages.HiveDataAdapterComposite_labelurl);
    urlComboViewer = new ComboViewer(this, SWT.NONE);
    urlCombo = urlComboViewer.getCombo();
    urlCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    urlComboViewer.add(CLOUDERA_HIVE_DETAILS);
    urlComboViewer.add(CLOUDERA_IMPALA_DETAILS);
    urlComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override/* w w w .  j  av a 2  s . c  o  m*/
        public void selectionChanged(SelectionChangedEvent event) {
            int selectionIndex = urlCombo.getSelectionIndex();
            if (selectionIndex == 0) {
                urlCombo.setText(CLOUDERA_HIVE_DETAILS.getValue());
            } else if (selectionIndex == 1) {
                urlCombo.setText(CLOUDERA_IMPALA_DETAILS.getValue());
            } else {
                // nothing
            }
        }
    });

    createLabel(Messages.HiveDataAdapterComposite_labelUsername);
    usernameField = new Text(this, SWT.BORDER);
    usernameField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    createLabel(Messages.HiveDataAdapterComposite_labelPassword);
    passwordField = new WSecretText(this, SWT.BORDER | SWT.PASSWORD);
    passwordField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
}

From source file:com.liferay.ide.project.ui.pref.TargetPlatformSettingsPage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout(2, false);
    layout.horizontalSpacing = 10;/*www  .j a  va  2s .co m*/
    comp.setLayout(layout);

    new Label(comp, SWT.NONE).setText("Liferay Target Platform Version:");

    targetPlatFormVersion = new ComboViewer(comp, SWT.READ_ONLY);
    targetPlatFormVersion.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return element.toString();
        }
    });
    targetPlatFormVersion.setContentProvider(new ArrayContentProvider());

    try {
        targetPlatFormVersion.setInput(TargetPlatformUtil.getAllTargetPlatfromVersions());
    } catch (IOException e) {
    }

    initvaules();

    return comp;
}

From source file:com.maccasoft.composer.InstrumentToolBar.java

License:Open Source License

public InstrumentToolBar(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(3, false);
    gridLayout.marginWidth = gridLayout.marginHeight = 0;
    composite.setLayout(gridLayout);/*from  w ww.j av  a2  s . c  o  m*/

    shell = parent.getShell();

    GC gc = new GC(parent);
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();

    Label label = new Label(composite, SWT.NONE);
    label.setText("Instrument");

    viewer = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.NO_FOCUS);
    viewer.getCombo().setVisibleItemCount(20);
    viewer.getCombo()
            .setLayoutData(new GridData(Dialog.convertWidthInCharsToPixels(fontMetrics, 30), SWT.DEFAULT));
    viewer.setContentProvider(new ObservableListContentProvider());
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return String.format("%s - %s", project.getInstrumentId((Instrument) element), element.toString());
        }
    });

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            duplicate.setEnabled(!selection.isEmpty());
            edit.setEnabled(!selection.isEmpty());
            delete.setEnabled(!selection.isEmpty());
        }
    });

    ToolBar toolBar = new ToolBar(composite, SWT.FLAT | SWT.NO_FOCUS);
    ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);
    toolItem.setImage(ImageRegistry.getImageFromResources("application_add.png"));
    toolItem.setToolTipText("New instrument");
    toolItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Instrument instrument = new InstrumentBuilder("New instrument") //
                    .setModulation(0, 50) //
                    .setVolume(95) //
                    .setEnvelope(2, 2).repeat(1) //
                    .jump(-1).build();

            InstrumentEditor editor = new InstrumentEditor(shell, instrument);
            editor.setSerialPort(serialPort);
            if (editor.open() == InstrumentEditor.OK) {
                project.add(instrument);
                viewer.setSelection(new StructuredSelection(instrument));
            }
        }
    });

    duplicate = new ToolItem(toolBar, SWT.PUSH);
    duplicate.setImage(ImageRegistry.getImageFromResources("application_double.png"));
    duplicate.setToolTipText("Duplicate instrument");
    duplicate.setEnabled(false);
    duplicate.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = viewer.getStructuredSelection();
            if (selection.isEmpty()) {
                return;
            }
            Instrument selectedInstrument = (Instrument) selection.getFirstElement();

            Instrument instrument = new Instrument(selectedInstrument.getName() + " (1)");
            List<Command> list = new ArrayList<Command>();
            try {
                for (Command cmd : selectedInstrument.getCommands()) {
                    list.add(cmd.clone());
                }
                instrument.setCommands(list);
            } catch (Exception ex) {
                ex.printStackTrace();
            }

            InstrumentEditor editor = new InstrumentEditor(shell, instrument);
            editor.setSerialPort(serialPort);
            if (editor.open() == InstrumentEditor.OK) {
                project.add(instrument);
                viewer.setSelection(new StructuredSelection(instrument));
            }
        }
    });

    edit = new ToolItem(toolBar, SWT.PUSH);
    edit.setImage(ImageRegistry.getImageFromResources("application_edit.png"));
    edit.setToolTipText("Edit instrument");
    edit.setEnabled(false);
    edit.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = viewer.getStructuredSelection();
            if (selection.isEmpty()) {
                return;
            }
            Instrument selectedInstrument = (Instrument) selection.getFirstElement();

            InstrumentEditor editor = new InstrumentEditor(shell, selectedInstrument);
            editor.setSerialPort(serialPort);
            if (editor.open() == InstrumentEditor.OK) {
                viewer.refresh();
                viewer.setSelection(new StructuredSelection(selectedInstrument));
            }
        }
    });

    new ToolItem(toolBar, SWT.SEPARATOR);

    delete = new ToolItem(toolBar, SWT.PUSH);
    delete.setImage(ImageRegistry.getImageFromResources("application_delete.png"));
    delete.setToolTipText("Delete instrument");
    delete.setEnabled(false);
    delete.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = viewer.getStructuredSelection();
            if (selection.isEmpty()) {
                return;
            }

            Instrument selectedInstrument = (Instrument) selection.getFirstElement();
            if (isInstrumentUsed(selectedInstrument)) {
                if (!MessageDialog.openConfirm(shell, Main.APP_TITLE,
                        "The instrument is used in a song.  You really want to delete?")) {
                    return;
                }
            }
            project.remove(selectedInstrument);
        }
    });
}

From source file:com.maccasoft.composer.MusicEditor.java

License:Open Source License

void createHeader(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(12, false);
    gridLayout.marginWidth = gridLayout.marginHeight = 0;
    composite.setLayout(gridLayout);// w w w  .  j  a va2 s  .com
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    Label label = new Label(composite, SWT.NONE);
    label.setText("Song");

    songsCombo = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.NO_FOCUS);
    songsCombo.getCombo().setVisibleItemCount(20);
    songsCombo.getCombo()
            .setLayoutData(new GridData(Dialog.convertWidthInCharsToPixels(fontMetrics, 30), SWT.DEFAULT));
    songsCombo.setContentProvider(new ObservableListContentProvider());
    songsCombo.setLabelProvider(new LabelProvider());

    ToolBar toolBar = new ToolBar(composite, SWT.FLAT | SWT.NO_FOCUS);

    edit = new ToolItem(toolBar, SWT.PUSH);
    edit.setImage(ImageRegistry.getImageFromResources("application_edit.png"));
    edit.setToolTipText("Rename");
    edit.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IInputValidator validator = new IInputValidator() {

                @Override
                public String isValid(String newText) {
                    if (newText.length() == 0) {
                        return "";
                    }
                    for (Song song : project.getSongs()) {
                        if (song != currentSong && newText.equalsIgnoreCase(song.getName())) {
                            return "A song with the same title already exists";
                        }
                    }
                    return null;
                }
            };
            InputDialog dlg = new InputDialog(shell, "Rename Song", "Title:", currentSong.getName(), validator);
            if (dlg.open() == InputDialog.OK) {
                currentSong.setName(dlg.getValue());
                songsCombo.refresh();
            }
        }
    });

    new ToolItem(toolBar, SWT.SEPARATOR);

    play = new ToolItem(toolBar, SWT.PUSH);
    play.setImage(ImageRegistry.getImageFromResources("control_play_blue.png"));
    play.setToolTipText("Play");
    play.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Runnable playThread = new Runnable() {

                @Override
                public void run() {
                    try {
                        ProjectCompiler compiler = new ProjectCompiler(project);
                        Music music = compiler.build(currentSong);
                        byte[] data = music.toArray();
                        try {
                            serialPort.writeInt('P');
                            serialPort.writeInt(data.length & 0xFF);
                            serialPort.writeInt((data.length >> 8) & 0xFF);
                            serialPort.writeBytes(data);
                        } catch (SerialPortException e) {
                            e.printStackTrace();
                        }
                    } catch (final ProjectException ex) {
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                if (shell.isDisposed()) {
                                    return;
                                }
                                MessageDialog.openError(shell, Main.APP_TITLE,
                                        "An error occurred while compiling song:\r\n\r\n" + ex.getMessage());
                                focusOnErrorCell(ex);
                            }
                        });
                    }
                }
            };
            new Thread(playThread).start();
        }
    });

    stop = new ToolItem(toolBar, SWT.PUSH);
    stop.setImage(ImageRegistry.getImageFromResources("control_stop_blue.png"));
    stop.setToolTipText("Stop");
    stop.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                serialPort.writeInt('0');
            } catch (SerialPortException ex) {
                ex.printStackTrace();
            }
        }
    });

    new ToolItem(toolBar, SWT.SEPARATOR);

    delete = new ToolItem(toolBar, SWT.PUSH);
    delete.setImage(ImageRegistry.getImageFromResources("application_delete.png"));
    delete.setToolTipText("Delete song");
    delete.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = songsCombo.getStructuredSelection();
            if (selection.isEmpty()) {
                return;
            }
            if (!MessageDialog.openConfirm(shell, Main.APP_TITLE, "You really want to delete this song?")) {
                return;
            }
            int index = project.getSongs().indexOf(selection.getFirstElement());
            if (index > 0) {
                songsCombo.setSelection(new StructuredSelection(project.getSong(index - 1)));
            } else {
                songsCombo.setSelection(new StructuredSelection(project.getSong(index + 1)));
            }
            project.getObservableSongs().remove(selection.getFirstElement());
            delete.setEnabled(currentSong != null && project.getSongs().size() > 1);
        }
    });

    label = new Label(composite, SWT.NONE);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    label = new Label(composite, SWT.NONE);
    label.setText("BPM");

    bpm = new Spinner(composite, SWT.BORDER | SWT.NO_FOCUS);
    bpm.setValues(120, 0, 9999, 0, 1, 1);
    bpm.setLayoutData(new GridData(Dialog.convertWidthInCharsToPixels(fontMetrics, 5), SWT.DEFAULT));
    bpm.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (currentSong != null) {
                currentSong.setBpm(bpm.getSelection());
            }
        }
    });

    label = new Label(composite, SWT.NONE);
    label.setText("Rows");

    rows = new Spinner(composite, SWT.BORDER | SWT.NO_FOCUS);
    rows.setValues(0, 0, 9999, 0, 1, 1);
    rows.setLayoutData(new GridData(Dialog.convertWidthInCharsToPixels(fontMetrics, 5), SWT.DEFAULT));
    rows.setEnabled(false);
    rows.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (currentSong == null) {
                return;
            }
            int totalRows = rows.getSelection();
            while (currentSong.getObservableRows().size() > totalRows) {
                currentSong.getObservableRows().remove(currentSong.getObservableRows().size() - 1);
            }
            while (currentSong.getObservableRows().size() < totalRows) {
                currentSong.getObservableRows().add(new SongRow());
            }
        }
    });

    label = new Label(composite, SWT.NONE);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    label = new Label(composite, SWT.NONE);
    label.setText("Octave");

    octave = new Spinner(composite, SWT.BORDER | SWT.NO_FOCUS);
    octave.setValues(3, 1, 9, 0, 1, 1);
    octave.setLayoutData(new GridData(Dialog.convertWidthInCharsToPixels(fontMetrics, 3), SWT.DEFAULT));
    octave.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            viewer.getControl().setFocus();
        }
    });

    instrumentToolBar = new InstrumentToolBar(composite);

    songsCombo.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            currentSong = (Song) selection.getFirstElement();
            updateSongView();
        }
    });
}

From source file:com.microsoft.azuretools.docker.ui.wizards.createhost.AzureNewDockerConfigPage.java

License:Open Source License

/**
 * Create contents of the wizard.//ww w .j  a  va2 s.  co  m
 * @param parent
 */
public void createControl(Composite parent) {
    Composite mainContainer = new Composite(parent, SWT.NONE);
    setControl(mainContainer);
    mainContainer.setLayout(new GridLayout(3, false));

    Label lblName = new Label(mainContainer, SWT.NONE);
    GridData gd_lblName = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblName.horizontalIndent = 5;
    lblName.setLayoutData(gd_lblName);
    lblName.setText("Name:");

    dockerHostNameTextField = new Text(mainContainer, SWT.BORDER);
    GridData gd_dockerHostNameTextField = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
    gd_dockerHostNameTextField.horizontalIndent = 3;
    gd_dockerHostNameTextField.widthHint = 200;
    dockerHostNameTextField.setLayoutData(gd_dockerHostNameTextField);

    Label lblNewLabel = new Label(mainContainer, SWT.NONE);
    GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblNewLabel.horizontalIndent = 5;
    lblNewLabel.setLayoutData(gd_lblNewLabel);
    lblNewLabel.setText("Subscription:");

    dockerSubscriptionComboViewer = new ComboViewer(mainContainer, SWT.READ_ONLY);
    dockerSubscriptionCombo = dockerSubscriptionComboViewer.getCombo();
    dockerSubscriptionCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(mainContainer, SWT.NONE);

    Label lblId = new Label(mainContainer, SWT.NONE);
    GridData gd_lblId = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblId.horizontalIndent = 5;
    lblId.setLayoutData(gd_lblId);
    lblId.setText("Id:");

    dockerSubscriptionIdTextField = new Text(mainContainer, SWT.NONE);
    GridData gd_dockerSubscriptionIdTextField = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_dockerSubscriptionIdTextField.horizontalIndent = 3;
    gd_dockerSubscriptionIdTextField.widthHint = 300;
    dockerSubscriptionIdTextField.setLayoutData(gd_dockerSubscriptionIdTextField);
    dockerSubscriptionIdTextField.setEditable(false);
    dockerSubscriptionIdTextField.setBackground(mainContainer.getBackground());
    new Label(mainContainer, SWT.NONE);

    Label lblRegion = new Label(mainContainer, SWT.NONE);
    GridData gd_lblRegion = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblRegion.horizontalIndent = 5;
    lblRegion.setLayoutData(gd_lblRegion);
    lblRegion.setText("Region:");

    dockerLocationComboBox = new Combo(mainContainer, SWT.READ_ONLY);
    GridData gd_dockerLocationComboBox = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_dockerLocationComboBox.widthHint = 200;
    dockerLocationComboBox.setLayoutData(gd_dockerLocationComboBox);
    new Label(mainContainer, SWT.NONE);

    hostDetailsTabFolder = new TabFolder(mainContainer, SWT.NONE);
    GridData gd_hostDetailsTabFolder = new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1);
    gd_hostDetailsTabFolder.heightHint = 128;
    hostDetailsTabFolder.setLayoutData(gd_hostDetailsTabFolder);

    vmKindTableItem = new TabItem(hostDetailsTabFolder, SWT.NONE);
    vmKindTableItem.setText("OS and Size");

    vmKindComposite = new Composite(hostDetailsTabFolder, SWT.NONE);
    vmKindTableItem.setControl(vmKindComposite);
    vmKindComposite.setLayout(new GridLayout(3, false));

    Label lblNewLabel_1 = new Label(vmKindComposite, SWT.NONE);
    lblNewLabel_1.setText("Host OS:");

    dockerHostOSTypeComboBox = new Combo(vmKindComposite, SWT.READ_ONLY);
    GridData gd_dockerHostOSTypeComboBox = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_dockerHostOSTypeComboBox.widthHint = 200;
    dockerHostOSTypeComboBox.setLayoutData(gd_dockerHostOSTypeComboBox);
    new Label(vmKindComposite, SWT.NONE);

    Label lblSize = new Label(vmKindComposite, SWT.NONE);
    lblSize.setText("Size:");

    dockerHostVMSizeComboBox = new Combo(vmKindComposite, SWT.READ_ONLY);
    GridData gd_dockerHostVMSizeComboBox = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
    gd_dockerHostVMSizeComboBox.widthHint = 200;
    dockerHostVMSizeComboBox.setLayoutData(gd_dockerHostVMSizeComboBox);

    Link dockerPricingHyperlink = new Link(vmKindComposite, SWT.NONE);
    dockerPricingHyperlink.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(
                        new URL("https://azure.microsoft.com/en-us/pricing/details/virtual-machines/linux/"));
            } catch (Exception ex) {
                DefaultLoader.getUIHelper().logError(ex.getMessage(), ex);
            }
        }
    });
    dockerPricingHyperlink.setText("<a>Pricing</a>");
    GridData gd_dockerPricingHyperlink = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 2);
    dockerPricingHyperlink.setLayoutData(gd_dockerPricingHyperlink);

    dockerHostVMPreferredSizesCheckBox = new Button(vmKindComposite, SWT.CHECK);
    dockerHostVMPreferredSizesCheckBox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    dockerHostVMPreferredSizesCheckBox.setText("Show preferred sizes only");

    rgTableItem = new TabItem(hostDetailsTabFolder, SWT.NONE);
    rgTableItem.setText("Resource Group");

    Composite rgComposite = new Composite(hostDetailsTabFolder, SWT.NONE);
    rgTableItem.setControl(rgComposite);
    rgComposite.setLayout(new GridLayout(2, false));

    dockerHostNewRGRadioButton = new Button(rgComposite, SWT.RADIO);
    dockerHostNewRGRadioButton.setText("New resource group:");

    dockerHostRGTextField = new Text(rgComposite, SWT.BORDER);
    GridData gd_dockerHostRGTextField = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_dockerHostRGTextField.horizontalIndent = 3;
    gd_dockerHostRGTextField.widthHint = 200;
    dockerHostRGTextField.setLayoutData(gd_dockerHostRGTextField);

    dockerHostSelectRGRadioButton = new Button(rgComposite, SWT.RADIO);
    dockerHostSelectRGRadioButton.setText("Existing resource group:");

    dockerHostSelectRGComboBox = new Combo(rgComposite, SWT.READ_ONLY);
    GridData gd_dockerHostSelectRGComboBox = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_dockerHostSelectRGComboBox.widthHint = 220;
    dockerHostSelectRGComboBox.setLayoutData(gd_dockerHostSelectRGComboBox);

    networkTableItem = new TabItem(hostDetailsTabFolder, SWT.NONE);
    networkTableItem.setText("Network");

    Composite networkComposite = new Composite(hostDetailsTabFolder, SWT.NONE);
    networkTableItem.setControl(networkComposite);
    networkComposite.setLayout(new GridLayout(2, false));

    dockerHostNewVNetRadioButton = new Button(networkComposite, SWT.RADIO);
    dockerHostNewVNetRadioButton.setText("New virtual network");

    dockerHostNewVNetNameTextField = new Text(networkComposite, SWT.BORDER);
    GridData gd_dockerHostNewVNetNameTextField = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_dockerHostNewVNetNameTextField.horizontalIndent = 3;
    gd_dockerHostNewVNetNameTextField.widthHint = 200;
    dockerHostNewVNetNameTextField.setLayoutData(gd_dockerHostNewVNetNameTextField);

    Label lblAddressSpacecdir = new Label(networkComposite, SWT.NONE);
    GridData gd_lblAddressSpacecdir = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblAddressSpacecdir.horizontalIndent = 18;
    lblAddressSpacecdir.setLayoutData(gd_lblAddressSpacecdir);
    lblAddressSpacecdir.setText("Address space (CDIR):");

    dockerHostNewVNetAddrSpaceTextField = new Text(networkComposite, SWT.BORDER);
    GridData gd_dockerHostNewVNetAddrSpaceTextField = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_dockerHostNewVNetAddrSpaceTextField.horizontalIndent = 3;
    gd_dockerHostNewVNetAddrSpaceTextField.widthHint = 200;
    dockerHostNewVNetAddrSpaceTextField.setLayoutData(gd_dockerHostNewVNetAddrSpaceTextField);

    dockerHostSelectVNetRadioButton = new Button(networkComposite, SWT.RADIO);
    dockerHostSelectVNetRadioButton.setText("Existing virtual network:");

    dockerHostSelectVnetComboBox = new Combo(networkComposite, SWT.READ_ONLY);
    GridData gd_dockerHostSelectVnetComboBox = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_dockerHostSelectVnetComboBox.widthHint = 220;
    dockerHostSelectVnetComboBox.setLayoutData(gd_dockerHostSelectVnetComboBox);

    Label lblSubnet = new Label(networkComposite, SWT.NONE);
    GridData gd_lblSubnet = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblSubnet.horizontalIndent = 18;
    lblSubnet.setLayoutData(gd_lblSubnet);
    lblSubnet.setText("Subnet:");

    dockerHostSelectSubnetComboBox = new Combo(networkComposite, SWT.READ_ONLY);
    GridData gd_dockerHostSelectSubnetComboBox = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_dockerHostSelectSubnetComboBox.widthHint = 220;
    dockerHostSelectSubnetComboBox.setLayoutData(gd_dockerHostSelectSubnetComboBox);

    storageTableItem = new TabItem(hostDetailsTabFolder, SWT.NONE);
    storageTableItem.setText("Storage");

    Composite storageComposite = new Composite(hostDetailsTabFolder, SWT.NONE);
    storageTableItem.setControl(storageComposite);
    storageComposite.setLayout(new GridLayout(2, false));

    dockerHostNewStorageRadioButton = new Button(storageComposite, SWT.RADIO);
    dockerHostNewStorageRadioButton.setText("New storage account:");

    dockerNewStorageTextField = new Text(storageComposite, SWT.BORDER);
    GridData gd_dockerNewStorageTextField = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_dockerNewStorageTextField.horizontalIndent = 3;
    gd_dockerNewStorageTextField.widthHint = 200;
    dockerNewStorageTextField.setLayoutData(gd_dockerNewStorageTextField);

    dockerHostSelectStorageRadioButton = new Button(storageComposite, SWT.RADIO);
    dockerHostSelectStorageRadioButton.setText("Existing storage account:");

    dockerSelectStorageComboBox = new Combo(storageComposite, SWT.READ_ONLY);
    GridData gd_dockerSelectStorageComboBox = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_dockerSelectStorageComboBox.widthHint = 220;
    dockerSelectStorageComboBox.setLayoutData(gd_dockerSelectStorageComboBox);

    FormToolkit toolkit = new FormToolkit(mainContainer.getDisplay());
    toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_HOVER);
    managedForm = new ManagedForm(mainContainer);
    errMsgForm = managedForm.getForm();
    errMsgForm.setVisible(false);
    //      errMsgForm.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 2, 1));
    //      errMsgForm.setBackground(mainContainer.getBackground());
    errDispatcher = managedForm.getMessageManager();

    initUIMainContainer(mainContainer);
}

From source file:com.minres.scviewer.e4.application.elements.RelationTypeToolControl.java

License:Open Source License

/**
 * Creates the gui.//from ww  w  .jav a  2s. c  o m
 *
 * @param parent the parent
 */
@PostConstruct
public void createGui(Composite parent) {
    comboViewer = new ComboViewer(parent, SWT.NONE);
    Combo comboBox = comboViewer.getCombo();
    comboBox.setBounds(0, 0, 26, 22);
    comboBox.setText("Select");
    comboViewer.setContentProvider(new ArrayContentProvider());
    comboViewer.setInput(new RelationType[] { dummy });
    comboViewer.setSelection(new StructuredSelection(dummy));
    comboViewer.addSelectionChangedListener(this);
}

From source file:com.mmkarton.mx7.reportgenerator.wizards.BIRTSQLWizardPage.java

License:Open Source License

private void createSchemaFilterComposite(boolean supportsSchema, boolean supportsProcedure,
        Composite tablescomposite) {
    // Group for selecting the Tables etc
    // Searching the Tables and Views
    Group selectTableGroup = new Group(tablescomposite, SWT.FILL);

    GridLayout groupLayout = new GridLayout();
    groupLayout.numColumns = 3;//from   w w  w.j  a  v  a 2  s .c om
    // groupLayout.horizontalSpacing = 10;
    groupLayout.verticalSpacing = 10;
    selectTableGroup.setLayout(groupLayout);

    GridData selectTableData = new GridData(GridData.FILL_HORIZONTAL);
    selectTableGroup.setLayoutData(selectTableData);

    schemaLabel = new Label(selectTableGroup, SWT.LEFT);
    schemaLabel.setText("Schema");

    schemaCombo = new Combo(selectTableGroup, prefetchSchema ? SWT.READ_ONLY : SWT.DROP_DOWN);

    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    schemaCombo.setLayoutData(gd);

    Label FilterLabel = new Label(selectTableGroup, SWT.LEFT);
    FilterLabel.setText("Filter");

    searchTxt = new Text(selectTableGroup, SWT.BORDER);
    GridData searchTxtData = new GridData(GridData.FILL_HORIZONTAL);
    searchTxtData.horizontalSpan = 2;
    searchTxt.setLayoutData(searchTxtData);

    // Select Type
    Label selectTypeLabel = new Label(selectTableGroup, SWT.NONE);
    selectTypeLabel.setText("Selecttype");

    // Filter Combo
    filterComboViewer = new ComboViewer(selectTableGroup, SWT.READ_ONLY);
    setFilterComboContents(filterComboViewer, supportsProcedure);
    GridData filterData = new GridData(GridData.FILL_HORIZONTAL);
    filterData.horizontalSpan = 2;
    filterComboViewer.getControl().setLayoutData(filterData);

    //setupShowSystemTableCheckBox( selectTableGroup );

    // Find Button
    Button findButton = new Button(selectTableGroup, SWT.NONE);
    GridData btnData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    btnData.horizontalSpan = 3;
    findButton.setLayoutData(btnData);

    findButton.setText("Filter");//$NON-NLS-1$

    // Add listener to the find button
    findButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    fc = populateFilterConfig();
                    DBNodeUtil.createTreeRoot(availableDbObjectsTree, new RootNode("MaximoDB"), fc);
                }
            });

        }
    });

    String[] allSchemaNames = null;
    String[] defaultSchemaName = null;

    if (supportsSchema) {
        String allFlag = "All";
        schemaCombo.add(allFlag);

        if (prefetchSchema) {
            allSchemaNames = JdbcMetaDataProvider.getInstance().getMaximoSchema();

            String defaultSchema = JdbcMetaDataProvider.getInstance().getDefaultschema();
            List<String> defaultnames = new ArrayList<String>();

            for (String name : allSchemaNames) {
                schemaCombo.add(name);
                if (name.equalsIgnoreCase(defaultSchema))
                    defaultnames.add(name);

            }
            defaultSchemaName = defaultnames.toArray(new String[0]);
        }
        schemaCombo.select(0);
    } else {
        schemaCombo.removeAll();
        schemaCombo.setEnabled(false);
        schemaLabel.setEnabled(false);
    }
    if (prefetchSchema) {
        fc = populateFilterConfig();
        DBNodeUtil.createTreeRoot(availableDbObjectsTree, new RootNode("MaximoDB", defaultSchemaName), fc);
    } else {
        DBNodeUtil.createRootTip(availableDbObjectsTree, new RootNode("MaximoDB"));
    }
}