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

The following examples show how to use org.eclipse.swt.widgets.Text#isDisposed() . These examples are extracted from open source projects. 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
/**
 * 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
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
/**
 * 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
/**
 * 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
@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
/**
 * 获取项目字段集合
 * @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
public static String getTextValue(final Text txt, final String defVal) {
    if ((txt == null) || (txt.isDisposed())) {
        return defVal;
    }
    
    return (txt.getText());
}
 
Example 8
@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
/**
 * 获取项目字段集合
 * @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
/**
 * 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
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
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
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" ) );
      }
    }
  }
}