Search in sources :

Example 21 with FocusAdapter

use of org.eclipse.swt.events.FocusAdapter 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 22 with FocusAdapter

use of org.eclipse.swt.events.FocusAdapter 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)

Example 23 with FocusAdapter

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

the class SetHostInfoPage method createControl.

/**
	 * Create the control for this page
	 * 
	 * @param parent Composite
	 */
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 10;
    layout.marginWidth = 10;
    composite.setLayout(layout);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    composite.setLayoutData(gridData);
    Group cmServerInfoGroup = new Group(composite, SWT.NONE);
    cmServerInfoGroup.setText(Messages.grpHostInfo);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    cmServerInfoGroup.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    cmServerInfoGroup.setLayout(layout);
    Label nickNameLable = new Label(cmServerInfoGroup, SWT.LEFT);
    nickNameLable.setText(Messages.lblNickName);
    nickNameLable.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    nickNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    nickNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Label ipLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    ipLabel.setText(Messages.lblIPAddress);
    ipLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    ipText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    ipText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    ipText.addModifyListener(this);
    Label portNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    portNameLabel.setText(Messages.lblPort);
    portNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    portText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    portText.setTextLimit(5);
    portText.setText("8001");
    portText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    portText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            portText.selectAll();
            portText.setFocus();
        }
    });
    portText.addModifyListener(this);
    Label userNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    userNameLabel.setText(Messages.lblUserName);
    userNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    userNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    userNameText.setText("admin");
    userNameText.setEnabled(false);
    userNameText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
    userNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Label passwordLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    passwordLabel.setText(Messages.lblPassword);
    passwordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    passwordText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
    passwordText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
    passwordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    passwordText.addModifyListener(this);
    passwordText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            passwordText.selectAll();
            passwordText.setFocus();
        }
    });
    Composite btnComposite = new Composite(composite, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 5;
    btnComposite.setLayout(rowLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalAlignment = GridData.END;
    btnComposite.setLayoutData(gridData);
    connectHostButton = new Button(btnComposite, SWT.NONE);
    connectHostButton.setText(Messages.btnConnect);
    connectHostButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String address = ipText.getText();
            String port = portText.getText();
            String userName = userNameText.getText();
            String password = passwordText.getText();
            String nickName = nickNameText.getText();
            if (nickName.trim().length() == 0) {
                nickNameText.setText(address + ":" + port);
            }
            ServerInfo serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(address, Integer.parseInt(port), userName);
            if (serverInfo == null) {
                serverInfo = new ServerInfo();
                serverInfo.setServerName(address);
                serverInfo.setHostAddress(address);
                serverInfo.setHostMonPort(Integer.parseInt(port));
                serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
                serverInfo.setUserName(userName);
                serverInfo.setUserPassword(password);
                serverInfo.setJdbcDriverVersion(ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION);
            }
            heartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
            heartbeatNodeInfoTask.setAllDb(false);
            heartbeatNodeInfoTask.setDbList(new ArrayList<String>());
            TaskExecutor executor = null;
            if (serverInfo.isConnected()) {
                if (CompatibleUtil.isSupportHA(serverInfo)) {
                    executor = new CommonTaskExec(null);
                    executor.addTask(heartbeatNodeInfoTask);
                }
            } else {
                executor = new ConnectHostExecutor(getShell(), serverInfo, true);
                executor.addTask(heartbeatNodeInfoTask);
            }
            if (executor != null) {
                new ExecTaskWithProgress(executor).exec(true, true);
            }
            changeBtnStatus();
        }
    });
    connectHostButton.setEnabled(false);
    init();
    nickNameText.setFocus();
    setTitle(Messages.titileHostInfoPage);
    setMessage(Messages.msgHostInfoPage);
    setControl(composite);
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) Composite(org.eclipse.swt.widgets.Composite) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask) GridLayout(org.eclipse.swt.layout.GridLayout) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ConnectHostExecutor(com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor)

Example 24 with FocusAdapter

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

the class ConnectHostNodeDialog method createDialogArea.

/**
	 * Create dialog area content
	 * 
	 * @param parent the parent composite
	 * @return the control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    Group cmServerInfoGroup = new Group(composite, SWT.NONE);
    cmServerInfoGroup.setText(Messages.grpHostInfo);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    cmServerInfoGroup.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    cmServerInfoGroup.setLayout(layout);
    Label ipLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    ipLabel.setText(Messages.lblIPAddress);
    ipLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    ipText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    ipText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    ipText.setEnabled(false);
    Label portNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    portNameLabel.setText(Messages.lblPort);
    portNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    portText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    portText.setText("8001");
    portText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    portText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            portText.selectAll();
            portText.setFocus();
        }
    });
    Label userNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    userNameLabel.setText(Messages.lblUserName);
    userNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    userNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    userNameText.setText("admin");
    userNameText.setEnabled(false);
    userNameText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
    userNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Label passwordLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    passwordLabel.setText(Messages.lblPassword);
    passwordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    passwordText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
    passwordText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
    passwordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    passwordText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            passwordText.selectAll();
            passwordText.setFocus();
        }
    });
    setTitle(Messages.titileHostInfoPage);
    setMessage(Messages.msgHostInfoPage);
    init();
    return composite;
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 25 with FocusAdapter

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

the class ColumnViewerSorter method registerContextMenu.

private void registerContextMenu() {
    final ActionManager manager = ActionManager.getInstance();
    final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    tableListView.getTable().addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            manager.changeFocusProvider(tableListView.getTable());
        }
    });
    Menu menu = new Menu(shell, SWT.POP_UP);
    // SELECT GROUP
    final Menu makeSelectQueryMenu = new Menu(menu);
    {
        MenuItem subMenuItem = new MenuItem(menu, SWT.CASCADE);
        subMenuItem.setText(com.cubrid.common.ui.spi.Messages.lblMakeSelectQueryGrp);
        subMenuItem.setMenu(makeSelectQueryMenu);
    }
    // SELECT
    initializeAction(makeSelectQueryMenu, getMakeQueryAction(MakeSelectQueryAction.ID));
    // Parameterized SELECT
    initializeAction(makeSelectQueryMenu, getMakeQueryAction(MakeSelectPstmtQueryAction.ID));
    // Parameterized INSERT
    initializeAction(menu, getMakeQueryAction(MakeInsertQueryAction.ID));
    // Parameterized UPDATE
    initializeAction(menu, getMakeQueryAction(MakeUpdateQueryAction.ID));
    // Parameterized DELETE
    initializeAction(menu, getMakeQueryAction(MakeDeleteQueryAction.ID));
    // CREATE
    initializeAction(menu, getMakeQueryAction(MakeCreateQueryAction.ID));
    new MenuItem(menu, SWT.SEPARATOR);
    final TableToJavaCodeAction createJavaCodeAction = (TableToJavaCodeAction) manager.getAction(TableToJavaCodeAction.ID);
    if (createJavaCodeAction != null) {
        MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
        menuItem.setText(createJavaCodeAction.getText());
        menuItem.setImage(CommonUITool.getImage(createJavaCodeAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode[] nodes = getAllSelectedNodes();
                if (nodes != null && nodes.length > 0) {
                    createJavaCodeAction.run(nodes);
                }
            }
        });
    }
    final TableToPhpCodeAction createPhpCodeAction = (TableToPhpCodeAction) manager.getAction(TableToPhpCodeAction.ID);
    if (createPhpCodeAction != null) {
        MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
        menuItem.setText(createPhpCodeAction.getText());
        menuItem.setImage(CommonUITool.getImage(createPhpCodeAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode[] nodes = getAllSelectedNodes();
                if (nodes != null && nodes.length > 0) {
                    createPhpCodeAction.run(nodes);
                }
            }
        });
    }
    final ExportTableDefinitionAction exportTableDefinitionAction = (ExportTableDefinitionAction) manager.getAction(ExportTableDefinitionAction.ID);
    if (exportTableDefinitionAction != null) {
        MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
        menuItem.setText(exportTableDefinitionAction.getText());
        menuItem.setImage(CommonUITool.getImage(exportTableDefinitionAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode[] nodes = getAllSelectedNodes();
                if (nodes != null && nodes.length > 0) {
                    exportTableDefinitionAction.run(nodes);
                }
            }
        });
    }
    new MenuItem(menu, SWT.SEPARATOR);
    // View data menu
    final Menu viewDataMenu = new Menu(menu);
    {
        final MenuItem subMenuItem = new MenuItem(menu, SWT.CASCADE);
        subMenuItem.setText(com.cubrid.common.ui.spi.Messages.viewDataMenuName);
        subMenuItem.setMenu(viewDataMenu);
    }
    final TableSelectAllAction selectAllAction = (TableSelectAllAction) manager.getAction(TableSelectAllAction.ID);
    if (selectAllAction != null) {
        MenuItem menuItem = new MenuItem(viewDataMenu, SWT.PUSH);
        menuItem.setText(selectAllAction.getText());
        menuItem.setImage(CommonUITool.getImage(selectAllAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode node = getFirstSelectedNode();
                if (node != null) {
                    selectAllAction.run((ISchemaNode) node);
                }
            }
        });
    }
    final SelectByOnePstmtDataAction selectPstmtAction = (SelectByOnePstmtDataAction) manager.getAction(SelectByOnePstmtDataAction.ID);
    if (selectPstmtAction != null) {
        MenuItem menuItem = new MenuItem(viewDataMenu, SWT.PUSH);
        menuItem.setText(selectPstmtAction.getText());
        menuItem.setImage(CommonUITool.getImage(selectPstmtAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode node = getFirstSelectedNode();
                if (node != null) {
                    selectPstmtAction.run((ISchemaNode) node);
                }
            }
        });
    }
    final SelectByMultiPstmtDataAction selectMultiPstmtAction = (SelectByMultiPstmtDataAction) manager.getAction(SelectByMultiPstmtDataAction.ID);
    if (selectMultiPstmtAction != null) {
        MenuItem menuItem = new MenuItem(viewDataMenu, SWT.PUSH);
        menuItem.setText(selectMultiPstmtAction.getText());
        menuItem.setImage(CommonUITool.getImage(selectMultiPstmtAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode node = getFirstSelectedNode();
                if (node != null) {
                    selectMultiPstmtAction.run((ISchemaNode) node);
                }
            }
        });
    }
    new MenuItem(viewDataMenu, SWT.SEPARATOR);
    final TableSelectCountAction selectCountAction = (TableSelectCountAction) manager.getAction(TableSelectCountAction.ID);
    if (selectCountAction != null) {
        MenuItem menuItem = new MenuItem(viewDataMenu, SWT.PUSH);
        menuItem.setText(selectCountAction.getText());
        menuItem.setImage(CommonUITool.getImage(selectAllAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode node = getFirstSelectedNode();
                if (node != null) {
                    selectCountAction.run((ISchemaNode) node);
                }
            }
        });
    }
    // Input data menu
    final Menu inputDataMenu = new Menu(menu);
    {
        MenuItem subMenuItem = new MenuItem(menu, SWT.CASCADE);
        subMenuItem.setText(com.cubrid.common.ui.spi.Messages.inputDataMenuName);
        subMenuItem.setMenu(inputDataMenu);
    }
    final InsertOneByPstmtAction insertStmtAction = (InsertOneByPstmtAction) manager.getAction(InsertOneByPstmtAction.ID);
    if (insertStmtAction != null) {
        MenuItem menuItem = new MenuItem(inputDataMenu, SWT.PUSH);
        menuItem.setText(insertStmtAction.getText());
        menuItem.setImage(CommonUITool.getImage(insertStmtAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode node = getFirstSelectedNode();
                if (node != null) {
                    insertStmtAction.run((ISchemaNode) node);
                }
            }
        });
    }
    final ImportDataFromFileAction insertMultiStmtAction = (ImportDataFromFileAction) manager.getAction(ImportDataFromFileAction.ID);
    if (insertMultiStmtAction != null) {
        MenuItem menuItem = new MenuItem(inputDataMenu, SWT.PUSH);
        menuItem.setText(insertMultiStmtAction.getText());
        menuItem.setImage(CommonUITool.getImage(insertMultiStmtAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode node = getFirstSelectedNode();
                if (node != null) {
                    insertMultiStmtAction.run((ISchemaNode) node);
                }
            }
        });
    }
    new MenuItem(menu, SWT.SEPARATOR);
    // Export & Import
    final ExportWizardAction exportWizardAction = (ExportWizardAction) manager.getAction(ExportWizardAction.ID);
    if (exportWizardAction != null) {
        MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
        menuItem.setText(exportWizardAction.getText());
        menuItem.setImage(CommonUITool.getImage(exportWizardAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode[] nodes = getAllSelectedNodes();
                if (nodes != null && nodes.length > 0) {
                    exportWizardAction.run(nodes);
                }
            }
        });
    }
    final ImportWizardAction importWizardAction = (ImportWizardAction) manager.getAction(ImportWizardAction.ID);
    if (importWizardAction != null) {
        MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
        menuItem.setText(importWizardAction.getText());
        menuItem.setImage(CommonUITool.getImage(importWizardAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode[] nodes = getAllSelectedNodes();
                if (nodes != null && nodes.length > 0) {
                    importWizardAction.run(nodes);
                }
            }
        });
    }
    new MenuItem(menu, SWT.SEPARATOR);
    final EditTableAction editTableAction = (EditTableAction) manager.getAction(EditTableAction.ID);
    if (editTableAction != null) {
        MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
        menuItem.setText(editTableAction.getText());
        menuItem.setImage(CommonUITool.getImage(editTableAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode node = getFirstSelectedNode();
                if (node != null) {
                    editTableAction.run((ISchemaNode) node);
                }
            }
        });
    }
    final RenameTableAction renameTableAction = (RenameTableAction) manager.getAction(RenameTableAction.ID);
    if (renameTableAction != null) {
        MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
        menuItem.setText(renameTableAction.getText());
        menuItem.setImage(CommonUITool.getImage(renameTableAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode node = getFirstSelectedNode();
                if (node != null) {
                    renameTableAction.run(database, (ISchemaNode) node);
                }
            }
        });
    }
    new MenuItem(menu, SWT.SEPARATOR);
    final Menu manageTableMenu = new Menu(menu);
    {
        final MenuItem subMenuItem = new MenuItem(menu, SWT.CASCADE);
        subMenuItem.setText(com.cubrid.common.ui.spi.Messages.tableMoreName);
        subMenuItem.setMenu(manageTableMenu);
    }
    final DeleteTableAction deleteTableAction = (DeleteTableAction) manager.getAction(DeleteTableAction.ID);
    if (deleteTableAction != null) {
        MenuItem menuItem = new MenuItem(manageTableMenu, SWT.PUSH);
        menuItem.setText(deleteTableAction.getText());
        menuItem.setImage(CommonUITool.getImage(deleteTableAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode[] nodes = getAllSelectedNodes();
                if (nodes != null && nodes.length > 0) {
                    deleteTableAction.run(nodes);
                }
            }
        });
    }
    final DropTableAction dropTableAction = (DropTableAction) manager.getAction(DropTableAction.ID);
    if (dropTableAction != null) {
        MenuItem menuItem = new MenuItem(manageTableMenu, SWT.PUSH);
        menuItem.setText(dropTableAction.getText());
        menuItem.setImage(CommonUITool.getImage(dropTableAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ICubridNode[] nodes = getAllSelectedNodes();
                if (nodes != null && nodes.length > 0) {
                    dropTableAction.run(nodes);
                }
            }
        });
    }
    if (CompatibleUtil.isSupportCreateTableLike(database.getDatabaseInfo())) {
        final CreateLikeTableAction createLikeTableAction = (CreateLikeTableAction) manager.getAction(CreateLikeTableAction.ID);
        if (createLikeTableAction != null) {
            MenuItem menuItem = new MenuItem(manageTableMenu, SWT.PUSH);
            menuItem.setText(createLikeTableAction.getText());
            menuItem.setImage(CommonUITool.getImage(createLikeTableAction.getImageDescriptor()));
            menuItem.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent event) {
                    ICubridNode node = getFirstSelectedNode();
                    if (node != null) {
                        createLikeTableAction.run((ISchemaNode) node);
                    }
                }
            });
        }
    }
    new MenuItem(menu, SWT.SEPARATOR);
    final NewTableAction newTableAction = (NewTableAction) manager.getAction(NewTableAction.ID);
    if (newTableAction != null) {
        MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
        menuItem.setText(newTableAction.getText());
        menuItem.setImage(CommonUITool.getImage(newTableAction.getImageDescriptor()));
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                newTableAction.run(database);
            }
        });
    }
    new MenuItem(menu, SWT.SEPARATOR);
    final MenuItem refreshItem = new MenuItem(menu, SWT.PUSH);
    refreshItem.setText(Messages.tablesDetailInfoPartRefreshMenu);
    refreshItem.setImage(CommonUIPlugin.getImage("icons/action/refresh.png"));
    refreshItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            refresh();
        }
    });
    tableListView.getTable().setMenu(menu);
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) ImportWizardAction(com.cubrid.common.ui.cubrid.table.action.ImportWizardAction) TableToPhpCodeAction(com.cubrid.common.ui.cubrid.table.action.TableToPhpCodeAction) RenameTableAction(com.cubrid.common.ui.cubrid.table.action.RenameTableAction) SelectByMultiPstmtDataAction(com.cubrid.common.ui.cubrid.table.action.SelectByMultiPstmtDataAction) TableSelectAllAction(com.cubrid.common.ui.cubrid.table.action.TableSelectAllAction) TableSelectCountAction(com.cubrid.common.ui.cubrid.table.action.TableSelectCountAction) FocusEvent(org.eclipse.swt.events.FocusEvent) ActionManager(com.cubrid.common.ui.spi.action.ActionManager) Shell(org.eclipse.swt.widgets.Shell) NewTableAction(com.cubrid.common.ui.cubrid.table.action.NewTableAction) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DropTableAction(com.cubrid.common.ui.cubrid.table.action.DropTableAction) ExportWizardAction(com.cubrid.common.ui.cubrid.table.action.ExportWizardAction) Menu(org.eclipse.swt.widgets.Menu) CreateLikeTableAction(com.cubrid.common.ui.cubrid.table.action.CreateLikeTableAction) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) EditTableAction(com.cubrid.common.ui.cubrid.table.action.EditTableAction) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) InsertOneByPstmtAction(com.cubrid.common.ui.cubrid.table.action.InsertOneByPstmtAction) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) ExportTableDefinitionAction(com.cubrid.common.ui.cubrid.table.action.ExportTableDefinitionAction) SelectByOnePstmtDataAction(com.cubrid.common.ui.cubrid.table.action.SelectByOnePstmtDataAction) DeleteTableAction(com.cubrid.common.ui.cubrid.table.action.DeleteTableAction) TableToJavaCodeAction(com.cubrid.common.ui.cubrid.table.action.TableToJavaCodeAction) ImportDataFromFileAction(com.cubrid.common.ui.cubrid.table.action.ImportDataFromFileAction)

Aggregations

FocusAdapter (org.eclipse.swt.events.FocusAdapter)68 FocusEvent (org.eclipse.swt.events.FocusEvent)64 SelectionEvent (org.eclipse.swt.events.SelectionEvent)42 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)36 Composite (org.eclipse.swt.widgets.Composite)29 GridData (org.eclipse.swt.layout.GridData)28 Text (org.eclipse.swt.widgets.Text)26 GridLayout (org.eclipse.swt.layout.GridLayout)25 Label (org.eclipse.swt.widgets.Label)20 Button (org.eclipse.swt.widgets.Button)17 Menu (org.eclipse.swt.widgets.Menu)17 Point (org.eclipse.swt.graphics.Point)16 MenuManager (org.eclipse.jface.action.MenuManager)15 MenuItem (org.eclipse.swt.widgets.MenuItem)15 ModifyEvent (org.eclipse.swt.events.ModifyEvent)14 ModifyListener (org.eclipse.swt.events.ModifyListener)14 KeyEvent (org.eclipse.swt.events.KeyEvent)12 Combo (org.eclipse.swt.widgets.Combo)12 KeyAdapter (org.eclipse.swt.events.KeyAdapter)11 Group (org.eclipse.swt.widgets.Group)11