Java Code Examples for org.eclipse.swt.widgets.TreeItem#getText()

The following examples show how to use org.eclipse.swt.widgets.TreeItem#getText() . 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: CapabilitySection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the item kind.
 *
 * @param item the item
 * @return the item kind
 */
private int getItemKind(TreeItem item) {
  String itemID = item.getText(TITLE_COL);

  if (CAPABILITY_SET.equals(itemID))
    return CS;
  if (TYPE_TITLE.equals(itemID))
    return TYPE;
  itemID = (String) item.getData();
  if (LANGS_TITLE.equals(itemID))
    return LANG;
  if (FEAT_TITLE.equals(itemID))
    return FEAT;
  if (LANG_TITLE.equals(itemID))
    return LANG_ITEM;
  if (SOFAS_TITLE.equals(itemID))
    return SOFA;
  if (SOFA_TITLE.equals(itemID))
    return SOFA_ITEM;
  throw new InternalErrorCDE("invalid state");
}
 
Example 2
Source File: ConstUi.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Get an array of strings containing the path from the given TreeItem to the parent.
 *
 * @param ti The TreeItem to look at
 * @return An array of string describing the path to the TreeItem.
 */
public static final String[] getTreeStrings( TreeItem ti ) {
  int nrlevels = getTreeLevel( ti ) + 1;
  String[] retval = new String[ nrlevels ];
  int level = 0;

  retval[ nrlevels - 1 ] = ti.getText();
  TreeItem parent = ti.getParentItem();
  while ( parent != null ) {
    level++;
    retval[ nrlevels - level - 1 ] = parent.getText();
    parent = parent.getParentItem();
  }

  return retval;
}
 
Example 3
Source File: PythonListEditor.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Moves the currently selected item up or down.
 *
 * @param up <code>true</code> if the item should move up, and <code>false</code> if it should move down
 */
private void swap(boolean up) {
    setPresentsDefaultValue(false);
    int index = getSelectionIndex();
    int target = up ? index - 1 : index + 1;

    if (index >= 0) {
        TreeItem curr = treeWithInterpreters.getItem(index);
        TreeItem replace = treeWithInterpreters.getItem(target);

        //Just update the text!
        String col0 = replace.getText(0);
        String col1 = replace.getText(1);
        replace.setText(new String[] { curr.getText(0), curr.getText(1) });
        curr.setText(new String[] { col0, col1 });

        treeWithInterpreters.setSelection(treeWithInterpreters.getItem(target));
    }
    selectionChanged();
}
 
Example 4
Source File: SofaMapSection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Adds the aggr map.
 *
 * @param selected the selected
 */
private void addAggrMap(TreeItem selected) {
  // pop up window: shows all available component mappings
  // minus current mappings for this aggrSofa
  // Available: a) not mapped,
  // User selects mappings to add
  String aggrSofa = selected.getText();
  Map availAndBoundSofas = getAvailAndBoundSofas(aggrSofa, AVAIL_ONLY);
  if (availAndBoundSofas.size() == 0) {
    Utility
            .popMessage(
                    "No available sofas",
                    "Because there are no sofas in the delegates that are not already bound, no sofa mapping can be created.",
                    MessageDialog.WARNING);
    return;
  }

  EditSofaBindingsDialog dialog = new EditSofaBindingsDialog(this, aggrSofa, availAndBoundSofas);
  if (dialog.open() == Window.CANCEL)
    return;
  addAggr(aggrSofa, dialog.selectedSofaNames);
  removeChildren(selected);
  fillBindings(selected, aggrSofa);
  selected.setExpanded(true);
  setFileDirty();
}
 
Example 5
Source File: ToolTipFaker.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private String getToolTip( TreeItem item )
{
	Object obj = item.getData( );
	if ( obj instanceof TreeData )
	{
		Object data = ( (TreeData) item.getData( ) ).getWrappedObject( );
		if ( data instanceof Field )
		{
			return ( (Field) data ).getName( )
					+ " : " //$NON-NLS-1$
					+ ClassParser.getTypeLabel( ( (Field) data ).getGenericType( ) );
		}
		if ( data instanceof Method )
		{
			return ( (Method) data ).getName( )
					+ "(" //$NON-NLS-1$
					+ ClassParser.getParametersLabel( (Method) data )
					+ ")" //$NON-NLS-1$
					+ " : " + ClassParser.getTypeLabel( ( (Method) data ).getGenericReturnType( ) ); //$NON-NLS-1$ 
		}
		return item.getText( );
	}
	return null;
}
 
Example 6
Source File: SpoonSlave.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public TreeEntry( TreeItem treeItem ) {
  TreeItem treeIt = treeItem;
  path = ConstUI.getTreeStrings( treeIt );
  this.length = path.length;
  if ( path.length > 0 ) {
    itemType = path[0];
  }
  if ( path.length > 1 ) {
    name = path[1];
  }
  if ( path.length == 3 ) {
    treeIt = treeIt.getParentItem();
  }
  status = treeIt.getText( 9 );
  id = treeIt.getText( 13 );
}
 
Example 7
Source File: ConstUI.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Get an array of strings containing the path from the given TreeItem to the parent.
 *
 * @param ti
 *          The TreeItem to look at
 * @return An array of string describing the path to the TreeItem.
 */
public static final String[] getTreeStrings( TreeItem ti ) {
  int nrlevels = getTreeLevel( ti ) + 1;
  String[] retval = new String[nrlevels];
  int level = 0;

  retval[nrlevels - 1] = ti.getText();
  TreeItem parent = ti.getParentItem();
  while ( parent != null ) {
    level++;
    retval[nrlevels - level - 1] = parent.getText();
    parent = parent.getParentItem();
  }

  return retval;
}
 
Example 8
Source File: TreeToClipboardAdapter.java    From logbook with MIT License 6 votes vote down vote up
/**
 * ツリーの選択されている部分をヘッダー付きでクリップボードにコピーします
 * 
 * @param header ヘッダー
 * @param tree ツリー
 */
public static void copyTree(String[] header, Tree tree) {
    TreeItem[] treeItems = tree.getSelection();
    StringBuilder sb = new StringBuilder();
    sb.append(StringUtils.join(header, "\t"));
    sb.append("\r\n");
    for (TreeItem column : treeItems) {
        String[] columns = new String[header.length];
        for (int i = 0; i < header.length; i++) {
            columns[i] = column.getText(i);
        }
        sb.append(StringUtils.join(columns, "\t"));
        sb.append("\r\n");
    }
    Clipboard clipboard = new Clipboard(Display.getDefault());
    clipboard.setContents(new Object[] { sb.toString() }, new Transfer[] { TextTransfer.getInstance() });
}
 
Example 9
Source File: DatabaseExplorerDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private String getSchemaTable() {
  TreeItem ti[] = wTree.getSelection();
  if ( ti.length == 1 ) {
    // Get the parent.
    TreeItem parent = ti[ 0 ].getParentItem();
    if ( parent != null ) {
      String schemaName = parent.getText();
      String tableName = ti[ 0 ].getText();

      if ( ti[ 0 ].getItemCount() == 0 ) // No children, only the tables themselves...
      {
        String tab = null;
        if ( schemaName.equalsIgnoreCase( STRING_TABLES ) ||
          schemaName.equalsIgnoreCase( STRING_VIEWS ) ||
          schemaName.equalsIgnoreCase( STRING_SYNONYMS ) ||
          ( schemaName != null && schemaName.length() == 0 )
        ) {
          tab = tableName;
        } else {
          tab = dbMeta.getQuotedSchemaTableCombination( schemaName, tableName );
        }
        return tab;
      }
    }
  }
  return null;
}
 
Example 10
Source File: CapabilitySection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Removes the all feat item gui.
 *
 * @param editItem the edit item
 * @param column the column
 */
private void removeAllFeatItemGui(TreeItem editItem, int column) {
  TreeItem allFeatItem = getAllFeatItem(editItem);
  if (null == allFeatItem)
    // throw new InternalErrorCDE("invalid state");
    return; // happens when no allfeat is set
  allFeatItem.setText(column, "");
  String otherCol = allFeatItem.getText((column == INPUT_COL) ? OUTPUT_COL : INPUT_COL);
  if (null == otherCol || "".equals(otherCol))
    allFeatItem.dispose();
}
 
Example 11
Source File: FileUtility.java    From AndroidRobot with Apache License 2.0 5 votes vote down vote up
public static void loadOthersByProject(TreeItem root,Display display){
	File fileScript = new File(System.getProperty("user.dir") + 
			"/workspace/"+root.getText());
	File[] fileScripts = fileScript.listFiles();
	for(int i=0;i<fileScripts.length;i++){
		if(fileScripts[i] != null && !fileScripts[i].isDirectory()){
			TreeItem folder = new TreeItem(root, SWT.NONE);
			folder.setText(fileScripts[i].getName());
			folder.setImage(new Image(display, ClassLoader.getSystemResourceAsStream("icons/unknow.png")));
		}
	}
	
}
 
Example 12
Source File: SaveScreen.java    From AndroidRobot with Apache License 2.0 5 votes vote down vote up
private String getPathFromTree(TreeItem treeItem) {
    String path = treeItem.getText();
    TreeItem root = treeItem.getParentItem();
    while (root != null) {
        path = root.getText() + "\\" + path;
        root = root.getParentItem();
    }
    return path;
}
 
Example 13
Source File: SelectFolderDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
public void handleOK() {
  TreeItem[] ti = wTree.getSelection();
  if ( ti.length == 1 ) {
    TreeItem parent = ti[ 0 ].getParentItem();
    String fullpath = ti[ 0 ].getText();
    while ( parent != null ) {
      fullpath = parent.getText() + MailConnectionMeta.FOLDER_SEPARATOR + fullpath;
      parent = parent.getParentItem();
    }

    selection = fullpath;
    dispose();
  }
}
 
Example 14
Source File: ScriptValuesModDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void treeDblClick( Event event ) {
  StyledTextComp wScript = getStyledTextComp();
  Point point = new Point( event.x, event.y );
  TreeItem item = wTree.getItem( point );

  // Qualifikation where the Click comes from
  if ( item != null && item.getParentItem() != null ) {
    if ( item.getParentItem().equals( wTreeScriptsItem ) ) {
      setActiveCtab( item.getText() );
    } else if ( !item.getData().equals( "Function" ) ) {
      int iStart = wScript.getCaretOffset();
      int selCount = wScript.getSelectionCount(); // this selection will be replaced by wScript.insert
      iStart = iStart - selCount; // when a selection is already there we need to subtract the position
      if ( iStart < 0 ) {
        iStart = 0; // just safety
      }
      String strInsert = (String) item.getData();
      if ( strInsert.equals( "jsFunction" ) ) {
        strInsert = item.getText();
      }
      wScript.insert( strInsert );
      wScript.setSelection( iStart, iStart + strInsert.length() );
    }
  }
  /*
   * if (item != null && item.getParentItem()!=null && !item.getData().equals("Function")) { int iStart =
   * wScript.getCaretOffset(); String strInsert =(String)item.getData(); if(strInsert.equals("jsFunction")) strInsert
   * = (String)item.getText(); wScript.insert(strInsert); wScript.setSelection(iStart,iStart+strInsert.length()); }
   */
}
 
Example 15
Source File: ScriptValuesModDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void treeDblClick( Event event ) {
  StyledTextComp wScript = getStyledTextComp();
  Point point = new Point( event.x, event.y );
  TreeItem item = wTree.getItem( point );

  // Qualifikation where the Click comes from
  if ( item != null && item.getParentItem() != null ) {
    if ( item.getParentItem().equals( wTreeScriptsItem ) ) {
      setActiveCtab( item.getText() );
    } else if ( !item.getData().equals( "Function" ) ) {
      int iStart = wScript.getCaretOffset();
      int selCount = wScript.getSelectionCount(); // this selection will be replaced by wScript.insert
      iStart = iStart - selCount; // when a selection is already there we need to subtract the position
      if ( iStart < 0 ) {
        iStart = 0; // just safety
      }
      String strInsert = (String) item.getData();
      if ( strInsert.equals( "jsFunction" ) ) {
        strInsert = item.getText();
      }
      wScript.insert( strInsert );
      wScript.setSelection( iStart, iStart + strInsert.length() );
    }
  }
  /*
   * if (item != null && item.getParentItem()!=null && !item.getData().equals("Function")) { int iStart =
   * wScript.getCaretOffset(); String strInsert =(String)item.getData(); if(strInsert.equals("jsFunction")) strInsert
   * = (String)item.getText(); wScript.insert(strInsert); wScript.setSelection(iStart,iStart+strInsert.length()); }
   */
}
 
Example 16
Source File: AbstractSectionParm.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if is group.
 *
 * @param item the item
 * @return true, if is group
 */
// Note: rest of code considers NOT_IN_ANY_GROUP to be a kind of group
protected boolean isGroup(TreeItem item) {
  String s = item.getText();
  return s.startsWith(GROUP_HEADER) || s.startsWith(COMMON_GROUP_HEADER)
          || s.startsWith(NOT_IN_ANY_GROUP_HEADER);
}
 
Example 17
Source File: HopVfsFileDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private String getTreeItemPath( TreeItem item ) {
  String path = "/" + item.getText();
  TreeItem parentItem = item.getParentItem();
  while ( parentItem != null ) {
    path = "/" + parentItem.getText() + path;
    parentItem = parentItem.getParentItem();
  }
  String filename = item.getText( 0 );
  if ( StringUtils.isNotEmpty( filename ) ) {
    path += filename;
  }
  return path;
}
 
Example 18
Source File: SpoonSlave.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
protected void sniff() {
  TreeItem[] ti = wTree.getSelection();
  if ( ti.length == 1 ) {
    TreeItem treeItem = ti[0];
    String[] path = ConstUI.getTreeStrings( treeItem );

    // Make sure we're positioned on a step
    if ( path.length <= 2 ) {
      return;
    }

    String name = path[1];
    String step = path[2];
    String copy = treeItem.getText( 1 );

    EnterNumberDialog numberDialog = new EnterNumberDialog( shell, PropsUI.getInstance().getDefaultPreviewSize(),
      BaseMessages.getString( PKG, "SpoonSlave.SniffSizeQuestion.Title" ),
      BaseMessages.getString( PKG, "SpoonSlave.SniffSizeQuestion.Message" ) );
    int lines = numberDialog.open();
    if ( lines <= 0 ) {
      return;
    }

    EnterSelectionDialog selectionDialog = new EnterSelectionDialog( shell,
      new String[] { SniffStepServlet.TYPE_INPUT, SniffStepServlet.TYPE_OUTPUT, },
      BaseMessages.getString( PKG, "SpoonSlave.SniffTypeQuestion.Title" ),
      BaseMessages.getString( PKG, "SpoonSlave.SniffTypeQuestion.Message" ) );
    String type = selectionDialog.open( 1 );
    if ( type == null ) {
      return;
    }

    try {
      String xml = slaveServer.sniffStep( name, step, copy, lines, type );

      Document doc = XMLHandler.loadXMLString( xml );
      Node node = XMLHandler.getSubNode( doc, SniffStepServlet.XML_TAG );
      Node metaNode = XMLHandler.getSubNode( node, RowMeta.XML_META_TAG );
      RowMetaInterface rowMeta = new RowMeta( metaNode );

      int nrRows = Const.toInt( XMLHandler.getTagValue( node, "nr_rows" ), 0 );
      List<Object[]> rowBuffer = new ArrayList<Object[]>();
      for ( int i = 0; i < nrRows; i++ ) {
        Node dataNode = XMLHandler.getSubNodeByNr( node, RowMeta.XML_DATA_TAG, i );
        Object[] row = rowMeta.getRow( dataNode );
        rowBuffer.add( row );
      }

      PreviewRowsDialog prd = new PreviewRowsDialog( shell, new Variables(), SWT.NONE, step, rowMeta, rowBuffer );
      prd.open();
    } catch ( Exception e ) {
      new ErrorDialog( shell,
        BaseMessages.getString( PKG, "SpoonSlave.ErrorSniffingStep.Title" ),
        BaseMessages.getString( PKG, "SpoonSlave.ErrorSniffingStep.Message" ), e );
    }
  }
}
 
Example 19
Source File: RepositoryExplorerDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void renameInTree() {
  TreeItem[] ti = wTree.getSelection();
  if ( ti.length == 1 ) {
    // Get the parent.
    final TreeItem item = ti[0];

    int level = ConstUI.getTreeLevel( item );
    String[] text = ConstUI.getTreeStrings( item );

    int cat = getItemCategory( item );

    switch ( cat ) {
      case ITEM_CATEGORY_DATABASE:
        renameDatabase();
        break;
      case ITEM_CATEGORY_TRANSFORMATION:
        String name = item.getText();

        // The first 3 levels of text[] don't belong to the path to this transformation!
        String[] path = new String[level - 2];
        for ( int i = 0; i < path.length; i++ ) {
          path[i] = text[i + 2];
        }

        // Find the directory in the directory tree...
        RepositoryDirectoryInterface repdir = directoryTree.findDirectory( path );

        if ( repdir != null ) {
          renameTransformation( name, repdir );
        }
        break;

      case ITEM_CATEGORY_JOB:
        name = item.getText();

        // The first 3 levels of text[] don't belong to the path to this transformation!
        path = new String[level - 2];
        for ( int i = 0; i < path.length; i++ ) {
          path[i] = text[i + 2];
        }

        // Find the directory in the directory tree...
        repdir = directoryTree.findDirectory( path );

        if ( repdir != null ) {
          renameJob( name, repdir );
        }
        break;

      case ITEM_CATEGORY_USER:
        renameUser();
        break;

      default:
        break;
    }
  }
}
 
Example 20
Source File: ScriptValuesModDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void modifyCTabItem( TreeItem tItem, int iModType, String strOption ) {

    switch ( iModType ) {
      case DELETE_ITEM:
        CTabItem dItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( dItem != null ) {
          dItem.dispose();
          input.setChanged();
        }
        break;

      case RENAME_ITEM:
        CTabItem rItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( rItem != null ) {
          rItem.setText( strOption );
          input.setChanged();
          if ( rItem.getImage().equals( imageActiveScript ) ) {
            strActiveScript = strOption;
          } else if ( rItem.getImage().equals( imageActiveStartScript ) ) {
            strActiveStartScript = strOption;
          } else if ( rItem.getImage().equals( imageActiveEndScript ) ) {
            strActiveEndScript = strOption;
          }
        }
        break;
      case SET_ACTIVE_ITEM:
        CTabItem aItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( aItem != null ) {
          input.setChanged();
          strActiveScript = tItem.getText();
          for ( int i = 0; i < folder.getItemCount(); i++ ) {
            if ( folder.getItem( i ).equals( aItem ) ) {
              aItem.setImage( imageActiveScript );
            } else {
              folder.getItem( i ).setImage( imageInactiveScript );
            }
          }
        }
        break;
      default:
        break;
    }

  }