Search in sources :

Example 26 with Combo

use of org.eclipse.swt.widgets.Combo in project translationstudio8 by heartsome.

the class ProjectSettingBaseInfoPage method createContents.

/**
	 * Create contents of the preference page.
	 * @param parent
	 */
@Override
public Control createContents(Composite parent) {
    // GridData fieldData = new GridData();
    // fieldData.heightHint = 10;
    // Composite container = new Composite(parent, SWT.NULL);
    // container.setLayout(new GridLayout());
    // container.setLayoutData(fieldData);
    //
    // ScrolledComposite cmpScrolled = new ScrolledComposite(container, SWT.V_SCROLL);
    // cmpScrolled.setAlwaysShowScrollBars(true);
    // cmpScrolled.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // cmpScrolled.setExpandHorizontal(true);
    // cmpScrolled.setExpandVertical(true);
    Composite cmpField = new Composite(parent, SWT.None);
    cmpField.setLayout(new GridLayout(2, false));
    // cmpScrolled.setContent(cmpField);
    // cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    Label label = new Label(cmpField, SWT.RIGHT);
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    label.setText(Messages.getString("projectsetting.ProjectSettingBaseInfoPage.projectNameLabel"));
    Point namePoint = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    projectNameLabel = new Label(cmpField, SWT.NONE);
    // cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    label = new Label(cmpField, SWT.RIGHT);
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    label.setText(Messages.getString("projectsetting.ProjectSettingBaseInfoPage.sourceLangLabel"));
    Point srcPoint = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    sourceLangLabel = new Label(cmpField, SWT.NONE);
    // cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    label = new Label(cmpField, SWT.RIGHT);
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    label.setText(Messages.getString("projectsetting.ProjectSettingBaseInfoPage.targetlangLabel"));
    Point tgtPoint = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    targetlangLabel = new Label(cmpField, SWT.NONE);
    // cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    initData();
    int width = Math.max(namePoint.x, Math.max(srcPoint.x, tgtPoint.x)) + 10;
    Map<String, String> mapField = projCfgBean.getMapField();
    if (mapField != null && mapField.size() > 0) {
        lstText = new ArrayList<Text>();
        Iterator<Entry<String, String>> it = mapField.entrySet().iterator();
        while (it.hasNext()) {
            Entry<String, String> entry = (Entry<String, String>) it.next();
            Label lbl = new Label(cmpField, SWT.WRAP);
            String strLbl = TextUtil.xmlToString(entry.getKey()).replaceAll("&", "&&") + Messages.getString("wizards.NewProjectWizardProjInfoPage.colon");
            lbl.setText(strLbl);
            GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
            GridData gd = (GridData) lbl.getLayoutData();
            Point p = lbl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            if (p.x > width) {
                gd.widthHint = width;
            }
            Text txt = new Text(cmpField, SWT.BORDER);
            txt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            txt.setText(TextUtil.xmlToString(entry.getValue()));
            txt.setData(TextUtil.xmlToString(entry.getKey()));
            txt.addModifyListener(new ModifyListener() {

                public void modifyText(ModifyEvent e) {
                    if (lstText != null && lstText.size() > 0) {
                        boolean isValid = true;
                        for (Text txt : lstText) {
                            String value = txt.getText();
                            if (value != null && !value.equals("")) {
                                if (value.trim().equals("")) {
                                    setErrorMessage(Messages.getString("wizard.NewProjectWizardProjInfoPage.msg3"));
                                    isValid = false;
                                    setValid(false);
                                    break;
                                } else if (value.trim().length() > 50) {
                                    setErrorMessage(Messages.getString("wizard.NewProjectWizardProjInfoPage.msg4"));
                                    setValid(false);
                                    isValid = false;
                                    break;
                                }
                            }
                        }
                        if (isValid) {
                            setErrorMessage(null);
                            setValid(true);
                        }
                    }
                }
            });
            lstText.add(txt);
        // cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        }
    }
    Map<String, Object[]> mapAttr = projCfgBean.getMapAttr();
    if (mapAttr != null && mapAttr.size() > 0) {
        lstCombo = new ArrayList<Combo>();
        Iterator<Entry<String, Object[]>> it = mapAttr.entrySet().iterator();
        while (it.hasNext()) {
            Entry<String, Object[]> entry = (Entry<String, Object[]>) it.next();
            String attrName = TextUtil.xmlToString(entry.getKey());
            String attrSelVal = TextUtil.xmlToString((String) entry.getValue()[0]);
            @SuppressWarnings("unchecked") List<String> lstAttrVal = (List<String>) entry.getValue()[1];
            String[] arrAttrVal = new String[lstAttrVal.size()];
            int selIndex = 0;
            for (int i = 0; i < lstAttrVal.size(); i++) {
                arrAttrVal[i] = TextUtil.xmlToString(lstAttrVal.get(i));
                if (attrSelVal.equals(arrAttrVal[i])) {
                    selIndex = i;
                }
            }
            Label lbl = new Label(cmpField, SWT.WRAP);
            String strLbl = attrName.replaceAll("&", "&&") + Messages.getString("wizards.NewProjectWizardProjInfoPage.colon");
            lbl.setText(strLbl);
            GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
            GridData gd = (GridData) lbl.getLayoutData();
            Point p = lbl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            if (p.x > width) {
                gd.widthHint = width;
            }
            Combo cmb = new Combo(cmpField, SWT.READ_ONLY);
            cmb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            cmb.setItems(arrAttrVal);
            cmb.select(selIndex);
            cmb.setData(attrName);
            lstCombo.add(cmb);
        // cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        }
    }
    return cmpField;
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) Entry(java.util.Map.Entry) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ArrayList(java.util.ArrayList) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) GridData(org.eclipse.swt.layout.GridData)

Example 27 with Combo

use of org.eclipse.swt.widgets.Combo in project translationstudio8 by heartsome.

the class ProjectSettingBaseInfoPage method performOk.

@Override
public boolean performOk() {
    if (lstText != null) {
        LinkedHashMap<String, String> mapField = new LinkedHashMap<String, String>();
        for (Text txt : lstText) {
            if (!txt.isDisposed()) {
                mapField.put(TextUtil.stringToXML((String) txt.getData()), TextUtil.stringToXML(txt.getText()).trim());
            }
        }
        projCfgBean.setMapField(mapField);
    }
    if (lstCombo != null) {
        LinkedHashMap<String, Object[]> mapAttr = new LinkedHashMap<String, Object[]>();
        for (Combo cmb : lstCombo) {
            if (!cmb.isDisposed()) {
                ArrayList<String> lstAttrValue = new ArrayList<String>();
                for (String attrVal : cmb.getItems()) {
                    lstAttrValue.add(TextUtil.stringToXML(attrVal));
                }
                mapAttr.put(TextUtil.stringToXML((String) cmb.getData()), new Object[] { TextUtil.stringToXML(cmb.getText()), lstAttrValue });
            }
        }
        projCfgBean.setMapAttr(mapAttr);
    }
    return super.performOk();
}
Also used : ArrayList(java.util.ArrayList) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) LinkedHashMap(java.util.LinkedHashMap)

Example 28 with Combo

use of org.eclipse.swt.widgets.Combo in project azure-tools-for-java by Microsoft.

the class CreateRedisCacheForm method createDialogArea.

/**
     * Create contents of the dialog.
     * 
     * @param parent
     */
@Override
protected Control createDialogArea(Composite parent) {
    resourceBundle = MessageHandler.getResourceBundle(MODULE_NAME);
    if (resourceBundle == null) {
        return null;
    }
    setTitle(MessageHandler.getResourceString(resourceBundle, DIALOG_TITLE));
    setMessage(MessageHandler.getResourceString(resourceBundle, DIALOG_MESSAGE));
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    GridLayout glContainer = new GridLayout(4, false);
    glContainer.horizontalSpacing = LAYOUT_SPACING;
    glContainer.verticalSpacing = LAYOUT_SPACING;
    container.setLayout(glContainer);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    Label lblDnsName = new Label(container, SWT.NONE);
    lblDnsName.setText(MessageHandler.getResourceString(resourceBundle, LABEL_DNS_NAME));
    txtDnsName = new Text(container, SWT.BORDER);
    txtDnsName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    decoratorDnsName = new ControlDecoration(txtDnsName, SWT.CENTER);
    decoratorDnsName.setDescriptionText(MessageHandler.getResourceString(resourceBundle, DECORACTOR_DNS));
    FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
    if (fieldDecoration != null) {
        Image image = fieldDecoration.getImage();
        decoratorDnsName.setImage(image);
    }
    Label lblDnsSuffix = new Label(container, SWT.NONE);
    lblDnsSuffix.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    lblDnsSuffix.setText(MessageHandler.getResourceString(resourceBundle, LABEL_DNS_SUFFIX));
    Label lblSubscription = new Label(container, SWT.NONE);
    lblSubscription.setText(MessageHandler.getResourceString(resourceBundle, LABEL_SUBSCRIPTION));
    cbSubs = new Combo(container, SWT.READ_ONLY);
    cbSubs.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    Label lblResourceGroup = new Label(container, SWT.NONE);
    lblResourceGroup.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
    lblResourceGroup.setText(MessageHandler.getResourceString(resourceBundle, LABEL_RESOURCE_GRP));
    rdoCreateNew = new Button(container, SWT.RADIO);
    rdoCreateNew.setText(MessageHandler.getResourceString(resourceBundle, RADIOBUTTON_NEW_GRP));
    rdoCreateNew.setSelection(true);
    txtNewResGrpName = new Text(container, SWT.BORDER);
    txtNewResGrpName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    txtNewResGrpName.setEnabled(true);
    rdoUseExisting = new Button(container, SWT.RADIO);
    rdoUseExisting.setText(MessageHandler.getResourceString(resourceBundle, RADIOBUTTON_USE_EXIST_GRP));
    rdoUseExisting.setSelection(false);
    cbUseExisting = new Combo(container, SWT.READ_ONLY);
    cbUseExisting.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    cbUseExisting.add(MessageHandler.getResourceString(resourceBundle, LOADING));
    cbUseExisting.select(0);
    cbUseExisting.setEnabled(false);
    Label lblLocation = new Label(container, SWT.NONE);
    lblLocation.setText(MessageHandler.getResourceString(resourceBundle, LABEL_LOCTION));
    cbLocations = new Combo(container, SWT.READ_ONLY);
    cbLocations.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    cbLocations.add(MessageHandler.getResourceString(resourceBundle, LOADING));
    cbLocations.select(0);
    cbLocations.setEnabled(false);
    Label lblPricingTier = new Label(container, SWT.READ_ONLY);
    lblPricingTier.setText(MessageHandler.getResourceString(resourceBundle, LABEL_PRICING));
    cbPricetiers = new Combo(container, SWT.READ_ONLY);
    cbPricetiers.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    if (skus.keySet().size() > 0) {
        for (String price : skus.keySet()) {
            cbPricetiers.add(price);
        }
        cbPricetiers.select(0);
        selectedPriceTierValue = cbPricetiers.getText();
    }
    Link lnkPrice = new Link(container, SWT.NONE);
    lnkPrice.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
    lnkPrice.setText(MessageHandler.getResourceString(resourceBundle, LINK_PRICE));
    lnkPrice.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            try {
                PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(event.text));
            } catch (Exception ex) {
                LOG.log(MessageHandler.getCommonStr(OPEN_BROWSER_ERROR), ex);
            }
        }
    });
    chkUnblockPort = new Button(container, SWT.CHECK);
    chkUnblockPort.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
    chkUnblockPort.setText(MessageHandler.getResourceString(resourceBundle, CHECKBOX_SSL));
    this.setHelpAvailable(false);
    txtDnsName.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent arg0) {
            dnsNameValue = txtDnsName.getText();
            if (dnsNameValue.length() > REDIS_CACHE_MAX_NAME_LENGTH || !dnsNameValue.matches(DNS_NAME_REGEX)) {
                decoratorDnsName.show();
            } else {
                decoratorDnsName.hide();
            }
            validateFields();
        }
    });
    for (SubscriptionDetail sub : selectedSubscriptions) {
        cbSubs.add(String.format(SUBS_COMBO_ITEMS_FORMAT, sub.getSubscriptionName(), sub.getSubscriptionId()));
    }
    cbSubs.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            currentSub = selectedSubscriptions.get(cbSubs.getSelectionIndex());
            if (loaded) {
                fillLocationsAndResourceGrps(currentSub);
            }
            validateFields();
        }
    });
    if (selectedSubscriptions.size() > 0) {
        cbSubs.select(0);
    }
    rdoCreateNew.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            txtNewResGrpName.setEnabled(true);
            cbUseExisting.setEnabled(false);
            newResGrp = true;
            selectedResGrpValue = txtNewResGrpName.getText();
            validateFields();
        }
    });
    rdoUseExisting.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            txtNewResGrpName.setEnabled(false);
            cbUseExisting.setEnabled(true);
            if (loaded) {
                newResGrp = false;
                selectedResGrpValue = sortedGroups.get(cbUseExisting.getSelectionIndex());
                validateFields();
            }
        }
    });
    txtNewResGrpName.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent arg0) {
            selectedResGrpValue = txtNewResGrpName.getText();
            validateFields();
        }
    });
    cbUseExisting.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            selectedResGrpValue = cbUseExisting.getText();
            validateFields();
        }
    });
    cbLocations.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            selectedLocationValue = sortedLocations.get(cbLocations.getSelectionIndex()).name();
            validateFields();
        }
    });
    cbPricetiers.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            selectedPriceTierValue = cbPricetiers.getText();
            validateFields();
        }
    });
    chkUnblockPort.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Button btn = (Button) e.getSource();
            if (btn.getSelection()) {
                noSSLPort = true;
            } else {
                noSSLPort = false;
            }
        }
    });
    DefaultLoader.getIdeHelper().runInBackground(null, MessageHandler.getResourceString(resourceBundle, LOADING_LOCATION_AND_GRPS), false, true, MessageHandler.getResourceString(resourceBundle, LOADING_LOCATION_AND_GRPS), new Runnable() {

        @Override
        public void run() {
            try {
                AzureModelController.updateSubscriptionMaps(null);
                DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        fillLocationsAndResourceGrps(currentSub);
                        cbLocations.setEnabled(true);
                        loaded = true;
                        validateFields();
                    }
                });
            } catch (Exception ex) {
                LOG.log(MessageHandler.getCommonStr(LOAD_LOCATION_AND_RESOURCE_ERROR), ex);
            }
        }
    });
    return area;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) Image(org.eclipse.swt.graphics.Image) URL(java.net.URL) IOException(java.io.IOException) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) Link(org.eclipse.swt.widgets.Link)

Example 29 with Combo

use of org.eclipse.swt.widgets.Combo in project azure-tools-for-java by Microsoft.

the class SelectImageStep method createSettingsPanel.

private void createSettingsPanel(Composite container) {
    final Composite composite = new Composite(container, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    GridData gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.verticalAlignment = GridData.BEGINNING;
    gridData.grabExcessHorizontalSpace = true;
    //		gridData.widthHint = 350;
    composite.setLayout(gridLayout);
    composite.setLayoutData(gridData);
    regionLabel = new Label(composite, SWT.LEFT);
    regionLabel.setText("Location:");
    //		regionLabel.setLayoutData(getGridDataForLabel());
    regionComboBox = new Combo(composite, SWT.READ_ONLY);
    regionComboBox.setLayoutData(getGridData(1));
    regionComboBox.setToolTipText("Specifies the location where your virtual machine will be created");
    knownImageBtn = new Button(composite, SWT.RADIO);
    knownImageBtn.setText("Recommended image:");
    knownImageBtn.setLayoutData(getGridData(2));
    knownImageComboBox = new Combo(composite, SWT.READ_ONLY);
    knownImageComboBox.setLayoutData(getGridData(2));
    for (KnownWindowsVirtualMachineImage image : KnownWindowsVirtualMachineImage.values()) {
        knownImageComboBox.add(image.offer() + " - " + image.sku());
        knownImageComboBox.setData(image.offer() + " - " + image.sku(), image);
    }
    for (KnownLinuxVirtualMachineImage image : KnownLinuxVirtualMachineImage.values()) {
        knownImageComboBox.add(image.offer() + " - " + image.sku());
        knownImageComboBox.setData(image.offer() + " - " + image.sku(), image);
    }
    knownImageComboBox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent selectionEvent) {
            wizard.setKnownMachineImage(knownImageComboBox.getData(knownImageComboBox.getText()));
            validateNext();
        }
    });
    knownImageComboBox.select(0);
    customImageBtn = new Button(composite, SWT.RADIO);
    customImageBtn.setText("Custom image:");
    customImageBtn.setLayoutData(getGridData(2));
    publisherLabel = new Label(composite, SWT.LEFT);
    publisherLabel.setText("Publisher:");
    publisherComboBox = new Combo(composite, SWT.READ_ONLY);
    publisherComboBox.setLayoutData(getGridData(1));
    publisherComboBox.setToolTipText("Specifies the publisher which created the image which you will use to create your virtual machine");
    offerLabel = new Label(composite, SWT.LEFT);
    offerLabel.setText("Offer:");
    offerComboBox = new Combo(composite, SWT.READ_ONLY);
    offerComboBox.setLayoutData(getGridData(1));
    offerComboBox.setToolTipText("Specifies which the virtual machine which offering to use from the selected publisher");
    skuLabel = new Label(composite, SWT.LEFT);
    skuLabel.setText("Sku:");
    //		skuLabel.setLayoutData(getGridDataForLabel());
    skuComboBox = new Combo(composite, SWT.READ_ONLY);
    skuComboBox.setLayoutData(getGridData(1));
    skuComboBox.setToolTipText("Specifies the Stockkeeping Unit (SKU) to use from the selected offering");
    versionLabel = new Label(composite, SWT.LEFT);
    versionLabel.setText("Version #:");
    imageLabelList = new org.eclipse.swt.widgets.List(composite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
    // gridData = new GridData();
    // gridData.widthHint = 300;
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.verticalIndent = 10;
    imageLabelList.setLayoutData(gridData);
    imageLabelList.setToolTipText("Specifies the label for the specific image to use from the selected SKU; this is often the version for an image");
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) KnownWindowsVirtualMachineImage(com.microsoft.azure.management.compute.KnownWindowsVirtualMachineImage) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) KnownLinuxVirtualMachineImage(com.microsoft.azure.management.compute.KnownLinuxVirtualMachineImage) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 30 with Combo

use of org.eclipse.swt.widgets.Combo in project azure-tools-for-java by Microsoft.

the class CreateArmStorageAccountForm method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    setTitle("Create New Storage Account");
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "com.microsoft.azuretools.azureexplorer.storage_account_dialog");
    Composite container = new Composite(parent, SWT.FILL);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridLayout.marginBottom = 10;
    container.setLayout(gridLayout);
    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = SWT.FILL;
    //		gridData.widthHint = 250;
    container.setLayoutData(gridData);
    nameLabel = new Label(container, SWT.LEFT);
    nameLabel.setText("Name:");
    nameTextField = new Text(container, SWT.LEFT | SWT.BORDER);
    //        gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    nameTextField.setLayoutData(gridDataForText(180));
    subscriptionLabel = new Label(container, SWT.LEFT);
    subscriptionLabel.setText("Subscription:");
    subscriptionComboBox = new Combo(container, SWT.READ_ONLY);
    subscriptionComboBox.setLayoutData(gridDataForText(180));
    resourceGroupLabel = new Label(container, SWT.LEFT);
    resourceGroupLabel.setText("Resource group:");
    gridData = new GridData();
    gridData.verticalAlignment = SWT.TOP;
    resourceGroupLabel.setLayoutData(gridData);
    final Composite composite = new Composite(container, SWT.NONE);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.verticalAlignment = GridData.BEGINNING;
    gridData.grabExcessHorizontalSpace = true;
    //        gridData.widthHint = 250;
    composite.setLayout(gridLayout);
    composite.setLayoutData(gridData);
    createNewRadioButton = new Button(composite, SWT.RADIO);
    createNewRadioButton.setText("Create new");
    createNewRadioButton.setSelection(true);
    resourceGrpField = new Text(composite, SWT.LEFT | SWT.BORDER);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    resourceGrpField.setLayoutData(gridData);
    useExistingRadioButton = new Button(composite, SWT.RADIO);
    useExistingRadioButton.setText("Use existing");
    resourceGrpCombo = new Combo(composite, SWT.READ_ONLY);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    resourceGrpCombo.setLayoutData(gridData);
    resourceGroupViewer = new ComboViewer(resourceGrpCombo);
    resourceGroupViewer.setContentProvider(ArrayContentProvider.getInstance());
    SelectionListener updateListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            updateResourceGroup();
        }
    };
    createNewRadioButton.addSelectionListener(updateListener);
    useExistingRadioButton.addSelectionListener(updateListener);
    updateResourceGroup();
    regionLabel = new Label(container, SWT.LEFT);
    regionLabel.setText("Region:");
    regionComboBox = new Combo(container, SWT.READ_ONLY);
    regionComboBox.setLayoutData(gridDataForText(180));
    kindLabel = new Label(container, SWT.LEFT);
    kindLabel.setText("Account kind:");
    kindCombo = new Combo(container, SWT.READ_ONLY);
    kindCombo.setLayoutData(gridDataForText(180));
    performanceLabel = new Label(container, SWT.LEFT);
    performanceLabel.setText("Performance:");
    performanceCombo = new Combo(container, SWT.READ_ONLY);
    performanceCombo.setLayoutData(gridDataForText(180));
    replicationLabel = new Label(container, SWT.LEFT);
    replicationLabel.setText("Replication:");
    replicationComboBox = new Combo(container, SWT.READ_ONLY);
    replicationComboBox.setLayoutData(gridDataForText(180));
    if (subscription == null) {
        // not showing access tier with general purpose storage account which is used when creating vm
        accessTierLabel = new Label(container, SWT.LEFT);
        accessTierLabel.setText("Access Tier:");
        accessTierComboBox = new Combo(container, SWT.READ_ONLY);
        accessTierComboBox.setLayoutData(gridDataForText(180));
        for (AccessTier type : AccessTier.values()) {
            accessTierComboBox.add(type.toString());
            accessTierComboBox.setData(type.toString(), type);
        }
        accessTierComboBox.select(0);
    }
    pricingLabel = new Link(container, SWT.LEFT);
    pricingLabel.setText(PRICING_LINK);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    pricingLabel.setLayoutData(gridData);
    pricingLabel.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            try {
                PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(event.text));
            } catch (Exception ex) {
                /*
					 * only logging the error in log file
					 * not showing anything to end user
					 */
                Activator.getDefault().log("Error occurred while opening link in default browser.", ex);
            }
        }
    });
    nameTextField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent modifyEvent) {
            validateEmptyFields();
        }
    });
    regionComboBox.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            validateEmptyFields();
        }
    });
    resourceGrpField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent modifyEvent) {
            validateEmptyFields();
        }
    });
    resourceGrpCombo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            validateEmptyFields();
        }
    });
    fillFields();
    return super.createDialogArea(parent);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) AccessTier(com.microsoft.azure.management.storage.AccessTier) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) URL(java.net.URL) InvocationTargetException(java.lang.reflect.InvocationTargetException) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Link(org.eclipse.swt.widgets.Link) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

Combo (org.eclipse.swt.widgets.Combo)232 GridData (org.eclipse.swt.layout.GridData)171 Label (org.eclipse.swt.widgets.Label)164 GridLayout (org.eclipse.swt.layout.GridLayout)150 Composite (org.eclipse.swt.widgets.Composite)135 SelectionEvent (org.eclipse.swt.events.SelectionEvent)122 Text (org.eclipse.swt.widgets.Text)112 Button (org.eclipse.swt.widgets.Button)105 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)98 Group (org.eclipse.swt.widgets.Group)80 ModifyEvent (org.eclipse.swt.events.ModifyEvent)54 ModifyListener (org.eclipse.swt.events.ModifyListener)54 SelectionListener (org.eclipse.swt.events.SelectionListener)37 ArrayList (java.util.ArrayList)22 Point (org.eclipse.swt.graphics.Point)20 FormAttachment (org.eclipse.swt.layout.FormAttachment)19 FormData (org.eclipse.swt.layout.FormData)19 FormLayout (org.eclipse.swt.layout.FormLayout)18 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)18 ComboViewer (org.eclipse.jface.viewers.ComboViewer)16