org.eclipse.swt.widgets.Text#addKeyListener ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Text#addKeyListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Pydev   文件: AbstractPythonWizardPage.java
/**
 * @param topLevel
 */
protected void createNameSelect(Composite topLevel, boolean setFocus) {
    createNameLabel(topLevel);
    textName = new Text(topLevel, SWT.BORDER);
    textName.addKeyListener(this);
    setLayout(null, textName, null);
    if (initialTextName != null) {
        textName.setText(initialTextName);
    }
    if (setFocus) {
        setFocusOn(textName, "name");
        textName.setSelection(textName.getText().length());
    }

    //just create an empty to complete the line (that needs 3 items in the layout)
    Label label = new Label(topLevel, SWT.NONE);
    label.setText("");
}
 
源代码2 项目: birt   文件: TextEditorComposite.java
protected void createTextEdit( )
{
	txtValue = new Text( this, iStyle );
	GridData gd = new GridData( GridData.FILL_BOTH );
	txtValue.setLayoutData( gd );
	if ( valueType == TYPE_NUMBERIC )
	{
		txtValue.setToolTipText( Messages.getString( "TextEditorComposite.Tooltip.EnterDecimalOrFractionValue" ) ); //$NON-NLS-1$
	}
	else if ( valueType == TYPE_DATETIME )
	{
		txtValue.setToolTipText( "MM-dd-yyyy HH:mm:ss" ); //$NON-NLS-1$
	}
	txtValue.addModifyListener( this );
	txtValue.addFocusListener( this );
	txtValue.addKeyListener( this );
}
 
源代码3 项目: neoscada   文件: FilterFreeFormComposite.java
private void createComponents ()
{
    final FillLayout layout = new FillLayout ( SWT.VERTICAL );
    layout.marginHeight = 12;
    layout.marginWidth = 12;
    setLayout ( layout );

    final Text filterTextField = new Text ( this, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL );
    filterTextField.setText ( this.filter );
    filterTextField.addKeyListener ( new KeyAdapter () {
        @Override
        public void keyReleased ( final KeyEvent e )
        {
            verifyFilter ( filterTextField.getText () );
        }
    } );
}
 
源代码4 项目: jbt   文件: NodesSearcher.java
/**
 * Creates the search text field (Text).
 * 
 * @param parent
 *            the Composite where the text field is placed.
 * @return the text field.
 */
private Text createTextField(Composite parent) {
	final Text textField = new Text(parent, SWT.BORDER);

	textField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

	/* If "enter" is pressed, perform the search. */
	textField.addKeyListener(new KeyAdapter() {
		public void keyPressed(KeyEvent e) {
			if (e.keyCode == SWT.CR) {
				performSearch(textField.getText());
			}
		}
	});

	return textField;
}
 
源代码5 项目: translationstudio8   文件: TextCellEditor.java
protected Text createTextControl(Composite parent) {
	IStyle cellStyle = getCellStyle();
	final Text textControl = new Text(parent, HorizontalAlignmentEnum.getSWTStyle(cellStyle));
	textControl.setBackground(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
	textControl.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
	textControl.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT));
	
	textControl.addKeyListener(new KeyAdapter() {
		private final Color originalColor = textControl.getForeground();
		@Override
		public void keyReleased(KeyEvent e) {
			if (!validateCanonicalValue()) {
				textControl.setForeground(GUIHelper.COLOR_RED);
			} else {
				textControl.setForeground(originalColor);
			}
		};
	});
	
	return textControl;
}
 
源代码6 项目: tmxeditor8   文件: TextCellEditor.java
protected Text createTextControl(Composite parent) {
	IStyle cellStyle = getCellStyle();
	final Text textControl = new Text(parent, HorizontalAlignmentEnum.getSWTStyle(cellStyle));
	textControl.setBackground(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
	textControl.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
	textControl.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT));
	
	textControl.addKeyListener(new KeyAdapter() {
		private final Color originalColor = textControl.getForeground();
		@Override
		public void keyReleased(KeyEvent e) {
			if (!validateCanonicalValue()) {
				textControl.setForeground(GUIHelper.COLOR_RED);
			} else {
				textControl.setForeground(originalColor);
			}
		};
	});
	
	return textControl;
}
 
源代码7 项目: eclipse   文件: WorkspaceWizardPage.java
private void createTargetTextField() {
  target = new Text(container, SWT.BORDER);
  setAutoCompletion();
  target.addKeyListener(new KeyAdapter() {
    @Override
    public void keyReleased(KeyEvent ke) {
      if (ke.keyCode == '\r' && (ke.stateMask & SWT.SHIFT) != 0 && !target.getText().isEmpty()) {
        addTarget();
      }
    }
  });
  target.addModifyListener(e -> updateControls());
}
 
源代码8 项目: xtext-eclipse   文件: QuickOutlinePopup.java
protected Text createFilterText(Composite parent) {
	filterText = new Text(parent, SWT.NONE);
	Dialog.applyDialogFont(filterText);

	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	data.horizontalAlignment = GridData.FILL;
	data.verticalAlignment = GridData.CENTER;
	filterText.setLayoutData(data);

	filterText.addKeyListener(new KeyAdapter() {
		@Override
		public void keyPressed(KeyEvent e) {
			if (e.keyCode == 0x0D) // return
				gotoSelectedElement();
			if (e.keyCode == SWT.ARROW_DOWN)
				treeViewer.getTree().setFocus();
			if (e.keyCode == SWT.ARROW_UP)
				treeViewer.getTree().setFocus();
			if (e.character == 0x1B) // ESC
				dispose();
			if (e.keyCode == invokingKeystroke.getNaturalKey()
					&& e.stateMask == invokingKeystroke.getModifierKeys()) {
				changeOutlineMode();
				e.doit = false;
			}

		}
	});
	return filterText;
}
 
源代码9 项目: xds-ide   文件: RenameRefactoringPage.java
private void createTxtNewName(Composite composite) {
	txtNewName = new Text(composite, SWT.BORDER);
	txtNewName.setText(refactoringInfo.getSelectedIdentifier());
	txtNewName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	txtNewName.selectAll();
	txtNewName.addKeyListener( new KeyAdapter() {
		public void keyReleased( final KeyEvent e ) {
			refactoringInfo.setNewName( txtNewName.getText() );
			validate();
		}
	} );
}
 
源代码10 项目: EasyShell   文件: MenuDataDialog.java
private void createSearchField(Composite parent) {
    UtilsUI.createLabel(parent, Activator.getResourceString("easyshell.menu.editor.dialog.label.text.filter"), Activator.getResourceString("easyshell.menu.editor.dialog.label.tooltip.filter"));
    filter = new CommandDataFilter();
    searchText = new Text(parent, SWT.BORDER | SWT.SEARCH);
    searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    searchText.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent ke) {
          filter.setSearchText(searchText.getText());
          commandComboViewer.getViewer().refresh();
          commandComboViewer.getViewer().getCombo().select(0);
          commandComboViewer.setSelection(getFirstSelected());
        }
    });
    searchText.setToolTipText(Activator.getResourceString("easyshell.command.page.text.tooltip.search"));
}
 
源代码11 项目: gama   文件: GamlQuickOutlinePopup.java
@Override
protected Text createFilterText(final Composite parent) {
	final Text filterText = new Text(parent, SWT.SEARCH | SWT.ICON_SEARCH);
	filterText.setMessage("Search keyword");
	Dialog.applyDialogFont(filterText);

	final GridData data = new GridData(GridData.FILL_HORIZONTAL);
	data.horizontalAlignment = GridData.FILL;
	data.verticalAlignment = GridData.CENTER;
	filterText.setLayoutData(data);

	filterText.addKeyListener(new KeyAdapter() {
		@Override
		public void keyPressed(final KeyEvent e) {
			if (e.keyCode == 0x0D) {
				gotoSelectedElement();
			}
			if (e.keyCode == SWT.ARROW_DOWN) {
				getTreeViewer().getTree().setFocus();
			}
			if (e.keyCode == SWT.ARROW_UP) {
				getTreeViewer().getTree().setFocus();
			}
			if (e.character == 0x1B) {
				dispose();
			}
		}
	});
	return filterText;
}
 
源代码12 项目: APICloud-Studio   文件: FindBarDecorator.java
/**
 * Creates a combo (find, replace).
 */
private Text createText(String preferenceName)
{
	final Text text = new Text(findBar, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
	text.setLayoutData(createdDefaultGridData(SWT.FILL, SWT.FILL, true, true));

	entriesControlHandles.add(findBarEntriesHelper.register(text, modifyListener, preferenceName));

	text.addFocusListener(findBarActions.createFocusListener(text));
	text.addKeyListener(textKeyListner);
	return text;
}
 
/**
 * {@inheritDoc}
 */
@Override
protected Text createFilterText(Composite parent) {
	Text text= super.createFilterText(parent);
	text.addKeyListener(getKeyAdapter());
	return text;
}
 
源代码14 项目: hop   文件: TextVarButton.java
protected void initialize( IVariables variables, Composite composite, int flags, String toolTipText,
                           IGetCaretPosition getCaretPositionInterface, IInsertText insertTextInterface,
                           SelectionListener selectionListener ) {
  this.toolTipText = toolTipText;
  this.getCaretPositionInterface = getCaretPositionInterface;
  this.insertTextInterface = insertTextInterface;
  this.variables = variables;

  PropsUi.getInstance().setLook( this );

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

  Button button = new Button( this, SWT.PUSH );
  PropsUi.getInstance().setLook( button );
  button.setText( "..." );
  FormData fdButton = new FormData();
  fdButton.top = new FormAttachment( 0, 0 );
  fdButton.right = new FormAttachment( 100, 0 );
  fdButton.bottom = new FormAttachment( 100 );
  fdButton.width = 30;
  button.setLayoutData( fdButton );
  if ( selectionListener != null ) {
    button.addSelectionListener( selectionListener );
  }

  // Add the variable $ image on the top right of the control
  //
  Label wlImage = new Label( this, SWT.NONE );
  wlImage.setImage( GuiResource.getInstance().getImageVariable() );
  wlImage.setToolTipText( BaseMessages.getString( PKG, "TextVar.tooltip.InsertVariable" ) );
  FormData fdlImage = new FormData();
  fdlImage.top = new FormAttachment( 0, 0 );
  fdlImage.right = new FormAttachment( button, 0 );
  wlImage.setLayoutData( fdlImage );

  // add a text field on it...
  wText = new Text( this, flags );
  FormData fdText = new FormData();
  fdText.top = new FormAttachment( 0, 0 );
  fdText.left = new FormAttachment( 0, 0 );
  fdText.right = new FormAttachment( wlImage, 0 );
  fdText.bottom = new FormAttachment( 100, 0 );
  wText.setLayoutData( fdText );

  modifyListenerTooltipText = getModifyListenerTooltipText( wText );
  wText.addModifyListener( modifyListenerTooltipText );

  controlSpaceKeyAdapter =
    new ControlSpaceKeyAdapter( variables, wText, getCaretPositionInterface, insertTextInterface );
  wText.addKeyListener( controlSpaceKeyAdapter );

}
 
源代码15 项目: elexis-3-core   文件: ChangePasswordDialog.java
/**
 * Create contents of the dialog.
 * 
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
	setMessage(String.format("Passwort für User %s ändern", user.getId()));
	setTitle("Passwort ändern");
	Composite area = (Composite) super.createDialogArea(parent);
	Composite container = new Composite(area, SWT.NONE);
	container.setLayout(new GridLayout(2, false));
	container.setLayoutData(new GridData(GridData.FILL_BOTH));

	Label lblNewPassword = new Label(container, SWT.NONE);
	lblNewPassword.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	lblNewPassword.setText("Neues Passwort");

	txtPassword1 = new Text(container, SWT.BORDER | SWT.PASSWORD);
	txtPassword1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	txtPassword1.addKeyListener(pcl);

	Label lblConfirm = new Label(container, SWT.NONE);
	lblConfirm.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	lblConfirm.setText("Bestätigen");

	txtPassword2 = new Text(container, SWT.BORDER | SWT.PASSWORD);
	txtPassword2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	txtPassword2.addKeyListener(pcl);
	new Label(container, SWT.NONE);
	new Label(container, SWT.NONE);

	Label lblHint = new Label(container, SWT.NONE);
	lblHint.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
	lblHint.setText("Tipp");

	Label lblHintText = new Label(container, SWT.NONE);
	lblHintText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	lblHintText.setText(
			"Denken Sie sich einen kompletten Satz mit einer Zahl.\nVerwenden Sie nun die Anfangsbuchstaben jedes Wortes, \nunter Berücksichtigung der Groß/Kleinschreibung.\n\nEin Beispiel:\nDer Satz „Vor kurzem wurde ich 42 Jahre alt.“ wird zum\nPasswort „Vkwi42Ja“.");
	new Label(container, SWT.NONE);

	Button btnDisableRules = new Button(container, SWT.CHECK);
	btnDisableRules.setText("Prüfregeln ignorieren (nicht empfohlen)");
	btnDisableRules.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			rulesDisabled = btnDisableRules.getSelection();
			update();
		}
	});

	return area;
}
 
源代码16 项目: statecharts   文件: GeneratorComposite.java
public GeneratorComposite(Composite parent, int style,
		ValidateCallback callback) {
	super(parent, style);
	if (callback != null)
		this.callback = callback;
	else
		this.callback = ValidateCallback.NULL;

	Composite generatorCheckboxGroup = this;
	generatorCheckboxGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP,
			true, false, 1, 1));
	generatorCheckboxGroup.setLayout(new GridLayout(2, false));
	
	cbGenerator = new Button(generatorCheckboxGroup, SWT.CHECK);
	cbGenerator.setText("Configure for Plugin Export");
	cbGenerator.addSelectionListener(new SelectionAdapter() {

		public void widgetSelected(SelectionEvent e) {
			setGroupEnabled(cbGenerator.getSelection());
			GeneratorComposite.this.callback.validate();
		}
	});
	

	generatorGroup = new Group(parent, SWT.NONE);
	generatorGroup.setLayout(new GridLayout(2, false));
	generatorGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true,
			false, 1, 1));

	Label lblGeneratorId = new Label(generatorGroup, SWT.WRAP);
	lblGeneratorId.setText("Generator Id:");

	txtGeneratorId = new Text(generatorGroup, SWT.SINGLE | SWT.BORDER);
	txtGeneratorId.setText("custom::sctGenerator");
	txtGeneratorId.addKeyListener(textBoxListener);
	GridDataFactory.fillDefaults().grab(true, false)
			.applyTo(txtGeneratorId);

	Label lblGeneratorName = new Label(generatorGroup, SWT.WRAP);
	lblGeneratorName.setText("Generator name:");

	setTxtGeneratorName(new Text(generatorGroup, SWT.SINGLE | SWT.BORDER));
	getTxtGeneratorName().addKeyListener(textBoxListener);
	GridDataFactory.fillDefaults().grab(true, false)
			.applyTo(getTxtGeneratorName());

	lblGeneratorClass = new Label(generatorGroup, SWT.WRAP);
	lblGeneratorClass.setText("Generator class:");

	setTxtGeneratorClass(new Text(generatorGroup, SWT.SINGLE | SWT.BORDER));
	getTxtGeneratorClass().addKeyListener(textBoxListener);
	GridDataFactory.fillDefaults().grab(true, false)
			.applyTo(getTxtGeneratorClass());

	Label lblGeneratorDesc = new Label(generatorGroup, SWT.WRAP);
	lblGeneratorDesc.setText("Generator description:");

	setTxtGeneratorDesc(new Text(generatorGroup, SWT.SINGLE | SWT.BORDER));
	getTxtGeneratorDesc().addKeyListener(textBoxListener);
	GridDataFactory.fillDefaults().grab(true, false)
			.applyTo(getTxtGeneratorDesc());

	cbLibrary = new Button(generatorGroup, SWT.CHECK);
	cbLibrary.setText("Create Feature Library");
}
 
public void createControl(Composite container) {
	Composite parent = new Composite(container, SWT.NULL);
	setControl(parent);
	parent.setLayout(new GridLayout(1, false));

	Composite projectNameGroup = new Composite(parent, SWT.NULL);
	projectNameGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true,
			false, 1, 1));
	projectNameGroup.setLayout(new GridLayout(2, false));

	Label lblProjectName = new Label(projectNameGroup, SWT.WRAP);
	lblProjectName.setText("Project name:");
	txtProjectName = new Text(projectNameGroup, SWT.SINGLE | SWT.BORDER);
	txtProjectName.addKeyListener(textBoxListener);
	txtProjectName.addMouseListener(mouseListener);
	GridDataFactory.fillDefaults().grab(true, false)
			.applyTo(txtProjectName);

	Label lblGeneratorClass = new Label(projectNameGroup, SWT.WRAP);
	lblGeneratorClass.setText("Generator class:");

	txtGeneratorClass = new Text(projectNameGroup, SWT.SINGLE | SWT.BORDER);
	txtGeneratorClass.addKeyListener(textBoxListener);
	txtGeneratorClass.addMouseListener(mouseListener);
	GridDataFactory.fillDefaults().grab(true, false)
			.applyTo(txtGeneratorClass);

	Composite generatorCheckboxGroup = new Composite(parent, SWT.NULL);
	generatorCheckboxGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP,
			true, false, 1, 1));
	generatorCheckboxGroup.setLayout(new GridLayout(2, false));

	cbXtend = new Button(generatorCheckboxGroup, SWT.CHECK);
	cbXtend.setText("Use Xtend");

	ValidateCallback callback = new ValidateCallback() {
		public void validate() {
			WorkspaceGeneratorWizardPage1.this.validate();
		}
	};
	generatorComposite = new GeneratorComposite(parent, SWT.NONE, callback);
	generatorComposite.disableGeneratorClass();

	generatorComposite.setGroupEnabled(false);

	setPageComplete(false);
}
 
源代码18 项目: elexis-3-core   文件: ContactSelectorView.java
@Override
public void createPartControl(Composite parent){
	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new GridLayout(1, false));
	
	Composite compositeSearch = new Composite(composite, SWT.NONE);
	compositeSearch.setLayout(new GridLayout(1, false));
	compositeSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	txtFilter = new Text(compositeSearch, SWT.BORDER | SWT.SEARCH | SWT.CANCEL);
	txtFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	tableViewerContacts = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
	Table table = tableViewerContacts.getTable();
	table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	
	Composite compositeStatus = new Composite(composite, SWT.NONE);
	compositeStatus.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	compositeStatus.setLayout(new GridLayout(1, false));
	
	lblStatus = new Label(compositeStatus, SWT.NONE);
	lblStatus.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	tableViewerContacts.setComparator(new ContactSelectorViewerComparator(tableViewerContacts));
	filterAnzeigeTyp = new KontaktAnzeigeTypViewerFilter(tableViewerContacts);
	ViewerFilter[] filters = new ViewerFilter[] {
		filterAnzeigeTyp, filterPositionTitle
	};
	tableViewerContacts.setFilters(filters);
	
	int operations = DND.DROP_COPY | DND.DROP_MOVE;
	Transfer[] transferTypes = new Transfer[] {
		TextTransfer.getInstance()
	};
	tableViewerContacts.addDragSupport(operations, transferTypes,
		new ContactSelectorDragListener(tableViewerContacts));
	tableViewerContacts.addDropSupport(operations, transferTypes,
		new ContactSelectorDropListener(tableViewerContacts));
	
	txtFilter.addKeyListener(new FilterKeyListener(txtFilter, tableViewerContacts));
	txtFilter.addSelectionListener(new SelectionAdapter() {
		public void widgetDefaultSelected(SelectionEvent e){
			if (e.detail == SWT.CANCEL) {
				filterPositionTitle.setSearchText(null);
				tableViewerContacts.getControl().setRedraw(false);
				tableViewerContacts.refresh();
				tableViewerContacts.getControl().setRedraw(true);
			}
		}
	});
	
	initDataBindings();
	
	MenuManager menuManager = new MenuManager();
	menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
	tableViewerContacts.getTable().setMenu(
		menuManager.createContextMenu(tableViewerContacts.getTable()));
	
	getSite().registerContextMenu(menuManager, tableViewerContacts);
	getSite().setSelectionProvider(tableViewerContacts);
	
	contactList.getRealm().asyncExec(loadContactsRunnable);
	
	tableViewerContacts
		.addSelectionChangedListener(new ContactSelectionChangedToEventDispatcher());
	tableViewerContacts.addSelectionChangedListener(new ISelectionChangedListener() {
		
		@Override
		public void selectionChanged(SelectionChangedEvent event){
			StructuredSelection ss = (StructuredSelection) event.getSelection();
			tableViewerContacts.refresh(ss.getFirstElement());
		}
	});
}
 
源代码19 项目: pentaho-kettle   文件: TextVarButton.java
protected void initialize( VariableSpace space, Composite composite, int flags, String toolTipText,
    GetCaretPositionInterface getCaretPositionInterface, InsertTextInterface insertTextInterface,
    SelectionListener selectionListener ) {
  this.toolTipText = toolTipText;
  this.getCaretPositionInterface = getCaretPositionInterface;
  this.insertTextInterface = insertTextInterface;
  this.variables = space;

  PropsUI.getInstance().setLook( this );

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

  Button button = new Button( this, SWT.PUSH );
  PropsUI.getInstance().setLook( button );
  button.setText( "..." );
  FormData fdButton = new FormData();
  fdButton.top = new FormAttachment( 0, 0 );
  fdButton.right = new FormAttachment( 100, 0 );
  fdButton.height = 25;
  fdButton.width = 30;
  button.setLayoutData( fdButton );
  if ( selectionListener != null ) {
    button.addSelectionListener( selectionListener );
  }

  wText = new Text( this, flags );
  controlDecoration = new ControlDecoration( wText, SWT.CENTER | SWT.RIGHT, this );
  Image image = GUIResource.getInstance().getImageVariable();
  controlDecoration.setImage( image );
  controlDecoration.setDescriptionText( BaseMessages.getString( PKG, "TextVar.tooltip.InsertVariable" ) );
  PropsUI.getInstance().setLook( controlDecoration.getControl() );

  modifyListenerTooltipText = getModifyListenerTooltipText( wText );
  wText.addModifyListener( modifyListenerTooltipText );

  controlSpaceKeyAdapter =
      new ControlSpaceKeyAdapter( variables, wText, getCaretPositionInterface, insertTextInterface );
  wText.addKeyListener( controlSpaceKeyAdapter );

  FormData fdText = new FormData();
  fdText.top = new FormAttachment( 0, 0 );
  fdText.left = new FormAttachment( 0, 0 );
  fdText.right = new FormAttachment( button, -image.getBounds().width );
  wText.setLayoutData( fdText );
}
 
源代码20 项目: pentaho-kettle   文件: TextVar.java
protected void initialize( VariableSpace space, Composite composite, int flags, String toolTipText,
    GetCaretPositionInterface getCaretPositionInterface, InsertTextInterface insertTextInterface,
    SelectionListener selectionListener ) {

  this.toolTipText = toolTipText;
  this.getCaretPositionInterface = getCaretPositionInterface;
  this.insertTextInterface = insertTextInterface;
  this.variables = space;

  PropsUI.getInstance().setLook( this );

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

  this.setLayout( formLayout );

  // add a text field on it...
  wText = new Text( this, flags );
  controlDecoration = new ControlDecoration( wText, SWT.CENTER | SWT.RIGHT, this );
  Image image = GUIResource.getInstance().getImageVariable();
  controlDecoration.setImage( image );
  controlDecoration.setDescriptionText( BaseMessages.getString( PKG, "TextVar.tooltip.InsertVariable" ) );
  PropsUI.getInstance().setLook( controlDecoration.getControl() );

  modifyListenerTooltipText = getModifyListenerTooltipText( wText );
  wText.addModifyListener( modifyListenerTooltipText );

  controlSpaceKeyAdapter =
    new ControlSpaceKeyAdapter( variables, wText, getCaretPositionInterface, insertTextInterface );
  wText.addKeyListener( controlSpaceKeyAdapter );

  FormData fdText = new FormData();
  fdText.top = new FormAttachment( 0, 0 );
  fdText.left = new FormAttachment( 0, 0 );
  fdText.right = new FormAttachment( 100, -image.getBounds().width );
  fdText.bottom = new FormAttachment( 100, 0 );
  wText.setLayoutData( fdText );
}