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

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

源代码1 项目: erflute   文件: ModelPropertiesDialog.java
private void edit(final TableItem item, final TableEditor tableEditor) {
    final Text text = new Text(table, SWT.NONE);
    text.setText(item.getText(targetColumn));

    text.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            item.setText(targetColumn, text.getText());
            text.dispose();
        }
    });

    tableEditor.setEditor(text, item, targetColumn);
    text.setFocus();
    text.selectAll();
}
 
源代码2 项目: ermasterr   文件: ModelPropertiesDialog.java
private void edit(final TableItem item, final TableEditor tableEditor) {
    final Text text = new Text(table, SWT.NONE);
    text.setText(item.getText(targetColumn));

    text.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(final FocusEvent e) {
            item.setText(targetColumn, text.getText());
            text.dispose();
        }

    });

    tableEditor.setEditor(text, item, targetColumn);
    text.setFocus();
    text.selectAll();
}
 
源代码3 项目: depan   文件: RelationDisplayEditor.java
/**
 * In a future world, this might provide access to a complete set
 * of {@code ResourceDocument} properties.
 */
@SuppressWarnings("unused")
private Composite setupProperties(Composite parent) {
  Composite result = Widgets.buildGridContainer(parent, 2);

  Label label = Widgets.buildCompactLabel(result, "&Name:");

  relSetName = new Text(result, SWT.BORDER | SWT.SINGLE);
  relSetName.setLayoutData(Widgets.buildHorzFillData());
  relSetName.addFocusListener(new FocusAdapter() {
    @Override
    public void focusLost(FocusEvent e) {
      if (propInfo.getName().equals(relSetName.getText())) {
        return;
      }
      setDirtyState(true);
      handleDocumentChange();
    }
  });
  return result;
}
 
源代码4 项目: depan   文件: EdgeMatcherEditor.java
/**
 * In a future world, this might provide access to a complete set
 * of {@code ResourceDocument} properties.
 */
@SuppressWarnings("unused")
private Composite setupProperties(Composite parent) {
  Composite result = Widgets.buildGridContainer(parent, 2);

  Label label = Widgets.buildCompactLabel(result, "&Name:");

  matcherName = new Text(result, SWT.BORDER | SWT.SINGLE);
  matcherName.setLayoutData(Widgets.buildHorzFillData());
  if (null != matcherInfo) {
    matcherName.setText(matcherInfo.getName());
  }
  matcherName.addFocusListener(new FocusAdapter() {
    @Override
    public void focusLost(FocusEvent e) {
      if (matcherInfo.getName().equals(matcherName.getText())) {
        return;
      }
      setDirtyState(true);
      handleDocumentChange();
    }
  });
  return result;
}
 
源代码5 项目: depan   文件: RelationSetDescriptorEditor.java
/**
 * In a future world, this might provide access to a complete set
 * of {@code ResourceDocument} properties.
 * @return 
 */
@SuppressWarnings("unused")
private Composite setupProperties(Composite parent) {
  Composite result = Widgets.buildGridContainer(parent, 2);

  Label label = Widgets.buildCompactLabel(result, "&Name:");

  relSetName = new Text(result, SWT.BORDER | SWT.SINGLE);
  relSetName.setLayoutData(Widgets.buildHorzFillData());
  relSetName.addFocusListener(new FocusAdapter() {
    @Override
    public void focusLost(FocusEvent e) {
      if (relSetInfo.getName().equals(relSetName.getText())) {
        return;
      }
      setDirtyState(true);
      handleDocumentChange();
    }
  });
  return result;
}
 
源代码6 项目: translationstudio8   文件: EquivalentPage.java
/**
 * 验证用户输入的加权系数的正确性
 * @param equiTxt
 */
private void validEquiTxt(final Text equiTxt){
	final String defaultStr = "0.50";
	equiTxt.setText(defaultStr);
	equiTxt.addFocusListener(new FocusAdapter() {
		@Override
		public void focusLost(FocusEvent e) {
			String textStr = equiTxt.getText().trim();
			if (textStr == null || textStr.trim().length() == 0) {
				equiTxt.setText(defaultStr);
			}else {
				String regular = "1\\.(0){0,2}|0\\.\\d{0,2}";
				if (!textStr.matches(regular)) {
					MessageDialog.openInformation(getShell(), Messages.getString("preference.EquivalentPage.msgTitle"), 
						Messages.getString("preference.EquivalentPage.msg5"));
					equiTxt.setText(defaultStr);
				}
			}
		}
	});
}
 
源代码7 项目: tmxeditor8   文件: EquivalentPage.java
/**
 * 验证用户输入的加权系数的正确性
 * @param equiTxt
 */
private void validEquiTxt(final Text equiTxt){
	final String defaultStr = "0.50";
	equiTxt.setText(defaultStr);
	equiTxt.addFocusListener(new FocusAdapter() {
		@Override
		public void focusLost(FocusEvent e) {
			String textStr = equiTxt.getText().trim();
			if (textStr == null || textStr.trim().length() == 0) {
				equiTxt.setText(defaultStr);
			}else {
				String regular = "1\\.(0){0,2}|0\\.\\d{0,2}";
				if (!textStr.matches(regular)) {
					MessageDialog.openInformation(getShell(), Messages.getString("preference.EquivalentPage.msgTitle"), 
						Messages.getString("preference.EquivalentPage.msg5"));
					equiTxt.setText(defaultStr);
				}
			}
		}
	});
}
 
源代码8 项目: 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 );
}
 
@Override
protected Control createDialogArea(final Composite parent) {
    text = new Text(parent, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.NO_FOCUS);

    // Use the compact margins employed by PopupDialog.
    final GridData gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
    gd.horizontalIndent = PopupDialog.POPUP_HORIZONTALSPACING;
    gd.verticalIndent = PopupDialog.POPUP_VERTICALSPACING;
    text.setLayoutData(gd);
    text.setText(contents);

    // since SWT.NO_FOCUS is only a hint...
    text.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(final FocusEvent event) {
            ContentProposalPopup.this.close();
        }
    });
    return text;
}
 
源代码10 项目: ermaster-b   文件: ModelPropertiesDialog.java
private void edit(final TableItem item, final TableEditor tableEditor) {
	final Text text = new Text(table, SWT.NONE);
	text.setText(item.getText(targetColumn));

	text.addFocusListener(new FocusAdapter() {

		@Override
		public void focusLost(FocusEvent e) {
			item.setText(targetColumn, text.getText());
			text.dispose();
		}

	});

	tableEditor.setEditor(text, item, targetColumn);
	text.setFocus();
	text.selectAll();
}
 
源代码11 项目: CogniCrypt   文件: CompositeForCodeTab.java
public CompositeForCodeTab(final Composite parent, final int style, final Answer answer) {
	super(parent, style);

	// Non-editable text box containing answer value
	final Text txtBoxAnswers = new Text(this, SWT.BORDER);
	txtBoxAnswers.setBounds(5, 5, 210, 25);
	txtBoxAnswers.setEditable(false);
	txtBoxAnswers.setText(answer.getValue());

	// Code dependency text field
	final Text txtValue = new Text(this, SWT.BORDER);
	txtValue.setBounds(220, 5, 200, 25);
	txtValue.setVisible(true);

	final CodeDependency codeDependency = new CodeDependency();

	if (answer.getCodeDependencies() != null) {
		for (final CodeDependency cd : answer.getCodeDependencies()) {
			if (cd.getValue() != null) {
				txtValue.setText(cd.getValue());
				codeDependency.setValue(txtValue.getText());
			}
		}
	}

	txtValue.addFocusListener(new FocusAdapter() {

		@Override
		public void focusLost(final FocusEvent e) {
			codeDependency.setValue(txtValue.getText());
		}
	});

	final ArrayList<CodeDependency> codeDependencies = new ArrayList<CodeDependency>();
	codeDependencies.add(codeDependency);
	answer.setCodeDependencies(codeDependencies);

}
 
源代码12 项目: texlipse   文件: TexlipseProjectFilesWizardPage.java
/**
 * Create the output file name field.
 * @param composite the parent container
 */
private void createOutputDirControl(Composite composite) {
    
    // add label
    Label mainLabel = new Label(composite, SWT.LEFT);
    mainLabel.setText(TexlipsePlugin.getResourceString("projectWizardOutputDirLabel"));
    mainLabel.setToolTipText(TexlipsePlugin.getResourceString("projectWizardOutputDirTooltip"));
    mainLabel.setLayoutData(new GridData());
    
    // add text field
    outputDirNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    outputDirNameField.setText(attributes.getOutputDir());
    outputDirNameField.setToolTipText(TexlipsePlugin.getResourceString("projectWizardOutputDirTooltip"));
    outputDirNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    outputDirNameField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) {
            if (outputDirItem != null) {
                dirTree.setSelection(new TreeItem[] { outputDirItem });
            }
        }});
    outputDirNameField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (!outputDirNameField.isDisposed()) {
                String t = outputDirNameField.getText();
                attributes.setOutputDir(t);
                validateDirName(outputDirNameField, t);
                if (t == null || t.length() == 0) {
                    recreateSubTree();
                } else if (outputDirItem == null) {
                    recreateSubTree();
                }
                if (outputDirItem != null) {
                    outputDirItem.setText(t);
                }
            }
        }});
}
 
源代码13 项目: texlipse   文件: TexlipseProjectFilesWizardPage.java
/**
 * Create the output file name field.
 * @param composite the parent container
 */
private void createOutputFileControl(Composite composite) {
    
    // add label
    Label mainLabel = new Label(composite, SWT.LEFT);
    mainLabel.setText(TexlipsePlugin.getResourceString("projectWizardOutputFileLabel"));
    mainLabel.setToolTipText(TexlipsePlugin.getResourceString("projectWizardOutputFileTooltip"));
    mainLabel.setLayoutData(new GridData());
    
    // add text field
    outputFileNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    outputFileNameField.setText(attributes.getOutputFile());
    outputFileNameField.setToolTipText(TexlipsePlugin.getResourceString("projectWizardOutputFileTooltip"));
    outputFileNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    outputFileNameField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) {
            dirTree.setSelection(new TreeItem[] { outputFileItem });
        }});
    outputFileNameField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (!outputFileNameField.isDisposed()) {
                String t = outputFileNameField.getText();
                outputFileItem.setText(t);
                validateOutputFileName(t);
            }
        }});
}
 
源代码14 项目: texlipse   文件: TexlipseProjectFilesWizardPage.java
/**
 * Create the output file name field.
 * @param composite the parent container
 */
private void createMainDirControl(Composite composite) {
    
    // add label
    Label mainLabel = new Label(composite, SWT.LEFT);
    mainLabel.setText(TexlipsePlugin.getResourceString("projectWizardMainDirLabel"));
    mainLabel.setToolTipText(TexlipsePlugin.getResourceString("projectWizardMainDirTooltip"));
    mainLabel.setLayoutData(new GridData());
    
    // add text field
    sourceDirNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    sourceDirNameField.setText(attributes.getSourceDir());
    sourceDirNameField.setToolTipText(TexlipsePlugin.getResourceString("projectWizardMainDirTooltip"));
    sourceDirNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    sourceDirNameField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) {
        	   if (sourceDirItem != null) {
        	       dirTree.setSelection(new TreeItem[] { sourceDirItem });
        	   }
        }});
    sourceDirNameField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (!sourceDirNameField.isDisposed()) {
                String t = sourceDirNameField.getText();
                attributes.setSourceDir(t);
                validateDirName(sourceDirNameField, t);
                if (t == null || t.length() == 0) {
                    recreateSubTree();
                } else if (sourceDirItem == null) {
                    recreateSubTree();
                }
                if (sourceDirItem != null) {
                    sourceDirItem.setText(t);
                }
            }
        }});
}
 
源代码15 项目: texlipse   文件: TexlipseProjectFilesWizardPage.java
/**
 * Create main file settings box.
 * @param composite the parent container
 */
private void createMainFileControl(Composite composite) {
    
    // add label
    Label mainLabel = new Label(composite, SWT.LEFT);
    mainLabel.setText(TexlipsePlugin.getResourceString("projectWizardMainFileLabel"));
    mainLabel.setToolTipText(TexlipsePlugin.getResourceString("projectWizardMainFileTooltip"));
    mainLabel.setLayoutData(new GridData());
    
    // add text field
    sourceFileNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    sourceFileNameField.setText(attributes.getSourceFile());
    sourceFileNameField.setToolTipText(TexlipsePlugin.getResourceString("projectWizardMainFileTooltip"));
    sourceFileNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    sourceFileNameField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) {
            dirTree.setSelection(new TreeItem[] { sourceFileItem });
        }});
    sourceFileNameField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (!sourceFileNameField.isDisposed()) {
                String t = sourceFileNameField.getText();
                sourceFileItem.setText(t);
                tempFileItem.setText(t.substring(0, t.lastIndexOf('.')+1) + "aux");
                validateMainFileName(t);
            }
        }});
}
 
源代码16 项目: texlipse   文件: TexlipseProjectFilesWizardPage.java
/**
 * Create the output file name field.
 * @param composite the parent container
 */
private void createTempDirControl(Composite composite) {
    
    // add label
    Label mainLabel = new Label(composite, SWT.LEFT);
    mainLabel.setText(TexlipsePlugin.getResourceString("projectWizardTempDirLabel"));
    mainLabel.setToolTipText(TexlipsePlugin.getResourceString("projectWizardTempDirTooltip"));
    mainLabel.setLayoutData(new GridData());
    
    // add text field
    tempDirNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    tempDirNameField.setText(attributes.getTempDir());
    tempDirNameField.setToolTipText(TexlipsePlugin.getResourceString("projectWizardTempDirTooltip"));
    tempDirNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tempDirNameField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) {
        	   if (tempDirItem != null) {
                dirTree.setSelection(new TreeItem[] { tempDirItem });
        	   }
        }});
    tempDirNameField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (!tempDirNameField.isDisposed()) {
                String t = tempDirNameField.getText();
                attributes.setTempDir(t);
                validateDirName(tempDirNameField, t);
                if (t == null || t.length() == 0) {
                    recreateSubTree();
                } else if (tempDirItem == null) {
                    recreateSubTree();
                }
                if (tempDirItem != null) {
                    tempDirItem.setText(t);
                }
            }
        }});
}
 
源代码17 项目: 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;
}
 
源代码18 项目: birt   文件: LocalizedNumberEditorComposite.java
protected void placeComponents( )
{
	GridLayout gl = new GridLayout( 1, false );
	gl.marginBottom = 0;
	gl.marginHeight = 0;
	gl.marginLeft = 0;
	gl.marginRight = 0;
	gl.marginTop = 0;
	gl.marginWidth = 0;
	this.setLayout( gl );
	if ( sUnit != null )
	{
		gl.numColumns = 2;
	}
	txtValue = new Text( this, iStyle );
	GridData gd = new GridData( GridData.FILL_HORIZONTAL );
	txtValue.setLayoutData( gd );
	txtValue.setToolTipText( Messages.getString( "TextEditorComposite.Tooltip.EnterDecimalOrFractionValue" ) ); //$NON-NLS-1$
	txtValue.addModifyListener( this );
	txtValue.addFocusListener( this );
	txtValue.addKeyListener( this );

	if ( sUnit != null )
	{
		this.lblUnit = new Label( this, SWT.NONE );
		if ( lblUnit != null )
		{
			lblUnit.setText( sUnit );
		}
	}
}
 
源代码19 项目: nebula   文件: DateTimeFormatter.java
/**
  * Sets the <code>Text</code> widget that will be managed by this formatter.<p>
  *
  * The ancestor is override to add a key listener on the text widget.
  *
  * @param text Text widget
  * @see ITextFormatter#setText(Text)
  */
public void setText(Text text) {
	super.setText(text);
	text.addKeyListener(klistener);
	text.addFocusListener(flistener);
}