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

The following examples show how to use org.eclipse.swt.widgets.Text#isDisposed() . 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: FindBarEntriesHelper.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Set the items available in the text (and ask it to ignore any changes while that's done).
 */
private void setTextText(Text text, IStartEndIgnore modifyListener, List<String> items)
{
	modifyListener.startIgnore();
	try
	{
		if (!text.isDisposed() && !CollectionsUtil.isEmpty(items))
		{
			if (ObjectUtil.areNotEqual(items.get(0), text.getText()))
			{
				text.setText(items.get(0));
			}
			text.setForeground(null);
		}
	}
	finally
	{
		modifyListener.endIgnore();
	}
}
 
Example 2
Source File: BookMarkExpressionPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void refreshMessage( )
{
	Text text = bookMarkSection.getExpressionControl( ).getTextControl( );
	if ( text != null && !text.isDisposed( ) )
	{
		boolean isHidden = noteSection.getTextControl( ).isVisible( );
		if ( !validateBookMark( text.getText( ).trim( ) ) )
		{
			noteSection.setHidden( false );
		}
		else
		{
			noteSection.setHidden( true );
		}
		if ( noteSection.getTextControl( ).isVisible( ) != isHidden )
		{
			FormWidgetFactory.getInstance( ).paintFormStyle( container );
			FormWidgetFactory.getInstance( ).adapt( container );
			container.layout( true );
			container.redraw( );
		}
	}
}
 
Example 3
Source File: GraphModelDialog.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 5 votes vote down vote up
/**
 * Someone changed something in the labels, update the active node
 */
private void getNodeLabelsFromView() {

  if ( activeNode != null ) {
    if ( monitorLabels ) {
      // System.out.println( "Labels changed! " + new Date().getTime() + " found " + wNodeLabels.nrNonEmpty() + " labels" );

      java.util.List<String> labels = new ArrayList<>();
      for ( int i = 0; i < wNodeLabels.nrNonEmpty(); i++ ) {
        labels.add( wNodeLabels.getNonEmpty( i ).getText( 1 ) );
      }

      TableEditor editor = wNodeLabels.getEditor();
      if ( editor != null && editor.getEditor() != null && ( editor.getEditor() instanceof Text ) ) {
        Text text = (Text) editor.getEditor();
        if ( !text.isDisposed() ) {
          if ( !labels.contains( text.getText() ) ) {
            labels.add( text.getText() );
          }
          // System.out.println( "editor content : " + text.getText() );
        }
      }

      activeNode.setLabels( labels );
      // System.out.println( "Set " + activeNode.getLabels().size() + " labels on active node" );
    }
  }
}
 
Example 4
Source File: GamlSearchField.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks if the text or shell has focus. If not, closes the shell.
 *
 * @param table
 *            the shell's table
 * @param text
 *            the search text field
 */
protected void checkFocusLost(final Table table, final Text text) {
	if (!shell.isDisposed() && !table.isDisposed() && !text.isDisposed()) {
		if (table.getDisplay().getActiveShell() == table.getShell()) {
			// If the user selects the trim shell, leave focus on the text
			// so shell stays open
			text.setFocus();
			return;
		}
		if (!shell.isFocusControl() && !table.isFocusControl() && !text.isFocusControl()) {
			quickAccessContents.doClose();
		}
	}
}
 
Example 5
Source File: ProjectSettingBaseInfoPage.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean performOk() {
	if (lstText != null) {
		LinkedHashMap<String, String> mapField = new LinkedHashMap<String, String>();
		for (Text txt : lstText) {
			if (!txt.isDisposed()) {
				mapField.put(TextUtil.stringToXML((String) txt.getData()), TextUtil.stringToXML(txt.getText()).trim());
			}
		}
		projCfgBean.setMapField(mapField);
	}

	if (lstCombo != null) {
		LinkedHashMap<String, Object[]> mapAttr = new LinkedHashMap<String, Object[]>();
		for (Combo cmb : lstCombo) {
			if (!cmb.isDisposed()) {
				ArrayList<String> lstAttrValue = new ArrayList<String>();
				for (String attrVal : cmb.getItems()) {
					lstAttrValue.add(TextUtil.stringToXML(attrVal));
				}
				mapAttr.put(TextUtil.stringToXML((String) cmb.getData()),
						new Object[] { TextUtil.stringToXML(cmb.getText()), lstAttrValue });
			}
		}
		projCfgBean.setMapAttr(mapAttr);
	}
	return super.performOk();
}
 
Example 6
Source File: NewProjectWizardProjInfoPage.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 获取项目字段集合
 * @return key 为字段名称,value 为字段值
 */
public LinkedHashMap<String, String> getFieldMap() {
	LinkedHashMap<String, String> mapField = new LinkedHashMap<String, String>();
	if (lstText != null) {
		for (Text txt : lstText) {
			if (!txt.isDisposed()) {
				mapField.put(TextUtil.stringToXML((String) txt.getData()), TextUtil.stringToXML(txt.getText()).trim());
			}
		}
	}
	return mapField;
}
 
Example 7
Source File: WizardUtils.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public static String getTextValue(final Text txt, final String defVal) {
    if ((txt == null) || (txt.isDisposed())) {
        return defVal;
    }
    
    return (txt.getText());
}
 
Example 8
Source File: ProjectSettingBaseInfoPage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean performOk() {
	if (lstText != null) {
		LinkedHashMap<String, String> mapField = new LinkedHashMap<String, String>();
		for (Text txt : lstText) {
			if (!txt.isDisposed()) {
				mapField.put(TextUtil.stringToXML((String) txt.getData()), TextUtil.stringToXML(txt.getText()).trim());
			}
		}
		projCfgBean.setMapField(mapField);
	}

	if (lstCombo != null) {
		LinkedHashMap<String, Object[]> mapAttr = new LinkedHashMap<String, Object[]>();
		for (Combo cmb : lstCombo) {
			if (!cmb.isDisposed()) {
				ArrayList<String> lstAttrValue = new ArrayList<String>();
				for (String attrVal : cmb.getItems()) {
					lstAttrValue.add(TextUtil.stringToXML(attrVal));
				}
				mapAttr.put(TextUtil.stringToXML((String) cmb.getData()),
						new Object[] { TextUtil.stringToXML(cmb.getText()), lstAttrValue });
			}
		}
		projCfgBean.setMapAttr(mapAttr);
	}
	return super.performOk();
}
 
Example 9
Source File: NewProjectWizardProjInfoPage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 获取项目字段集合
 * @return key 为字段名称,value 为字段值
 */
public LinkedHashMap<String, String> getFieldMap() {
	LinkedHashMap<String, String> mapField = new LinkedHashMap<String, String>();
	if (lstText != null) {
		for (Text txt : lstText) {
			if (!txt.isDisposed()) {
				mapField.put(TextUtil.stringToXML((String) txt.getData()), TextUtil.stringToXML(txt.getText()).trim());
			}
		}
	}
	return mapField;
}
 
Example 10
Source File: SymitarSession.java    From RepDev with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Helper method for runRepGen stuff
 * @param progress
 * @param value
 * @param text
 * @param str
 */
protected void setProgress(ProgressBar progress, int value, Text text, String str){
	if( progress != null && !progress.isDisposed() )
		progress.setSelection(value);

	if( text != null && str != null && !text.isDisposed())
		text.setText(str.replace("\r", "\n"));
}
 
Example 11
Source File: PropertyBindingPage.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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( );
}
 
Example 12
Source File: JobHistoryDelegate.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void showLogEntry() {
  JobHistoryLogTab model = models[tabFolder.getSelectionIndex()];

  Text text = model.logDisplayText;

  if ( text == null || text.isDisposed() ) {
    return;
  }

  List<Object[]> list = model.rows;

  if ( list == null || list.size() == 0 ) {
    String message;
    if ( model.logTable.isDefined() ) {
      message = BaseMessages.getString( PKG, "JobHistory.PleaseRefresh.Message" );
    } else {
      message = BaseMessages.getString( PKG, "JobHistory.HistoryConfiguration.Message" );
    }
    text.setText( message );
    return;
  }

  // grab the selected line in the table:
  int nr = model.logDisplayTableView.table.getSelectionIndex();
  if ( nr >= 0 && nr < list.size() ) {
    // OK, grab this one from the buffer...
    Object[] row = list.get( nr );

    // What is the name of the log field?
    //
    LogTableField logField = model.logTable.getLogField();
    if ( logField != null ) {
      int index = model.logTableFields.indexOf( logField );
      if ( index >= 0 ) {
        String logText = row[index].toString();

        text.setText( Const.NVL( logText, "" ) );

        text.setSelection( text.getText().length() );
        text.showSelection();
      } else {
        text.setText( BaseMessages.getString( PKG, "JobHistory.HistoryConfiguration.NoLoggingFieldDefined" ) );
      }
    }
  }
}
 
Example 13
Source File: TransHistoryDelegate.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void showLogEntry() {
  TransHistoryLogTab model = models[tabFolder.getSelectionIndex()];

  Text text = model.logDisplayText;

  if ( text == null || text.isDisposed() ) {
    return;
  }

  List<Object[]> list = model.rows;

  if ( list == null || list.size() == 0 ) {
    String message;
    if ( model.logTable.isDefined() ) {
      message = BaseMessages.getString( PKG, "TransHistory.PleaseRefresh.Message" );
    } else {
      message = BaseMessages.getString( PKG, "TransHistory.HistoryConfiguration.Message" );
    }
    text.setText( message );
    return;
  }

  // grab the selected line in the table:
  int nr = model.logDisplayTableView.table.getSelectionIndex();
  if ( nr >= 0 && nr < list.size() ) {
    // OK, grab this one from the buffer...
    Object[] row = list.get( nr );

    // What is the name of the log field?
    //
    LogTableField logField = model.logTable.getLogField();
    if ( logField != null ) {
      int index = model.logTableFields.indexOf( logField );
      if ( index >= 0 ) {
        String logText = row[index].toString();

        text.setText( Const.NVL( logText, "" ) );

        text.setSelection( text.getText().length() );
        text.showSelection();
      } else {
        text.setText( BaseMessages.getString( PKG, "TransHistory.HistoryConfiguration.NoLoggingFieldDefined" ) );
      }
    }
  }
}