Java Code Examples for org.eclipse.swt.events.ModifyEvent

The following examples show how to use org.eclipse.swt.events.ModifyEvent. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
protected Control createExternalRootContentArea(Composite parent) {

    Composite c = SWTFactory.createComposite(parent, 1, 1,
        GridData.FILL_HORIZONTAL);
    SWTFactory.createLabel(c, "External server root:", 1);
    externalUrlPrefixText = SWTFactory.createSingleText(c, 1);
    externalUrlPrefixTextCache = WebAppProjectProperties.getLaunchConfigExternalUrlPrefix(project);
    externalUrlPrefixText.setText(externalUrlPrefixTextCache);
    externalUrlPrefixText.addModifyListener(new ModifyListener() {
      public void modifyText(ModifyEvent e) {
        externalUrlPrefixTextCache = externalUrlPrefixText.getText();
        updateUrlLabelText();
      }
    });

    return c;
  }
 
Example 2
Source Project: statecharts   Source File: StyledTextCellEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Processes a modify event that occurred in this text cell editor. This
 * framework method performs validation and sets the error message
 * accordingly, and then reports a change via
 * <code>fireEditorValueChanged</code>. Subclasses should call this method
 * at appropriate times. Subclasses may extend or reimplement.
 * 
 * @param e
 *            the SWT modify event
 */
protected void editOccured(ModifyEvent e) {
	String value = text.getText();
	if (value == null) {
		value = "";//$NON-NLS-1$
	}
	Object typedValue = value;
	boolean oldValidState = isValueValid();
	boolean newValidState = isCorrect(typedValue);
	if (!newValidState) {
		// try to insert the current value into the error message.
		setErrorMessage(MessageFormat.format(getErrorMessage(),
				new Object[] { value }));
	}
	valueChanged(oldValidState, newValidState);
}
 
Example 3
private Text createCWTimeoutEntry(Composite comp, String label, String prefKey) {
    Label timeoutLabel = new Label(comp, SWT.NONE);
    timeoutLabel.setText(label);
    timeoutLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, false, false));
    
    Text text = new Text(comp, SWT.BORDER);
    text.setText(Integer.toString(prefs.getInt(prefKey)));
    GridData data = new GridData(GridData.BEGINNING, GridData.FILL, false, false);
	data.widthHint = 50;
	text.setLayoutData(data);
	
	text.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent arg0) {
			validate();
		}
	});
	
    return text;
}
 
Example 4
Source Project: hadoop-gpu   Source File: HadoopLocationWizard.java    License: Apache License 2.0 6 votes vote down vote up
public void modifyText(ModifyEvent e) {
  final Text text = (Text) e.widget;
  Object hProp = text.getData("hProp");
  final ConfProp prop = (hProp != null) ? (ConfProp) hProp : null;
  Object hPropName = text.getData("hPropName");
  final String propName =
      (hPropName != null) ? (String) hPropName : null;

  Display.getDefault().syncExec(new Runnable() {
    public void run() {
      if (prop != null)
        mediator.notifyChange(TabAdvanced.this, prop, text.getText());
      else
        mediator
            .notifyChange(TabAdvanced.this, propName, text.getText());
    }
  });
}
 
Example 5
Source Project: birt   Source File: CTextCellEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Processes a modify event that occurred in this text cell editor. This
 * framework method performs validation and sets the error message
 * accordingly, and then reports a change via
 * <code>fireEditorValueChanged</code>. Subclasses should call this method
 * at appropriate times. Subclasses may extend or reimplement.
 * 
 * @param e
 *            the SWT modify event
 */
protected void editOccured( ModifyEvent e )
{
	String value = text.getText( );
	if ( value.equals( "" ) )
	{
		value = null;//$NON-NLS-1$
	}
	Object typedValue = value;
	boolean oldValidState = isValueValid( );
	boolean newValidState = isCorrect( typedValue );

	if ( !newValidState )
	{
		// try to insert the current value into the error message.
		setErrorMessage( MessageFormat.format( getErrorMessage( ),
				new Object[]{
					value
				} ) );
	}
	valueChanged( oldValidState, newValidState );
}
 
Example 6
Source Project: nebula   Source File: RichTextCellEditor.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Processes a modify event that occurred in this rich text cell editor. This framework method
 * performs validation and sets the error message accordingly, and then reports a change via
 * <code>fireEditorValueChanged</code>. Subclasses should call this method at appropriate times.
 * Subclasses may extend or reimplement.
 *
 * @param e
 *            the SWT modify event
 *
 * @see TextCellEditor
 */
protected void editOccured(ModifyEvent e) {
	String value = this.editor.getText();
	if (value == null) {
		value = "";//$NON-NLS-1$
	}
	Object typedValue = value;
	boolean oldValidState = isValueValid();
	boolean newValidState = isCorrect(typedValue);
	if (!newValidState) {
		// try to insert the current value into the error message.
		setErrorMessage(MessageFormat.format(getErrorMessage(),
				new Object[] { value }));
	}
	valueChanged(oldValidState, newValidState);
}
 
Example 7
/**
 * Creates or returns the created text control.
 * @param parent The parent composite or <code>null</code> when the widget has
 * already been created.
 * @return the text control
 */
public Text getTextControl(Composite parent) {
	if (fTextControl == null) {
		assertCompositeNotNull(parent);
		fModifyListener= new ModifyListener() {
			public void modifyText(ModifyEvent e) {
				doModifyText();
			}
		};

		fTextControl= createTextControl(parent);
		// moved up due to 1GEUNW2
		fTextControl.setText(fText);
		fTextControl.setFont(parent.getFont());
		fTextControl.addModifyListener(fModifyListener);

		fTextControl.setEnabled(isEnabled());
		if (fContentAssistProcessor != null) {
		    ControlContentAssistHelper.createTextContentAssistant(fTextControl, fContentAssistProcessor);
		}
	}
	return fTextControl;
}
 
Example 8
Source Project: codeexamples-eclipse   Source File: SamplePart.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@PostConstruct
public void createComposite(Composite parent) {
	parent.setLayout(new GridLayout(1, false));

	txtInput = new Text(parent, SWT.BORDER);
	txtInput.setMessage("Enter text to mark part as dirty");
	txtInput.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent e) {
			dirty.setDirty(true);
		}
	});
	txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	tableViewer = new TableViewer(parent);

	tableViewer.add("Sample item 1");
	tableViewer.add("Sample item 2");
	tableViewer.add("Sample item 3");
	tableViewer.add("Sample item 4");
	tableViewer.add("Sample item 5");
	tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
}
 
Example 9
Source Project: pentaho-kettle   Source File: JobEntryBaseDialog.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void modifyText( ModifyEvent modifyEvent ) {
  ExecutorService executorService = ExecutorUtil.getExecutor();
  final String runConfiguration = jobMeta.environmentSubstitute( wRunConfiguration.getText() );
  executorService.submit( () -> {
    List<Object> items = Arrays.asList( runConfiguration, false );
    try {
      ExtensionPointHandler.callExtensionPoint( Spoon.getInstance().getLog(), KettleExtensionPoint
              .RunConfigurationSelection.id, items );
    } catch ( KettleException ignored ) {
      // Ignore errors
    }
    display.asyncExec( () -> {
      if ( (Boolean) items.get( IS_PENTAHO ) ) {
        wWaitingToFinish.setSelection( false );
        wWaitingToFinish.setEnabled( false );
      } else {
        wWaitingToFinish.setEnabled( true );
      }
    } );
  } );
}
 
Example 10
/**
 * Create contents of the dialog.
 *
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
  Composite comp = (Composite) super.createDialogArea(parent);
  ((GridLayout) comp.getLayout()).numColumns = 2;

  Label nameLabel = new Label(comp, SWT.NONE);
  nameLabel.setText("Variable &name:");
  GridData gd_nameLabel = new GridData();
  gd_nameLabel.horizontalAlignment = SWT.LEFT;
  nameLabel.setLayoutData(gd_nameLabel);

  variableName = new Text(comp, SWT.BORDER);
  // disable OK button if variable name is empty..
  variableName.addModifyListener(new ModifyListener() {
    public void modifyText(ModifyEvent e) {
      final boolean enable = ((Text) e.widget).getText().trim().length() > 0;
      final Button button = getButton(IDialogConstants.OK_ID);
      button.setEnabled(enable);
    }
  });
  variableName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

  return comp;
}
 
Example 11
Source Project: pentaho-kettle   Source File: TextVar.java    License: Apache License 2.0 6 votes vote down vote up
protected ModifyListener getModifyListenerTooltipText( final Text textField ) {
  return new ModifyListener() {
    public void modifyText( ModifyEvent e ) {
      if ( textField.getEchoChar() == '\0' ) { // Can't show passwords ;-)

        String tip = textField.getText();
        if ( !Utils.isEmpty( tip ) && !Utils.isEmpty( toolTipText ) ) {
          tip += Const.CR + Const.CR + toolTipText;
        }

        if ( Utils.isEmpty( tip ) ) {
          tip = toolTipText;
        }
        textField.setToolTipText( variables.environmentSubstitute( tip ) );
      }
    }
  };
}
 
Example 12
Source Project: codeexamples-eclipse   Source File: SamplePart.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@PostConstruct
public void createComposite(Composite parent) {
	parent.setLayout(new GridLayout(1, false));

	txtInput = new Text(parent, SWT.BORDER);
	txtInput.setMessage("Enter text to mark part as dirty");
	txtInput.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent e) {
			dirty.setDirty(true);
		}
	});
	txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	tableViewer = new TableViewer(parent);

	tableViewer.setContentProvider(ArrayContentProvider.getInstance());;
	tableViewer.setInput(createInitialDataModel());
	tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
}
 
Example 13
private void createParameterNameInput(Group group) {
	Label l= new Label(group, SWT.NONE);
	l.setText(RefactoringMessages.IntroduceParameterObjectWizard_parameterfield_label);
	final Text text= new Text(group, SWT.BORDER);
	text.setText(fProcessor.getParameterName());
	text.addModifyListener(new ModifyListener() {

		public void modifyText(ModifyEvent e) {
			fProcessor.setParameterName(text.getText());
			updateSignaturePreview();
			validateRefactoring();
		}

	});
	text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
 
Example 14
private void createNameArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = 0;
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.numColumns = 2;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
composite.setFont(parent.getFont());

Label label = new Label(composite, SWT.NONE);
label.setText(Policy.bind("CommitSetDialog_0")); 
label.setLayoutData(new GridData(GridData.BEGINNING));

nameText = new Text(composite, SWT.BORDER);
nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      nameText.addModifyListener(new ModifyListener() {
          public void modifyText(ModifyEvent e) {
              updateEnablements();
          }
      });
  }
 
Example 15
Source Project: xtext-eclipse   Source File: RenameElementWizard.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new GridLayout(2, false));
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	composite.setFont(parent.getFont());
	Label label = new Label(composite, SWT.NONE);
	label.setText("New name:");//$NON-NLS-1$
	label.setLayoutData(new GridData());
	nameField = new Text(composite, SWT.BORDER);

	nameField.setText(currentName);
	nameField.setFont(composite.getFont());
	nameField.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
	nameField.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent e) {
			validatePage();
		}
	});
	nameField.selectAll();
	validatePage();
	setControl(composite);
}
 
Example 16
/**
 * Create project main file section of the page.
 * @param parent parent component
 */
private void addMainSection(Composite parent) {
    Composite composite = createDefaultComposite(parent, 2);

    //Label for path field
    Label pathLabel = new Label(composite, SWT.NONE);
    pathLabel.setText(TexlipsePlugin.getResourceString("propertiesMainFileLabel"));
    pathLabel.setLayoutData(new GridData());
    pathLabel.setToolTipText(TexlipsePlugin.getResourceString("propertiesMainFileTooltip"));
    
    // Path text field
    sourceFileField = new Text(composite, SWT.SINGLE | SWT.WRAP | SWT.BORDER);
    sourceFileField.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
    sourceFileField.setToolTipText(TexlipsePlugin.getResourceString("propertiesMainFileTooltip"));
    sourceFileField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            validateSourceFileField();
        }});
}
 
Example 17
/**
 * Create the temp dir section of the page.
 * @param parent parent component
 */
private void addTempDirSection(Composite parent) {
    Composite composite = createDefaultComposite(parent, 3);

    //Label for path field
    Label label = new Label(composite, SWT.NONE);
    label.setText(TexlipsePlugin.getResourceString("propertiesTempDirLabel"));
    label.setLayoutData(new GridData());
    label.setToolTipText(TexlipsePlugin.getResourceString("propertiesTempDirTooltip"));

    // Path text field
    tempDirField = new Text(composite, SWT.SINGLE | SWT.WRAP | SWT.BORDER);
    tempDirField.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
    tempDirField.setToolTipText(TexlipsePlugin.getResourceString("propertiesTempDirTooltip"));
    tempDirField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            validateTempFileField();}});
}
 
Example 18
/**
 * Create the bibRef dir section of the page.
 * @param parent parent component
 */
private void addBibRefDirSection(Composite parent) {
    Composite composite = createDefaultComposite(parent, 3);

    //Label for path field
    Label label = new Label(composite, SWT.NONE);
    label.setText(TexlipsePlugin.getResourceString("propertiesBibRefDirLabel"));
    label.setLayoutData(new GridData());
    label.setToolTipText(TexlipsePlugin.getResourceString("propertiesBibRefDirTooltip"));

    // Path text field
    bibRefDirField = new Text(composite, SWT.SINGLE | SWT.WRAP | SWT.BORDER);
    bibRefDirField.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
    bibRefDirField.setToolTipText(TexlipsePlugin.getResourceString("propertiesBibRefDirTooltip"));
    bibRefDirField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            validateBibRefFileField();}});
}
 
Example 19
Source Project: birt   Source File: DataSetParametersPage.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void createNameCell( Composite parent, String lable )
{
	ControlProvider.createLabel( parent, lable );

	dataSetParamName = ControlProvider.createText( parent,
			structureHandle.getName( ) );
	dataSetParamName.setLayoutData( ControlProvider.getGridDataWithHSpan( 2 ) );
	dataSetParamName.addModifyListener( new ModifyListener( ) {

		public void modifyText( ModifyEvent e )
		{
			validateSyntax( );
		}

	} );
}
 
Example 20
private void createFilterBox() {
	//TODO: Directly use the hint flags once Bug 293230 is fixed
	FilterTextControl filterTextControl= new FilterTextControl(fParentComposite);

	final Text filterBox= filterTextControl.getFilterControl();
	filterBox.setMessage(PreferencesMessages.OptionsConfigurationBlock_TypeFilterText);
	
	filterBox.addModifyListener(new ModifyListener() {
		private String fPrevFilterText;

		public void modifyText(ModifyEvent e) {
			String input= filterBox.getText();
			if (input != null && input.equalsIgnoreCase(fPrevFilterText))
				return;
			fPrevFilterText= input;
			doFilter(input);
		}
	});
}
 
Example 21
Source Project: uima-uimaj   Source File: TypeCombo.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Instantiates a new type combo.
 *
 * @param parent the parent
 */
public TypeCombo(Composite parent) {
  super(parent, SWT.NONE);

  setLayout(new FillLayout());

  typeCombo = new Combo(this, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
  
  typeCombo.addModifyListener(new ModifyListener() {
    @Override
    public void modifyText(ModifyEvent e) {
      Type newType = getType();

      for (ITypePaneListener listener : listeners) {
        listener.typeChanged(newType);
      }
    }
  });
}
 
Example 22
Source Project: sarl   Source File: SARLArgumentsTab.java    License: Apache License 2.0 5 votes vote down vote up
private void createSREArgsText(Group group, Font font) {
	this.sreArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
	this.sreArgumentsText.addTraverseListener(new TraverseListener() {
		@Override
		public void keyTraversed(TraverseEvent event) {
			switch (event.detail) {
			case SWT.TRAVERSE_ESCAPE:
			case SWT.TRAVERSE_PAGE_NEXT:
			case SWT.TRAVERSE_PAGE_PREVIOUS:
				event.doit = true;
				break;
			case SWT.TRAVERSE_RETURN:
			case SWT.TRAVERSE_TAB_NEXT:
			case SWT.TRAVERSE_TAB_PREVIOUS:
				if ((SARLArgumentsTab.this.sreArgumentsText.getStyle() & SWT.SINGLE) != 0) {
					event.doit = true;
				} else {
					if (!SARLArgumentsTab.this.sreArgumentsText.isEnabled() || (event.stateMask & SWT.MODIFIER_MASK) != 0) {
						event.doit = true;
					}
				}
				break;
			default:
			}
		}
	});
	final GridData gd = new GridData(GridData.FILL_BOTH);
	gd.heightHint = HEIGHT_HINT;
	gd.widthHint = WIDTH_HINT;
	this.sreArgumentsText.setLayoutData(gd);
	this.sreArgumentsText.setFont(font);
	this.sreArgumentsText.addModifyListener(new ModifyListener() {
		@SuppressWarnings("synthetic-access")
		@Override
		public void modifyText(ModifyEvent evt) {
			scheduleUpdateJob();
		}
	});
	ControlAccessibleListener.addListener(this.sreArgumentsText, group.getText());
}
 
Example 23
Source Project: e4Preferences   Source File: SamplePart.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@PostConstruct
public void createComposite(Composite parent, @Preference(value = "prefColor") String colorKey)
{
	parent.setLayout(new GridLayout(1, false));

	txtInput = new Text(parent, SWT.BORDER);
	txtInput.setMessage("Enter text to mark part as dirty");
	txtInput.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent e)
		{
			dirty.setDirty(true);
		}
	});
	txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	tableViewer = new TableViewer(parent);

	tableViewer.add("Sample item 1");
	tableViewer.add("Sample item 2");
	tableViewer.add("Sample item 3");
	tableViewer.add("Sample item 4");
	tableViewer.add("Sample item 5");
	tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
	
	reactOnPrefColorChange(colorKey);
}
 
Example 24
Source Project: offspring   Source File: SendMoneyWizard.java    License: MIT License 5 votes vote down vote up
@Override
public Control createControl(Composite parent) {
  textAmount = new Text(parent, SWT.BORDER);
  textAmount.setText("0");
  textAmount.addModifyListener(new ModifyListener() {

    @Override
    public void modifyText(ModifyEvent e) {
      requestVerification();
    }
  });
  return textAmount;
}
 
Example 25
/**
    * creates the following controls (sample)
    * File Format : [{added_flag}{dirty_flag}{name} {revision}  {date}  {author}]  [Add Variables]
    * Example : [                           ]
    * supportedBindings is a map of {key : description} (ex : {"name","name of the resource being decorated"})
    * @returns the text control for the format and the text control for the example         
    */
protected TextPair createFormatEditorControl(
       Composite composite, 
       String title, 
       String buttonText, 
       final Map supportedBindings) {
       
       createLabel(composite, title, 1);
	
       Text format = new Text(composite, SWT.BORDER);
	format.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	format.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {				
			updateExamples();
		}
	});
	Button b = new Button(composite, SWT.NONE);
	b.setText(buttonText);
	GridData data = new GridData();
	data.horizontalAlignment = GridData.FILL;
	int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	data.widthHint = Math.max(widthHint, b.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
	b.setLayoutData(data);
	final Text formatToInsert = format;
	b.addListener(SWT.Selection, new Listener() {
		public void handleEvent (Event event) {
			addVariables(formatToInsert, supportedBindings);
		}			
	});
	
	return new TextPair(format, null);
}
 
Example 26
Source Project: depan   Source File: NewEdgeMatcherPage.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Composite createOptionsControl(Composite container) {
  Group result = new Group(container, SWT.NONE);
  result.setText("Edge Matcher Options");

  GridLayout grid = new GridLayout();
  grid.numColumns = 2;
  grid.verticalSpacing = 9;
  result.setLayout(grid);

  GridData fillHorz = new GridData(SWT.FILL, SWT.BEGINNING, true, false);

  // Row 1) Container selection
  Label label = new Label(result, SWT.NULL);
  label.setText("&Name:");

  nameText = new Text(result, SWT.BORDER | SWT.SINGLE);
  nameText.setLayoutData(fillHorz);
  nameText.addModifyListener(new ModifyListener() {

    @Override
    public void modifyText(ModifyEvent e) {
      updatePageStatus();
    }
  });

  return result;
}
 
Example 27
Source Project: nebula   Source File: CalculatorComboSnippet.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setLayout(new GridLayout(2, false));

	final Label label = new Label(shell, SWT.NONE);
	label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
	label.setText("Calculator combo:");

	final CalculatorCombo combo = new CalculatorCombo(shell, SWT.NONE);
	combo.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false));

	combo.addModifyListener(new ModifyListener() {

		@Override
		public void modifyText(final ModifyEvent e) {
			System.out.println("New value is " + combo.getValue());

		}
	});

	shell.pack();
	shell.open();

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();
}
 
Example 28
Source Project: birt   Source File: ExpressionEditor.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected Control createDialogArea( Composite parent )
{
	Composite composite = (Composite) super.createDialogArea( parent );

	Composite container = new Composite( composite, SWT.NONE );
	GridLayout layout = new GridLayout( );
	layout.numColumns = 3;
	layout.verticalSpacing = 10;
	container.setLayout( layout );

	new Label( container, SWT.NONE ).setText( Messages.getString( "ExpressionEditor.Label.Expression" ) ); //$NON-NLS-1$
	exprText = new Text( container, SWT.BORDER | SWT.MULTI );
	GridData gd = new GridData( );
	gd.widthHint = 200;
	gd.heightHint = exprText.computeSize( SWT.DEFAULT, SWT.DEFAULT ).y
			- exprText.getBorderWidth( )
			* 2;
	exprText.setLayoutData( gd );
	exprText.addModifyListener( new ModifyListener( ) {

		public void modifyText( ModifyEvent e )
		{
			checkStatus( );
		}

	} );

	ExpressionButtonUtil.createExpressionButton( container,
			exprText,
			provider,
			contextObject,
			allowConstant,
			SWT.PUSH );

	ExpressionButtonUtil.initExpressionButtonControl( exprText, expression );

	UIUtil.bindHelp( parent, IHelpContextIds.EXPRESSION_EDITOR_ID );

	return composite;
}
 
Example 29
Source Project: birt   Source File: CComboAssistField.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected void initModifyListener( )
{
	( (CCombo) control ).addModifyListener( new ModifyListener( ) {

		public void modifyText( ModifyEvent event )
		{
			FieldAssistHelper.getInstance( )
					.handleFieldModify( CComboAssistField.this );
		}
	} );
}
 
Example 30
Source Project: arx   Source File: DialogComboSelection.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
    // create composite
    Composite composite = (Composite) super.createDialogArea(parent);
    // create message
    if (message != null) {
        Label label = new Label(composite, SWT.WRAP);
        label.setText(message);
        GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL |
                                     GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
        data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        label.setLayoutData(data);
        label.setFont(parent.getFont());
    }
    combo = new Combo(composite, SWT.NONE);
    combo.setItems(choices);
    combo.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    combo.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });
    errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.WRAP);
    errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    // Set the error message text
    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292
    setErrorMessage(errorMessage);

    applyDialogFont(composite);
    return composite;
}