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

The following examples show how to use org.eclipse.swt.widgets.TreeItem#setExpanded() . 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: 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 2
Source File: CapabilitySection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Handle add capability.
 */
private void handleAddCapability() {
  Capability newCset = addCapabilitySet();

  // update the GUI
  TreeItem item = new TreeItem(tt, SWT.NONE);
  item.setText(CAPABILITY_SET);
  item.setData(newCset);
  createLanguageHeaderGui(item);
  createSofaHeaderGui(item);

  item.setExpanded(true);
  tt.setSelection( item );
  if (tt.getItemCount() == 1)
    tt.getColumn(TITLE_COL).pack();
  finishAction();
}
 
Example 3
Source File: ExtnlResBindSection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Bind button - enabled only when one dependency is selected, and one External Resource, not
 * already bound to this key, is selected.
 */
private void handleBind() {
  TreeItem xrItem = tree.getSelection()[0];
  if (null != xrItem.getParentItem())
    xrItem = xrItem.getParentItem();
  ExternalResourceDescription xrd = getXRDescriptionFromTreeItem(xrItem);

  TableItem keyItem = resourceDependencySection.getTable().getSelection()[0];

  ExternalResourceBinding xrb = new ExternalResourceBinding_impl();
  String key = keyItem.getText(ResourceDependencySection.KEY_COL);
  xrb.setKey(key);
  xrb.setResourceName(xrd.getName());
  getResourceManagerConfiguration().addExternalResourceBinding(xrb);
  addBindingToGUI(xrItem, key, xrb);
  xrItem.setExpanded(true);
  keyItem.setText(0, "Bound");
  keyItem.getParent().getColumn(0).pack();
  setFileDirty();
}
 
Example 4
Source File: ResourcePickerDialog.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Setup resources by location.
 */
protected void setupResourcesByLocation() {
  resourcesUI.removeAll();
  resourcesUI.removeListener(SWT.Expand, this);    // remove to prevent triggering while setting up
  resourcesUI.removeListener(SWT.Selection, this); // remove to prevent triggering while setting up
  resourcesUIc1.setWidth(500);
  resourcesUIc2.setWidth(0);
  resourcesUI.setHeaderVisible(false);
  
  TreeItem topItem = new TreeItem(resourcesUI, SWT.NONE);
  topItem.setText("Workspace");
  IWorkspaceRoot root = TAEConfiguratorPlugin.getWorkspace().getRoot().getWorkspace().getRoot();
  try {
  IResource[] projects = root.members();
  populate(topItem, projects);
  } catch (CoreException e) {
    throw new InternalErrorCDE("unhandled exception", e);
  }
  topItem.setExpanded(true);
  resourcesUI.addListener(SWT.Expand, this);
  resourcesUI.addListener(SWT.Selection, this);
}
 
Example 5
Source File: ReportPropertySheetPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void restoreExpandedMemento( TreeItem root, MementoElement memento )
{
	if ( memento.getKey( ).equals( root.getText( ) ) )
	{
		if ( !root.getExpanded( ) )
			viewer.createChildren( root );
		if ( root.getItemCount( ) > 0 )
		{
			if ( !root.getExpanded( ) )
				root.setExpanded( true );
			MementoElement[] children = memento.getChildren( );
			for ( int i = 0; i < children.length; i++ )
			{
				MementoElement child = children[i];
				int index = ( (Integer) child.getValue( ) ).intValue( );
				if ( index >= 0 && index < root.getItemCount( ) )
				{
					TreeItem item = root.getItem( index );
					restoreExpandedMemento( item, child );
				}
			}
		}
	}
}
 
Example 6
Source File: ReportPropertySheetPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void restoreSelectedMemento( TreeItem root,
		MementoElement[] selectedPath )
{
	if ( selectedPath.length <= 1 )
		return;

	for ( int i = 1; i < selectedPath.length; i++ )
	{
		MementoElement element = selectedPath[i];
		if ( !root.getExpanded( ) )
		{
			viewer.createChildren( root );
			root.setExpanded( true );
		}
		if ( root.getItemCount( ) > ( (Integer) element.getValue( ) ).intValue( ) )
		{
			root = root.getItem( ( (Integer) element.getValue( ) ).intValue( ) );
		}
		else
			return;
	}
	viewer.getTree( ).setSelection( root );

}
 
Example 7
Source File: ModelTextFilter.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void expand(TreeViewer viewer) {
	TreeItem[] items = viewer.getTree().getItems();
	while (items != null && items.length > 0) {
		TreeItem next = items[0];
		next.setExpanded(true);
		for (int i = 1; i < items.length; i++)
			items[i].setExpanded(false);
		items = next.getItems();
		viewer.refresh();
	}
}
 
Example 8
Source File: RepositoryDirectoryUI.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Set the name of this directory on a TreeItem. Also, create children on this TreeItem to reflect the subdirectories.
 * In these sub-directories, fill in the available transformations from the repository.
 *
 * @param ti
 *          The TreeItem to set the name on and to create the subdirectories
 * @param rep
 *          The repository
 * @param objectMap
 *          The tree path to repository object mapping to populate.
 * @param dircolor
 *          The color in which the directories will be drawn.
 * @param sortPosition
 *          The sort position
 * @param ascending
 *          The ascending flag
 * @param getTransformations
 *          Include transformations in the tree or not
 * @param getJobs
 *          Include jobs in the tree or not
 * @throws KettleDatabaseException
 */
public static void getTreeWithNames( TreeItem ti, Repository rep, Color dircolor, int sortPosition,
  boolean includeDeleted, boolean ascending, boolean getTransformations, boolean getJobs,
  RepositoryDirectoryInterface dir, String filterString, Pattern pattern ) throws KettleDatabaseException {
  ti.setText( dir.getName() );
  ti.setData( dir );
  ti.setData( "isFolder", true );

  // First, we draw the directories
  List<RepositoryDirectoryInterface> children = dir.getChildren();
  Collections.sort( children, new Comparator<RepositoryDirectoryInterface>() {
    @Override
    public int compare( RepositoryDirectoryInterface o1, RepositoryDirectoryInterface o2 ) {
      return o1.getName().compareToIgnoreCase( o2.getName() );
    }
  } );
  for ( int i = 0; i < children.size(); i++ ) {
    RepositoryDirectory subdir = (RepositoryDirectory) children.get( i );
    TreeItem subti = new TreeItem( ti, SWT.NONE );
    subti.setImage( GUIResource.getInstance().getImageFolder() );
    subti.setData( "isFolder", true );
    getTreeWithNames(
      subti, rep, dircolor, sortPosition, includeDeleted, ascending, getTransformations, getJobs, subdir,
      filterString, pattern );
  }

  List<RepositoryElementMetaInterface> repositoryObjects =
      loadRepositoryObjects( dir, getTransformations, getJobs, rep );

  // Sort the directory list appropriately...
  RepositoryObject.sortRepositoryObjects( repositoryObjects, sortPosition, ascending );

  addToTree( ti, filterString, pattern, repositoryObjects );

  ti.setExpanded( dir.isRoot() );
}
 
Example 9
Source File: MainShell.java    From RepDev with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Expands or Collapses the item passed to it on the tree
 * 
 * @param item
 */
private void doTree(TreeItem item) {
	item.setExpanded(!item.getExpanded());

	if (item.getExpanded()) {
		Event e = new Event();
		e.item = item;
		tree.notifyListeners(SWT.Expand, e);
	}
}
 
Example 10
Source File: ExtnlResBindSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the external resource description to GUI.
 *
 * @param xrd the xrd
 * @param bindings the bindings
 */
private void addExternalResourceDescriptionToGUI(ExternalResourceDescription xrd,
        ExternalResourceBinding[] bindings) {
  TreeItem item = new TreeItem(tree, SWT.NONE);
  fillXrdItem(item, xrd);
  fillBindings(item, xrd, bindings);
  item.setExpanded(true);
}
 
Example 11
Source File: CapabilitySection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public void refresh() {
  super.refresh();
  sofaMapSection = editor.getCapabilityPage().getSofaMapSection();
  tt.getParent().setRedraw(false);
  tt.removeAll();

  Capability[] cs = getCapabilities();
  if (null != cs) {
    for (int i = 0; i < cs.length; i++) {
      TreeItem item = new TreeItem(tt, SWT.NONE);
      item.setText(TITLE_COL, CAPABILITY_SET);
      item.setData(cs[i]);
      tt.setSelection( item ); // set default selection
      fillCapability(item, cs[i]);
      // if (0 == i) {
      item.setExpanded(true);
      TreeItem[] types = item.getItems();
      if (types != null)
        for (int j = 0; j < types.length; j++) {
          types[j].setExpanded(true);
        }
      // }
    }
  }
  packTree(tt);
  enable();
  tt.getParent().setRedraw(true);
}
 
Example 12
Source File: TypeSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the type to GUI.
 *
 * @param td the td
 */
private void addTypeToGUI(TypeDescription td) {
  TreeItem item = new TreeItem(tt, SWT.NONE);
  item.setText(NAME_COL, formatName(td.getName()));
  item.setText(SUPER_COL, formatName(td.getSupertypeName()));
  item.setData(td);
  setItemColor(item, isLocalType(td));

  FeatureDescription[] features = td.getFeatures();
  addFeaturesToGui(td, item, features);

  TypeDescription builtInTd = getBuiltInTypeDescription(td);
  if (null != builtInTd) {
    FeatureDescription[] additionalBuiltInFeatures = setDifference(builtInTd.getFeatures(), td
            .getFeatures());
    addFeaturesToGui(td, item, additionalBuiltInFeatures);
  }

  AllowedValue[] avs = td.getAllowedValues();
  if (null != avs) {
    for (int i = 0; i < avs.length; i++) {
      TreeItem avItem = new TreeItem(item, SWT.NONE);
      avItem.setText(NAME_COL, HEADER_ALLOWED_VALUE);
      avItem.setText(AV_COL, convertNull(avs[i].getString()));
      avItem.setData(avs[i]);
      setItemColor(avItem, null != getLocalAllowedValue(td, avs[i]));
    }
  }
  // No built-ins have "allowed values" so we don't have to add any
  item.setExpanded(true);
}
 
Example 13
Source File: TreeManager.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void setExpanded( TreeNode treeNode ) {
  TreeItem treeItem = treeNodeItemMap.get( treeNode );
  if ( treeItem != null ) {
    treeItem.setExpanded( treeNode.isExpanded() );
    for ( TreeNode childTreeNode : treeNode.getChildren() ) {
      setExpanded( childTreeNode );
    }
  }
}
 
Example 14
Source File: ColumnChooserDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void expandAllLeaves() {
	List<TreeItem> allLeaves = ArrayUtil.asList(selectedTree.getItems());

	for (TreeItem leaf : allLeaves) {
		if(isColumnGroupLeaf(leaf)){
			ColumnGroupEntry columnGroupEntry = (ColumnGroupEntry) leaf.getData();
			leaf.setExpanded(! columnGroupEntry.isCollapsed());
		}
	}
}
 
Example 15
Source File: SelectVisibleColumnDialog.java    From logbook with MIT License 5 votes vote down vote up
/**
 * Create contents of the dialog.
 */
private void createContents() {
    this.shell = new Shell(this.getParent(), SWT.SHELL_TRIM | SWT.PRIMARY_MODAL);
    this.shell.setSize(300, 275);
    this.shell.setText("列の表示非表示");
    this.shell.setLayout(new FillLayout(SWT.HORIZONTAL));

    // ヘッダー
    String[] header = Stream.of(this.table.getColumns()).map(c -> c.getText()).toArray(String[]::new);
    // カラム設定を取得
    boolean[] visibles = AppConfig.get().getVisibleColumnMap().get(this.clazz.getName());
    if ((visibles == null) || (visibles.length != header.length)) {
        visibles = new boolean[header.length];
        Arrays.fill(visibles, true);
        AppConfig.get().getVisibleColumnMap().put(this.clazz.getName(), visibles);
    }

    Tree tree = new Tree(this.shell, SWT.BORDER | SWT.CHECK);

    for (int i = 1; i < header.length; i++) {
        TreeItem column = new TreeItem(tree, SWT.CHECK);
        column.setText(header[i]);
        column.setChecked(visibles[i]);
        column.setExpanded(true);
    }
    this.shell.addShellListener(new TreeShellAdapter(tree, visibles));
}
 
Example 16
Source File: DatabaseExplorerDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void expandAllItems( TreeItem[] treeitems, boolean expand ) {
  for ( TreeItem item : treeitems ) {
    item.setExpanded( expand );
    if ( item.getItemCount() > 0 ) {
      expandAllItems( item.getItems(), expand );
    }
  }
}
 
Example 17
Source File: HopVfsFileDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void refreshBrowser() {
  String filename = wFilename.getText();
  if ( StringUtils.isEmpty( filename ) ) {
    return;
  }

  // Browse to the selected file location...
  //
  try {
    activeFileObject = HopVfs.getFileObject( filename );
    if ( activeFileObject.isFolder() ) {
      activeFolder = activeFileObject;
    } else {
      activeFolder = activeFileObject.getParent();
    }
    wBrowser.removeAll();

    fileObjectsMap = new HashMap<>();

    TreeItem parentFolderItem = new TreeItem( wBrowser, SWT.NONE );
    parentFolderItem.setImage( GuiResource.getInstance().getImageFolder() );
    parentFolderItem.setText( activeFolder.getName().getBaseName() );
    fileObjectsMap.put( getTreeItemPath( parentFolderItem ), activeFolder );

    populateFolder( activeFolder, parentFolderItem );

    parentFolderItem.setExpanded( true );
  } catch ( Throwable e ) {
    showError( "Error browsing to location: " + filename, e );
  }

}
 
Example 18
Source File: FeedbackDialog.java    From Rel with Apache License 2.0 4 votes vote down vote up
private void setupTreeItem(TreeItem item, String text) {
	item.setText(text);
	item.setChecked(true);
	item.setExpanded(true);
}
 
Example 19
Source File: BattleAggDialog.java    From logbook with MIT License 4 votes vote down vote up
/**
 * テーブルをリロードする
 */
private void reloadTable() {
    this.disposeTableBody();
    boolean first = true;
    Map<BattleAggUnit, BattleAggUnitDto> aggMap = this.load();
    for (Entry<BattleAggUnit, BattleAggUnitDto> entry : aggMap.entrySet()) {
        BattleAggUnitDto dto = entry.getValue();
        BattleAggDetailsDto total = dto.getTotal();

        TreeItem root = new TreeItem(this.tree, SWT.NONE);
        // 合計
        root.setText(new String[] { entry.getKey().toString(), Integer.toString(total.getStart()),
                Integer.toString(total.getWin()), Integer.toString(total.getS()), Integer.toString(total.getA()),
                Integer.toString(total.getB()), Integer.toString(total.getC()), Integer.toString(total.getD()) });
        // ボス
        TreeItem boss = new TreeItem(root, SWT.NONE);
        boss.setText(new String[] { "ボス", "-", Integer.toString(total.getBossWin()),
                Integer.toString(total.getBossS()), Integer.toString(total.getBossA()),
                Integer.toString(total.getBossB()), Integer.toString(total.getBossC()),
                Integer.toString(total.getBossD()) });
        // 海域毎
        for (Entry<String, BattleAggDetailsDto> areaEntry : dto.getAreaDetails()) {
            BattleAggDetailsDto area = areaEntry.getValue();

            TreeItem sub = new TreeItem(root, SWT.NONE);
            sub.setText(new String[] { areaEntry.getKey(), Integer.toString(area.getStart()),
                    Integer.toString(area.getWin()), Integer.toString(area.getS()), Integer.toString(area.getA()),
                    Integer.toString(area.getB()), Integer.toString(area.getC()), Integer.toString(area.getD()) });
            // ボス
            TreeItem subBoss = new TreeItem(sub, SWT.NONE);
            subBoss.setText(new String[] { "ボス", "-",
                    Integer.toString(area.getBossWin()), Integer.toString(area.getBossS()),
                    Integer.toString(area.getBossA()), Integer.toString(area.getBossB()),
                    Integer.toString(area.getBossC()), Integer.toString(area.getBossD()) });
        }
        if (first)
            root.setExpanded(true);
        first = false;
    }
    this.packTableHeader();
}
 
Example 20
Source File: ParameterSection.java    From uima-uimaj with Apache License 2.0 3 votes vote down vote up
/**
 * called from add Override action.
 *
 * @param override the override
 * @param parent the parent
 * @param cp the cp
 */
private void addOverride(String override, TreeItem parent, ConfigurationParameter cp) {
  cp.setOverrides(addOverrideToArray(cp.getOverrides(), override));
  addOverrideToGUI(parent, override);
  parent.setExpanded(true);
  commonActionFinish();
}