Search in sources :

Example 31 with FocusEvent

use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.

the class ViewDashboardEditorPart method registerContextMenu.

private void registerContextMenu() {
    viewsDetailInfoTable.getTable().addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            ActionManager.getInstance().changeFocusProvider(viewsDetailInfoTable.getTable());
        }
    });
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    Menu contextMenu = menuManager.createContextMenu(viewsDetailInfoTable.getTable());
    viewsDetailInfoTable.getTable().setMenu(contextMenu);
    Menu menu = new Menu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.POP_UP);
    final MenuItem editViewItem = new MenuItem(menu, SWT.PUSH);
    editViewItem.setText(Messages.viewDetailInfoPartTableEditViewBtn);
    editViewItem.setImage(CommonUIPlugin.getImage("icons/action/schema_view_edit.png"));
    editViewItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            editView();
        }
    });
    final MenuItem dropViewItem = new MenuItem(menu, SWT.PUSH);
    dropViewItem.setText(Messages.viewDetailInfoPartTableDropViewBtn);
    dropViewItem.setImage(CommonUIPlugin.getImage("icons/action/schema_view_delete.png"));
    dropViewItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            dropView();
        }
    });
    new MenuItem(menu, SWT.SEPARATOR);
    final MenuItem addViewItem = new MenuItem(menu, SWT.PUSH);
    addViewItem.setText(Messages.viewDetailInfoPartTableCreateViewBtn);
    addViewItem.setImage(CommonUIPlugin.getImage("icons/action/schema_view_add.png"));
    addViewItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            addView();
        }
    });
    viewsDetailInfoTable.getTable().setMenu(menu);
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 32 with FocusEvent

use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.

the class ConnectionComposite method createBrokerInfoGroup.

private void createBrokerInfoGroup(Composite composite) {
    Group brokerInfoGroup = new Group(composite, SWT.NONE);
    brokerInfoGroup.setText(Messages.grpBrokerInfo);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    brokerInfoGroup.setLayoutData(gridData);
    brokerInfoGroup.setLayout(createGridLayout(3));
    Label brokerIpLabel = new Label(brokerInfoGroup, SWT.LEFT);
    brokerIpLabel.setText(Messages.lblLoginServerName);
    brokerIpLabel.setLayoutData(createGridData(1, 1, -1, -1));
    brokerIpText = new Text(brokerInfoGroup, SWT.LEFT | SWT.BORDER);
    brokerIpText.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
    brokerIpText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            brokerIpText.selectAll();
        }
    });
    Label brokerPortLabel = new Label(brokerInfoGroup, SWT.LEFT);
    brokerPortLabel.setText(Messages.lblLoginBrokerPort);
    brokerPortLabel.setLayoutData(createGridData(1, 1, -1, -1));
    VerifyListener verifyListener = new VerifyListener() {

        public void verifyText(VerifyEvent event) {
            Pattern pattern = Pattern.compile("[0-9]*");
            Matcher matcher = pattern.matcher(event.text);
            if (matcher.matches()) {
                event.doit = true;
            } else if (event.text.length() > 0) {
                event.doit = false;
            } else {
                event.doit = true;
            }
        }
    };
    Composite portAndShardComp = new Composite(brokerInfoGroup, SWT.NONE);
    portAndShardComp.setLayout(createGridLayout(3, 0, 0));
    portAndShardComp.setLayoutData(createGridData(FILL_HORIZONTAL, 2, 1, -1, -1));
    if (isMultiBroker) {
        brokerPortCombo = new Combo(portAndShardComp, SWT.LEFT | SWT.BORDER);
        brokerPortCombo.setLayoutData(createGridData(GridData.BEGINNING, 1, 1, 100, -1));
        brokerPortCombo.addVerifyListener(verifyListener);
    } else {
        brokerPortText = new Text(portAndShardComp, SWT.LEFT | SWT.BORDER);
        brokerPortText.setLayoutData(createGridData(BEGINNING, 1, 1, 100, -1));
        brokerPortText.addVerifyListener(verifyListener);
    }
    btnShard = new Button(portAndShardComp, SWT.CHECK);
    btnShard.setLayoutData(createGridData(BEGINNING, 1, 1, -1, -1));
    btnShard.setText(com.cubrid.common.ui.query.Messages.shardBrokerLabel);
    btnShard.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (btnShard.getSelection()) {
                openWarningBox(shardBrokerAlert);
            }
            btnShardId.setEnabled(btnShard.getSelection());
        }
    });
    btnShardId = new Button(portAndShardComp, SWT.PUSH);
    btnShardId.setLayoutData(createGridData(HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
    btnShardId.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            ShardIdSelectionDialog dialog = new ShardIdSelectionDialog(getShell());
            dialog.setDatabaseInfo(dbInfo);
            dialog.setShardId(curShardId);
            dialog.setShardVal(curShardVal);
            dialog.setShardQueryType(shardQueryType);
            if (dialog.open() == OK_ID) {
                curShardId = dialog.getShardId();
                curShardVal = dialog.getShardVal();
                shardQueryType = dialog.getShardQueryType();
                if (dbInfo != null) {
                    dbInfo.setCurrentShardId(curShardId);
                    dbInfo.setCurrentShardVal(curShardVal);
                    dbInfo.setShardQueryType(shardQueryType);
                }
                updateShardIdButtonText();
            }
        }
    });
    updateShardIdButtonText();
    Label charsetLabel = new Label(brokerInfoGroup, SWT.LEFT);
    charsetLabel.setText(com.cubrid.common.ui.query.Messages.lblCharSet);
    charsetLabel.setLayoutData(createGridData(1, 1, -1, -1));
    charsetCombo = new Combo(brokerInfoGroup, SWT.LEFT | SWT.BORDER);
    charsetCombo.setLayoutData(createGridData(FILL_HORIZONTAL, 2, 1, 100, -1));
    Label jdbcLabel = new Label(brokerInfoGroup, SWT.LEFT);
    jdbcLabel.setText(Messages.lblDbJdbcVersion);
    jdbcLabel.setLayoutData(createGridData(1, 1, -1, -1));
    jdbcCombo = new Combo(brokerInfoGroup, SWT.LEFT | SWT.READ_ONLY | SWT.BORDER);
    jdbcCombo.setLayoutData(createGridData(FILL_HORIZONTAL, 1, 1, 100, -1));
    Button btnOpen = new Button(brokerInfoGroup, SWT.NONE);
    btnOpen.setText(Messages.btnBrowse);
    btnOpen.setLayoutData(createGridData(1, 1, 80, -1));
    btnOpen.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            JdbcManageDialog dialog = new JdbcManageDialog(getShell());
            if (dialog.open() == OK_ID) {
                String jdbcVersion = dialog.getSelectedJdbcVersion();
                if (isBlank(jdbcVersion)) {
                    jdbcVersion = jdbcCombo.getText();
                }
                resetJdbcCombo(jdbcVersion);
            }
        }
    });
    // JDBC attributes
    Label attrLabel = new Label(brokerInfoGroup, SWT.LEFT);
    attrLabel.setText(Messages.lblJdbcAttr);
    attrLabel.setLayoutData(createGridData(1, 1, -1, -1));
    attrText = new Text(brokerInfoGroup, SWT.LEFT | SWT.BORDER);
    attrText.setEditable(false);
    attrText.setLayoutData(createGridData(FILL_HORIZONTAL, 1, 1, 100, -1));
    Button btnAttr = new Button(brokerInfoGroup, SWT.NONE);
    btnAttr.setText(Messages.btnJdbcAttr);
    btnAttr.setLayoutData(createGridData(1, 1, 80, -1));
    btnAttr.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            JdbcOptionDialog dialog = new JdbcOptionDialog(getShell(), attrText.getText());
            if (dialog.open() == OK_ID) {
                attrText.setText(dialog.getJdbcOptions());
            }
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Pattern(java.util.regex.Pattern) JdbcOptionDialog(com.cubrid.common.ui.common.dialog.JdbcOptionDialog) VerifyListener(org.eclipse.swt.events.VerifyListener) Composite(org.eclipse.swt.widgets.Composite) Matcher(java.util.regex.Matcher) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Messages.shardValLabel(com.cubrid.common.ui.query.Messages.shardValLabel) Messages.autoCommitLabel(com.cubrid.common.ui.query.Messages.autoCommitLabel) Label(org.eclipse.swt.widgets.Label) Messages.shardIdLabel(com.cubrid.common.ui.query.Messages.shardIdLabel) ShardIdSelectionDialog(com.cubrid.common.ui.common.dialog.ShardIdSelectionDialog) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) FocusEvent(org.eclipse.swt.events.FocusEvent) Button(org.eclipse.swt.widgets.Button) CommonUITool.createGridData(com.cubrid.common.ui.spi.util.CommonUITool.createGridData) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) JdbcManageDialog(com.cubrid.common.ui.common.dialog.JdbcManageDialog) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 33 with FocusEvent

use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.

the class RunSQLFileDialog method registerContextMenu.

/**
	 * register context menu
	 */
private void registerContextMenu() {
    sqlFileTableViewer.getTable().addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            ActionManager.getInstance().changeFocusProvider(sqlFileTableViewer.getTable());
        }
    });
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    Menu contextMenu = menuManager.createContextMenu(sqlFileTableViewer.getTable());
    sqlFileTableViewer.getTable().setMenu(contextMenu);
    Menu menu = new Menu(getShell(), SWT.POP_UP);
    final MenuItem itemDelete = new MenuItem(menu, SWT.PUSH);
    itemDelete.setText("delete");
    itemDelete.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            List<String> deleteFiles = new ArrayList<String>();
            for (int i = 0; i < sqlFileTableViewer.getTable().getSelectionIndices().length; i++) {
                int index = sqlFileTableViewer.getTable().getSelectionIndices()[i];
                deleteFiles.add(filesList.get(index));
            }
            filesList.removeAll(deleteFiles);
            sqlFileTableViewer.setInput(filesList);
            sqlFileTableViewer.refresh();
        }
    });
    sqlFileTableViewer.getTable().setMenu(menu);
    Menu dbTablecontextMenu = menuManager.createContextMenu(databaseTableViewer.getTable());
    databaseTableViewer.getTable().setMenu(dbTablecontextMenu);
    Menu dbTableMenu = new Menu(getShell(), SWT.POP_UP);
    final MenuItem dbTableItemDelete = new MenuItem(dbTableMenu, SWT.PUSH);
    dbTableItemDelete.setText("delete");
    dbTableItemDelete.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            List<CubridDatabase> deleteCubridDatabase = new ArrayList<CubridDatabase>();
            for (int i = 0; i < databaseTableViewer.getTable().getSelectionIndices().length; i++) {
                int index = databaseTableViewer.getTable().getSelectionIndices()[i];
                deleteCubridDatabase.add(cubridDatabases[index]);
            }
            List<CubridDatabase> dbList = Arrays.asList(cubridDatabases);
            ArrayList<CubridDatabase> newDbList = new ArrayList<CubridDatabase>();
            for (CubridDatabase cubridDatabase : dbList) {
                if (deleteCubridDatabase.contains(cubridDatabase)) {
                    continue;
                }
                newDbList.add(cubridDatabase);
            }
            cubridDatabases = newDbList.toArray(new CubridDatabase[newDbList.size()]);
            databaseTableViewer.setInput(cubridDatabases);
            databaseTableViewer.refresh();
        }
    });
    sqlFileTableViewer.getTable().setMenu(menu);
    databaseTableViewer.getTable().setMenu(dbTableMenu);
    runSQLFileDialogDNDController = new RunSQLFileDialogDNDController(this);
    runSQLFileDialogDNDController.registerDropTarget();
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArrayList(java.util.ArrayList) MenuItem(org.eclipse.swt.widgets.MenuItem) FocusEvent(org.eclipse.swt.events.FocusEvent) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) ArrayList(java.util.ArrayList) Menu(org.eclipse.swt.widgets.Menu) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 34 with FocusEvent

use of org.eclipse.swt.events.FocusEvent in project azure-tools-for-java by Microsoft.

the class AppServiceCreateDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    setMessage("Create Azure App Service");
    setTitle("Create App Service");
    Composite area = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(area, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
    Group grpAppService = new Group(composite, SWT.NONE);
    grpAppService.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
    grpAppService.setLayout(new GridLayout(3, false));
    Label lblAppName = new Label(grpAppService, SWT.NONE);
    lblAppName.setText("Enter name");
    textAppName = new Text(grpAppService, SWT.BORDER);
    textAppName.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            cleanError();
        }
    });
    textAppName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textAppName.setMessage("<enter name>");
    dec_textAppName = decorateContorolAndRegister(textAppName);
    Label lblazurewebsitescom = new Label(grpAppService, SWT.NONE);
    lblazurewebsitescom.setText(".azurewebsites.net");
    Label lblWebContainer = new Label(grpAppService, SWT.NONE);
    lblWebContainer.setText("Web container");
    comboWebContainer = new Combo(grpAppService, SWT.READ_ONLY);
    comboWebContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    dec_comboWebContainer = decorateContorolAndRegister(comboWebContainer);
    Label lblSubscription = new Label(grpAppService, SWT.NONE);
    lblSubscription.setText("Subscription");
    comboSubscription = new Combo(grpAppService, SWT.READ_ONLY);
    comboSubscription.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            fillResourceGroups();
            fillAppServicePlans();
            fillAppServicePlansDetails();
            fillAppServicePlanLocations();
        }
    });
    dec_comboSubscription = decorateContorolAndRegister(comboSubscription);
    comboSubscription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    // ====
    tabFolder = new TabFolder(composite, SWT.NONE);
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    tabItemAppServicePlan = new TabItem(tabFolder, SWT.NONE);
    tabItemAppServicePlan.setText("App service plan");
    compositeAppServicePlan = new Composite(tabFolder, SWT.NONE);
    tabItemAppServicePlan.setControl(compositeAppServicePlan);
    compositeAppServicePlan.setLayout(new GridLayout(2, false));
    btnAppServiceCreateNew = new Button(compositeAppServicePlan, SWT.RADIO);
    btnAppServiceCreateNew.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            radioAppServicePlanLogic();
        }
    });
    btnAppServiceCreateNew.setSelection(true);
    btnAppServiceCreateNew.setBounds(0, 0, 90, 16);
    btnAppServiceCreateNew.setText("Create new");
    textAppSevicePlanName = new Text(compositeAppServicePlan, SWT.BORDER);
    textAppSevicePlanName.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            cleanError();
        }
    });
    textAppSevicePlanName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textAppSevicePlanName.setMessage("<enter name>");
    dec_textAppSevicePlanName = decorateContorolAndRegister(textAppSevicePlanName);
    lblAppServiceCreateNewLocation = new Label(compositeAppServicePlan, SWT.NONE);
    GridData gd_lblAppServiceCreateNewLocation = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblAppServiceCreateNewLocation.horizontalIndent = 15;
    lblAppServiceCreateNewLocation.setLayoutData(gd_lblAppServiceCreateNewLocation);
    lblAppServiceCreateNewLocation.setText("Location");
    comboAppServicePlanLocation = new Combo(compositeAppServicePlan, SWT.READ_ONLY);
    comboAppServicePlanLocation.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            cleanError();
        }
    });
    comboAppServicePlanLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    dec_comboAppServicePlanLocation = decorateContorolAndRegister(comboAppServicePlanLocation);
    lblAppServiceCreateNewPricingTier = new Label(compositeAppServicePlan, SWT.NONE);
    GridData gd_lblAppServiceCreateNewPricingTier = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblAppServiceCreateNewPricingTier.horizontalIndent = 15;
    lblAppServiceCreateNewPricingTier.setLayoutData(gd_lblAppServiceCreateNewPricingTier);
    lblAppServiceCreateNewPricingTier.setText("Pricing tier");
    comboAppServicePlanPricingTier = new Combo(compositeAppServicePlan, SWT.READ_ONLY);
    comboAppServicePlanPricingTier.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    btnAppServiceUseExisting = new Button(compositeAppServicePlan, SWT.RADIO);
    btnAppServiceUseExisting.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            radioAppServicePlanLogic();
        }
    });
    btnAppServiceUseExisting.setText("Use existing");
    comboAppServicePlan = new Combo(compositeAppServicePlan, SWT.READ_ONLY);
    comboAppServicePlan.setEnabled(false);
    comboAppServicePlan.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboAppServicePlan.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            fillAppServicePlansDetails();
        }
    });
    comboAppServicePlan.setBounds(0, 0, 26, 22);
    dec_comboAppServicePlan = decorateContorolAndRegister(comboAppServicePlan);
    lblAppServiceUseExictingLocation = new Label(compositeAppServicePlan, SWT.NONE);
    lblAppServiceUseExictingLocation.setEnabled(false);
    GridData gd_lblAppServiceUseExictingLocation = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblAppServiceUseExictingLocation.horizontalIndent = 15;
    lblAppServiceUseExictingLocation.setLayoutData(gd_lblAppServiceUseExictingLocation);
    lblAppServiceUseExictingLocation.setText("Location");
    lblAppSevicePlanLocation = new Label(compositeAppServicePlan, SWT.NONE);
    lblAppSevicePlanLocation.setEnabled(false);
    lblAppSevicePlanLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    lblAppSevicePlanLocation.setText("N/A");
    lblAppServiceUseExistiogPrisingTier = new Label(compositeAppServicePlan, SWT.NONE);
    lblAppServiceUseExistiogPrisingTier.setEnabled(false);
    GridData gd_lblAppServiceUseExistiogPrisingTier = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblAppServiceUseExistiogPrisingTier.horizontalIndent = 15;
    lblAppServiceUseExistiogPrisingTier.setLayoutData(gd_lblAppServiceUseExistiogPrisingTier);
    lblAppServiceUseExistiogPrisingTier.setText("Pricing tier");
    lblAppServicePlanPricingTier = new Label(compositeAppServicePlan, SWT.NONE);
    lblAppServicePlanPricingTier.setEnabled(false);
    lblAppServicePlanPricingTier.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    lblAppServicePlanPricingTier.setText("N/A");
    new Label(compositeAppServicePlan, SWT.NONE);
    //dec_comboAppServicePlanPricingTier = decorateContorolAndRegister(comboAppServicePlanPricingTier);
    linkAppServicePricing = new Link(compositeAppServicePlan, SWT.NONE);
    linkAppServicePricing.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    linkAppServicePricing.setText("<a>App service pricing details</a>");
    linkAppServicePricing.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            try {
                PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL("https://azure.microsoft.com/en-us/pricing/details/app-service/"));
            } catch (PartInitException | MalformedURLException ex) {
                LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "widgetSelected@SelectionAdapter@linkAppServicePricing@AppServiceCreateDialog", ex));
            }
        }
    });
    tabItemResourceGroup = new TabItem(tabFolder, SWT.NONE);
    tabItemResourceGroup.setText("Resource group");
    compositeResourceGroup = new Composite(tabFolder, SWT.NONE);
    tabItemResourceGroup.setControl(compositeResourceGroup);
    compositeResourceGroup.setLayout(new GridLayout(2, false));
    btnResourceGroupCreateNew = new Button(compositeResourceGroup, SWT.RADIO);
    btnResourceGroupCreateNew.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            radioResourceGroupLogic();
        }
    });
    btnResourceGroupCreateNew.setSelection(true);
    btnResourceGroupCreateNew.setText("Create new");
    textResourceGroupName = new Text(compositeResourceGroup, SWT.BORDER);
    textResourceGroupName.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            cleanError();
        }
    });
    textResourceGroupName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textResourceGroupName.setBounds(0, 0, 64, 19);
    textResourceGroupName.setMessage("<enter name>");
    dec_textNewResGrName = decorateContorolAndRegister(textResourceGroupName);
    btnResourceGroupUseExisting = new Button(compositeResourceGroup, SWT.RADIO);
    btnResourceGroupUseExisting.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            radioResourceGroupLogic();
        }
    });
    btnResourceGroupUseExisting.setText("Use existing");
    comboResourceGroup = new Combo(compositeResourceGroup, SWT.READ_ONLY);
    comboResourceGroup.setEnabled(false);
    comboResourceGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboResourceGroup.setBounds(0, 0, 26, 22);
    dec_comboSelectResGr = decorateContorolAndRegister(comboResourceGroup);
    tabItemJDK = new TabItem(tabFolder, SWT.NONE);
    tabItemJDK.setText("JDK");
    compositeJDK = new Composite(tabFolder, SWT.NONE);
    tabItemJDK.setControl(compositeJDK);
    compositeJDK.setLayout(new GridLayout(3, false));
    btnJdkDefault = new Button(compositeJDK, SWT.RADIO);
    btnJdkDefault.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            radioJdkLogic();
        }
    });
    btnJdkDefault.setSelection(true);
    btnJdkDefault.setText("Default");
    lblJdkDefaultComment = new Label(compositeJDK, SWT.NONE);
    lblJdkDefaultComment.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    lblJdkDefaultComment.setText("Deploy the default JDK (JDK 8)");
    new Label(compositeJDK, SWT.NONE);
    btnJdk3rdParty = new Button(compositeJDK, SWT.RADIO);
    btnJdk3rdParty.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            radioJdkLogic();
        }
    });
    btnJdk3rdParty.setText("3rd party");
    comboJdk3Party = new Combo(compositeJDK, SWT.READ_ONLY);
    comboJdk3Party.setEnabled(false);
    comboJdk3Party.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    dec_comboJdk3Party = decorateContorolAndRegister(comboJdk3Party);
    linkJdkLicense = new Link(compositeJDK, SWT.NONE);
    linkJdkLicense.setEnabled(false);
    linkJdkLicense.setText("<a>License</a>");
    linkJdkLicense.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            try {
                PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(AzulZuluModel.getLicenseUrl()));
            } catch (Exception ex) {
                LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "widgetSelected@SelectionAdapter@AppServiceCreateDialo", ex));
            }
        }
    });
    btnJdkOwnDownloadUrl = new Button(compositeJDK, SWT.RADIO);
    btnJdkOwnDownloadUrl.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            radioJdkLogic();
        }
    });
    btnJdkOwnDownloadUrl.setText("Download URL");
    textJdkOwnUrl = new Text(compositeJDK, SWT.BORDER);
    textJdkOwnUrl.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            cleanError();
        }
    });
    textJdkOwnUrl.setEnabled(false);
    textJdkOwnUrl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textJdkOwnUrl.setMessage("<enter url>");
    dec_textJdkOwnUrl = decorateContorolAndRegister(textJdkOwnUrl);
    new Label(compositeJDK, SWT.NONE);
    lblJdkOwnSrorageAccountKey = new Label(compositeJDK, SWT.NONE);
    GridData gd_lblJdkOwnSrorageAccountKey = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblJdkOwnSrorageAccountKey.horizontalIndent = 15;
    lblJdkOwnSrorageAccountKey.setLayoutData(gd_lblJdkOwnSrorageAccountKey);
    lblJdkOwnSrorageAccountKey.setText("Storage account key");
    textJdkOwnStorageAccountKey = new Text(compositeJDK, SWT.BORDER);
    textJdkOwnStorageAccountKey.setEnabled(false);
    textJdkOwnStorageAccountKey.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textJdkOwnStorageAccountKey.setMessage("<enter storage account key>");
    decorateContorolAndRegister(textJdkOwnStorageAccountKey);
    new Label(compositeJDK, SWT.NONE);
    new Label(compositeJDK, SWT.NONE);
    lblJdkOwnComment = new Label(compositeJDK, SWT.NONE);
    lblJdkOwnComment.setEnabled(false);
    lblJdkOwnComment.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    lblJdkOwnComment.setText("(If the URL above is a private blob)");
    new Label(compositeJDK, SWT.NONE);
    DateFormat df = new SimpleDateFormat("yyMMddHHmmss");
    String date = df.format(new Date());
    textAppName.setText("webapp-" + date);
    textAppSevicePlanName.setText("asp-" + date);
    textResourceGroupName.setText("rg-webapp-" + date);
    fillWebContainers();
    fillSubscriptions();
    fillResourceGroups();
    fillAppServicePlans();
    fillAppServicePlansDetails();
    fillAppServicePlanLocations();
    fillAppServicePlanPricingTiers();
    fill3PartyJdk();
    return area;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) TabFolder(org.eclipse.swt.widgets.TabFolder) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) FocusEvent(org.eclipse.swt.events.FocusEvent) URL(java.net.URL) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MalformedURLException(java.net.MalformedURLException) Date(java.util.Date) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SimpleDateFormat(java.text.SimpleDateFormat) Link(org.eclipse.swt.widgets.Link)

Example 35 with FocusEvent

use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.

the class UnifyHostConfigEditor method registerCubridCMConfTableContextMenu.

/**
	 * register CubridCMConfTable context menu
	 */
private void registerCubridCMConfTableContextMenu() {
    cubridCMConfTabTableViewer.getTable().addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent event) {
            ActionManager.getInstance().changeFocusProvider(cubridCMConfTabTableViewer.getTable());
        }
    });
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    Menu contextMenu = menuManager.createContextMenu(cubridCMConfTabTableViewer.getTable());
    cubridCMConfTabTableViewer.getTable().setMenu(contextMenu);
    Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
    final MenuItem itemEditAnnotation = new MenuItem(menu, SWT.PUSH);
    itemEditAnnotation.setText(Messages.confEditorTableMenuEditAnnotation);
    itemEditAnnotation.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("all")
        public void widgetSelected(SelectionEvent event) {
            //seems like MenuEvent can't get the mouse click Point
            //so use the point which table MouseDown event marked 
            Point pt = cubridCMConfTableClickPoint;
            int selectIndex = cubridCMConfTabTableViewer.getTable().getSelectionIndex();
            final TableItem item = cubridCMConfTabTableViewer.getTable().getItem(selectIndex);
            if (item == null) {
                return;
            }
            for (int i = 0; i < cubridCMConfTabTableViewer.getTable().getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                    if (i == 0) {
                        CommonUITool.openErrorBox(getSite().getShell(), Messages.annotationDialogOpenErrorMsg);
                        return;
                    }
                    IStructuredSelection selection = (IStructuredSelection) cubridCMConfTabTableViewer.getSelection();
                    HashMap<String, String> valueMap = (HashMap<String, String>) selection.getFirstElement();
                    String serverName = cubridConfCMConfigListData.get(0).get(i + "");
                    String parentPropertyKey = valueMap.get("0");
                    String parentKey = " ";
                    Map<String, String> cubridMap = cubridConfCMConfigListData.get(1);
                    String cubridName = "";
                    if (cubridMap != null) {
                        cubridName = cubridMap.get(i + "");
                    }
                    if (selectIndex == 0) {
                        parentKey += serverName;
                    } else {
                        if (selectIndex == 1) {
                            parentKey += serverName + "->" + cubridName;
                        } else {
                            parentKey += serverName + "->" + cubridName + "->" + parentPropertyKey;
                        }
                    }
                    String annotationKey = Integer.toString(i) + BrokerConfPersistUtil.ANNOTATION;
                    CubridBrokerConfEditAnnotationDialog dialog = new CubridBrokerConfEditAnnotationDialog(getSite().getShell(), parentKey, annotationKey, valueMap);
                    if (IDialogConstants.OK_ID == dialog.open()) {
                        setDirty(true);
                    }
                }
            }
        }
    });
    menu.addMenuListener(new MenuAdapter() {

        public void menuShown(MenuEvent event) {
            //seems like MenuEvent can't get the mouse click Point
            //so use the point which table MouseDown event marked 
            Point pt = cubridCMConfTableClickPoint;
            // click timing
            if (System.currentTimeMillis() - cubridCMConfTableClickPointTiming > 300) {
                itemEditAnnotation.setEnabled(false);
                return;
            }
            int selectIndex = cubridCMConfTabTableViewer.getTable().getSelectionIndex();
            if (selectIndex == -1) {
                itemEditAnnotation.setEnabled(false);
                return;
            }
            if (selectIndex == 0) {
                itemEditAnnotation.setEnabled(false);
                return;
            }
            final TableItem item = cubridCMConfTabTableViewer.getTable().getItem(selectIndex);
            if (item == null) {
                return;
            }
            for (int i = 0; i < cubridCMConfTabTableViewer.getTable().getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                    if (i == 0) {
                        itemEditAnnotation.setEnabled(false);
                    } else {
                        itemEditAnnotation.setEnabled(true);
                    }
                }
            }
        }
    });
    cubridCMConfTabTableViewer.getTable().setMenu(menu);
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) CubridBrokerConfEditAnnotationDialog(com.cubrid.common.ui.common.dialog.CubridBrokerConfEditAnnotationDialog) MenuAdapter(org.eclipse.swt.events.MenuAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FocusEvent(org.eclipse.swt.events.FocusEvent) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) MenuEvent(org.eclipse.swt.events.MenuEvent)

Aggregations

FocusEvent (org.eclipse.swt.events.FocusEvent)115 FocusAdapter (org.eclipse.swt.events.FocusAdapter)64 SelectionEvent (org.eclipse.swt.events.SelectionEvent)54 FocusListener (org.eclipse.swt.events.FocusListener)47 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)42 GridData (org.eclipse.swt.layout.GridData)38 Composite (org.eclipse.swt.widgets.Composite)34 Text (org.eclipse.swt.widgets.Text)33 GridLayout (org.eclipse.swt.layout.GridLayout)32 Label (org.eclipse.swt.widgets.Label)26 Menu (org.eclipse.swt.widgets.Menu)22 KeyEvent (org.eclipse.swt.events.KeyEvent)21 Button (org.eclipse.swt.widgets.Button)21 Point (org.eclipse.swt.graphics.Point)20 ModifyEvent (org.eclipse.swt.events.ModifyEvent)19 MenuManager (org.eclipse.jface.action.MenuManager)18 ModifyListener (org.eclipse.swt.events.ModifyListener)18 Combo (org.eclipse.swt.widgets.Combo)17 Group (org.eclipse.swt.widgets.Group)17 SelectionListener (org.eclipse.swt.events.SelectionListener)15