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

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

public static final SelectionAdapter getSelectionAdapter( final Shell shell, final Text destination ) {
  // Listen to the Browse... button
  return new SelectionAdapter() {
    public void widgetSelected( SelectionEvent e ) {
      DirectoryDialog dialog = new DirectoryDialog( shell, SWT.OPEN );
      if ( destination.getText() != null ) {
        String fpath = destination.getText();
        // String fpath = StringUtil.environmentSubstitute(destination.getText());
        dialog.setFilterPath( fpath );
      }

      if ( dialog.open() != null ) {
        String str = dialog.getFilterPath();
        destination.setText( str );
      }
    }
  };
}
 
源代码2 项目: Pydev   文件: PyEditorHoverConfigurationBlock.java
private void handleModifierModified(Text source) {
    int i = fHoverTable.getSelectionIndex();
    PyEditorTextHoverDescriptor hover = null;
    Text editor = source;
    if (source == fCombiningHoverModifierEditor) {
        hover = PydevPlugin.getCombiningHoverDescriptor();
    } else {
        if (i < 0) {
            return;
        }
        hover = fHoverDescs[i];
    }

    String modifiers = editor.getText();
    hover.fModifierString = modifiers;
    hover.fStateMask = PyEditorTextHoverDescriptor.computeStateMask(modifiers);

    // update table
    if (!fHoverTableViewer.isCellEditorActive() && i >= 0) {
        fHoverTableViewer.refresh(fHoverDescs[i]);
    }

    updateStatus(hover);
}
 
源代码3 项目: tracecompass   文件: AbstractSelectTreeViewer.java
/**
 * Save the checked entries' ID in the view context before changing trace and
 * check them again in the new tree.
 */
private void saveViewContext() {
    ITmfTrace previousTrace = getTrace();
    if (previousTrace != null) {
        Object[] checkedElements = fCheckboxTree.getCheckedElements();
        Set<Long> ids = new HashSet<>();
        for (Object checkedElement : checkedElements) {
            if (checkedElement instanceof TmfGenericTreeEntry) {
                ids.add(((TmfGenericTreeEntry) checkedElement).getModel().getId());
            }
        }
        Text filterControl = fCheckboxTree.getFilterControl();
        String filterString = filterControl != null ? filterControl.getText() : null;
        TmfTraceManager.getInstance().updateTraceContext(previousTrace,
                builder -> builder.setData(getDataContextId(CHECKED_ELEMENTS), ids)
                .setData(getDataContextId(FILTER_STRING), filterString));
    }
}
 
源代码4 项目: birt   文件: ResourceConfigurationBlock.java
protected void textChanged( Text textControl )
{
	Key key = (Key) textControl.getData( );
	String path = textControl.getText( );

	if ( path != null && textControl == resourceText )
	{
		if ( path.startsWith( DEFAULT_RESOURCE_FOLDER_DISPLAY ) )
		{
			path = path.replaceFirst( DEFAULT_RESOURCE_FOLDER_DISPLAY,
					PREF_RESOURCE.getDefaultValue( fPref ) );
		}
	}

	String oldValue = setValue( key, path );

	validateSettings( key, oldValue, path );
}
 
源代码5 项目: birt   文件: WizardCSSSettingPage.java
private static boolean isTextEmpty( Text text )
{
	String s = text.getText( );
	if ( ( s != null ) && ( s.trim( ).length( ) > 0 ) )
		return false;
	return true;
}
 
源代码6 项目: elexis-3-core   文件: ScriptView.java
@Override
protected void okPressed(){
	StringBuilder sb = new StringBuilder();
	for (Text text : inputs) {
		String varname = (String) text.getData("varname");
		String varcontents = text.getText();
		sb.append(varname).append("=").append(varcontents).append(",");
	}
	sb.deleteCharAt(sb.length() - 1);
	result = sb.toString();
	super.okPressed();
}
 
源代码7 项目: Pydev   文件: GlobalsTwoPanelElementSelector2.java
public InfoFilter() {
    super();
    //We have to get the actual text from the control, because the
    Text pattern = (Text) getPatternControl();
    String stringPattern = ""; //$NON-NLS-1$
    if (pattern != null && !pattern.getText().equals("*")) { //$NON-NLS-1$
        stringPattern = pattern.getText();
    }
    this.initialPattern = stringPattern;
}
 
源代码8 项目: olca-app   文件: DataBinding.java
private void setStringValue(Object bean, String property, Text text) {
	log.trace("Change value {} @ {}", property, bean);
	String val = text.getText();
	try {
		Bean.setValue(bean, property, val);
	} catch (Exception e) {
		error("Cannot set bean value", e);
	}
}
 
源代码9 项目: tracecompass   文件: ViewFilterDialog.java
private void handleEnterPressed(Composite parent, Composite labels, Text filterText) {
    String currentRegex = filterText.getText();
    if (currentRegex.isEmpty() || fFilterRegexes.size() == MAX_FILTER_REGEX_SIZE || fFilterRegexes.contains(currentRegex)) {
        filterText.setBackground(fColorScheme.getColor(TimeGraphColorScheme.TOOL_BACKGROUND));
        return;
    }
    boolean added = fFilterRegexes.add(currentRegex);
    if (added) {
        filterText.setText(EMPTY_STRING);
        fRegex = EMPTY_STRING;

        createCLabels(parent, labels, currentRegex);
    }
}
 
源代码10 项目: statecharts   文件: StatechartDefinitionSection.java
protected void createNameLabel(Composite labelComposite) {
	nameLabel = new Text(labelComposite, SWT.SINGLE | SWT.NORMAL);
	GridDataFactory.fillDefaults().indent(5, 1).grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(nameLabel);
	Optional<String> name = getStatechartName();
	if (name.isPresent()) {
		nameLabel.setText(name.get());
	}
	nameLabel.setEditable(isStatechart());
	nameLabel.setBackground(ColorConstants.white);
	nameModificationListener = new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent e) {
			Optional<Statechart> sct = getStatechart();
			if (sct.isPresent()) {
				if (Objects.equals(sct.get().getName(), nameLabel.getText())) {
					return;
				}
				getSash().setRedraw(false);
				TransactionalEditingDomain domain = getTransactionalEditingDomain();
				SetCommand command = new SetCommand(domain, sct.get(),
						BasePackage.Literals.NAMED_ELEMENT__NAME, nameLabel.getText());
				domain.getCommandStack().execute(command);
				refresh(nameLabel.getParent());
				getSash().setRedraw(true);
			}
		}
	};
	nameLabel.addModifyListener(nameModificationListener);
}
 
源代码11 项目: XPagesExtensionLibrary   文件: WizardUtils.java
public static String getTextValue(final Text txt, final String defVal) {
    if ((txt == null) || (txt.isDisposed())) {
        return defVal;
    }
    
    return (txt.getText());
}
 
源代码12 项目: pentaho-kettle   文件: DatabaseDialog.java
public static final void checkPasswordVisible( Text wPassword ) {
  String password = wPassword.getText();
  java.util.List<String> list = new ArrayList<String>();
  StringUtil.getUsedVariables( password, list, true );
  // ONLY show the variable in clear text if there is ONE variable used
  // Also, it has to be the only string in the field.
  //

  if ( list.size() != 1 ) {
    wPassword.setEchoChar( '*' );
  } else {
    String variableName = null;
    if ( ( password.startsWith( StringUtil.UNIX_OPEN ) && password.endsWith( StringUtil.UNIX_CLOSE ) ) ) {
      // ${VAR}
      // 012345
      //
      variableName =
        password.substring( StringUtil.UNIX_OPEN.length(), password.length() - StringUtil.UNIX_CLOSE.length() );
    }
    if ( ( password.startsWith( StringUtil.WINDOWS_OPEN ) && password.endsWith( StringUtil.WINDOWS_CLOSE ) ) ) {
      // %VAR%
      // 01234
      //
      variableName =
        password.substring( StringUtil.WINDOWS_OPEN.length(), password.length()
          - StringUtil.WINDOWS_CLOSE.length() );
    }

    // If there is a variable name in there AND if it's defined in the system properties...
    // Otherwise, we'll leave it alone.
    //
    if ( variableName != null && System.getProperty( variableName ) != null ) {
      wPassword.setEchoChar( '\0' ); // Show it all...
    } else {
      wPassword.setEchoChar( '*' );
    }
  }
}
 
源代码13 项目: APICloud-Studio   文件: FindBarDecorator.java
void inputNewline(Text text)
{
	StringBuilder sb = new StringBuilder(text.getText());
	Point selection = text.getSelection();
	String delimiter = Text.DELIMITER;
	sb.replace(selection.x, selection.y, delimiter);
	text.setText(sb.toString());
	text.setSelection(selection.x + delimiter.length());
}
 
源代码14 项目: erflute   文件: AbstractDialog.java
protected Integer getIntegerValue(Text text) {
    final String value = text.getText();
    if (Check.isEmpty(value)) {
        return null;
    }
    try {
        return Integer.valueOf(value.trim());
    } catch (final NumberFormatException e) {
        return null;
    }
}
 
源代码15 项目: Pydev   文件: AbstractPydevPrefs.java
protected void numberFieldChanged(Text textControl) {
    String number = textControl.getText();
    IStatus status = validatePositiveNumber(number);
    if (!status.matches(IStatus.ERROR)) {
        fOverlayStore.setValue(fTextFields.get(textControl), number);
    }
    updateStatus(status);
}
 
源代码16 项目: atdl4j   文件: SWTAtdl4jInputAndFilterDataPanel.java
public static String getTextValue( Text aText )
{
	String tempText = aText.getText();
	if ( "".equals( tempText ) )
	{
		return null;
	}
	else
	{
		return tempText;
	}
}
 
源代码17 项目: elexis-3-core   文件: ImporterPage.java
public ODBCBasedImporter(final Composite parent, final ImporterPage home){
	super(parent, SWT.NONE);
	setLayout(new GridLayout());
	final Label lSource = new Label(this, SWT.NONE);
	tSource = new Text(this, SWT.BORDER);
	lSource.setText(Messages.ImporterPage_source); //$NON-NLS-1$
	tSource.setEditable(false);
	lSource.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	tSource.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	tSource.setText(CoreHub.localCfg.get(
		"ImporterPage/" + home.getTitle() + "/ODBC-Source", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	home.results = new String[1];
	home.results[0] = tSource.getText();
	Button bSource = new Button(this, SWT.PUSH);
	bSource.setText(Messages.ImporterPage_enter); //$NON-NLS-1$
	bSource.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(final SelectionEvent e){
			InputDialog in =
				new InputDialog(parent.getShell(), Messages.ImporterPage_odbcSource, //$NON-NLS-1$
					Messages.ImporterPage_pleaseEnterODBC, null, null); //$NON-NLS-1$
			if (in.open() == Dialog.OK) {
				tSource.setText(in.getValue());
				home.results[0] = in.getValue();
				CoreHub.localCfg.set(
					"ImporterPage/" + home.getTitle() + "/ODBC-Source", home.results[0]); //$NON-NLS-1$ //$NON-NLS-2$
			}
			
		}
		
	});
	
}
 
源代码18 项目: hop   文件: GuiCompositeWidgets.java
private void getWidgetsData( Object sourceData, GuiElements guiElements ) {
  if ( guiElements.isIgnored() ) {
    return;
  }

  // Do we add the element or the children?
  //
  if ( guiElements.getId() != null ) {

    Control control = widgetsMap.get( guiElements.getId() );
    if ( control != null ) {

      // What's the value?
      //
      Object value = null;

      switch ( guiElements.getType() ) {
        case TEXT:
          if ( guiElements.isVariablesEnabled() ) {
            TextVar textVar = (TextVar) control;
            value = textVar.getText();
          } else {
            Text text = (Text) control;
            value = text.getText();
          }
          break;
        case CHECKBOX:
          Button button = (Button) control;
          value = button.getSelection();
          break;
        case COMBO:
          if ( guiElements.isVariablesEnabled() ) {
            ComboVar comboVar = (ComboVar) control;
            value = comboVar.getText();
          } else {
            Combo combo = (Combo) control;
            value = combo.getText();
          }
          break;
        default:
          System.err.println( "WARNING: getting data from widget with ID " + guiElements.getId() + " : not implemented type " + guiElements.getType() + " yet." );
          break;
      }

      // Set the value on the source data object
      //
      try {
        new PropertyDescriptor( guiElements.getFieldName(), sourceData.getClass() )
          .getWriteMethod()
          .invoke( sourceData, value )
        ;
      } catch ( Exception e ) {
        System.err.println( "Unable to set value '" + value + "'on field: '" + guiElements.getFieldName() + "' : " + e.getMessage() );
        e.printStackTrace();
      }

    } else {
      System.err.println( "Widget not found to set value on for id: " + guiElements.getId()+", label: "+guiElements.getLabel() );
    }
  } else {

    // Add the children
    //
    for ( GuiElements child : guiElements.getChildren() ) {
      getWidgetsData( sourceData, child );
    }
  }
}
 
源代码19 项目: birt   文件: PropertyBindingPage.java
public boolean performOk( )
{
	for ( int i = 0; i < propList.size( ); i++ )
	{
		try
		{
			String value = null;
			Text propertyText = (Text) propertyTextList.get( i );
			
			if ( !propertyText.isDisposed( )
					&& propertyText.getText( ) != null
					&& propertyText.getText( ).trim( ).length( ) > 0 )
			{
				value = propertyText.getText( ).trim( );
			}
			Expression expr = new Expression( value,
					(String) propertyText.getData( DataUIConstants.EXPR_TYPE ) );
			
			if ( ds instanceof DesignElementHandle )
			{
				if ( propList.get( i ) instanceof String[] )
				{
					( (DesignElementHandle) ds ).setPropertyBinding( ( (String[]) propList.get( i ) )[0],
							expr );
				}
				else if ( propList.get( i ) instanceof Property )
				{
					( (DesignElementHandle) ds ).setPropertyBinding( ( (Property) propList.get( i ) ).getName( ),
							expr );
				}
			}
		}
		catch ( Exception e )
		{
			logger.log( Level.FINE, e.getMessage( ), e );
			ExceptionHandler.handle( e );
			return true;
		}
	}
	return super.performOk( );
}
 
protected void textChanged(Text textControl) {
	Key key= (Key) textControl.getData();
	String number= textControl.getText();
	String oldValue= setValue(key, number);
	validateSettings(key, oldValue, number);
}