Search in sources :

Example 1 with SparkVersionsLabelProvider

use of org.talend.repository.hadoopcluster.ui.dynamic.form.labelprovider.SparkVersionsLabelProvider in project tbd-studio-se by Talend.

the class DynamicDistributionOptionForm method createControl.

protected void createControl() {
    Composite parent = this;
    Composite container = createFormContainer(parent);
    final int ALIGN_VERTICAL = getAlignVertical();
    final int ALIGN_VERTICAL_INNER = getAlignVerticalInner();
    final int ALIGN_HORIZON = getAlignHorizon();
    final int HORZON_WIDTH = getHorizonWidth();
    final int ALIGN_HORIZON_VERSION_LABEL = ALIGN_HORIZON * 2;
    newConfigBtn = new Button(container, SWT.RADIO);
    // $NON-NLS-1$
    newConfigBtn.setText(Messages.getString("DynamicDistributionOptionForm.form.newConfigBtn"));
    newConfigBtn.setSelection(true);
    FormData formData = new FormData();
    formData.top = new FormAttachment(0);
    formData.left = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    newConfigBtn.setLayoutData(formData);
    newConfigGroup = new Composite(container, SWT.NONE);
    formData = new FormData();
    formData.top = new FormAttachment(newConfigBtn, 0, SWT.BOTTOM);
    formData.left = new FormAttachment(newConfigBtn, 0, SWT.LEFT);
    formData.right = new FormAttachment(newConfigBtn, 0, SWT.RIGHT);
    newConfigGroup.setLayoutData(formData);
    newConfigGroup.setLayout(new FormLayout());
    int refreshButtonWidth = 0;
    refreshButton = new Button(newConfigGroup, SWT.PUSH);
    // $NON-NLS-1$
    refreshButton.setText(Messages.getString("DynamicDistributionOptionForm.form.refresh.label"));
    formData = new FormData();
    formData.top = new FormAttachment(0, ALIGN_VERTICAL_INNER);
    refreshButtonWidth = getNewButtonSize(refreshButton).x;
    formData.width = refreshButtonWidth;
    formData.right = new FormAttachment(100);
    refreshButton.setLayoutData(formData);
    Label versionLabel = new Label(newConfigGroup, SWT.NONE);
    // $NON-NLS-1$
    versionLabel.setText(Messages.getString("DynamicDistributionOptionForm.form.versionLabel.distribution"));
    formData = new FormData();
    formData.top = new FormAttachment(refreshButton, 0, SWT.CENTER);
    formData.right = new FormAttachment(0, HORZON_WIDTH);
    versionLabel.setLayoutData(formData);
    versionsComboViewer = new ComboViewer(newConfigGroup, SWT.READ_ONLY);
    versionsComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    versionsComboViewer.setLabelProvider(new LabelProvider());
    formData = new FormData();
    formData.top = new FormAttachment(refreshButton, 0, SWT.CENTER);
    formData.left = new FormAttachment(versionLabel, ALIGN_HORIZON_VERSION_LABEL, SWT.RIGHT);
    formData.right = new FormAttachment(refreshButton, -1 * ALIGN_HORIZON, SWT.LEFT);
    versionsComboViewer.getControl().setLayoutData(formData);
    showOnlyCompatibleBtn = new Button(newConfigGroup, SWT.CHECK);
    // $NON-NLS-1$
    showOnlyCompatibleBtn.setText(Messages.getString("DynamicDistributionOptionForm.form.showOnlyCompatible.label"));
    showOnlyCompatibleBtn.setSelection(true);
    formData = new FormData();
    formData.top = new FormAttachment(versionsComboViewer.getControl(), ALIGN_VERTICAL_INNER, SWT.BOTTOM);
    formData.right = new FormAttachment(versionsComboViewer.getControl(), 0, SWT.RIGHT);
    showOnlyCompatibleBtn.setLayoutData(formData);
    Label sparkVersionLabel = new Label(newConfigGroup, SWT.NONE);
    // $NON-NLS-1$
    sparkVersionLabel.setText(Messages.getString("DynamicDistributionOptionForm.form.versionLabel.spark"));
    formData = new FormData();
    formData.top = new FormAttachment(showOnlyCompatibleBtn, 0, SWT.CENTER);
    formData.right = new FormAttachment(versionLabel, 0, SWT.RIGHT);
    sparkVersionLabel.setLayoutData(formData);
    sparkVersionsComboViewer = new TableComboViewer(newConfigGroup, SWT.READ_ONLY | SWT.BORDER);
    sparkVersionsComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    sparkVersionsComboViewer.setLabelProvider(new SparkVersionsLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof ESparkVersion) {
                return ((ESparkVersion) element).getVersionLabel();
            }
            return super.getText(element);
        }

        @Override
        protected boolean isSelected(Object element) {
            if (selectedSparkVersions.contains(element)) {
                return true;
            } else {
                return false;
            }
        }
    });
    TableCombo tableCombo = sparkVersionsComboViewer.getTableCombo();
    tableCombo.setClosePopupAfterSelection(false);
    tableCombo.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
    formData = new FormData();
    formData.top = new FormAttachment(sparkVersionLabel, 0, SWT.CENTER);
    formData.left = new FormAttachment(versionsComboViewer.getControl(), 0, SWT.LEFT);
    // formData.right = new FormAttachment(showOnlyCompatibleBtn, -1 * ALIGN_HORIZON, SWT.LEFT);
    formData.width = HORZON_WIDTH;
    sparkVersionsComboViewer.getControl().setLayoutData(formData);
    editExistingConfigBtn = new Button(container, SWT.RADIO);
    // $NON-NLS-1$
    editExistingConfigBtn.setText(Messages.getString("DynamicDistributionOptionForm.form.editExistingConfigBtn"));
    formData = new FormData();
    formData.top = new FormAttachment(newConfigGroup, ALIGN_VERTICAL, SWT.BOTTOM);
    formData.left = new FormAttachment(newConfigGroup, 0, SWT.LEFT);
    formData.right = new FormAttachment(newConfigGroup, 0, SWT.RIGHT);
    editExistingConfigBtn.setLayoutData(formData);
    editExistingGroup = new Composite(container, SWT.NONE);
    formData = new FormData();
    formData.top = new FormAttachment(editExistingConfigBtn, 0, SWT.BOTTOM);
    formData.left = new FormAttachment(editExistingConfigBtn, 0, SWT.LEFT);
    formData.right = new FormAttachment(editExistingConfigBtn, 0, SWT.RIGHT);
    editExistingGroup.setLayoutData(formData);
    editExistingGroup.setLayout(new FormLayout());
    existingConfigsComboViewer = new ComboViewer(editExistingGroup, SWT.READ_ONLY);
    existingConfigsComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    existingConfigsComboViewer.setLabelProvider(new DynamicDistributionsLabelProvider());
    Label existVersionLabel = new Label(editExistingGroup, SWT.NONE);
    // $NON-NLS-1$
    existVersionLabel.setText(Messages.getString("DynamicDistributionOptionForm.form.versionLabel.distribution"));
    formData = new FormData();
    formData.top = new FormAttachment(existingConfigsComboViewer.getControl(), 0, SWT.CENTER);
    formData.right = new FormAttachment(0, HORZON_WIDTH);
    existVersionLabel.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(0, ALIGN_VERTICAL_INNER);
    formData.left = new FormAttachment(existVersionLabel, ALIGN_HORIZON_VERSION_LABEL, SWT.RIGHT);
    formData.right = new FormAttachment(100);
    existingConfigsComboViewer.getControl().setLayoutData(formData);
    importConfigBtn = new Button(container, SWT.RADIO);
    // $NON-NLS-1$
    importConfigBtn.setText(Messages.getString("DynamicDistributionOptionForm.form.importConfigBtn"));
    formData = new FormData();
    formData.top = new FormAttachment(editExistingGroup, ALIGN_VERTICAL, SWT.BOTTOM);
    formData.left = new FormAttachment(editExistingGroup, 0, SWT.LEFT);
    formData.right = new FormAttachment(editExistingGroup, 0, SWT.RIGHT);
    importConfigBtn.setLayoutData(formData);
    importConfigGroup = new Composite(container, SWT.NONE);
    formData = new FormData();
    formData.top = new FormAttachment(importConfigBtn, 0, SWT.BOTTOM);
    formData.left = new FormAttachment(importConfigBtn, 0, SWT.LEFT);
    formData.right = new FormAttachment(importConfigBtn, 0, SWT.RIGHT);
    importConfigGroup.setLayoutData(formData);
    importConfigGroup.setLayout(new FormLayout());
    importConfigText = new Text(importConfigGroup, SWT.BORDER);
    importConfigText.setEditable(false);
    importConfigBrowseBtn = new Button(importConfigGroup, SWT.PUSH);
    // $NON-NLS-1$
    importConfigBrowseBtn.setText(Messages.getString("DynamicDistributionOptionForm.form.importConfig.browse"));
    formData = new FormData();
    formData.top = new FormAttachment(0, ALIGN_VERTICAL_INNER);
    formData.left = new FormAttachment(100, -1 * getNewButtonSize(importConfigBrowseBtn).x);
    formData.right = new FormAttachment(100);
    importConfigBrowseBtn.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(importConfigBrowseBtn, 0, SWT.CENTER);
    formData.left = new FormAttachment(0, HORZON_WIDTH + ALIGN_HORIZON_VERSION_LABEL);
    formData.right = new FormAttachment(importConfigBrowseBtn, -1 * ALIGN_HORIZON, SWT.LEFT);
    importConfigText.setLayoutData(formData);
}
Also used : FormData(org.eclipse.swt.layout.FormData) FormLayout(org.eclipse.swt.layout.FormLayout) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) TableComboViewer(org.eclipse.nebula.jface.tablecomboviewer.TableComboViewer) Point(org.eclipse.swt.graphics.Point) ESparkVersion(org.talend.hadoop.distribution.ESparkVersion) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) TableComboViewer(org.eclipse.nebula.jface.tablecomboviewer.TableComboViewer) SparkVersionsLabelProvider(org.talend.repository.hadoopcluster.ui.dynamic.form.labelprovider.SparkVersionsLabelProvider) DynamicDistributionsLabelProvider(org.talend.repository.hadoopcluster.ui.dynamic.form.labelprovider.DynamicDistributionsLabelProvider) TableCombo(org.eclipse.nebula.widgets.tablecombo.TableCombo) DynamicDistributionsLabelProvider(org.talend.repository.hadoopcluster.ui.dynamic.form.labelprovider.DynamicDistributionsLabelProvider) SparkVersionsLabelProvider(org.talend.repository.hadoopcluster.ui.dynamic.form.labelprovider.SparkVersionsLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

ComboViewer (org.eclipse.jface.viewers.ComboViewer)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 TableComboViewer (org.eclipse.nebula.jface.tablecomboviewer.TableComboViewer)1 TableCombo (org.eclipse.nebula.widgets.tablecombo.TableCombo)1 Point (org.eclipse.swt.graphics.Point)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1 ESparkVersion (org.talend.hadoop.distribution.ESparkVersion)1 DynamicDistributionsLabelProvider (org.talend.repository.hadoopcluster.ui.dynamic.form.labelprovider.DynamicDistributionsLabelProvider)1 SparkVersionsLabelProvider (org.talend.repository.hadoopcluster.ui.dynamic.form.labelprovider.SparkVersionsLabelProvider)1