Java Code Examples for org.eclipse.swt.widgets.Combo#setEnabled()

The following examples show how to use org.eclipse.swt.widgets.Combo#setEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TabPageIndentation.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private Control addSettingControl(Composite parent, FormatterProfile.IndentSetting bs, String label) {
    if (bs.isRange()) {
        Button cbox = null;
        if (bs.isRangeWithCheckbox()) {
            cbox = SWTFactory.createCheckbox(parent, label, 1);
        } else {
            SWTFactory.createLabel(parent, label, 1);
        }
        Combo cmb = SWTFactory.createCombo(parent, 1, SWT.DROP_DOWN | SWT.READ_ONLY, GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END);
        for (int i=bs.getMinVal(); i<=bs.getMaxVal(); ++i) {
            cmb.add(""+i); //$NON-NLS-1$
        }
        cmb.select(fp.getValueForDialog(bs) - bs.getMinVal());
        SettingSelectionListener ssl = new SettingSelectionListener(cmb, cbox, bs);
        cmb.addSelectionListener(ssl);
        if (cbox != null) {
            boolean unch = fp.getRangeCheckboxUncheckedState(bs);
            cbox.setSelection(!unch);
            cmb.setEnabled(!unch);
            cbox.addSelectionListener(ssl);
        }
        return cmb;
    } else {
        Button cb = SWTFactory.createCheckbox(parent, label, 2);
        cb.setSelection(fp.getAsBoolean(bs));
        cb.addSelectionListener(new SettingSelectionListener(cb, null, bs));
        
        GridData gd = (GridData)cb.getLayoutData();
        gd.heightHint = prefHeight;
        cb.setLayoutData(gd);
        
        return cb;
    }
}
 
Example 2
Source File: Lines2PatternDesign.java    From ldparteditor with MIT License 5 votes vote down vote up
/**
 * Create contents of the dialog.
 *
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite cmp_container = (Composite) super.createDialogArea(parent);
    GridLayout gridLayout = (GridLayout) cmp_container.getLayout();
    gridLayout.verticalSpacing = 10;
    gridLayout.horizontalSpacing = 10;

    Label lbl_specify = new Label(cmp_container, SWT.NONE);
    lbl_specify.setText(I18n.LINES_Title);

    Label lbl_separator = new Label(cmp_container, SWT.SEPARATOR | SWT.HORIZONTAL);
    lbl_separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    Combo cmb_scope = new Combo(cmp_container, SWT.READ_ONLY);
    cmb_scope.setItems(new String[] {I18n.LINES_ScopeSelection});
    cmb_scope.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    cmb_scope.setText(cmb_scope.getItem(0));
    cmb_scope.select(0);
    cmb_scope.setEnabled(false);

    Label lbl_info = new Label(cmp_container, SWT.NONE);
    lbl_info.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    lbl_info.setText(I18n.LINES_Hint);

    cmp_container.pack();
    return cmp_container;
}
 
Example 3
Source File: ChangeSignatureWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void createAccessControl(Composite parent) throws JavaModelException {
	Composite access= new Composite(parent, SWT.NONE);
	GridLayout layout= new GridLayout();
	layout.marginHeight= 0;
	layout.marginWidth= 0;
	access.setLayout(layout);

	final int[] availableVisibilities= getChangeMethodSignatureProcessor().getAvailableVisibilities();
	int currentVisibility= getChangeMethodSignatureProcessor().getVisibility();

	Label label= new Label(access, SWT.NONE);
	label.setText(RefactoringMessages.ChangeSignatureInputPage_access_modifier);

	final Combo combo= new Combo(access, SWT.DROP_DOWN | SWT.READ_ONLY);
	if (availableVisibilities.length == 0) {
		combo.setEnabled(false);
	} else {
		for (int i= 0; i < availableVisibilities.length; i++) {
			combo.add(getAccessModifierString(availableVisibilities[i]));
		}
		combo.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				int newVisibility= availableVisibilities[combo.getSelectionIndex()];
				getChangeMethodSignatureProcessor().setVisibility(newVisibility);
				update(true);
			}
		});
	}
	combo.setText(getAccessModifierString(currentVisibility));
	combo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

	// ensure that "Access modifier:" and "Return type:" Labels are not too close:
	Dialog.applyDialogFont(access);
	access.pack();
	int minLabelWidth= label.getSize().x + 3 * layout.horizontalSpacing;
	if (minLabelWidth > combo.getSize().x)
		label.setLayoutData(new GridData(minLabelWidth, label.getSize().y));
}
 
Example 4
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected void setComboEnabled(Key key, boolean enabled) {
	Combo combo= getComboBox(key);
	Label label= fLabels.get(combo);
	combo.setEnabled(enabled);
	label.setEnabled(enabled);
	if (!enabled) {
		highlight(combo.getParent(), label, combo, HIGHLIGHT_NONE);
	}
}
 
Example 5
Source File: OptionsConfigurationBlock.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void setComboEnabled( Key key, boolean enabled )
{
	Combo combo = getComboBox( key );
	Label label = (Label) fLabels.get( combo );
	combo.setEnabled( enabled );
	label.setEnabled( enabled );
}
 
Example 6
Source File: DartProjectPage.java    From dartboard with Eclipse Public License 2.0 4 votes vote down vote up
private void createAdditionalControls(Composite parent) {
	Group dartGroup = new Group(parent, SWT.NONE);
	dartGroup.setFont(parent.getFont());
	dartGroup.setText(Messages.NewProject_Group_Label);
	dartGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
	dartGroup.setLayout(new GridLayout(2, false));

	Label labelSdkLocation = new Label(dartGroup, SWT.NONE);
	labelSdkLocation.setText(Messages.Preference_SDKLocation_Dart);
	GridDataFactory.swtDefaults().applyTo(labelSdkLocation);

	Label sdkLocation = new Label(dartGroup, SWT.NONE);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(sdkLocation);
	sdkLocation.setText(preferences.getString(GlobalConstants.P_SDK_LOCATION_DART));

	// ------------------------------------------
	Group stagehandGroup = new Group(parent, SWT.NONE);
	stagehandGroup.setFont(parent.getFont());
	stagehandGroup.setText(Messages.NewProject_Stagehand_Title);
	stagehandGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
	stagehandGroup.setLayout(new GridLayout(1, false));

	useStagehandButton = new Button(stagehandGroup, SWT.CHECK);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(useStagehandButton);
	useStagehandButton.setEnabled(false);

	stagehandTemplates = new Combo(stagehandGroup, SWT.READ_ONLY);
	stagehandTemplates.setEnabled(useStagehandButton.getSelection());
	GridDataFactory.fillDefaults().grab(true, false).applyTo(stagehandTemplates);

	useStagehandButton.setText(Messages.NewProject_Stagehand_UseStagehandButtonText);
	useStagehandButton.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			// Enable/Disable the stagehand templates list if the button is
			// checked/unchecked
			stagehandTemplates.setEnabled(useStagehandButton.getSelection());
			if (stagehandTemplates.getSelectionIndex() == -1) {
				stagehandTemplates.select(0);
			}
		}
	});

	ProgressIndicator indicator = new ProgressIndicator(stagehandGroup);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(indicator);
	indicator.beginAnimatedTask();

	Job.create(Messages.NewProject_Stagehand_FetchStagehand, monitor -> {
		templates = StagehandService.getStagehandTemplates();

		Display.getDefault().asyncExec(() -> {
			if (!indicator.isDisposed()) {
				indicator.done();
			}
			if (!stagehandTemplates.isDisposed()) {
				templates.forEach(str -> stagehandTemplates.add(str.getDisplayName()));
				useStagehandButton.setEnabled(true);
			}
		});
	}).schedule();
}
 
Example 7
Source File: OptionsConfigurationBlock.java    From typescript.java with MIT License 4 votes vote down vote up
protected void setComboEnabled(Key key, boolean enabled) {
	Combo combo = getComboBox(key);
	Control label = (Control) fLabels.get(combo);
	combo.setEnabled(enabled);
	label.setEnabled(enabled);
}
 
Example 8
Source File: SymSplitterDesign.java    From ldparteditor with MIT License 4 votes vote down vote up
/**
 * Create contents of the dialog.
 *
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite cmp_container = (Composite) super.createDialogArea(parent);
    GridLayout gridLayout = (GridLayout) cmp_container.getLayout();
    gridLayout.verticalSpacing = 10;
    gridLayout.horizontalSpacing = 10;

    Label lbl_specify = new Label(cmp_container, SWT.NONE);
    lbl_specify.setText(I18n.SYMSPLITTER_Title);

    Label lbl_separator = new Label(cmp_container, SWT.SEPARATOR | SWT.HORIZONTAL);
    lbl_separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    Label lbl_hint = new Label(cmp_container, SWT.NONE);
    lbl_hint.setText(I18n.SYMSPLITTER_Hint);

    BigDecimalSpinner spn_offset = new BigDecimalSpinner(cmp_container, SWT.NONE);
    this.spn_offset [0] = spn_offset;
    spn_offset.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    spn_offset.setMaximum(new BigDecimal(100000000));
    spn_offset.setMinimum(new BigDecimal(-100000000));
    spn_offset.setValue(ss.getOffset());

    Label lbl_precision = new Label(cmp_container, SWT.NONE);
    lbl_precision.setText(I18n.SYMSPLITTER_VertexThreshold);

    BigDecimalSpinner spn_precision = new BigDecimalSpinner(cmp_container, SWT.NONE);
    this.spn_precision [0] = spn_precision;
    spn_precision.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    spn_precision.setMaximum(new BigDecimal(1000));
    spn_precision.setMinimum(new BigDecimal(0));
    spn_precision.setValue(ss.getPrecision());

    Label lbl_splitPlane = new Label(cmp_container, SWT.NONE);
    lbl_splitPlane.setText(I18n.SYMSPLITTER_SplittingPlane);

    {
        Combo cmb_splitPlane = new Combo(cmp_container, SWT.READ_ONLY);
        this.cmb_splitPlane[0] = cmb_splitPlane;
        cmb_splitPlane.setItems(new String[] {I18n.SYMSPLITTER_Zp, I18n.SYMSPLITTER_Yp, I18n.SYMSPLITTER_Xp, I18n.SYMSPLITTER_Zm, I18n.SYMSPLITTER_Ym, I18n.SYMSPLITTER_Xm});
        cmb_splitPlane.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        cmb_splitPlane.setText(cmb_splitPlane.getItem(ss.getSplitPlane()));
        cmb_splitPlane.select(ss.getSplitPlane());
    }

    Label lbl_hide = new Label(cmp_container, SWT.NONE);
    lbl_hide.setText(I18n.SYMSPLITTER_SelectWhat);
    {
        Combo cmb_hide = new Combo(cmp_container, SWT.READ_ONLY);
        this.cmb_hide[0] = cmb_hide;
        cmb_hide.setItems(new String[] {I18n.SYMSPLITTER_ShowAll, I18n.SYMSPLITTER_ShowMiddle, I18n.SYMSPLITTER_ShowFront, I18n.SYMSPLITTER_ShowBehind});
        cmb_hide.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        cmb_hide.setText(cmb_hide.getItem(ss.getHideLevel()));
        cmb_hide.select(ss.getHideLevel());
    }

    Label lbl_dummy = new Label(cmp_container, SWT.NONE);
    lbl_dummy.setText(""); //$NON-NLS-1$

    {
        Combo cmb_validate = new Combo(cmp_container, SWT.READ_ONLY);
        this.cmb_validate[0] = cmb_validate;
        cmb_validate.setItems(new String[] {I18n.SYMSPLITTER_NoValidation, I18n.SYMSPLITTER_Validation});
        cmb_validate.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        cmb_validate.setText(cmb_validate.getItem(ss.isValidate() ? 1 : 0));
        cmb_validate.select(ss.isValidate() ? 1 : 0);
    }
    {
        Combo cmb_cutAcross = new Combo(cmp_container, SWT.READ_ONLY);
        this.cmb_cutAcross[0] = cmb_cutAcross;
        cmb_cutAcross.setItems(new String[] {I18n.SYMSPLITTER_DoNotCut, I18n.SYMSPLITTER_Cut});
        cmb_cutAcross.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        cmb_cutAcross.setText(cmb_cutAcross.getItem(ss.isCutAcross() ? 1 : 0));
        cmb_cutAcross.select(ss.isCutAcross() ? 1 : 0);
    }
    {
        Combo cmb_colourise = new Combo(cmp_container, SWT.READ_ONLY);
        this.cmb_colourise[0] = cmb_colourise;
        cmb_colourise.setItems(new String[] {I18n.SYMSPLITTER_NotColourise, I18n.SYMSPLITTER_Colourise});
        cmb_colourise.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        cmb_colourise.setText(cmb_colourise.getItem(ss.isColourise() ? 1 : 0));
        cmb_colourise.select(ss.isColourise() ? 1 : 0);
    }
    Combo cmb_scope = new Combo(cmp_container, SWT.READ_ONLY);
    this.cmb_scope[0] = cmb_scope;
    cmb_scope.setItems(new String[] {I18n.SYMSPLITTER_ScopeFile, I18n.SYMSPLITTER_ScopeSelection});
    cmb_scope.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    cmb_scope.setText(cmb_scope.getItem(0));
    cmb_scope.select(0);
    cmb_scope.setEnabled(false);

    cmp_container.pack();
    return cmp_container;
}
 
Example 9
Source File: IntersectorDesign.java    From ldparteditor with MIT License 4 votes vote down vote up
/**
 * Create contents of the dialog.
 *
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite cmp_container = (Composite) super.createDialogArea(parent);
    GridLayout gridLayout = (GridLayout) cmp_container.getLayout();
    gridLayout.verticalSpacing = 10;
    gridLayout.horizontalSpacing = 10;

    Label lbl_specify = new Label(cmp_container, SWT.NONE);
    lbl_specify.setText(I18n.INTERSECTOR_Title);

    Label lbl_separator = new Label(cmp_container, SWT.SEPARATOR | SWT.HORIZONTAL);
    lbl_separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    Label lbl_description = new Label(cmp_container, SWT.NONE);
    lbl_description.setText(I18n.INTERSECTOR_Description);
    
    NButton btn_hideOther = new NButton(cmp_container, SWT.CHECK);
    this.btn_hideOther[0] = btn_hideOther;
    btn_hideOther.setText(I18n.INTERSECTOR_HideOther);
    btn_hideOther.setSelection(ins.isHidingOther());
    
    Combo cmb_scope = new Combo(cmp_container, SWT.READ_ONLY);
    this.cmb_scope[0] = cmb_scope;
    cmb_scope.setItems(new String[] {I18n.INTERSECTOR_ScopeFile, I18n.INTERSECTOR_ScopeSelection});
    cmb_scope.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    cmb_scope.setText(cmb_scope.getItem(ins.getScope()));
    cmb_scope.select(ins.getScope());
    cmb_scope.setEnabled(false);

    {
        Combo cmb_colourise = new Combo(cmp_container, SWT.READ_ONLY);
        this.cmb_colourise[0] = cmb_colourise;
        cmb_colourise.setItems(new String[] {I18n.INTERSECTOR_NoMods, I18n.INTERSECTOR_ColourMods});
        cmb_colourise.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        cmb_colourise.setText(cmb_colourise.getItem(ins.isColourise() ? 1 : 0));
        cmb_colourise.select(ins.isColourise() ? 1 : 0);
    }

    cmp_container.pack();
    return cmp_container;
}
 
Example 10
Source File: ContentAssistPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * createNatureSelector
 * 
 * @param parent
 */
protected void createNatureSelector(Composite parent)
{
	// grab nature label+id list
	SortedMap<String, String> natureMap = getNatureMap();

	// combo label
	Label label = new Label(parent, SWT.LEFT);
	label.setFont(parent.getFont());
	label.setText(Messages.ContentAssistPreferencePage_NatureComboLabel);

	// create combo
	natureCombo = new Combo(parent, SWT.READ_ONLY);
	natureCombo.setFont(parent.getFont());

	GridData gd = new GridData();
	gd.horizontalSpan = 1;
	gd.horizontalAlignment = GridData.FILL;
	natureCombo.setLayoutData(gd);

	// Selected nature, in case it's a property page.
	boolean isProjectPreference = isProjectPreferencePage();
	String primaryProjectNature = null;
	if (isProjectPreference)
	{
		try
		{
			String[] aptanaNatures = ResourceUtil.getAptanaNatures(getProject().getDescription());
			if (!ArrayUtil.isEmpty(aptanaNatures))
			{
				primaryProjectNature = aptanaNatures[0];
			}
		}
		catch (CoreException e)
		{
		}
	}
	// set combo list
	for (Map.Entry<String, String> entry : natureMap.entrySet())
	{
		if (primaryProjectNature != null)
		{
			// Select only the matching entry
			if (primaryProjectNature.equals(entry.getValue()))
			{
				natureCombo.add(entry.getKey());
				break;
			}
		}
		else
		{
			natureCombo.add(entry.getKey());
		}
	}

	// select first item and save reference to that nature id for future selection updates
	natureCombo.select(0);
	activeNatureID = natureMap.get(natureCombo.getText());

	natureCombo.setEnabled(!isProjectPreference);
	if (!isProjectPreference)
	{
		natureCombo.addSelectionListener(new SelectionAdapter()
		{
			public void widgetSelected(SelectionEvent evt)
			{
				// update selection in model
				userAgentsByNatureID.put(activeNatureID, getSelectedUserAgents());

				// update nature id
				activeNatureID = getNatureMap().get(natureCombo.getText());

				// update visible selection
				updateUserAgentSelection();
			}
		});
	}
}
 
Example 11
Source File: AddOrEditElementOfXmlConvertDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite tparent = (Composite) super.createDialogArea(parent);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);

	Composite composite = new Composite(tparent, SWT.NONE);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
	GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(composite);

	// 元素类型下拉框的值, 备注:不能本地化
	String[] typeValues = { "segment", "inline", "ignore" };
	// 内联类型下拉框的值, 备注:不能本地化
	String[] internalValues = { "", "image", "pb", "lb", "x-bold", "x-entry", "x-font", "x-italic", "x-link",
			"x-underlined", "x-other" };
	// 保留空格下拉框的值, 备注:不能本地化
	String[] remainSpaceVlaues = { "", "yes", "no" };

	GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false);
	textData.widthHint = 100;

	// 元素名称
	Label nameLbl = new Label(composite, SWT.NONE);
	nameLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.nameLbl"));
	nameLbl.setAlignment(SWT.RIGHT);
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(nameLbl);

	nameTxt = new Text(composite, SWT.BORDER);
	nameTxt.setLayoutData(textData);

	// 元素类型
	Label typeLbl = new Label(composite, SWT.NONE);
	typeLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.typeLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(typeLbl);

	typeCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
	typeCmb.setLayoutData(textData);
	typeCmb.setItems(typeValues);
	typeCmb.select(0);

	// 内联类型
	Label inlineLbl = new Label(composite, SWT.NONE);
	inlineLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.inlineLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(inlineLbl);

	inlineCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
	inlineCmb.setLayoutData(textData);
	inlineCmb.setItems(internalValues);
	inlineCmb.setEnabled(false);

	// 可翻译属性
	Label transAttriLbl = new Label(composite, SWT.NONE);
	transAttriLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.transAttriLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(transAttriLbl);

	transAtrriTxt = new Text(composite, SWT.BORDER);
	transAtrriTxt.setLayoutData(textData);

	// 保留空格
	Label remainSpaceLbl = new Label(composite, SWT.NONE);
	remainSpaceLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.remainSpaceLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(remainSpaceLbl);

	remainSpaceCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
	remainSpaceCmb.setLayoutData(textData);
	remainSpaceCmb.setItems(remainSpaceVlaues);

	// 当元素类型是segment时,禁用内联内型,当元素类型是inline时,禁用可翻译属性。当元素类型是ignore时,禁用可翻译属性与内联内型
	typeCmb.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {
			String type = typeCmb.getText();
			if ("segment".equals(type)) {
				inlineCmb.setText("");
				inlineCmb.setEnabled(false);
				transAtrriTxt.setEnabled(true);
			} else if ("inline".equals(type)) {
				inlineCmb.setEnabled(true);
				transAtrriTxt.setText("");
				transAtrriTxt.setEnabled(false);
			} else if ("ignore".equals(type)) {
				inlineCmb.setText("");
				inlineCmb.setEnabled(false);
				transAtrriTxt.setText("");
				transAtrriTxt.setEnabled(false);
			}
		}
	});

	return tparent;
}
 
Example 12
Source File: CompositeTableRow.java    From dawnsci with Eclipse Public License 1.0 4 votes vote down vote up
public CompositeTableRow(CompositeEntry entry,
					     Table container,
						 CompositingControl control,
						 boolean disableOp) {
	
	this.name = entry.getName();
	TableItem newItem = new TableItem(container,SWT.DOUBLE_BUFFERED);
	TableEditor editor0 = new TableEditor(container);
	editor0.horizontalAlignment = SWT.CENTER;
	editor0.grabHorizontal = true;
	chkActive = new Button(container,SWT.CHECK);
	chkActive.setSelection(true);
	chkActive.addSelectionListener(control);
	editor0.setEditor(chkActive,newItem,0);
	
	TableEditor editor = new TableEditor(container);
	editor.horizontalAlignment = SWT.CENTER;
	editor.grabHorizontal = true;
	panel = new Composite(container, SWT.NONE);
	panel.setLayout(new GridLayout(2,true));
	slider = new Slider(panel,SWT.HORIZONTAL|SWT.NO_TRIM);
	slider.setValues((int)(entry.getWeight()*100), 0, 104, 5, 1, 5);
	slider.addSelectionListener(this);
	slider.addSelectionListener(control);
	spinner = new Spinner(panel,SWT.DOUBLE_BUFFERED);
	spinner.setMinimum(0);
	spinner.setMaximum(100);
	spinner.setSelection((int)(entry.getWeight()*100));
	spinner.addSelectionListener(control);
	spinner.addSelectionListener(this);
	panel.pack();
	editor.setEditor(panel,newItem,2);
	newItem.setText(1,name);
	TableEditor editor2 = new TableEditor(container);
	editor2.horizontalAlignment = SWT.CENTER;
	editor2.grabHorizontal = true;
	editor2.grabVertical = true;
	op = new Combo(container,SWT.NONE);
	op.add("ADD");
	op.add("SUBTRACT");
	op.add("MULTIPLY");
	op.add("DIVIDE");
	op.add("MINIMUM");
	op.add("MAXIMUM");
	op.select(convertOperationToInt(entry.getOperation()));
	op.pack();
	op.addSelectionListener(control);
	op.setEnabled(!disableOp);
	editor2.setEditor(op,newItem,3);
	TableEditor editor3 = new TableEditor(container);
	editor3.horizontalAlignment = SWT.CENTER;
	editor3.grabHorizontal = true;
	editor3.grabVertical = true;
	chkRed = new Button(container,SWT.CHECK);
	chkRed.setSelection(true);
	chkRed.pack();
	chkRed.addSelectionListener(control);
	editor3.setEditor(chkRed,newItem,4);
	TableEditor editor4 = new TableEditor(container);
	editor4.horizontalAlignment = SWT.CENTER;
	editor4.grabHorizontal = true;
	editor4.grabVertical = true;
	chkGreen = new Button(container,SWT.CHECK);
	chkGreen.pack();
	chkGreen.setSelection(true);
	chkGreen.addSelectionListener(control);
	editor4.setEditor(chkGreen,newItem,5);
	TableEditor editor5 = new TableEditor(container);
	editor5.horizontalAlignment = SWT.CENTER;
	editor5.grabHorizontal = true;
	editor5.grabVertical = true;
	chkBlue = new Button(container,SWT.CHECK);
	chkBlue.pack();
	chkBlue.setSelection(true);
	chkBlue.addSelectionListener(control);
	editor5.setEditor(chkBlue,newItem,6);		
	
}
 
Example 13
Source File: AddOrEditElementOfXmlConvertDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite tparent = (Composite) super.createDialogArea(parent);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);

	Composite composite = new Composite(tparent, SWT.NONE);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
	GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(composite);

	// 元素类型下拉框的值, 备注:不能本地化
	String[] typeValues = { "segment", "inline", "ignore" };
	// 内联类型下拉框的值, 备注:不能本地化
	String[] internalValues = { "", "image", "pb", "lb", "x-bold", "x-entry", "x-font", "x-italic", "x-link",
			"x-underlined", "x-other" };
	// 保留空格下拉框的值, 备注:不能本地化
	String[] remainSpaceVlaues = { "", "yes", "no" };

	GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false);
	textData.widthHint = 100;

	// 元素名称
	Label nameLbl = new Label(composite, SWT.NONE);
	nameLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.nameLbl"));
	nameLbl.setAlignment(SWT.RIGHT);
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(nameLbl);

	nameTxt = new Text(composite, SWT.BORDER);
	nameTxt.setLayoutData(textData);

	// 元素类型
	Label typeLbl = new Label(composite, SWT.NONE);
	typeLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.typeLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(typeLbl);

	typeCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
	typeCmb.setLayoutData(textData);
	typeCmb.setItems(typeValues);
	typeCmb.select(0);

	// 内联类型
	Label inlineLbl = new Label(composite, SWT.NONE);
	inlineLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.inlineLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(inlineLbl);

	inlineCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
	inlineCmb.setLayoutData(textData);
	inlineCmb.setItems(internalValues);
	inlineCmb.setEnabled(false);

	// 可翻译属性
	Label transAttriLbl = new Label(composite, SWT.NONE);
	transAttriLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.transAttriLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(transAttriLbl);

	transAtrriTxt = new Text(composite, SWT.BORDER);
	transAtrriTxt.setLayoutData(textData);

	// 保留空格
	Label remainSpaceLbl = new Label(composite, SWT.NONE);
	remainSpaceLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.remainSpaceLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(remainSpaceLbl);

	remainSpaceCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
	remainSpaceCmb.setLayoutData(textData);
	remainSpaceCmb.setItems(remainSpaceVlaues);

	// 当元素类型是segment时,禁用内联内型,当元素类型是inline时,禁用可翻译属性。当元素类型是ignore时,禁用可翻译属性与内联内型
	typeCmb.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {
			String type = typeCmb.getText();
			if ("segment".equals(type)) {
				inlineCmb.setText("");
				inlineCmb.setEnabled(false);
				transAtrriTxt.setEnabled(true);
			} else if ("inline".equals(type)) {
				inlineCmb.setEnabled(true);
				transAtrriTxt.setText("");
				transAtrriTxt.setEnabled(false);
			} else if ("ignore".equals(type)) {
				inlineCmb.setText("");
				inlineCmb.setEnabled(false);
				transAtrriTxt.setText("");
				transAtrriTxt.setEnabled(false);
			}
		}
	});

	return tparent;
}
 
Example 14
Source File: ConfigurationSettingsWizardPage.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Setups gateway SWT controls by populating a gateway combobox and configuring an information
 * Label and the enabling checkbox.
 *
 * @param combo {@link Combo} selector to populate with discovered gateways
 * @param info {@link Label} displaying status information of the discovery
 * @param checkbox {@link Button} checkbox to enable/disable UPnP support
 */
private void populateGatewaySelectionControls(
    List<GatewayDevice> gateways, final Combo combo, final Label info, final Button checkbox) {

  combo.setEnabled(false);
  checkbox.setEnabled(false);
  combo.removeAll();

  // if no devices are found, return now - nothing to populate
  if (gateways == null || gateways.isEmpty()) {
    info.setText(Messages.UPnPUIUtils_no_gateway);
    info.getParent().pack();
    return;
  }

  this.gateways = new ArrayList<GatewayDevice>();

  // insert found gateways into combobox
  for (GatewayDevice gw : gateways) {
    try {
      String name = gw.getFriendlyName();
      if (!gw.isConnected()) name += Messages.UPnPUIUtils_disconnected;

      combo.add(name);
      this.gateways.add(gw);

    } catch (Exception e) {
      log.debug("Error updating UPnP selector:" + e.getMessage()); // $NON-NLS-1$
      // ignore faulty gateway
    }
  }

  // if valid gateway found, show info and enable
  if (combo.getItemCount() > 0) {
    checkbox.setEnabled(true);
    combo.setEnabled(true);
    combo.select(0);
    combo.pack();
    info.setVisible(false);
  } else {
    info.setText(Messages.UPnPUIUtils_no_valid_gateway);
  }
  info.getParent().pack();
}
 
Example 15
Source File: JsonImportDialog.java    From olca-app with Mozilla Public License 2.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite root = (Composite) super.createDialogArea(parent);
	UI.gridLayout(root, 1, 10, 10);

	Composite comp = new Composite(root, SWT.NONE);
	UI.gridLayout(comp, 2, 10, 0);
	UI.formLabel(comp, M.File);
	String fileText = Strings.cut(provider.file.getParent(), 50)
			+ File.separator
			+ Strings.cut(provider.file.getName(), 50);
	Label label = UI.formLabel(comp, fileText);
	label.setForeground(Colors.linkBlue());

	Button openCheck = new Button(root, SWT.RADIO);
	openCheck.setText("Open mapping definition");
	Combo combo = new Combo(root, SWT.READ_ONLY);
	Controls.onSelect(combo, e -> {
		selectedMap = flowMaps.get(combo.getSelectionIndex());
	});
	UI.gridData(combo, true, false);
	Controls.onSelect(openCheck, e -> {
		selectedMap = flowMaps.get(combo.getSelectionIndex());
		combo.setEnabled(true);
	});

	Button genCheck = new Button(root, SWT.RADIO);
	genCheck.setText("Generate mapping based on flow attributes");
	Controls.onSelect(genCheck, e -> {
		selectedMap = null;
		combo.setEnabled(false);
	});

	if (flowMaps.isEmpty()) {
		genCheck.setSelection(true);
		openCheck.setSelection(false);
		combo.setEnabled(false);
		openCheck.setEnabled(false);
	} else {
		openCheck.setSelection(true);
		genCheck.setSelection(false);
		String[] items = this.flowMaps
				.stream()
				.map(m -> m.name)
				.toArray(len -> new String[len]);
		combo.setItems(items);
		combo.select(0);
		selectedMap = flowMaps.get(0);
	}
	return root;
}