Java Code Examples for org.eclipse.swt.widgets.TreeItem#setImage()
The following examples show how to use
org.eclipse.swt.widgets.TreeItem#setImage() .
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 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 2
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 3
Source File: AppEngineConfigWizardPage.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * 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 4
Source File: ScriptDialog.java From hop with Apache License 2.0 | 5 votes |
private void modifyScriptTree( CTabItem ctabitem, int iModType ) { switch ( iModType ) { case DELETE_ITEM: TreeItem dItem = getTreeItemByName( ctabitem.getText() ); if ( dItem != null ) { dItem.dispose(); input.setChanged(); } break; case ADD_ITEM: TreeItem item = new TreeItem( wTreeScriptsItem, SWT.NULL ); item.setImage( imageActiveScript ); item.setText( ctabitem.getText() ); input.setChanged(); break; case RENAME_ITEM: input.setChanged(); break; case SET_ACTIVE_ITEM: input.setChanged(); break; default: break; } }
Example 5
Source File: UserDefinedJavaClassDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void modifyTabTree( CTabItem ctabitem, TabActions action ) { switch ( action ) { case DELETE_ITEM: TreeItem dItem = getTreeItemByName( ctabitem.getText() ); if ( dItem != null ) { dItem.dispose(); input.setChanged(); } break; case ADD_ITEM: TreeItem item = new TreeItem( wTreeClassesItem, SWT.NULL ); item.setImage( imageActiveScript ); item.setText( ctabitem.getText() ); input.setChanged(); break; case RENAME_ITEM: input.setChanged(); break; case SET_ACTIVE_ITEM: input.setChanged(); break; default: break; } }
Example 6
Source File: ExpressionTreeSupport.java From birt with Eclipse Public License 1.0 | 5 votes |
private TreeItem createSubFolderItem( 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 ) ); return item; }
Example 7
Source File: ExpressionTreeSupport.java From birt with Eclipse Public License 1.0 | 5 votes |
private TreeItem createTopTreeItem( Tree tree, Object element, IExpressionProvider provider ) { TreeItem item = new TreeItem( tree, SWT.NONE ); item.setText( provider.getDisplayText( element ) ); item.setImage( provider.getImage( element ) ); item.setData( ITEM_DATA_KEY_TOOLTIP, provider.getTooltipText( element ) ); return item; }
Example 8
Source File: ExpressionTreeSupport.java From birt with Eclipse Public License 1.0 | 5 votes |
private TreeItem createSubTreeItem( TreeItem parent, String text, Image image, String textData, String toolTip, boolean isEnabled ) { TreeItem item = new TreeItem( parent, SWT.NONE ); item.setText( text ); if ( image != null ) { item.setImage( image ); } item.setData( ITEM_DATA_KEY_TOOLTIP, toolTip ); item.setData( ITEM_DATA_KEY_TEXT, textData ); item.setData( ITEM_DATA_KEY_ENABLED, Boolean.valueOf( isEnabled ) ); return item; }
Example 9
Source File: ExpressionTreeSupport.java From birt with Eclipse Public License 1.0 | 5 votes |
private TreeItem createTopTreeItem( Tree parent, String text, int index ) { TreeItem item = new TreeItem( parent, SWT.NONE, index ); item.setText( text ); item.setImage( IMAGE_FOLDER ); item.setData( ITEM_DATA_KEY_TOOLTIP, "" );//$NON-NLS-1$ return item; }
Example 10
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 11
Source File: DBNodeUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
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 12
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 13
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 14
Source File: RepositoryDirectoryUI.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * Gets a directory tree on a TreeItem to work with. * * @param ti * The TreeItem to set the directory tree on * @param dircolor * The color of the directory tree item. */ public static void getDirectoryTree( TreeItem ti, Color dircolor, RepositoryDirectoryInterface dir ) { ti.setText( dir.getName() ); ti.setForeground( dircolor ); // First, we draw the directories for ( int i = 0; i < dir.getNrSubdirectories(); i++ ) { RepositoryDirectory subdir = dir.getSubdirectory( i ); TreeItem subti = new TreeItem( ti, SWT.NONE ); subti.setImage( GUIResource.getInstance().getImageFolder() ); getDirectoryTree( subti, dircolor, subdir ); } }
Example 15
Source File: ScriptDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void modifyScriptTree( CTabItem ctabitem, int iModType ) { switch ( iModType ) { case DELETE_ITEM: TreeItem dItem = getTreeItemByName( ctabitem.getText() ); if ( dItem != null ) { dItem.dispose(); input.setChanged(); } break; case ADD_ITEM: TreeItem item = new TreeItem( wTreeScriptsItem, SWT.NULL ); item.setImage( imageActiveScript ); item.setText( ctabitem.getText() ); input.setChanged(); break; case RENAME_ITEM: input.setChanged(); break; case SET_ACTIVE_ITEM: input.setChanged(); break; default: break; } }
Example 16
Source File: RunConfigurationViewTreeExtension.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private TreeItem createTreeItem( TreeItem parent, String text, Image image, int index, boolean disabled ) { TreeItem item = index == -1 ? new TreeItem( parent, SWT.NONE ) : new TreeItem( parent, SWT.NONE, index ); if ( disabled ) { item.setForeground( getDisabledColor() ); } item.setText( text ); item.setImage( image ); return item; }
Example 17
Source File: RepositoryDirectoryUI.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * 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 18
Source File: HopVfsFileDialog.java From hop with Apache License 2.0 | 5 votes |
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 19
Source File: SpoonSlave.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private synchronized void refreshView() { if ( wTree.isDisposed() ) { return; } if ( refreshBusy ) { return; } refreshBusy = true; if ( log.isDetailed() ) { log.logDetailed( "Refresh" ); } transParentItem.removeAll(); jobParentItem.removeAll(); wText.setText( "" ); // Determine the transformations on the slave servers try { slaveServerStatus = slaveServer.getStatus(); } catch ( Exception e ) { slaveServerStatus = new SlaveServerStatus( "Error contacting server" ); slaveServerStatus.setErrorDescription( Const.getStackTracker( e ) ); if ( log.isDebug() ) { log.logDebug( slaveServerStatus.getErrorDescription() ); } wText.setText( setExceptionMessage( e ) ); } List<SlaveServerTransStatus> transStatusList = slaveServerStatus.getTransStatusList(); for ( SlaveServerTransStatus transStatus : transStatusList ) { TreeItem transItem = new TreeItem( transParentItem, SWT.NONE ); transItem.setText( 0, transStatus.getTransName() ); transItem.setText( 9, transStatus.getStatusDescription() ); transItem.setText( 13, Const.NVL( transStatus.getId(), "" ) ); transItem.setText( 14, Const.NVL( XMLHandler.date2string( transStatus.getLogDate() ), "" ) ); transItem.setImage( GUIResource.getInstance().getImageTransGraph() ); transItem.setData( "transStatus", transStatus ); } for ( int i = 0; i < slaveServerStatus.getJobStatusList().size(); i++ ) { SlaveServerJobStatus jobStatus = slaveServerStatus.getJobStatusList().get( i ); TreeItem jobItem = new TreeItem( jobParentItem, SWT.NONE ); jobItem.setText( 0, jobStatus.getJobName() ); jobItem.setText( 9, jobStatus.getStatusDescription() ); jobItem.setText( 13, Const.NVL( jobStatus.getId(), "" ) ); jobItem.setText( 14, Const.NVL( XMLHandler.date2string( jobStatus.getLogDate() ), "" ) ); jobItem.setImage( GUIResource.getInstance().getImageJobGraph() ); jobItem.setData( "jobStatus", jobStatus ); } TreeMemory.setExpandedFromMemory( wTree, STRING_SLAVE_LOG_TREE_NAME + slaveServer.toString() ); TreeUtil.setOptimalWidthOnColumns( wTree ); refreshBusy = false; }
Example 20
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 4 votes |
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..."); } } }