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

The following examples show how to use org.eclipse.swt.widgets.Combo#addSelectionListener() . 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: SettingsDialog.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
private void createNorth() {
	
	Composite northComposite = new Composite(shell, SWT.NONE);
	northComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	northComposite.setLayout(new GridLayout(2, false));
	
	Label comboLabel = new Label(northComposite, SWT.NONE);
	comboLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	comboLabel.setText("Please select your chart type: ");
	
	comboChartSelect = new Combo(northComposite, SWT.NONE | SWT.READ_ONLY);
	comboChartSelect.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	comboChartSelect.add("Bar Chart");
	comboChartSelect.add("Bubble Chart");
	comboChartSelect.add("Pie Chart");
	comboChartSelect.select(-1);

	comboChartSelect.addSelectionListener(this);
	
}
 
Example 2
Source File: ComboField.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public ComboField(Composite parent, int displayBits, String displayName, String... values){
	super(parent, displayBits, displayName);
	int swtflag = SWT.READ_ONLY | SWT.SINGLE;
	if (isReadonly()) {
		swtflag |= SWT.READ_ONLY;
	}
	combo = new Combo(parent, swtflag);
	combo.setItems(values);
	combo.addSelectionListener(new SelectionAdapter() {
		
		@Override
		public void widgetSelected(SelectionEvent e){
			textContents = combo.getText();
		}
		
	});
	setControl(combo);
}
 
Example 3
Source File: AccountSelector.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
public AccountSelector(Composite parent, IGoogleLoginService loginService) {
  super(parent, SWT.NONE);
  this.loginService = loginService;
  loginMessage = Messages.getString("ACCOUNT_SELECTOR_LOGIN");

  combo = new Combo(this, SWT.READ_ONLY);

  List<Account> sortedAccounts = new ArrayList<>(loginService.getAccounts());
  Collections.sort(sortedAccounts, new Comparator<Account>() {
    @Override
    public int compare(Account o1, Account o2) {
      return o1.getEmail().compareTo(o2.getEmail());
    }
  });
  for (Account account : sortedAccounts) {
    combo.add(account.getEmail());
    combo.setData(account.getEmail(), account);
  }
  combo.add(loginMessage);
  combo.addSelectionListener(logInOnSelect);

  GridDataFactory.fillDefaults().grab(true, false).applyTo(combo);
  GridLayoutFactory.fillDefaults().generateLayout(this);
}
 
Example 4
Source File: ImportTracePackageWizardPage.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void createFilePathGroup(Composite parent, String label, int fileDialogStyle) {
    super.createFilePathGroup(parent, label, fileDialogStyle);

    Combo filePathCombo = getFilePathCombo();
    filePathCombo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            updateWithFilePathSelection();
        }
    });

    // User can type-in path and press return to validate
    filePathCombo.addTraverseListener(e -> {
        if (e.detail == SWT.TRAVERSE_RETURN) {
            e.doit = false;
            updateWithFilePathSelection();
        }
    });
}
 
Example 5
Source File: OptionsConfigurationBlock.java    From typescript.java with MIT License 6 votes vote down vote up
protected Combo newComboControl(Composite composite, Key key, String[] values, String[] valueLabels,
		boolean readOnly) {
	Combo comboBox = new Combo(composite, readOnly ? SWT.READ_ONLY : SWT.NONE);
	comboBox.setItems(valueLabels);
	comboBox.setFont(JFaceResources.getDialogFont());

	makeScrollableCompositeAware(comboBox);

	String currValue = getValue(key);
	if (readOnly) {
		ControlData data = new ControlData(key, values);
		comboBox.setData(data);
		comboBox.addSelectionListener(getSelectionListener());
		comboBox.select(data.getSelection(currValue));
	} else {
		comboBox.setData(key);
		if (currValue != null) {
			comboBox.setText(currValue);
		}
		comboBox.addModifyListener(getTextModifyListener());
	}

	fComboBoxes.add(comboBox);
	return comboBox;
}
 
Example 6
Source File: ReportConfigurationTab.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void createPriorityGroup(Composite parent) {
    Composite prioGroup = new Composite(parent, SWT.NONE);
    prioGroup.setLayout(new GridLayout(2, false));

    Label minPrioLabel = new Label(prioGroup, SWT.NONE);
    minPrioLabel.setText(getMessage("property.minPriority"));
    minPrioLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

    minPriorityCombo = new Combo(prioGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    minPriorityCombo.add(ProjectFilterSettings.HIGH_PRIORITY);
    minPriorityCombo.add(ProjectFilterSettings.MEDIUM_PRIORITY);
    minPriorityCombo.add(ProjectFilterSettings.LOW_PRIORITY);
    minPriorityCombo.setText(propertyPage.getOriginalUserPreferences().getFilterSettings().getMinPriority());
    minPriorityCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    minPriorityCombo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            String data = minPriorityCombo.getText();
            getCurrentProps().getFilterSettings().setMinPriority(data);
        }
    });


}
 
Example 7
Source File: HTMLFormatterIndentationTabPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructor.
 * 
 * @param controlManager
 * @param tabSize
 */
public TabOptionHandler(IFormatterControlManager controlManager, Combo tabOptions, Text indentationSize,
		Text tabSize)
{
	this.manager = controlManager;
	this.tabOptions = tabOptions;
	this.indentationSize = indentationSize;
	this.tabSize = tabSize;
	tabOptions.addSelectionListener(this);
	manager.addInitializeListener(this);
}
 
Example 8
Source File: NavigationPageComboRenderer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void createUI(Composite parent) {
	GridLayout layout = new GridLayout(1, false);
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	this.setLayout(layout);

	pageCombo = new Combo(parent, SWT.READ_ONLY);
	pageCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	pageCombo.addSelectionListener(this);
}
 
Example 9
Source File: AbstractEditor.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
protected Control createComboParameterControl(final Composite comp) {
	possibleValues = new ArrayList<T>(param.getAmongValue(getScope()));
	final String[] valuesAsString = new String[possibleValues.size()];
	for (int i = 0; i < possibleValues.size(); i++) {
		// if ( param.isLabel() ) {
		// valuesAsString[i] = possibleValues.get(i).toString();
		// } else {
		if (getExpectedType() == Types.STRING) {
			valuesAsString[i] = StringUtils.toJavaString(StringUtils.toGaml(possibleValues.get(i), false));
		} else {
			valuesAsString[i] = StringUtils.toGaml(possibleValues.get(i), false);
			// }
		}
	}
	combo = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN);
	combo.setForeground(IGamaColors.BLACK.color()); // force text color, see #2601
	combo.setItems(valuesAsString);
	combo.select(possibleValues.indexOf(getOriginalValue()));
	// combo.addModifyListener(new ModifyListener() {
	//
	// @Override
	// public void modifyText(final ModifyEvent me) {
	// modifyValue(possibleValues.get(combo.getSelectionIndex()));
	// }
	// });
	combo.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(final SelectionEvent me) {
			modifyValue(possibleValues.get(combo.getSelectionIndex()));
		}
	});

	final GridData d = new GridData(SWT.LEFT, SWT.CENTER, false, true);
	d.minimumWidth = 48;
	// d.widthHint = 100; // SWT.DEFAULT
	combo.setLayoutData(d);
	combo.pack();
	return combo;
}
 
Example 10
Source File: DataDefinitionSelector.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Combo createSeriesSelectCombo( Composite cmpTop,
		ChartWizardContext wizardContext )
{
	Combo combo = new Combo( cmpTop, SWT.DROP_DOWN | SWT.READ_ONLY );
	{
		combo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
		combo.addSelectionListener( this );
		refreshSeriesCombo( combo );
		combo.select( 0 );
	}
	return combo;
}
 
Example 11
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 12
Source File: WizardUtils.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public static Combo createCombo(Composite parent, int span, SelectionListener listener) {
    Combo combo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = span;
    combo.setLayoutData(gd);
    combo.setVisibleItemCount(10);
    if (listener != null) {
        combo.addSelectionListener(listener);            
    }        
    return combo;
}
 
Example 13
Source File: WizardUtils.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public static Combo createEditCombo(Composite parent, int span, SelectionListener listener) {
    Combo combo = new Combo(parent, SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = span;
    combo.setLayoutData(gd);
    combo.setVisibleItemCount(10);
    if (listener != null) {
        combo.addSelectionListener(listener);            
    }        
    return combo;
}
 
Example 14
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 15
Source File: JavaCamelJobScriptsExportWSWizardPage.java    From tesb-studio-se with Apache License 2.0 4 votes vote down vote up
@Override
protected void createUnzipOptionGroup(Composite parent) {
    // options group
    Group optionsGroup = new Group(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    optionsGroup.setLayout(layout);
    optionsGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
    optionsGroup.setText(Messages.getString("JavaJobScriptsExportWSWizardPage.BuildType")); //$NON-NLS-1$
    optionsGroup.setFont(parent.getFont());

    optionsGroup.setLayout(new GridLayout(2, false));

    Label label = new Label(optionsGroup, SWT.NONE);
    label.setText(Messages.getString("JavaJobScriptsExportWSWizardPage.BuildLabel")); //$NON-NLS-1$

    boolean canESBMicroServiceDockerImage = PluginChecker.isDockerPluginLoaded();

    exportTypeCombo = new Combo(optionsGroup, SWT.PUSH);

    // TESB-5328
    exportTypeCombo.add(EXPORTTYPE_KAR);
    if (PluginChecker.isTIS()) {
        exportTypeCombo.add(EXPORTTYPE_SPRING_BOOT);

        if (canESBMicroServiceDockerImage) {
            exportTypeCombo.add(EXPORTTYPE_SPRING_BOOT_DOCKER_IMAGE);
        }
    }
    // exportTypeCombo.setEnabled(false); // only can export kar file
    exportTypeCombo.setText(EXPORTTYPE_KAR);

    exportTypeCombo.addSelectionListener(new SelectionAdapter() {

        /*
         * (non-Javadoc)
         *
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            Widget source = e.widget;
            if (source instanceof Combo) {
                String destination = ((Combo) source).getText();
                boolean isMS = destination.equals(EXPORTTYPE_SPRING_BOOT)
                        || destination.equals(EXPORTTYPE_SPRING_BOOT_DOCKER_IMAGE);

                if (isMS) {
                    contextButton.dispose();
                    addBSButton.dispose();
                    exportAsZipButton.dispose();

                    optionsDockerGroupComposite.dispose();

                    if (destination.equals(EXPORTTYPE_SPRING_BOOT)) {
                        updateDestinationGroup(false);
                        createOptionsForKar(optionsGroupComposite, optionsGroupFont);
                        optionsGroupComposite.layout(true, true);
                    } else {
                        updateDestinationGroup(true);
                        createOptionsForDocker(optionsGroupComposite, optionsGroupFont);
                        createDockerOptions(parent);
                        restoreWidgetValuesForImage();
                        optionsGroupComposite.layout(true, true);
                    }

                    parent.layout();

                } else {
                    if(contextButton != null) contextButton.setEnabled(false);
                    if(exportAsZipButton != null) exportAsZipButton.setEnabled(false);
                }

                String destinationValue = getDestinationValue();

                if (isMS) {
                    if (exportAsZip) {
                        destinationValue = destinationValue.substring(0, destinationValue.lastIndexOf("."))
                                + FileConstants.ZIP_FILE_SUFFIX;
                    } else {
                        destinationValue = destinationValue.substring(0, destinationValue.lastIndexOf("."))
                                + FileConstants.JAR_FILE_SUFFIX;
                    }
                } else {
                    destinationValue = destinationValue.substring(0, destinationValue.lastIndexOf(".")) + getOutputSuffix();
                }

                setDestinationValue(destinationValue);
            }

        }
    });
}
 
Example 16
Source File: JSParserValidatorPreferenceCompositeFactory.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public Composite createPreferenceComposite(Composite parent, final IBuildParticipantWorkingCopy participant)
{
	Composite master = new Composite(parent, SWT.NONE);
	master.setLayout(GridLayoutFactory.fillDefaults().create());

	GridDataFactory fillHoriz = GridDataFactory.fillDefaults().grab(true, false);

	// Options
	Group group = new Group(master, SWT.BORDER);
	group.setText(Messages.JSParserValidatorPreferenceCompositeFactory_OptionsGroup);
	group.setLayout(new GridLayout());
	group.setLayoutData(fillHoriz.create());

	Composite pairs = new Composite(group, SWT.NONE);
	pairs.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());

	Label label = new Label(pairs, SWT.WRAP);
	label.setText(Messages.JSParserValidatorPreferenceCompositeFactory_MissingSemicolons);

	Combo combo = new Combo(pairs, SWT.READ_ONLY | SWT.SINGLE);
	for (IProblem.Severity severity : IProblem.Severity.values())
	{
		combo.add(severity.label());
		combo.setData(severity.label(), severity);
	}
	String severityValue = participant.getPreferenceString(IPreferenceConstants.PREF_MISSING_SEMICOLON_SEVERITY);
	combo.setText(IProblem.Severity.create(severityValue).label());

	combo.addSelectionListener(new SelectionAdapter()
	{
		@Override
		public void widgetSelected(SelectionEvent e)
		{
			Combo c = ((Combo) e.widget);
			int index = c.getSelectionIndex();
			String text = c.getItem(index);
			IProblem.Severity s = (Severity) c.getData(text);
			participant.setPreference(IPreferenceConstants.PREF_MISSING_SEMICOLON_SEVERITY, s.id());
		}
	});
	fillHoriz.applyTo(pairs);

	// Filters
	Composite filtersGroup = new ValidatorFiltersPreferenceComposite(master, participant);
	filtersGroup.setLayoutData(fillHoriz.grab(true, true).hint(SWT.DEFAULT, 150).create());

	return master;
}
 
Example 17
Source File: EditorCriterionProfitability.java    From arx with Apache License 2.0 4 votes vote down vote up
@Override
protected Composite build(Composite parent) {
    
       // Create input group
       Composite group = new Composite(parent, SWT.NONE);
       group.setLayoutData(SWTUtil.createFillHorizontallyGridData());
       GridLayout groupInputGridLayout = new GridLayout();
       groupInputGridLayout.numColumns = 4;
       group.setLayout(groupInputGridLayout);
       
       // Attacker model
       Label labelAttackerModel = new Label(group, SWT.NONE);
       labelAttackerModel.setText(Resources.getMessage("CriterionDefinitionView.120"));

       comboAttackerModel = new Combo(group, SWT.READ_ONLY);
       comboAttackerModel.setLayoutData(SWTUtil.createFillHorizontallyGridData());
       comboAttackerModel.setItems(LABELS);
       comboAttackerModel.select(0);
       comboAttackerModel.addSelectionListener(new SelectionAdapter() {
           @Override
           public void widgetSelected(final SelectionEvent arg0) {
               if (comboAttackerModel.getSelectionIndex() != -1) {
                   model.setAttackerModel(MODELS[comboAttackerModel.getSelectionIndex()]);
               }
           }
       });
       
       // Allow attack
       Label labelAllowAttack = new Label(group, SWT.NONE);
       labelAllowAttack.setText(Resources.getMessage("CriterionDefinitionView.123"));

       checkboxAllowAttack = new Button(group, SWT.CHECK);
       checkboxAllowAttack.addSelectionListener(new SelectionAdapter() {
           @Override
           public void widgetSelected(SelectionEvent e) {
               model.setAllowAttacks(checkboxAllowAttack.getSelection());
           }
       });
       
       return group;
}
 
Example 18
Source File: CustomMatchConditionDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 初始化过滤器列表控件
 */
private void initFilterName() {
	filterName = new Combo(this, SWT.BORDER);
	filterName.setLayoutData(new GridData(80, 35));
	setComboData(filterName, filterData);
	filterName.setData("filterName");
	filterName.select(0);
	filterName.addSelectionListener(new SelectionAdapter() {
		private void createSource() {
			disposeChild();
			initTxt(2);
			initBtn();
		}

		private void createKeyword() {
			disposeChild();
			initConditions(conditionData2);
			initTxt(1);
			initBtn();
		}

		private void createMatchQt() {
			disposeChild();
			initConditions(conditionData1);
			initTxt(1);
			initMatchQtTextListener();
			initBtn();
		}

		@Override
		public void widgetSelected(SelectionEvent e) {
			if (isMatchQt()) {
				createMatchQt();
			}
			if (isKeyword()) {
				createKeyword();
			}
			if (isSource()) {
				createSource();
			}
			DynaComposite.this.layout();
		}
	});
}
 
Example 19
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 20
Source File: ExternalizedTextEditorDialog.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected Control createDialogArea( Composite parent )
{
	GridLayout glContent = new GridLayout( );
	glContent.numColumns = 2;
	glContent.horizontalSpacing = 5;
	glContent.verticalSpacing = 16;
	glContent.marginHeight = 7;
	glContent.marginWidth = 7;

	Composite cmpContent = new Composite( parent, SWT.NONE );
	cmpContent.setLayout( glContent );
	cmpContent.setLayoutData( new GridData( GridData.FILL_BOTH ) );

	cbExternalize = new Button( cmpContent, SWT.CHECK );
	GridData gdCBExternalize = new GridData( GridData.FILL_HORIZONTAL );
	gdCBExternalize.horizontalSpan = 2;
	cbExternalize.setLayoutData( gdCBExternalize );
	cbExternalize.setText( Messages.getString( "ExternalizedTextEditorDialog.Lbl.ExternalizeText" ) ); //$NON-NLS-1$
	cbExternalize.addSelectionListener( this );

	Label lblKey = new Label( cmpContent, SWT.NONE );
	GridData gdLBLKey = new GridData( );
	lblKey.setLayoutData( gdLBLKey );
	lblKey.setText( Messages.getString( "ExternalizedTextEditorDialog.Lbl.LookupKey" ) ); //$NON-NLS-1$

	cmbKeys = new Combo( cmpContent, SWT.DROP_DOWN | SWT.READ_ONLY );
	GridData gdCMBKeys = new GridData( GridData.FILL_HORIZONTAL );
	cmbKeys.setLayoutData( gdCMBKeys );
	cmbKeys.addSelectionListener( this );

	// Layout for Current Value composite
	GridLayout glCurrent = new GridLayout( );
	glCurrent.horizontalSpacing = 5;
	glCurrent.verticalSpacing = 5;
	glCurrent.marginHeight = 0;
	glCurrent.marginWidth = 0;

	Composite cmpCurrent = new Composite( cmpContent, SWT.NONE );
	GridData gdCMPCurrent = new GridData( GridData.FILL_BOTH );
	gdCMPCurrent.horizontalSpan = 2;
	cmpCurrent.setLayoutData( gdCMPCurrent );
	cmpCurrent.setLayout( glCurrent );

	Label lblValue = new Label( cmpCurrent, SWT.NONE );
	GridData gdLBLValue = new GridData( GridData.VERTICAL_ALIGN_BEGINNING );
	lblValue.setLayoutData( gdLBLValue );
	lblValue.setText( Messages.getString( "ExternalizedTextEditorDialog.Lbl.DefaultValue" ) ); //$NON-NLS-1$

	txtValue = new Text( cmpCurrent, SWT.BORDER
			| SWT.MULTI
			| SWT.WRAP
			| SWT.H_SCROLL
			| SWT.V_SCROLL );
	GridData gdTXTValue = new GridData( GridData.FILL_BOTH );
	gdTXTValue.widthHint = 280;
	gdTXTValue.heightHint = 40;
	txtValue.setLayoutData( gdTXTValue );

	// Layout for Current Value composite
	GridLayout glExtValue = new GridLayout( );
	glExtValue.horizontalSpacing = 5;
	glExtValue.verticalSpacing = 5;
	glExtValue.marginHeight = 0;
	glExtValue.marginWidth = 0;

	Composite cmpExtValue = new Composite( cmpContent, SWT.NONE );
	GridData gdCMPExtValue = new GridData( GridData.FILL_BOTH );
	gdCMPExtValue.horizontalSpan = 2;
	cmpExtValue.setLayoutData( gdCMPExtValue );
	cmpExtValue.setLayout( glExtValue );

	Label lblExtValue = new Label( cmpExtValue, SWT.NONE );
	GridData gdLBLExtValue = new GridData( GridData.VERTICAL_ALIGN_BEGINNING );
	lblExtValue.setLayoutData( gdLBLExtValue );
	lblExtValue.setText( Messages.getString( "ExternalizedTextEditorDialog.Lbl.ExternalizedValue" ) ); //$NON-NLS-1$

	txtCurrent = new Text( cmpExtValue, SWT.BORDER
			| SWT.MULTI
			| SWT.WRAP
			| SWT.H_SCROLL
			| SWT.V_SCROLL
			| SWT.READ_ONLY );
	GridData gdTXTCurrent = new GridData( GridData.FILL_BOTH );
	gdTXTCurrent.widthHint = 280;
	gdTXTCurrent.heightHint = 40;
	txtCurrent.setLayoutData( gdTXTCurrent );

	// Layout for button composite
	GridLayout glButtons = new GridLayout( );
	glButtons.numColumns = 2;
	glButtons.horizontalSpacing = 5;
	glButtons.verticalSpacing = 0;
	glButtons.marginWidth = 0;
	glButtons.marginHeight = 0;

	populateList( );

	return cmpContent;
}