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

The following examples show how to use org.eclipse.swt.widgets.TreeItem#setText() . 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: AppEngineConfigWizardPage.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * The tree/externalSourceFolders/varibleSubstitution  must be already empty at this point
 */
private void fillExternalSourceFolders(Map<String, String> variableSubstitution, String[] libFoldersForPythonpath) {
    TreeItem item = new TreeItem(tree, SWT.NONE);

    item.setText(AppEngineConstants.GOOGLE_APP_ENGINE_VARIABLE + ": "
            + variableSubstitution.get(AppEngineConstants.GOOGLE_APP_ENGINE_VARIABLE));
    item.setImage(ImageCache.asImage(imageAppEngine));

    for (String file : libFoldersForPythonpath) {
        TreeItem subItem = new TreeItem(item, SWT.NONE);
        subItem.setText(file);
        subItem.setImage(ImageCache.asImage(imageSystemLib));
        item.setExpanded(true);

        externalSourceFolders.add(file);
    }
}
 
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: DeleteWarningDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the dialog area.
 * 
 * @param parent
 *            the parent
 */
protected Control createDialogArea( Composite parent )
{
	Composite composite = (Composite) super.createDialogArea( parent );

	new Label( composite, SWT.NONE ).setText( preString );
	Tree tree = new Tree( composite, SWT.NONE );
	tree.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	for ( Iterator itor = refrenceList.iterator( ); itor.hasNext( ); )
	{
		Object reference = itor.next( );
		TreeItem item = new TreeItem( tree, SWT.NONE );
		item.setText( DEUtil.getDisplayLabel( reference ) );
		item.setImage( ReportPlatformUIImages.getImage( reference ) );
	}
	new Label( composite, SWT.NONE ).setText( sufString );
	
	UIUtil.bindHelp( parent,IHelpContextIds.DELETE_WARNING_DIALOG_ID ); 

	return composite;
}
 
Example 4
Source File: TreeWithAddRemove.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @param pathAsString
 */
private void addTreeItem(String pathAsString) {
    if (pathAsString != null && pathAsString.trim().length() > 0) {

        // forbid duplicate selections
        TreeItem[] items = tree.getItems();
        for (int i = 0; i < items.length; i++) {
            if (items[i].getText().equals(pathAsString)) {
                return;
            }
        }

        TreeItem item = new TreeItem(tree, 0);
        item.setText(pathAsString);
        item.setImage(ImageCache.asImage(SharedUiPlugin.getImageCache().get(getImageConstant())));
    }
}
 
Example 5
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 6
Source File: CapabilitySection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Handle add type.
 *
 * @param selItem the sel item
 * @param itemKind the item kind
 */
private void handleAddType(TreeItem selItem, int itemKind) {
  if (itemKind == LANG || itemKind == TYPE || itemKind == SOFA)
    selItem = selItem.getParentItem();
  else if (itemKind == LANG_ITEM || itemKind == FEAT || itemKind == SOFA_ITEM)
    selItem = selItem.getParentItem().getParentItem();
  Capability c = getCapabilityFromTreeItem(selItem);
  AddCapabilityTypeDialog dialog = new AddCapabilityTypeDialog(this, c);
  if (dialog.open() == Window.CANCEL)
    return;

  for (int i = 0; i < dialog.types.length; i++) {

    if (dialog.inputs[i])
      c.addInputType(dialog.types[i], dialog.inputs[i]);

    if (dialog.outputs[i])
      c.addOutputType(dialog.types[i], dialog.outputs[i]);

    TreeItem item = new TreeItem(selItem, SWT.NONE);
    setGuiTypeName(item, dialog.types[i]);
    item.setText(INPUT_COL, dialog.inputs[i] ? INPUT : "");
    item.setText(OUTPUT_COL, dialog.outputs[i] ? OUTPUT : "");

    TreeItem fItem = new TreeItem(item, SWT.NONE);
    fItem.setData(FEAT_TITLE);
    fItem.setText(NAME_COL, ALL_FEATURES);
    fItem.setText(INPUT_COL, dialog.inputs[i] ? INPUT : "");
    fItem.setText(OUTPUT_COL, dialog.outputs[i] ? OUTPUT : "");

    item.setExpanded(true);
  }
  pack04();
  selItem.setExpanded(true);
  finishAction();
}
 
Example 7
Source File: AbstractSectionParm.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the group text.
 *
 * @param groupItem the group item
 * @param names the names
 */
protected void setGroupText(TreeItem groupItem, String names) {
  if (names.equals(COMMON_GROUP))
    groupItem.setText(COMMON_GROUP_HEADER);
  else if (names.equals(NOT_IN_ANY_GROUP))
    groupItem.setText(NOT_IN_ANY_GROUP_HEADER);
  else
    // next line formats the names with the right number of spaces and makes it
    // possible to do future equal compares
    groupItem.setText(GROUP_HEADER + groupNameArrayToString(groupNamesToArray(names)));
}
 
Example 8
Source File: TypeSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Handle add allowed value.
 *
 * @param parent the parent
 */
// disabled unless type having String as supertype is selected
public void handleAddAllowedValue(TreeItem parent) {
  boolean refreshNeeded = false;

  TypeDescription td = getTypeDescriptionFromTableTreeItem(parent);
  // guaranteed non-null - otherwise can't add an allowed value
  TypeDescription localTd = getLocalTypeDefinition(td);

  AddAllowedValueDialog dialog = new AddAllowedValueDialog(this, null);
  if (dialog.open() == Window.CANCEL) {
    return;
  }

  AllowedValue av = UIMAFramework.getResourceSpecifierFactory().createAllowedValue();
  allowedValueUpdate(av, dialog);
  addAllowedValue(localTd, av);

  if (!Utility.arrayContains(td.getAllowedValues(), av))
    addAllowedValue(td, (AllowedValue) av.clone());
  else
    refreshNeeded = true;

  // update the GUI
  if (refreshNeeded)
    refresh();
  else {
    TreeItem item = new TreeItem(parent, SWT.NONE);
    item.setText(NAME_COL, HEADER_ALLOWED_VALUE);
    item.setText(AV_COL, convertNull(av.getString()));
    item.setData(av);

    parent.setExpanded(true);
  }

  editor.addDirtyTypeName(td.getName());
  finishActionPack();
}
 
Example 9
Source File: TmfSynchronizationView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void updateTable() {
    fTree.setItemCount(0);
    if (fAlgoSync == null) {
        return;
    }

    for (Map.Entry<String, Map<String, Object>> entry : fAlgoSync.getStats().entrySet()) {
        TreeItem item = new TreeItem(fTree, SWT.NONE);
        item.setText(0, entry.getKey().toString());
        item.setText(1, entry.getValue().toString());

        for (Map.Entry<String, Object> subentry : entry.getValue().entrySet()) {
            TreeItem subitem = new TreeItem(item, SWT.NONE);
            subitem.setText(0, subentry.getKey().toString());
            subitem.setText(1, subentry.getValue().toString());
        }
    }

    /* Expand the tree items */
    for (int i = 0; i < fTree.getItemCount(); i++) {
        fTree.getItem(i).setExpanded(true);
    }

    for (TreeColumn column : fTree.getColumns()) {
        column.pack();
    }
}
 
Example 10
Source File: DBNodeUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public static void createTreeRoot( Tree tree, RootNode node, FilterConfig fc, String metadataBidiFormatStr,
		long timeout )
{
	tree.removeAll( );
	TreeItem dummyItem = new TreeItem( tree, SWT.NONE );
	dummyItem.setText( JdbcPlugin.getResourceString( "tablepage.refreshing" ) );
	
	if ( ! node.isChildrenPrepared( ) )
	{
		node.prepareChildren( fc, timeout );
	}
	tree.removeAll( );
	TreeItem root = new TreeItem( tree, SWT.NONE );
	root.setText( node.getDisplayName( null ) );
	root.setImage( node.getImage( ) );
	root.setData( node );
	IDBNode[] children = node.getChildren( );
	if ( children != null )
	{
		for ( IDBNode child : children )
		{
			//bidi_hcg: pass value of metadataBidiFormatStr to child element
			createTreeItem( root, child, metadataBidiFormatStr );
		}
	}
	root.setExpanded( true );
}
 
Example 11
Source File: AbstractSectionParm.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Takes an existing model parm and fills a pre-allocated treeItem. 3 callers:
 * addNewConfigurationParameter, alterExistingConfigurationParamater (editing), fill (bulk update
 * from refresh)
 *
 * @param item the item
 * @param parm the parm
 */
protected void fillParmItem(TreeItem item, ConfigurationParameter parm) {
  item.setText(parmGuiString(parm));

  // // set data if tree == parmsection tree
  // if (item.getParent() == parameterSectionTree)
  // back link used to find corresponding model parm decl from tree item
  item.setData(parm);
}
 
Example 12
Source File: PluginHelpDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
private void recurseTree(Element elementParent, TreeItem itemParent, String basePath) throws Exception {
	List<Element> children = elementParent.getChildren();
	for (int i = 0; i < children.size(); i++) {
		Element element = children.get(i);
		String url = element.getAttributeValue("url", "");
		TreeItem item = new TreeItem(itemParent, SWT.NONE);
		if (url.startsWith(".")) {
			// relative path
			url = CommonFunction.getAbsolutePath(basePath, url);
		}
		if (!url.toLowerCase().startsWith("http:")) {
			File f = new File(url);
			if (!f.exists() || !f.isAbsolute()) {
				url = CommonFunction.getAbsolutePath(basePath, url);
			}
		}
		item.setData(element.getName());
		if (element.getName().equals("toc")) {
			item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_TOC_CLOSED).createImage());
			item.setText(element.getText());
			if (url.startsWith(".")) {
				url = CommonFunction.getAbsolutePath(basePath, url);
			}
			loadToc(item, new File(url).getCanonicalPath());
		}
		if (element.getName().equals("book")) {
			item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_BOOK_CLOSED).createImage());
			item.setText(element.getAttributeValue("title"));
			recurseTree(element, item, basePath);
			if (!url.equals("")) {
				hashTable.put(item, new File(url).toURI().toURL().toString());
			}
		}
		if (element.getName().equals("item")) {
			item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_TOPIC).createImage());
			item.setText(element.getText());
			hashTable.put(item, new File(url).toURI().toURL().toString());
		}
	}
}
 
Example 13
Source File: DBNodeUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public static TreeItem createTreeItem( TreeItem parent, IDBNode node, String  metadataBidiFormatStr)
{
	TreeItem item = new TreeItem( parent, SWT.NONE );
	//bidi_hcg: pass value of metadataBidiFormatStr
	item.setText(  node.getDisplayName( metadataBidiFormatStr ) );
	item.setImage( node.getImage( ) );
	item.setData( node );
	item.setExpanded( false );
	if ( node instanceof ChildrenAllowedNode )
	{
		if ( ( (ChildrenAllowedNode) node ).isChildrenPrepared( ) )
		{
			//add all prepared children
			IDBNode[] children = ( (ChildrenAllowedNode) node ).getChildren( );
			if ( children != null )
			{
				for ( IDBNode child : children )
				{
					//bidi_hcg: pass value of metadataBidiFormatStr
					createTreeItem( item, child, metadataBidiFormatStr );
				}
			}
		}
		else
		{
			//create a dummy child to flag that this tree node may have children waiting to be explored
			new TreeItem(item, SWT.NONE);
		}
	}
	return item;
}
 
Example 14
Source File: RelPanel.java    From Rel with Apache License 2.0 5 votes vote down vote up
private void buildSubtree(String section, String imageName, String query, String displayAttributeName, Predicate<String> filter, DbTreeAction player, DbTreeAction editor, DbTreeAction creator, DbTreeAction dropper, DbTreeAction designer, DbTreeAction renamer, DbTreeAction exporter) {
	TreeItem root = getRoot(section, imageName, creator);
	if (query != null) {
		Tuples names = connection.getTuples(query);
		if (names != null)
			for (Tuple tuple: names) {
				String name = tuple.getAttributeValue(displayAttributeName).toString();
				if (filter.test(name)) {
					TreeItem item = new IconTreeItem(root, imageName, SWT.NONE);
					item.setText(name);
					item.setData(new DbTreeItem(section, player, editor, creator, dropper, designer, renamer, exporter, name));
				}
			}
	}
}
 
Example 15
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 16
Source File: PluginHelpDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private void recurseTree(Element elementParent, TreeItem itemParent, String basePath) throws Exception {
	List<Element> children = elementParent.getChildren();
	for (int i = 0; i < children.size(); i++) {
		Element element = children.get(i);
		String url = element.getAttributeValue("url", "");
		TreeItem item = new TreeItem(itemParent, SWT.NONE);
		if (url.startsWith(".")) {
			// relative path
			url = CommonFunction.getAbsolutePath(basePath, url);
		}
		if (!url.toLowerCase().startsWith("http:")) {
			File f = new File(url);
			if (!f.exists() || !f.isAbsolute()) {
				url = CommonFunction.getAbsolutePath(basePath, url);
			}
		}
		item.setData(element.getName());
		if (element.getName().equals("toc")) {
			item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_TOC_CLOSED).createImage());
			item.setText(element.getText());
			if (url.startsWith(".")) {
				url = CommonFunction.getAbsolutePath(basePath, url);
			}
			loadToc(item, new File(url).getCanonicalPath());
		}
		if (element.getName().equals("book")) {
			item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_BOOK_CLOSED).createImage());
			item.setText(element.getAttributeValue("title"));
			recurseTree(element, item, basePath);
			if (!url.equals("")) {
				hashTable.put(item, new File(url).toURI().toURL().toString());
			}
		}
		if (element.getName().equals("item")) {
			item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_TOPIC).createImage());
			item.setText(element.getText());
			hashTable.put(item, new File(url).toURI().toURL().toString());
		}
	}
}
 
Example 17
Source File: CapabilitySection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the language header gui.
 *
 * @param parent the parent
 * @return the table tree item
 */
private TreeItem createLanguageHeaderGui(TreeItem parent) {
  TreeItem langHdr = new TreeItem(parent, SWT.NONE);
  langHdr.setText(TITLE_COL, LANGS_TITLE);
  langHdr.setData(LANGS_TITLE);
  return langHdr;
}
 
Example 18
Source File: MainShell.java    From RepDev with GNU General Public License v3.0 4 votes vote down vote up
private void addProject() {
	int sym = -1;
	String dir = null;

	TreeItem[] selection = tree.getSelection();
	if (selection.length != 1)
		return;

	TreeItem cur = selection[0];
	while (cur.getParentItem() != null)
		cur = cur.getParentItem();

	if (cur.getData() instanceof Integer)
		sym = (Integer) cur.getData();
	else if (cur.getData() instanceof String)
		dir = (String) cur.getData();

	if( dir == null && sym != -1 && !RepDevMain.SYMITAR_SESSIONS.get(sym).isConnected() ) {
		MessageBox err = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR );
		err.setText("Can not create project");
		err.setMessage("Unable to create project when not connected to a sym");
		err.open();
		return;
	}

	String str = NewProjShell.askForName(display, shell);

	if (str != null) {
		Project proj = null;

		// TODO: Add error message for already existing projects
		if (cur.getData() instanceof Integer) {
			if (ProjectManager.containsProject(sym, str))
				return;

			proj = ProjectManager.createProject(str, sym);
		} else if (cur.getData() instanceof String) {
			if (ProjectManager.containsProject(dir, str))
				return;

			proj = ProjectManager.createProject(str, dir);
		}

		if (proj != null) {
			TreeItem item = new TreeItem(cur, SWT.NONE);
			item.setText(proj.getName());
			item.setData(proj);
			item.setImage(RepDevMain.smallProjectImage);
			new TreeItem(item, SWT.NONE).setText("Loading...");
		}
	}
}
 
Example 19
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 20
Source File: RelPanel.java    From Rel with Apache License 2.0 4 votes vote down vote up
private void buildSubtreeOperator(String whereSysStr, Predicate<String> filter) {
	String query =
		"EXTEND " +
		"  UNION {" +
		"	 ((sys.Operators UNGROUP Implementations) " + whereSysStr + ") {Name, Signature, ReturnsType, Definition}," +
		"	 ((EXTEND sys.OperatorsBuiltin: {Owner := 'Rel'}) " + whereSysStr + ") {ALL BUT Owner}" +
		"  }" +
		": {SigReturn := Signature || IF ReturnsType <> '' THEN ' RETURNS ' || ReturnsType ELSE '' END IF}" +
		"GROUP {ALL BUT Name} AS Impl " +
		"ORDER (ASC Name)";
	OperatorCreator creator = new OperatorCreator(this);
	String section = CATEGORY_OPERATOR;
	TreeItem root = getRoot(section, "flow_chart", creator);
	if (query != null) {
		Tuples names = connection.getTuples(query);
		if (names != null)
			for (Tuple tuple: names) {
				String name = tuple.getAttributeValue("Name").toString();
				if (filter.test(name)) {
					TreeItem itemHeading = new IconTreeItem(root, "flow_chart", SWT.NONE);
					itemHeading.setText(name);
					itemHeading.setData(new DbTreeItem(section, null, null, creator, null, null, null, null, name));
					int implementationCount = 0;
					String lastSignatureWithReturns = "";
					DbTreeItem lastitem = null;
					for (Tuple detailTuple: (Tuples)tuple.get("Impl")) {
						TreeItem item = new IconTreeItem(itemHeading, "flow_chart", SWT.NONE);
						lastSignatureWithReturns = detailTuple.getAttributeValue("SigReturn").toString();
						lastitem = new DbTreeItem(section, 
								new OperatorPlayer(this), 
								null,
								creator, 
								new OperatorDropper(this), 
								new OperatorDesigner(this), 
								null, 
								null,
								detailTuple.getAttributeValue("Signature").toString());
						item.setText(lastSignatureWithReturns);
						item.setData(lastitem);
						implementationCount++;
					}
					if (implementationCount == 0)
						itemHeading.dispose();
					else if (implementationCount == 1) {
						itemHeading.removeAll();
						itemHeading.setText(lastSignatureWithReturns);
						itemHeading.setData(lastitem);
					}
				}
			}
	}
}