Package org.eclipse.swt.custom

Examples of org.eclipse.swt.custom.CCombo


* @param parent
*            the parent of the new text field
* @return the new text field
*/
private CCombo createCombo(Composite parent) {
  CCombo combo= new CCombo(parent, SWT.BORDER);
  combo.addModifyListener(this);
  GridData data = new GridData();
  data.horizontalSpan = 3;
  data.horizontalAlignment = GridData.FILL;
  data.grabExcessHorizontalSpace = true;
  data.verticalAlignment = GridData.CENTER;
  data.grabExcessVerticalSpace = false;
  combo.setLayoutData(data);
  return combo;
}
View Full Code Here


    createLabel(client, messagePrefix);
    return createCombo(client, messagePrefix, values);
  }
 
  public static IObservableValue createCombo(Composite client, String messagePrefix, String[] values) {
    CCombo combo = new CCombo(client, SWT.DROP_DOWN | SWT.READ_ONLY
        | SWT.FLAT | SWT.BORDER);
    for (String value : values) {
      combo.add(value);
    }

    toolkit.adapt(combo);
    toolkit.paintBordersFor(combo);
   
    combo.setToolTipText(Messages.getString(messagePrefix + "_hint")); //$NON-NLS-1$
   
    //Format
    TableWrapData td = new TableWrapData();
    combo.setLayoutData(td);
   
    return SWTObservables.observeSelection(combo);
  }
View Full Code Here

  }
 
  public static AbstractListViewer createLabelFieldCombobox(Composite client, String messagePrefix) {
    createLabel(client, messagePrefix);
   
    final CCombo combo = new CCombo(client, SWT.FLAT | SWT.BORDER);
    TableWrapData td = new TableWrapData();
    td.grabHorizontal = true;
    //td.maxWidth = 400;
    combo.setLayoutData(td);

    toolkit.adapt(combo);
    toolkit.paintBordersFor(combo);
   
    combo.setToolTipText(Messages.getString(messagePrefix + "_hint")); //$NON-NLS-1$
    final ComboViewer comboViewer = new ComboViewer(combo);
   
    //Add Focus-Lost Listener so that the entered text gets converted to a IField and gets selected.
    //This way the databinding works
    combo.addFocusListener(new FocusListener() {

      private StringToFieldConverter converter = new StringToFieldConverter(null, comboViewer);     
     
      public void focusGained(FocusEvent e) {}
      public void focusLost(FocusEvent e) {
        //already selected (due to combobox select)
        if (!comboViewer.getSelection().isEmpty())
          return;
       
        converter.setExistingFields((List<IField>)comboViewer.getInput());
        Object convertedText = converter.convert(combo.getText());
        comboViewer.setSelection(new StructuredSelection(convertedText));
      }
     
    });   
   
View Full Code Here

  }

  public static AbstractListViewer createLabelMethodCombobox(Composite client, String messagePrefix) {
    createLabel(client, messagePrefix);
   
    final CCombo combo = new CCombo(client, SWT.FLAT | SWT.BORDER);
    TableWrapData td = new TableWrapData();
    td.grabHorizontal = true;
    //td.maxWidth = 400;
    combo.setLayoutData(td);

    toolkit.adapt(combo);
    toolkit.paintBordersFor(combo);
   
    combo.setToolTipText(Messages.getString(messagePrefix + "_hint")); //$NON-NLS-1$
   
    final ComboViewer comboViewer = new ComboViewer(combo);
   
    //Add Focus-Lost Listener so that the entered text gets converted to a IMethod and gets selected.
    //This way the databinding works
    combo.addFocusListener(new FocusListener() {

      private StringToMethodConverter converter = new StringToMethodConverter(null, comboViewer);
     
      public void focusGained(FocusEvent e) {}
      public void focusLost(FocusEvent e) {
        //already selected (due to combobox select)
        if (!comboViewer.getSelection().isEmpty())
          return;
       
        converter.setExistingMethods((List<IMethod>)comboViewer.getInput());
        Object convertedText = converter.convert(combo.getText());
        comboViewer.setSelection(new StructuredSelection(convertedText));
      }
     
    });   
   
View Full Code Here

    fComboBoxes = new HashMap();
    fComboBoxListener = new SelectionListener() {

      public void widgetDefaultSelected(SelectionEvent e)
      {
        CCombo combo = (CCombo)e.widget;
        fOverlayStore.setValue((String)fComboBoxes.get(combo), combo.getSelectionIndex());
      }

      public void widgetSelected(SelectionEvent e)
      {
        CCombo combo = (CCombo)e.widget;
        fOverlayStore.setValue((String)fComboBoxes.get(combo), combo.getSelectionIndex());
      }

    };
    fNumberFields = new ArrayList();
    fNumberFieldListener = new ModifyListener() {
View Full Code Here

   
    label = "Enable bracket highlighting";
    Button bracketMatchingBox = addCheckBox(appearanceComposite, label, EditorPreferenceConstants.P_BRACKET_MATCHING_ENABLED, 0);
    String items[] = new String[] {"Outline box", "Solid box", "Bold text"};
    CCombo bracketStyleCombo  = addComboList(appearanceComposite,"Bracket matching style",EditorPreferenceConstants.P_BRACKET_MATCHING_STYLE,items);
    createDependency(bracketMatchingBox, EditorPreferenceConstants.P_BRACKET_MATCHING_ENABLED, bracketStyleCombo);
   
    label = "Enable smart Home and End";
    addCheckBox(appearanceComposite, label, EditorPreferenceConstants.P_NAVIGATION_SMART_HOME_END, 0);
   
View Full Code Here

    {
      t = (Text)e.next();
      key = (String)fTextFields.get(t);
    }

    CCombo c;
    for(Iterator e = fComboBoxes.keySet().iterator(); e.hasNext(); c.select(fOverlayStore.getInt(key)))
    {
      c = (CCombo)e.next();
      key = (String)fComboBoxes.get(c);
    }
View Full Code Here

    labelControl.setText(label);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.horizontalIndent = 0;
   
    labelControl.setLayoutData(gd);
    CCombo combo = new CCombo(parent,SWT.BORDER|SWT.SINGLE|SWT.READ_ONLY);
    for (int i=0;i<items.length;i++) {
      combo.add(items[i]);
    }
    combo.setBackground(new Color(parent.getDisplay(),255,255,255));
   
    combo.addSelectionListener(fComboBoxListener);
    fComboBoxes.put(combo,key);
   
    return combo;
  }
View Full Code Here

            false, false, 1, 1);
    gd_btnCommandSourceFile.widthHint = 258;
    btnCommandSourceFile.setLayoutData(gd_btnCommandSourceFile);
    btnCommandSourceFile.setText("Command Source File");

    final CCombo combo = new CCombo(grpSourceFileType, SWT.BORDER);
    combo.setItems(new String[] { "Empty Main Function", "Main Function with Parameters", "Simple Web Server" });
    combo.select(0);
    combo.setEnabled(false);
    combo.setEditable(false);

    GridData gd_combo = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
    gd_combo.widthHint = 231;
    combo.setLayoutData(gd_combo);
    combo.addSelectionListener(new SelectionListener() {
     
      @Override
      public void widgetSelected(SelectionEvent e) { eval();}
     
      @Override
      public void widgetDefaultSelected(SelectionEvent e) { eval();}
     
      public void eval() {
        switch (combo.getSelectionIndex()){
          case 0:
            sourceFileType = SourceFileType.MAIN_DEFAULT;
            return;
          case 1:
            sourceFileType = SourceFileType.MAIN_WITH_PARAMETERS;
            return;
          case 2:
            sourceFileType = SourceFileType.MAIN_WEBSERVER;
            return;
          }
      }
    });

    btnCommandSourceFile.addSelectionListener(new SelectionListener() {

      @Override
      public void widgetSelected(SelectionEvent e) {
        eval();
      }

      @Override
      public void widgetDefaultSelected(SelectionEvent e) {
        eval();
      }

      public void eval() {
        if (btnCommandSourceFile.getSelection()) {
          combo.setEnabled(true);
       
          switch (combo.getSelectionIndex()){
            case 0:
              sourceFileType = SourceFileType.MAIN_DEFAULT;
              break;
            case 1:
              sourceFileType = SourceFileType.MAIN_WITH_PARAMETERS;
              break;
            case 2:
              sourceFileType = SourceFileType.MAIN_WEBSERVER;
              break;
          }
         
          //Update the filename
          sourceFilename.setText(getNewFileName(sourceFilename.getText(), false));
        } else {
          combo.setEnabled(false);
        }
      }
    });

    final Button btnTestSourceFile = new Button(grpSourceFileType, SWT.RADIO);
View Full Code Here

    if (control instanceof Text) {
      Text text = (Text) control;
      text.setBackground(new Color(control.getDisplay(), ERROR_COLOR));
      text.setToolTipText(e.getMessage());
    } else if (control instanceof CCombo) {
      CCombo combo = (CCombo) control;
      combo.setBackground(new Color(control.getDisplay(), ERROR_COLOR));
      combo.setToolTipText(e.getMessage());
    } else if (control instanceof Composite) {
      Composite composite = (Composite) control;
      composite.setBackground(new Color(control.getDisplay(), ERROR_COLOR));
      for (final Control childControl : composite.getChildren()) {
        childControl.setBackground(new Color(control.getDisplay(), ERROR_COLOR));
View Full Code Here

TOP

Related Classes of org.eclipse.swt.custom.CCombo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.