Java Code Examples for org.eclipse.swt.widgets.Text#addModifyListener()

The following examples show how to use org.eclipse.swt.widgets.Text#addModifyListener() . 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: SamplePart.java    From codeexamples-eclipse with 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 2
Source File: CrosstabBindingDialogHelper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void createCommonSection( Composite composite )
{
	new Label( composite, SWT.NONE ).setText( EXPRESSION );
	txtExpression = new Text( composite, SWT.BORDER | SWT.MULTI );
	GridData gd = new GridData( GridData.FILL_HORIZONTAL );
	gd.horizontalSpan = 2;
	gd.heightHint = txtExpression.computeSize( SWT.DEFAULT, SWT.DEFAULT ).y
			- txtExpression.getBorderWidth( )
			* 2;
	txtExpression.setLayoutData( gd );
	createExpressionButton( composite, txtExpression );
	txtExpression.addModifyListener( new ModifyListener( ) {

		public void modifyText( ModifyEvent e )
		{
			modifyDialogContent( );
			validate( );
		}

	} );
}
 
Example 3
Source File: IssueAssetWizard.java    From offspring with MIT License 6 votes vote down vote up
@Override
public Control createControl(Composite parent) {
  Composite comp = new Composite(parent, SWT.NONE);
  GridLayoutFactory.fillDefaults().numColumns(1).applyTo(comp);

  textDescr = new Text(comp, SWT.BORDER | SWT.MULTI);
  GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
      .hint(SWT.DEFAULT, 100).applyTo(textDescr);

  textDescr.setText("");
  textDescr.addModifyListener(new ModifyListener() {

    @Override
    public void modifyText(ModifyEvent e) {
      requestVerification();
    }
  });
  return comp;
}
 
Example 4
Source File: SendMessageWizard.java    From offspring with MIT License 6 votes vote down vote up
@Override
public Control createControl(Composite parent) {
  textRecipient = new Text(parent, SWT.BORDER);
  textRecipient.setMessage("account number");
  if (accountId != null)
    textRecipient.setText(Convert.toUnsignedLong(accountId));
  else
    textRecipient.setText("");
  textRecipient.addModifyListener(new ModifyListener() {

    @Override
    public void modifyText(ModifyEvent e) {
      requestVerification();
    }
  });
  return textRecipient;
}
 
Example 5
Source File: FileStoreSelectDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createFilter(final Composite listComposite) {
    final Text fileStoreListFilter = new Text(listComposite,
            SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    fileStoreListFilter.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    fileStoreListFilter.setMessage(WorkbenchMessages.FilteredTree_FilterMessage);
    fileStoreListFilter.addModifyListener(new ModifyListener() {

        private ViewerFilter filter;

        @Override
        public void modifyText(final ModifyEvent e) {
            final String textForFiltering = fileStoreListFilter.getText();
            if (filter != null) {
                fileStoreListViewer.removeFilter(filter);
            }
            if (textForFiltering != null
                    && !textForFiltering.isEmpty()) {
                filter = new ViewerFilterOnFileStoreName(textForFiltering);
                fileStoreListViewer.addFilter(filter);
            }

        }
    });
}
 
Example 6
Source File: Expression.java    From Rel with Apache License 2.0 6 votes vote down vote up
@Override
protected void buildControlPanel(Composite container) {
	container.setLayout(new GridLayout(2, false));

	Label label = new Label(container, SWT.None);
	label.setText("Expression:");

	Text expression = new Text(container, SWT.None);
	expression.setText(operatorLabel.getText());
	expression.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	expression.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent e) {
			operatorLabel.setText(expression.getText());
			Expression.this.pack();
		}
	});
}
 
Example 7
Source File: CancelBuyOrderWizard.java    From offspring with MIT License 6 votes vote down vote up
@Override
public Control createControl(Composite parent) {
  Composite comp = new Composite(parent, SWT.NONE);
  GridLayoutFactory.fillDefaults().numColumns(1).applyTo(comp);

  textDescr = new Text(comp, SWT.BORDER | SWT.MULTI);
  GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
      .hint(SWT.DEFAULT, 100).applyTo(textDescr);

  textDescr.setText("");
  textDescr.addModifyListener(new ModifyListener() {

    @Override
    public void modifyText(ModifyEvent e) {
      requestVerification();
    }
  });
  return comp;
}
 
Example 8
Source File: TexlipseProjectPropertyPage.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create project main file section of the page.
 * @param parent parent component
 */
private void addOutSection(Composite parent) {
    Composite composite = createDefaultComposite(parent, 2);

    //Label for path field
    Label pathLabel = new Label(composite, SWT.NONE);
    pathLabel.setText(TexlipsePlugin.getResourceString("propertiesOutFileLabel"));
    pathLabel.setLayoutData(new GridData());
    pathLabel.setToolTipText(TexlipsePlugin.getResourceString("propertiesOutFileTooltip"));
    
    // Path text field
    outFileField = new Text(composite, SWT.SINGLE | SWT.WRAP | SWT.BORDER);
    outFileField.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
    outFileField.setToolTipText(TexlipsePlugin.getResourceString("propertiesOutFileTooltip"));
    outFileField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            validateOutputFileField();
        }});
}
 
Example 9
Source File: Dialog.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void activityRow(Composite body, FormToolkit tk) {
	String label = M.ActivityVariable;
	if (aspect.indicator.activityVariable != null)
		label += " (" + aspect.indicator.activityVariable + ")";
	Text t = UI.formText(body, tk, label);
	t.setText(Double.toString(aspect.activityValue));
	t.addModifyListener(e -> {
		try {
			double d = Double.parseDouble(t.getText());
			aspect.activityValue = d;
		} catch (Exception ex) {
		}
	});
	String unit = "";
	if (aspect.indicator.activityUnit != null)
		unit = aspect.indicator.activityUnit.name;
	UI.formLabel(body, tk, unit);
}
 
Example 10
Source File: CancelBuyOrderWizard.java    From offspring with MIT License 5 votes vote down vote up
@Override
public Control createControl(Composite parent) {
  textName = new Text(parent, SWT.BORDER);
  textName.setText("");
  textName.addModifyListener(new ModifyListener() {

    @Override
    public void modifyText(ModifyEvent e) {
      requestVerification();
    }
  });
  return textName;
}
 
Example 11
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected Text addTextField(Composite parent, String label, Key key, int indent, int widthHint) {
	Label labelControl= new Label(parent, SWT.WRAP);
	labelControl.setText(label);
	labelControl.setFont(JFaceResources.getDialogFont());
	GridData gd= new GridData();
	gd.horizontalIndent= indent;
	labelControl.setLayoutData(gd);

	Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE);
	textBox.setData(key);

	makeScrollableCompositeAware(textBox);

	fLabels.put(textBox, labelControl);

	updateText(textBox);
	
	textBox.addModifyListener(getTextModifyListener());

	GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	if (widthHint != 0) {
		data.widthHint= widthHint;
	}
	data.horizontalSpan= 2;
	textBox.setLayoutData(data);

	fTextBoxes.add(textBox);
	return textBox;
}
 
Example 12
Source File: Summarize.java    From Rel with Apache License 2.0 5 votes vote down vote up
private void addRow(Composite parent, Aggregate r) {
	Text as = new Text(parent, SWT.NONE);
	as.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	as.setText(r.getAs());
	as.addModifyListener(e -> r.setAs(as.getText()));

	new Label(parent, SWT.None);

	Combo aggOps = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);

	Text expression1 = new Text(parent, SWT.NONE);
	expression1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	expression1.setText(r.getExpression1());
	expression1.addModifyListener(e -> r.setExpression1(expression1.getText()));

	Text expression2 = new Text(parent, SWT.NONE);
	expression2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	expression2.setText(r.getExpression2());
	expression2.addModifyListener(e -> r.setExpression2(expression2.getText()));

	int index = 0;
	for (AggOp op : aggregateOperators) {
		aggOps.add(op.getName());
		if (op.getName().equals(r.getAggOpName())) {
			aggOps.select(index);
			setRowVisibility(index, expression1, expression2);
		}
		index++;
	}
	aggOps.addModifyListener(e -> {
		int selected = aggOps.getSelectionIndex();
		r.setAggOpName(aggOps.getText());
		setRowVisibility(selected, expression1, expression2);
	});
}
 
Example 13
Source File: AppEngineWizardPage.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private void createServiceField(Composite parent) {
  Label serviceNameLabel = new Label(parent, SWT.LEAD);
  serviceNameLabel.setText(Messages.getString("app.engine.service")); //$NON-NLS-1$
  serviceNameField = new Text(parent, SWT.BORDER);
  serviceNameField.setMessage("default"); //$NON-NLS-1$
  serviceNameField.addModifyListener(event -> revalidate());
}
 
Example 14
Source File: LabeledTextMapComponent.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Add a modify listener that triggers whenever a text within this component is modified.
 */
public void addModifyListener(ModifyListener listener) {
  textModifyListeners.add(listener);
  for (Text text : texts.values()) {
    text.addModifyListener(listener);
  }
}
 
Example 15
Source File: TextInputWizardPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
protected Text createTextInputField(Composite parent, int style) {
    fTextField = new Text(parent, style);
    fTextField.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            textModified(getText());
        }
    });
    fTextField.setText(fInitialValue);
    return fTextField;
}
 
Example 16
Source File: ExtractVariableWizard.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite composite= new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout(2, false);
	layout.verticalSpacing = 16;
	composite.setLayout(layout);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	composite.setFont(parent.getFont());

	Label label= new Label(composite, SWT.NONE);
	label.setText("Variable name:");
	label.setFont(composite.getFont());
	label.setLayoutData(new GridData());

	nameField= new Text(composite, SWT.BORDER);
	nameField.setText(refactoring.getVariableName());
	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();
	
	finalButton = new Button(composite, SWT.CHECK);
	finalButton.setText("Declare as final 'val'");
	finalButton.setFont(composite.getFont());
	finalButton.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 2, 1));
	finalButton.setSelection(refactoring.isFinal());
	setControl(composite);
	validatePage();
}
 
Example 17
Source File: HTMLFormatterIndentationTabPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void createOptions(IFormatterControlManager manager, Composite parent)
{
	Group group = SWTFactory.createGroup(parent,
			Messages.HTMLFormatterIndentationTabPage_indentationGeneralGroupLabel, 2, 1, GridData.FILL_HORIZONTAL);
	final Combo tabOptions = manager.createCombo(group, HTMLFormatterConstants.FORMATTER_TAB_CHAR,
			FormatterMessages.IndentationTabPage_general_group_option_tab_policy, tabOptionItems, tabOptionNames);
	final Text indentationSize = manager.createNumber(group, HTMLFormatterConstants.FORMATTER_INDENTATION_SIZE,
			FormatterMessages.IndentationTabPage_general_group_option_indent_size, 1);
	final Text tabSize = manager.createNumber(group, HTMLFormatterConstants.FORMATTER_TAB_SIZE,
			FormatterMessages.IndentationTabPage_general_group_option_tab_size, 1);
	tabSize.addModifyListener(new ModifyListener()
	{
		public void modifyText(ModifyEvent e)
		{
			int index = tabOptions.getSelectionIndex();
			if (index >= 0)
			{
				final boolean tabMode = CodeFormatterConstants.TAB.equals(tabOptionItems[index]);
				if (tabMode)
				{
					indentationSize.setText(tabSize.getText());
				}
			}
		}
	});
	new TabOptionHandler(manager, tabOptions, indentationSize, tabSize);

	group = SWTFactory.createGroup(parent, Messages.HTMLFormatterTabPage_exclusionsGroupLabel, 1, 1,
			GridData.FILL_BOTH);
	Label exclutionLabel = new Label(group, SWT.WRAP);
	exclutionLabel.setText(Messages.HTMLFormatterIndentationTabPage_exclusionsMessage);
	manager.createManagedList(group, HTMLFormatterConstants.INDENT_EXCLUDED_TAGS);
}
 
Example 18
Source File: HadoopLocationWizard.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/**
 * Create a SWT Text component for the given {@link ConfProp} text
 * configuration property.
 * 
 * @param listener
 * @param parent
 * @param prop
 * @return
 */
private Text createConfText(ModifyListener listener, Composite parent,
    ConfProp prop) {

  Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
  GridData data = new GridData(GridData.FILL_HORIZONTAL);
  text.setLayoutData(data);
  text.setData("hProp", prop);
  text.setText(location.getConfProp(prop));
  text.addModifyListener(listener);

  return text;
}
 
Example 19
Source File: GWTJUnitSettingsTab.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
protected void createGWTJUnitSettingsComponent(Composite parent) {
  Group group = SWTFactory.createGroup(parent, "GWT JUnit Settings", 2, 1,
      GridData.FILL_HORIZONTAL);

  SWTFactory.createLabel(group, "Log level:", 1);
  logLevelComboViewer = new ComboViewer(group, SWT.READ_ONLY);
  logLevelComboViewer.setContentProvider(new ArrayContentProvider());
  logLevelComboViewer.setLabelProvider(new DefaultComboLabelProvider());
  logLevelComboViewer.setInput(LogLevelArgumentProcessor.LOG_LEVELS);
  // logLevelComboViewer.setSelection(new StructuredSelection("DEBUG"));
  logLevelComboViewer.addSelectionChangedListener(settingChangedListener);

  SWTFactory.createLabel(group, "Output style:", 1);
  outputStyleComboViewer = new ComboViewer(group, SWT.READ_ONLY);
  outputStyleComboViewer.setContentProvider(new ArrayContentProvider());
  outputStyleComboViewer.setLabelProvider(new DefaultComboLabelProvider());
  outputStyleComboViewer.setInput(GWTLaunchConstants.OUTPUT_STYLES);
  // outputStyleComboViewer.setSelection(new StructuredSelection("PRETTY"));
  outputStyleComboViewer.addSelectionChangedListener(settingChangedListener);

  notHeadlessButton = SWTFactory.createCheckButton(group,
      "Display the log window and browser windows (useful for debugging)",
      null, true, 2);
  notHeadlessButton.addSelectionListener(settingChangedListener);

  webModeButton = SWTFactory.createCheckButton(group,
      "Run tests in production mode", null, false, 2);
  webModeButton.addSelectionListener(settingChangedListener);

  standardsModeButton = SWTFactory.createCheckButton(group,
      "Use standards mode", null, false, 2);
  standardsModeButton.addSelectionListener(settingChangedListener);
  GridData standardsModeButtonData = new GridData(SWT.BEGINNING,
      SWT.BEGINNING, false, false, 2, 1);
  standardsModeButton.setLayoutData(standardsModeButtonData);

  SWTFactory.createLabel(group, "Output directory:", 1);
  outputDirectoryField = new Text(group, SWT.BORDER);
  outputDirectoryField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  outputDirectoryField.addModifyListener(settingChangedListener);
}
 
Example 20
Source File: LabelTimeComposite.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public LabelTimeComposite( Composite composite, String labelText, String toolTipText ) {
  super( composite, SWT.NONE );
  props.setLook( this );

  int middle = props.getMiddlePct();
  int threeQuarters = ( middle + 100 ) / 2;
  int margin = Const.MARGIN;

  FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = 0;
  formLayout.marginHeight = 0;
  formLayout.marginTop = 0;
  formLayout.marginBottom = 0;

  this.setLayout( formLayout );

  wText = new Text( this, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
  FormData fdText = new FormData();
  fdText.left = new FormAttachment( middle, margin );
  fdText.right = new FormAttachment( threeQuarters, 0 );
  wText.setLayoutData( fdText );
  wText.setToolTipText( toolTipText );

  wTimeUnit = new CCombo( this, SWT.SINGLE | SWT.DROP_DOWN | SWT.BORDER | SWT.LEFT );
  FormData fdCombo = new FormData();
  fdCombo.left = new FormAttachment( threeQuarters, margin );
  fdCombo.right = new FormAttachment( 100, 0 );
  wTimeUnit.setEditable( false );
  wTimeUnit.setLayoutData( fdCombo );
  wTimeUnit.setItems( getTimeUnits() );
  wTimeUnit.setToolTipText( toolTipText );

  wLabel = new Label( this, SWT.RIGHT );
  props.setLook( wLabel );
  wLabel.setText( labelText );
  FormData fdLabel = new FormData();
  fdLabel.left = new FormAttachment( 0, 0 );
  fdLabel.right = new FormAttachment( middle, 0 );
  fdLabel.top = new FormAttachment( wText, 0, SWT.CENTER );
  wLabel.setLayoutData( fdLabel );
  wLabel.setToolTipText( toolTipText );

  wText.addModifyListener( new ModifyListener() {
    public void modifyText( ModifyEvent e ) {
      if ( !StringUtils.isNumeric( wText.getText() ) ) {
        wText.setText( lastValidValue );
      } else {
        lastValidValue = wText.getText();
      }
    }
  } );
}