Java Code Examples for org.eclipse.swt.widgets.TreeItem#setData()
The following examples show how to use
org.eclipse.swt.widgets.TreeItem#setData() .
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: MainShell.java From RepDev with GNU General Public License v3.0 | 6 votes |
private void addSym() { int sym = SymLoginShell.symLogin(display, shell, -1); if (sym != -1) { boolean exists = false; for (TreeItem current : tree.getItems()) { if (current.getData() instanceof Integer && ((Integer) current.getData()) == sym) { current.setImage(RepDevMain.smallSymOnImage); exists = true; } } if (!exists) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText("Sym " + sym); item.setImage(RepDevMain.smallSymOnImage); item.setData(sym); new TreeItem(item, SWT.NONE).setText("Loading..."); } } }
Example 2
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 6 votes |
private void addFolder() { DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NONE); dialog.setMessage("Select a folder to mount in RepDev"); String dir; if ((dir = dialog.open()) != null) { boolean exists = false; for (TreeItem current : tree.getItems()) { if (current.getData() instanceof String && ((String) current.getData()).equals(dir)) exists = true; } if (!exists) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText(dir.substring(dir.lastIndexOf("\\"))); item.setImage(RepDevMain.smallFolderImage); item.setData(dir); new TreeItem(item, SWT.NONE).setText("Loading..."); Config.getMountedDirs().add(dir); } } }
Example 3
Source File: ProjectUtil.java From AndroidRobot with Apache License 2.0 | 6 votes |
public static TreeItem importProject(String path,Tree tree,Display display) throws Exception{ String project = readProjectName(path); Vector <IDeviceObject>vecDevices = readDevices(path); TreeItem root = new TreeItem(tree, SWT.NONE); root.setText(project); root.setImage(new Image(display, ClassLoader.getSystemResourceAsStream("icons/project.png"))); TreeItem devices = new TreeItem(root, SWT.NONE); devices.setText("Devices"); devices.setImage(new Image(display, ClassLoader.getSystemResourceAsStream("icons/devices.png"))); for(int i =0;i<vecDevices.size();i++){ TreeItem column = new TreeItem(devices, SWT.NONE); column.setText(vecDevices.get(i).name); column.setData("index",vecDevices.get(i).index); column.setData("sn",vecDevices.get(i).sn); column.setData("pixel",vecDevices.get(i).pixel); column.setData("name",vecDevices.get(i).name); column.setImage(new Image(display, ClassLoader.getSystemResourceAsStream("icons/disconn.png"))); } return root; }
Example 4
Source File: RepositoryDirectoryUI.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private static void createTreeItem( TreeItem parent, RepositoryElementMetaInterface repositoryObject ) { TreeItem tiObject = new TreeItem( parent, SWT.NONE ); tiObject.setData( repositoryObject ); if ( repositoryObject.getObjectType() == RepositoryObjectType.TRANSFORMATION ) { tiObject.setImage( GUIResource.getInstance().getImageTransRepo() ); } else if ( repositoryObject.getObjectType() == RepositoryObjectType.JOB ) { tiObject.setImage( GUIResource.getInstance().getImageJobRepo() ); } SimpleDateFormat simpleDateFormat = new SimpleDateFormat( DATE_FORMAT ); tiObject.setText( 0, Const.NVL( repositoryObject.getName(), "" ) ); tiObject.setText( 1, Const.NVL( repositoryObject.getObjectType().getTypeDescription(), "" ).toUpperCase() ); tiObject.setText( 2, Const.NVL( repositoryObject.getModifiedUser(), "" ) ); tiObject.setText( 3, repositoryObject.getModifiedDate() != null ? simpleDateFormat .format( repositoryObject.getModifiedDate() ) : "" ); tiObject.setText( 4, Const.NVL( repositoryObject.getDescription(), "" ) ); if ( repositoryObject.isDeleted() ) { tiObject.setForeground( GUIResource.getInstance().getColorRed() ); } }
Example 5
Source File: PluginHelpDialog.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
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 6
Source File: ExpressionTreeSupport.java From birt with Eclipse Public License 1.0 | 5 votes |
private TreeItem createSubTreeItem( TreeItem parent, Object element, IExpressionProvider provider ) { TreeItem item = new TreeItem( parent, SWT.NONE ); item.setText( provider.getDisplayText( element ) ); item.setImage( provider.getImage( element ) ); item.setData( ITEM_DATA_KEY_TOOLTIP, provider.getTooltipText( element ) ); item.setData( ITEM_DATA_KEY_TEXT, provider.getInsertText( element ) ); item.setData( ITEM_DATA_KEY_ENABLED, Boolean.TRUE ); return item; }
Example 7
Source File: CapabilitySection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Handle add lang. * * @param selItem the sel item * @param itemKind the item kind */ private void handleAddLang(TreeItem selItem, int itemKind) { if (itemKind == CS) selItem = selItem.getItems()[0]; // lang is 1st item in capability set else if (itemKind == LANG_ITEM) selItem = selItem.getParentItem(); else if (itemKind == TYPE || itemKind == SOFA) selItem = selItem.getParentItem().getItems()[0]; else if (itemKind == FEAT || itemKind == SOFA_ITEM) selItem = selItem.getParentItem().getParentItem().getItems()[0]; Capability c = getCapabilityFromTreeItem(selItem.getParentItem()); CommonInputDialog dialog = new CommonInputDialog( this, "Add Language", "Enter a two letter ISO-639 language code, followed optionally by a two-letter ISO-3166 country code (Examples: fr or fr-CA)", CommonInputDialog.LANGUAGE); if (dialogForLanguage(c, dialog) == Window.CANCEL) return; c.setLanguagesSupported(stringArrayAdd(c.getLanguagesSupported(), dialog.getValue())); // update GUI TreeItem lItem = new TreeItem(selItem, SWT.NONE); lItem.setData(LANG_TITLE); lItem.setText(NAME_COL, dialog.getValue()); selItem.setExpanded(true); pack04(); finishAction(); }
Example 8
Source File: CapabilitySection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Sets the gui sofa name. * * @param item the item * @param sofaName the sofa name * @param isInput the is input */ private void setGuiSofaName(TreeItem item, String sofaName, boolean isInput) { item.setData(SOFA_TITLE); item.setText(NAME_COL, sofaName); if (isInput) { item.setText(INPUT_COL, INPUT); item.setText(OUTPUT_COL, ""); } else { item.setText(OUTPUT_COL, OUTPUT); item.setText(INPUT_COL, ""); } }
Example 9
Source File: IndexSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Update index spec. * * @param item the item * @param ndx the ndx */ private void updateIndexSpec(TreeItem item, FsIndexDescription ndx) { item.setText(INDEX_NAME_COL, ndx.getLabel()); item.setText(INDEX_TYPE_COL, formatName(ndx.getTypeName())); item.setText(INDEX_KIND_COL, handleDefaultIndexKind(ndx.getKind())); item.setData(ndx); removeChildren(item); FsIndexKeyDescription[] keys = ndx.getKeys(); if (null != keys) for (int i = 0; i < keys.length; i++) { updateKeySpec(new TreeItem(item, SWT.NONE), keys[i]); } }
Example 10
Source File: ParameterDelegatesSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Adds the delegate to GUI. * * @param key the key * @param delegate the delegate */ private void addDelegateToGUI(String key, ResourceSpecifier delegate) { if (delegate instanceof AnalysisEngineDescription || delegate instanceof CasConsumerDescription || delegate instanceof FlowControllerDescription) { TreeItem d = new TreeItem(tree, SWT.NONE); d.setText(((delegate instanceof FlowControllerDescription) ? FLOWCTLR_HEADER : DELEGATE_HEADER) + key); d.setData(key); addDelegateGroupsToGUI(d, (ResourceCreationSpecifier) delegate); d.setExpanded(true); } }
Example 11
Source File: TypeSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * 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 12
Source File: ResourcePickerDialog.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Populate. * * @param parent the parent * @param resources the resources */ private void populate(TreeItem parent, IResource[] resources) { Arrays.sort(resources, resourceComparator); for (int i = 0; i < resources.length; i++) { TreeItem item = new TreeItem(parent, SWT.NULL); IResource r = resources[i]; item.setText(r.getName()); item.setData(r); if (r instanceof IContainer) { new TreeItem(item, SWT.NULL); } } }
Example 13
Source File: TreeManager.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void populateTreeItem( TreeItem childTreeItem, TreeNode treeNode ) { childTreeItem.setText( treeNode.getLabel() != null ? treeNode.getLabel() : "" ); childTreeItem.setImage( treeNode.getImage() ); childTreeItem.setData( treeNode.getData() ); childTreeItem.setForeground( treeNode.getForeground() ); childTreeItem.setBackground( treeNode.getBackground() ); childTreeItem.setFont( treeNode.getFont() ); treeNode.getData().forEach( childTreeItem::setData ); treeNodeItemMap.put( treeNode, childTreeItem ); }
Example 14
Source File: PluginHelpDialog.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
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 15
Source File: ExecutionContextLabelProvider.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected static TreeEditor createEditor(TreeItem currentItem) { TreeEditor editor = new TreeEditor(currentItem.getParent()); editor.grabVertical = true; editor.grabHorizontal = true; currentItem.setData(TreeEditorDisposeListener.EDITOR_DATA, editor); return editor; }
Example 16
Source File: TypeSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * 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 17
Source File: PageLoaderStrategyHelper.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * This method loads the paginated list by using the given page loader * {@link IPageLoader} and information about pagination from the given * controller {@link PageableController}. After loading paginated list * returned in a pagination structure {@link PageResult}, this method : * * <ul> * <li>update the total elements of the given controller * {@link PageableController}</li> * <li>refresh the given {@link Viewer} by replacing data with the new * paginated list.</li> * </ul> * * @param controller * the controller to use to load paginated list and update the * total elements. * @param viewer * the viewer to refresh with new paginated list. * @param pageLoader * the page loader used to load paginated list. * @pageContentProvider the page content provider to retrieves total * elements+paginated list from the page result * structure returned by the pageLoader. * @param handler * the page loader handler to observe before/after page loading * process. If null no observation is done. */ public static void loadPageAndAddItems(final PageableController controller, final Object parentElementOrTreePath, final TreeViewer viewer, final IPageLoader<?> pageLoader, final IPageContentProvider pageContentProvider, final IPageLoaderHandler<PageableController> handler) { Object page = loadPageAndUpdateTotalElements(controller, pageLoader, pageContentProvider, handler); if (page != null) { List<?> content = pageContentProvider.getPaginatedList(page); if (content != null && !content.isEmpty()) { viewer.add(parentElementOrTreePath, content.toArray()); int count = viewer.getTree().getItemCount(); if (count > 0) { TreeItem item = viewer.getTree().getItem(count - 1); item.setData(LazyItemsSelectionListener.LAST_ITEM_LOADED, true); } } } }
Example 18
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 4 votes |
private void newFileInProject() { FileDialog dialog; if (isCurrentItemLocal()) dialog = new FileDialog(shell, FileDialog.Mode.SAVE, getCurrentTreeDir()); else dialog = new FileDialog(shell, FileDialog.Mode.SAVE, getCurrentTreeSym()); ArrayList<SymitarFile> files = dialog.open(); if (files.size() > 0) { SymitarFile file = files.get(0); TreeItem[] selection = tree.getSelection(); if (selection.length != 1) return; TreeItem cur = selection[0]; while (cur != null && !(cur.getData() instanceof Project)) cur = cur.getParentItem(); if (cur == null) return; Project proj = (Project) cur.getData(); SessionError error = file.saveFile(""); if (error == SessionError.NONE) { if (!proj.hasFile(file)) { proj.addFile(file); TreeItem item = new TreeItem(cur, SWT.NONE); item.setText(file.getName()); item.setData(file); item.setImage(getFileImage(file)); if (proj.isLocal()) ProjectManager.saveProjects(proj.getDir()); else ProjectManager.saveProjects(proj.getSym()); } openFile(file); tree.notifyListeners(SWT.Selection, null); } } }
Example 19
Source File: RelPanel.java From Rel with Apache License 2.0 | 4 votes |
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); } } } } }
Example 20
Source File: ExecutionContextLabelProvider.java From statecharts with Eclipse Public License 1.0 | 4 votes |
protected static void manageEditorDisposal(TreeItem currentItem, TreeEditorDisposeListener listener) { listener.disposeTreeEditor(); listener.removeDisposeListener(); currentItem.addDisposeListener(listener); currentItem.setData(TreeEditorDisposeListener.LISTENER_DATA, listener); }