Treeview structure
how to create treeview structure using java........like a hierarchy of folder stored in hard disk. does TreeMap class meets the objective..?
I'm guessing you mean a graphical tree. TreeMap is a data structure, so not what you're after. What you want is a JTree
Similar Messages
-
Hierarchical treeview structure in Reports
Hi,
I am working with an MNC, can anybody help me out by valuable guidelines in doing an hierarchical treeview structure in Reports.
Your early response would b helpful to me.
Bye
PavanHI
see this site you wil find lots of examples
http://www.sapdev.co.uk/reporting/alv/alvtree.htm
The ALV tree report produces uses OBJECT METHOD functionality in-order to produce a
tree structured ALV output.
The creation of an ALVtree report first requires the creation of a simple program to build the ALV
details such as the fieldcatalog and to call a screen which will be used to display the ALVTree.
The screen should be created with a 'custom control' where you wish the ALVtree report to appear.
For the following example it will have the name 'SCREEN_CONTAINER'.
<b>Creation of Main Program code, Data declaration and screen call</b>
*& Report ZDEMO_ALVTREE *
*& Example of a simple ALV Grid Report *
*& The basic requirement for this demo is to display a number of *
*& fields from the EKPO and EKKO table in a tree structure. *
Amendment History *
REPORT zdemo_alvgrid .
*Data Declaration
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
it_ekpo TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
it_emptytab TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko,
wa_ekpo TYPE t_ekko.
DATA: ok_code like sy-ucomm, "OK-Code
save_ok like sy-ucomm.
*ALV data declarations
DATA: fieldcatalog TYPE lvc_t_fcat WITH HEADER LINE.
DATA: gd_fieldcat TYPE lvc_t_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv.
*ALVtree data declarations
CLASS cl_gui_column_tree DEFINITION LOAD.
CLASS cl_gui_cfw DEFINITION LOAD.
DATA: gd_tree TYPE REF TO cl_gui_alv_tree,
gd_hierarchy_header TYPE treev_hhdr,
gd_report_title TYPE slis_t_listheader,
gd_logo TYPE sdydo_value,
gd_variant TYPE disvariant.
*Create container for alv-tree
DATA: l_tree_container_name(30) TYPE c,
l_custom_container TYPE REF TO cl_gui_custom_container.
*Includes
*INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules
*INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules
*INCLUDE ZDEMO_ALVTREEF01. "ABAP Subroutines(FORMS)
*Start-of-selection.
START-OF-SELECTION.
ALVtree setup data
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM build_hierarchy_header CHANGING gd_hierarchy_header.
PERFORM build_report_title USING gd_report_title gd_logo.
PERFORM build_variant.
Display ALVtree report
call screen 100.
*& Form DATA_RETRIEVAL
Retrieve data into Internal tables
FORM data_retrieval.
SELECT ebeln
UP TO 10 ROWS
FROM ekko
INTO corresponding fields of TABLE it_ekko.
loop at it_ekko into wa_ekko.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
FROM ekpo
appending TABLE it_ekpo
where ebeln eq wa_ekko-ebeln.
endloop.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
Please not there are a number of differences between the structure of
ALVtree fieldcatalogs and ALVgrid fieldcatalogs.
For example the field seltext_m is replace by scrtext_m in ALVtree.
fieldcatalog-fieldname = 'EBELN'. "Field name in itab
fieldcatalog-scrtext_m = 'Purchase Order'. "Column text
fieldcatalog-col_pos = 0. "Column position
fieldcatalog-outputlen = 15. "Column width
fieldcatalog-emphasize = 'X'. "Emphasize (X or SPACE)
fieldcatalog-key = 'X'. "Key Field? (X or SPACE)
fieldcatalog-do_sum = 'X'. "Sum Column?
fieldcatalog-no_zero = 'X'. "Don't display if zero
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-scrtext_m = 'PO Iten'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-scrtext_m = 'Status'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-scrtext_m = 'Item change date'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-scrtext_m = 'Material Number'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-scrtext_m = 'PO quantity'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-scrtext_m = 'Order Unit'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-scrtext_m = 'Net Price'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 7.
fieldcatalog-datatype = 'CURR'.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-scrtext_m = 'Price Unit'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
ENDFORM. " BUILD_LAYOUT
*& Form build_hierarchy_header
build hierarchy-header-information
-->P_L_HIERARCHY_HEADER structure for hierarchy-header
FORM build_hierarchy_header CHANGING
p_hierarchy_header TYPE treev_hhdr.
p_hierarchy_header-heading = 'Hierarchy Header'(013).
p_hierarchy_header-tooltip = 'This is the Hierarchy Header !'(014).
p_hierarchy_header-width = 30.
p_hierarchy_header-width_pix = ''.
ENDFORM. " build_hierarchy_header
*& Form BUILD_REPORT_TITLE
Build table for ALVtree header
<-> p1 Header details
<-> p2 Logo value
FORM build_report_title CHANGING
pt_report_title TYPE slis_t_listheader
pa_logo TYPE sdydo_value.
DATA: ls_line TYPE slis_listheader,
ld_date(10) TYPE c.
List Heading Line(TYPE H)
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-key "Not Used For This Type(H)
ls_line-info = 'PO ALVTree Display'.
APPEND ls_line TO pt_report_title.
Status Line(TYPE S)
ld_date(2) = sy-datum+6(2).
ld_date+2(1) = '/'.
ld_date3(2) = sy-datum4(2).
ld_date+5(1) = '/'.
ld_date+6(4) = sy-datum(4).
ls_line-typ = 'S'.
ls_line-key = 'Date'.
ls_line-info = ld_date.
APPEND ls_line TO pt_report_title.
Action Line(TYPE A)
CLEAR ls_line.
ls_line-typ = 'A'.
CONCATENATE 'Report: ' sy-repid INTO ls_line-info SEPARATED BY space.
APPEND ls_line TO pt_report_title.
ENDFORM.
*& Form BUILD_VARIANT
Build variant
form build_variant.
Set repid for storing variants
gd_variant-report = sy-repid.
endform. " BUILD_VARIANT
<b>Creation of 'INCLUDES' to store ALVtree code</b>
Three includes need to be created in-order to store the ABAP code required for the ALVtree report.
Typically these will be one for the PBO modules, one for PAI modules and one for the subroutines(FORMs):
*Includes
include zdemo_alvtreeo01. "Screen PBO Modules
include zdemo_alvtreei01. "Screen PAI Modules
include zdemo_alvtreef01. "ABAP Subroutines(FORMS)
If you are using the code provide within the ALVtree section of this web site simply create the includes by
un-commenting the 'Includes' section within the code(see below) and double clicking on the name
i.e. 'zdemo_alvtreeo01'. Obviously these can be renamed.
*Includes
*include zdemo_alvtreeo01. "Screen PBO Modules
*include zdemo_alvtreei01. "Screen PAI Modules
*include zdemo_alvtreef01. "ABAP Subroutines(FORMS)
*Start-of-selection.
start-of-selection.
<b>Create Screen along with PBO and PAI modules for screen</b>
The next step is to create screen 100, to do this double click on the '100' within the call screen
command(Call screen 100.). Enter short description and select 'Normal' as screen type.
To create the PBO and PAI modules insert that code below into the screen's flow logic. Much of this code
should automatically have been inserted during screen creation but with the module lines commented out.
Simple remove the comments and double click the module name(STATUS_0100 and
USER_COMMAND_0100) in-order to create them, this will display the perform/module creation screen.
The MODULES are usually created within two includes one ending in 'O01' for PBO modules and
one ending in 'I01' for PAI modules(See code below).
Please note in order for these includes to be displayed on the creation screen they need to have be
created along with the following lines of code added to the main prog(see previous step):
INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules
INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules
Otherwise use the 'New Include' entry and SAP will add the necassary line for you.
Screen flow logic code
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
***INCLUDE Z......O01 .
*& Module STATUS_0100 OUTPUT
PBO Module
module status_0100 output.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
endmodule. " STATUS_0100 OUTPUT
***INCLUDE Z......I01 .
*& Module USER_COMMAND_0100 INPUT
PAI Module
module user_command_0100 input.
endmodule. " USER_COMMAND_0100 INPUT
<b>Define OK CODE(SY-UCOMM) variable</b>
In order to define the OK CODE you must fist declare a variable of type SY-UCOM and then insert this
variable into the OK code declaration within the element list (see screen shot below). If you have used
the code contained on the iwebsite the ok code should already have been declared as OK_CODE.
i.e. OK_CODE like sy-ucom.
Note: there is also a variable called SAVE_OK, it is good practice to store the returned ok code into
a work area as soon as you enter the PAI processing.
<b>Add screen control to PAI module(INCLUDE Z......I01)</b>
The following code adds simple screen control to the report and whenever the user presses the cancel,
exit or back icon they will exit from the report. It also processes the ALVtree user interactions within the
'others' case statement
INCLUDE Z......I01 *
*& Module USER_COMMAND_0100 INPUT
text
module user_command_0100 input.
DATA return TYPE REF TO cl_gui_event.
save_ok = ok_code.
case ok_code.
when 'BACK' or '%EX' or 'RW'.
Exit program
leave to screen 0.
Process ALVtree user actions
when others.
call method cl_gui_cfw=>get_current_event_object
receiving
event_object = return.
call method cl_gui_cfw=>dispatch.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
<b>Create pf-status</b>
In order to created the pf-status for the screen you need to un-comment '* SET PF-STATUS 'xxxxxxxx'
and give it a name.
i.e. SET PF-STATUS 'STATUS1'.
Step 1
Now double click on 'STATUS1' in-order to create the pf-status. Enter short text, select status type as
'Online status' and click save.
Step2
You should now be presented with the status creation screen. Choose 'Adjust template' from the Extras menu
(4.6 onwards only).
Step 3
Now select 'List status' and click the green tick (see below).
Step 3
All the basic menu bars/buttons should now have been entered. Now click save then activate. The
pf-status has now been completed.
Once you have the main program code in place to call the screen which will display the
ALVtree, you now need to setup the actual ALVtree and populate it. As this is screen
based(dialog) the display coding will be performed within the PBO screen module.
Therefor you need to add the following processes to the PBO(STATUS_0100) module
of the screen.
<b>Create Custom control</b>
Via screen painter insert 'custom control' on to screen and give it the name 'SCREEN_CONTAINER'. This is
the possition the ALVtree will appear so align appropriately.
http://www.sapdev.co.uk/reporting/alv/alvtree/alvtree_basic.htm
see this site you wil find lots of examples
http://www.sapdev.co.uk/reporting/alv/alvtree.htm
<b>Reward if usefull</b> -
Would like to create a script for list all elements and structure of an indesign document
Hello everybody,
I'm a very beginner in indesign scripting.
I would like to create a script in order to list all elements and the inner structure of a n indesign document.
The aim for me is to understand how elements are sorted and arranged into indesign, and be able to find an specific element by its item name.
The output document could be an xml or txt document with a treeview structure.
I would like have a rough idea of which kind of javascript code I should use for that.
Thanks for answers.Hi Ossydoc,
You can use Muse to create such a website. All you need to do is, create links in Muse for the sermons and select " link to File " in the hyperlink option and link to those Mp3 files.
Please refer to this screenshot :- http://prntscr.com/4xvdup
Now, when you publish your site, Muse would automatically upload those files onto the server and the users would then be able to listen as well as download those sermons using the links on your site.
Hope this helps
Regards,
Rohit Nair -
The first thing i'm doing is to get from my ftp server all the ftp content information and i tag it so i can identify later if it's a file or a directory:
private int total_dirs;
private int searched_until_now_dirs;
private int max_percentage;
private TreeNode directories_real_time;
private string SummaryText;
private TreeNode CreateDirectoryNode(string path, string name , int recursive_levl )
var directoryNode = new TreeNode(name);
var directoryListing = GetDirectoryListing(path);
var directories = directoryListing.Where(d => d.IsDirectory);
var files = directoryListing.Where(d => !d.IsDirectory);
total_dirs += directories.Count<FTPListDetail>();
searched_until_now_dirs++;
int percentage = 0;
foreach (var dir in directories)
directoryNode.Nodes.Add(CreateDirectoryNode(dir.FullPath, dir.Name, recursive_levl+1));
if (recursive_levl == 1)
TreeNode temp_tn = (TreeNode)directoryNode.Clone();
this.BeginInvoke(new MethodInvoker( delegate
UpdateList(temp_tn);
percentage = (searched_until_now_dirs * 100) / total_dirs;
if (percentage > max_percentage)
SummaryText = String.Format("Searched dirs {0} / Total dirs {1}", searched_until_now_dirs, total_dirs);
max_percentage = percentage;
backgroundWorker1.ReportProgress(percentage, SummaryText);
percentage = (searched_until_now_dirs * 100) / total_dirs;
if (percentage > max_percentage)
SummaryText = String.Format("Searched dirs {0} / Total dirs {1}", searched_until_now_dirs, total_dirs);
max_percentage = percentage;
backgroundWorker1.ReportProgress(percentage, SummaryText);
foreach (var file in files)
TreeNode file_tree_node = new TreeNode(file.Name);
file_tree_node.Tag = "file";
directoryNode.Nodes.Add(file_tree_node);
numberOfFiles.Add(file.FullPath);
return directoryNode;
The line i'm using to Tag is:
file_tree_node.Tag = "file";
So i know what is "file" then i make a simple check if the Tag is not null then i know it's a "file" if it's null then it's directory.
For example this is how i'm checking if it's file or directory after getting all the content from my ftp server:
if (treeViewMS1.SelectedNode.Tag != null)
string s = (string)treeViewMS1.SelectedNode.Tag;
if (s == "file")
file = false;
DeleteFile(treeViewMS1.SelectedNode.FullPath, file);
else
RemoveDirectoriesRecursive(treeViewMS1.SelectedNode, treeViewMS1.SelectedNode.FullPath);
I also update in real time when getting the content of the ftp server xml file on my hard disk with the treeView structure information so when i'm running the program each time it will load the treeView structure with all directories and files.
This is the class of the xml file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Windows.Forms;
namespace FTP_ProgressBar
class TreeViewXmlPopulation
// Xml tag for node, e.g. 'node' in case of <node></node>
private const string XmlNodeTag = "node";
// Xml attributes for node e.g. <node text="Asia" tag=""
// imageindex="1"></node>
private const string XmlNodeTextAtt = "text";
private const string XmlNodeTagAtt = "tag";
private const string XmlNodeImageIndexAtt = "imageindex";
public static void DeserializeTreeView(TreeView treeView, string fileName)
XmlTextReader reader = null;
try
// disabling re-drawing of treeview till all nodes are added
treeView.BeginUpdate();
reader = new XmlTextReader(fileName);
TreeNode parentNode = null;
while (reader.Read())
if (reader.NodeType == XmlNodeType.Element)
if (reader.Name == XmlNodeTag)
TreeNode newNode = new TreeNode();
bool isEmptyElement = reader.IsEmptyElement;
// loading node attributes
int attributeCount = reader.AttributeCount;
if (attributeCount > 0)
for (int i = 0; i < attributeCount; i++)
reader.MoveToAttribute(i);
SetAttributeValue(newNode,
reader.Name, reader.Value);
// add new node to Parent Node or TreeView
if (parentNode != null)
parentNode.Nodes.Add(newNode);
else
treeView.Nodes.Add(newNode);
// making current node 'ParentNode' if its not empty
if (!isEmptyElement)
parentNode = newNode;
// moving up to in TreeView if end tag is encountered
else if (reader.NodeType == XmlNodeType.EndElement)
if (reader.Name == XmlNodeTag)
parentNode = parentNode.Parent;
else if (reader.NodeType == XmlNodeType.XmlDeclaration)
//Ignore Xml Declaration
else if (reader.NodeType == XmlNodeType.None)
return;
else if (reader.NodeType == XmlNodeType.Text)
parentNode.Nodes.Add(reader.Value);
finally
// enabling redrawing of treeview after all nodes are added
treeView.EndUpdate();
reader.Close();
/// <span class="code-SummaryComment"><summary>
/// Used by Deserialize method for setting properties of
/// TreeNode from xml node attributes
/// <span class="code-SummaryComment"></summary>
private static void SetAttributeValue(TreeNode node,
string propertyName, string value)
if (propertyName == XmlNodeTextAtt)
node.Text = value;
else if (propertyName == XmlNodeImageIndexAtt)
node.ImageIndex = int.Parse(value);
else if (propertyName == XmlNodeTagAtt)
node.Tag = value;
public static void SerializeTreeView(TreeView treeView, string fileName)
XmlTextWriter textWriter = new XmlTextWriter(fileName,
System.Text.Encoding.ASCII);
// writing the xml declaration tag
textWriter.WriteStartDocument();
//textWriter.WriteRaw("\r\n");
// writing the main tag that encloses all node tags
textWriter.WriteStartElement("TreeView");
// save the nodes, recursive method
SaveNodes(treeView.Nodes, textWriter);
textWriter.WriteEndElement();
textWriter.Close();
private static void SaveNodes(TreeNodeCollection nodesCollection,
XmlTextWriter textWriter)
for (int i = 0; i < nodesCollection.Count; i++)
TreeNode node = nodesCollection[i];
textWriter.WriteStartElement(XmlNodeTag);
textWriter.WriteAttributeString(XmlNodeTextAtt,
node.Text);
textWriter.WriteAttributeString(
XmlNodeImageIndexAtt, node.ImageIndex.ToString());
if (node.Tag != null)
textWriter.WriteAttributeString(XmlNodeTagAtt,
node.Tag.ToString());
// add other node properties to serialize here
if (node.Nodes.Count > 0)
SaveNodes(node.Nodes, textWriter);
textWriter.WriteEndElement();
And this is how i'm using the class this method i'm calling it inside the CreateDirectoryNode and i'm updating the treeView in real time when getting the ftp content from the server i build the treeView structure in real time.
DateTime last_update;
private void UpdateList(TreeNode tn_rt)
TimeSpan ts = DateTime.Now - last_update;
if (ts.TotalMilliseconds > 200)
last_update = DateTime.Now;
treeViewMS1.BeginUpdate();
treeViewMS1.Nodes.Clear();
treeViewMS1.Nodes.Add(tn_rt);
TreeViewXmlPopulation.SerializeTreeView(treeViewMS1, @"c:\XmlFile\Original.xml");
ExpandToLevel(treeViewMS1.Nodes, 1);
treeViewMS1.EndUpdate();
And when i'm running the program again in the constructor i'm doing:
if (File.Exists(@"c:\XmlFile\Original.xml"))
TreeViewXmlPopulation.DeserializeTreeView(treeViewMS1, @"c:\XmlFile\Original.xml");
My question is how can i update the xml file in real time like i'm doing now but also with the Tag property so next time i will run the program and will not get the content from the ftp i will know in the treeView what is file and what is directory.
The problem is that now if i will run the program the Tag property is null. I must get the ftp content from the server each time.
But i want that withoutout getting the ftp content from server to Tag each file as file in the treeView structure.
So what i need is somehow where i;m Tagging "file" or maybe when updating the treeView also to add something to the xml file so when i will run the progrma again and read back the xml file it will also Tag the files in the treeView.Hi
Chocolade1972,
Your case related to Winform Data Controls, So i will move your thread to Windows Forms> Windows
Forms Data Controls and Databinding forum for better support.
Best regards,
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
i have a treeview , i can select a treeItem but i am not able get which treeItem is selected .
this is the sample treeview structure
root>subroot
>sample // i want to get this item
i used setOnMouseClicked for the treeView not able to get the selected treeItem.
please help.Hi Gotham,
To the example what Shakir has provided, I have added the changes ( Opening stage on double click). Please check it.
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.util.Callback;
public class TreeViewSample extends Application {
private final Node rootIcon = new ImageView(
new Image(getClass().getResourceAsStream("folder_16.png"))
public static void main(String[] args) {
launch(args);
@SuppressWarnings("unchecked")
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Tree View Sample");
TreeItem<String> rootItem = new TreeItem<String> ("Inbox", rootIcon);
rootItem.setExpanded(true);
for (int i = 1; i < 6; i++) {
TreeItem<String> item = new TreeItem<String> ("Message" + i);
rootItem.getChildren().add(item);
TreeView<String> tree = new TreeView<String> (rootItem);
tree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
/*tree.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
TreeItem treeItem = (TreeItem)newValue;
System.out.println("Selected item is" + treeItem);
tree.setCellFactory(new Callback<TreeView<String>, TreeCell<String>>() {
@Override
public TreeCell<String> call(TreeView<String> paramP) {
return new TreeCell<String>(){
@Override
protected void updateItem(String paramT, boolean paramBoolean) {
super.updateItem(paramT, paramBoolean);
if(!isEmpty()){
setGraphic(new Label(paramT));
final TreeCell<String> this$ = this;
this.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
if(event.getClickCount()==2){
// Getting the node value.
String nodeValue = this$.getItem();
// Opening a new stage by passing this value.
Group root = new Group();
root.getChildren().add(new Label(nodeValue));
Scene scene = new Scene(root, 300, 300, Color.AQUA);
Stage stg = new Stage();
stg.setScene(scene);
stg.show();
StackPane root = new StackPane();
root.getChildren().add(tree);
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();
}Regards,
Sai Pradeep Dandem. -
layout:treeview Closed tree structure?
HI,
I'm able to generate the tree view structure
but the problem is, when close & open the window , it is showing open tree structure
i want it to be close tree view
<layout:treeview expandedLevelsAtFirst="-1" >
<logic:present name="agrovoc" >
<logic:iterate id="agrovoc" name="agrovoc" scope="session">
<c:set var="term" value="${agrovoc.AGTerm}" />
<c:set var="bterm" value="${agrovoc.AGBTerm}" />
<c:set var="nterm" value="${agrovoc.AGNTerm}" />
<c:set var="rterm" value="${agrovoc.AGRTerm}" />
<layout:menuItem key="${agrovoc.AGURI}" link="#" >
<logic:notEmpty name="bterm">
<layout:menuItem key="BroaderTerms">
<layout:menuItem key="${agrovoc.AGBURI}" link="#"/>
</layout:menuItem>
</logic:notEmpty>
<logic:notEmpty name="nterm">
<layout:menuItem key="NarrowerTerms">
<layout:menuItem key="${agrovoc.AGNURI}" link="#" />
</layout:menuItem>
</logic:notEmpty>
<logic:notEmpty name="rterm">
<layout:menuItem key="RelatedTerms">
<layout:menuItem key="${agrovoc.AGRURI}" link="#" />
</layout:menuItem>
</logic:notEmpty>
</layout:menuItem>
</logic:iterate>
</logic:present>
</layout:treeview>I'm using the above code, the tree structure in turn call the java script for tits operations
i even cleared the session object also, but no use..
how to solve this..?Thanks a lot for the help so far, I've created a method to check the basePanel for any components it holds and try to create a JTree display from it. The code I currently have is :
public void updateObjectSelector()
// Setup the tree viewer
DefaultMutableTreeNode root = new DefaultMutableTreeNode(basePanel.getClass());
addChildren(root, basePanel);
tree = new JTree(root);
public void addChildren(DefaultMutableTreeNode root, JPanel parent)
Component [] children = parent.getComponents();
for(int i = 0; i < children.length; i++)
DefaultMutableTreeNode child = new DefaultMutableTreeNode(children.getClass());
try
addChildren(child, (JPanel) children[i]);
catch(ClassCastException e)
root.add(child);
basePanel and tree are both global variables. basePanel is the root Panel to which everything is added to.
I am calling "updateObjectSelector()" every time a component is added to the basePanel but at the moment all I can get displayed by the JTree is the getClass() of the basePanel, none of its children are being displayed. Can anyone see what I have done wrong here?
Many thanks again for all your help so far. -
Foreign domain ou-structure to treeview object...expertise needed
Here is my simple script which works fine on my own domain (first one: TreeViewOwnDomain.ps1). Now I want to read foreign domain and use treeview as same way.
Here is also another script which connect foreign domain and read user data (second one: ForeignDomainUserData.ps1).
Can anyone help me?
function Add-Node {
param ($selectedNode, $name)
$newNode = new-object System.Windows.Forms.TreeNode
$newNode.Name = $name
$newNode.Text = $name
$selectedNode.Nodes.Add($newNode) | Out-Null
return $newNode
function Get-NextLevel {
param ($selectedNode, $dn)
$OUs = Get-ADObject -Filter 'ObjectClass -eq "organizationalUnit" -or ObjectClass -eq "container"' -SearchScope OneLevel -SearchBase $dn
if ($OUs -eq $null) {
$node = Add-Node $selectedNode $dn
} else {
$node = Add-Node $selectedNode $dn
$OUs | % {
Get-NextLevel $node $_.distinguishedName
function Build-TreeViewNew {
param ($tNode, $tDomainDN, $tviewOU1)
# Tab 1
$tNode.text = "Active Directory Hierarchy"
$tNode.Name = "Active Directory Hierarchy"
$tNode.Tag = "root"
$tviewOU1.Nodes.Add($treeNode) | Out-Null
Get-NextLevel $treeNode $tDomainDN
Build-TreeViewNew $treeNode "DC=w12,DC=local" $treeviewOU1
$JobEncrypted = Get-Content "C:\Tools\PowershellScripts\Test\encrypted_password_PS.txt" | ConvertTo-SecureString
$JobCredential = New-Object System.Management.Automation.PsCredential($JobUsername, $JobEncrypted)
$SessionX = New-PSSEssion -ComputerName "192.168.xxx.xxx" -Credential $JobCredential -ErrorAction 'SilentlyContinue'
Enter-PSSession -Session $SessionX
$t = Invoke-Command -Session $SessionX -ScriptBlock {
$tmp = $null
$t1 = (Get-ADUser Administrator).distinguishedName; $tmp += $t1; $tmp += "`n"
$t2 = (Get-ADUser Administrator -Properties *).description; $tmp += $t2; $tmp += "`n"
$tmp
Exit-PSSession
$richtextboxOU1.Text = $tHi Jyrkis700,
If you want to add the other domain's information to TreeView, you can try the cmdlet "Get-ADUser -Server otherdoman.com -Credential otherdomain\Administrator" instead of "Invoke-Command" and "Enter-Pssession":
Get-ADUser ann –Server test.server.com -Credentail TEST\Administrator
Reference from:
Adding/removing members from another forest or domain to groups in Active Directory
In addition, to work with TreeView, this script may be helpful for you:
PowerShell help browser using Windows Forms and TreeView Control
If I have any misunderstanding, please let me know.
If you have any feedback on our support, please click here.
Best Regards,
Anna
TechNet Community Support -
How get SharePoint Library Folders and Files directory structure in to my custom web site.
Hi,
Actually my requirement is, I would like to pass site name and document library name as a parameter and get a folders and files from the document library and form the directory structure by using Treeview control in my web site.
How should i get? Using Web service / object model?
Web service would return the dataset as a result so from that how could i form the directory structure using Treeview control.
I will select specified files and folders then i ll update sharepoint document library columns for corresponding selected files.
Can anyone help over this, that would be great appreciate.
Thanks in Advance.
Poomani SankaranHello,
Here is the code to iterate through sites and lists:
//iterate through sites and lists
SPSecurity.RunWithElevatedPrivileges(delegate()
using (SPSite site = new SPSite(webUrl)) {
using (SPWeb oWebsite = site.OpenWeb())
SPListCollection collList = oWebsite.Lists;
foreach (SPList oList in collList)
{//your code goes here }
Then use RecursiveAll to get all files and folders.
http://www.codeproject.com/Articles/116138/Programatically-Copy-and-Check-In-a-Full-Directory
http://sharepoint.stackexchange.com/questions/48959/get-all-documents-from-a-sharepoint-document-library
Here is the full code:
http://antoniolanaro.blogspot.in/2011/04/show-document-library-hierarchy-in-tree.html
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
Struts layout:treeview taglibs...
Hi Friends,
I'm developing small search engine with struts framework
from the database I'm getting the words(terms.search results), now i want display those terms in Tree structure like
+ Rain (root word)
+Broader terms
Precipitation
+Narrower Terms
Artificial precipitation
+Related Terms
Runoff water
Lodging
right now I'm using <logic:iterate> tags for display
how to implement these with <layout:treeview> tags, i added jar file & tld file to the project folder
can anyone tell me how to build sample treeview ( dynamic from database depending on search) so that i can implement that on my application.....
Thank u... :)hi,
Can you please send me the example on how to use tree view from struts-layout
Thanks
crr -
Tree structure xtras and flash buttons
im doing a prototype of small project in Director for an
e-learning application. i need to build a tree like structure based
menu with graphical icons as the main navigation method of the
movie. there is a TreeView Xtra by broadband but it is too
expensive for my client's budget. this is the first job of this
type im getting. so i need to know is there any other way to get
this done??? i thought of doing the menu in flash but how to give
navigation commands to director timeline from several symbol
components inside a flash asset component i dont know. your
experience on this will be much appreciate if shared with me.
regards
Bhanuka> i thought of doing the menu in flash but how to give
navigation
> commands to director timeline from several symbol
components inside a flash
> asset component i dont know.
There are various ways of having Flash inform Director of
items that are
interacted with. Search the docs for getURL(), or search the
newsgroup
for previous suggestions -
I am trying to refactor a piece of code that was originally designed using HTMLB to create a tree view role menu that invokes an event in another iView.
My question is, can portal eventing be done with traditional JavaScript as opposed to using HTMLB? We are not using WebDynPro for this project.
I would like to use a jsp treeview to re-engineer the existing htmlb tree structure, but wanted to get some feedback on the options...thanksHi Ryan,
> whether or not the eventing
> has to be done on the server side
The eventing between iViews is done by EPCF, and this is, as said, a pure JS framework. Often it might be senseful for the iView which gets "informed" by some other iView about some event with some event data, to use this data and to refresh itself. This depends on the concrete use case.
Having this said, it is obviously totally independent if you usue EPCF from some portal HTMLB-JSP, a "pure" JSP without HTMLB or a BSP - all of these things end up in HTML with the possibility to include JS - the EPCF calls.
See http://help.sap.com/saphelp_nw04/helpdata/en/82/04b340be3dff5fe10000000a155106/frameset.htm for further details.
> Can all of this be done without post backs
> to the server,
As said before, the eventing through EPCF works on client side, but in many cases it makes sense to refresh some iView with some data sent by the event.
Imagine a List-Details iView combination. The user has one iView with a list of products and another iView with the details of one product. By choosing one product in the list iView, this iView could raise an event, which is subscribed by the details iView, for example passing some product-ID. Now it would make sense to refresh the details iView with the ID given. The alternative would be to load all details data and only to show up the chosen details and to switch on the event. Two disadvantages: It's much harder to code and you may have a very long transmission/network time for the inital call of this iView.
> without using htmlb using JSP not BSP
See above, it's independent from the HTML-Layer.
> can you store a result set in a client side object,
> like a cookie, and if so, how?
For sure, somehow you can (at least some representation). But here I'm unsure again, in which direction this question aims, if this is really helpful.
Hope it helps
Detlev -
TreeView with JDeveloper 10.0.1.3
I´m looking a example step-by-step about TreeView for JDeveloper 10.0.1.3.
In OTN.ORACLE.COM there is one but it is built and I can´t learn how could I to do this.
Thanks.What does the directory structure of your module in
CVS look like? After checking out, does the directory
structure on disk reflect this properly? Yes, the directory structure in disk reflect properly with de CVS.
If you check the generated project settings, and look
on the Project Content page, are the Java Content
paths set correctly?Yes too.
This sounds like it may be some kind of bug. Any
information you can provide may help me put together
a reproducable test case so that I can report this.
Thanks,
BrianStep by step:
1 - I make de CVS connection... and it is ok.
2 - In the CVS Navigator, I checkout the selected module.
3 - After checkout, in the dialog "Handle New Files" I wish "Create New Project From Files".
In Application Navigator:
Applications
|__ module_name
|__ module_name [ip_cvs_server]
In System Navigator:
|__ module_name.jws
|__ module_name.jpr [ip_cvs_server]
|__ loading...
The project properties are ok, but in the this navigators I can´t see/access the files/directory strutucture of the project.
Thanks Brian! -
Using Microsoft's TreeView Control in Forms 5.0
I created the OCX item, assigned it the OLE class 'COMCTL.TreeCtrl.1', inserted Microsoft TreeView Control 5.0, imported the appropriate OLE packages and set the appropriate OCX specific properties. With all that done, I created a simple code to clear the nodes collection and then populate it with two dummy nodes. The following is that snippet of code:
PROCEDURE DO$TREE_INIT(
i_study_id IN VARCHAR2 DEFAULT NULL
) IS
v_inodes COMCTLLIB_CONSTANTS.INODES;
v_inode0 COMCTLLIB_CONSTANTS.INODE;
v_inode1 COMCTLLIB_CONSTANTS.INODE;
BEGIN
-- Get pointer to the treeview control's nodes collection.
v_inodes := COMCTL_ITREEVIEW.NODES(:item('CB_MAIN.OCX_TREE').interface);
-- Clear nodes collection
COMCTL_INODES.CLEAR(v_inodes);
-- Create initial tree structure when provided with a study.
IF (i_study_id IS NOT NULL) THEN
v_inode0 := COMCTL_INODES.OLE_ADD(
interface => v_inodes
,relative => OLEVAR_NULL
,relationship => OLEVAR_NULL -- TO_VARIANT(COMCTLLIB_CONSTANTS.TVWFIRST, vtype => VT_R8)
,key => TO_VARIANT('STUD|AA|123|BC|12', vtype => VT_BSTR)
,text => TO_VARIANT('Dursban MOR Study (12312123)', vtype => VT_BSTR)
,image => OLEVAR_NULL
,selectedimage => OLEVAR_NULL
v_inode1 := COMCTL_INODES.OLE_ADD(
interface => v_inodes
,relative => TO_VARIANT(COMCTL_INODE.OLE_INDEX(v_inode0), vtype => VT_R8)
,relationship => TO_VARIANT(COMCTLLIB_CONSTANTS.TVWCHILD, vtype => VT_R8)
,key => TO_VARIANT('FF+|AA|123|BC|12', vtype => VT_BSTR)
,text => TO_VARIANT('Facility Functions', vtype => VT_BSTR)
,image => OLEVAR_NULL
,selectedimage => OLEVAR_NULL
END IF;
END DO$TREE_INIT;
My form complies properly but during runtime I get this error:
FRM-40735: < ... > trigger raised unhandled exception ORA-100504.
This form is very simple. It contains only one control block, the tree control, OLE packages, WHEN-NEW-FORM-INSTANCE trigger, and this package. I have tried everything within my understanding. Do you have any suggestions?
Any help would be appreciated.
Thanks,
RahulI have the same situation too. The only solution
I could think of is to install "Additional ActiveX"
from custom VB5 installation. Besides there is
a problem when VB6 is installed, because the controls are
called "Microsft TreeView ... (SP2)".
If you find any progress , keep me in touch :) ...
Iain Sutherst (guest) wrote:
: I have spent sometime implementing ListView and TreeView
: controls (provided by COMCTL32.OCX, under VB 5) in Oracle
Forms
: 5.0, believing that the only files I would need to distribute
: when I came to implement on other machines were COMCTL32.DLL
and
: COMCTL32.OCX, followed by registering COMCTL32.OCX.
: This does not seem to be the case, since the control (ListView
: or TreeView) is not being activated during run-time, and when
I
: try to use 'Insert Object...' in the layout editor for the
: control, nothing happens.
: Unfortunately, I have loaded VB 5, and Oracle Objects for OLE
on
: to my original development environment, and so I cannot now be
: sure whether I need just COMCTL32.* or whether I need
something
: else as well.
: If anyone has had experience of using these controls and has
had
: to roll-out the developed applications to other machines, I'd
be
: grateful for any information.
: Thanks.
: Iain
null -
WCF RIA zero-one to many ultimate treeview
Hi,
I am using ultimate treeview extension (http://visualstudiogallery.msdn.microsoft.com/ca292c74-661c-48ba-8262-d79a2671c33f)
This requires a zero-one to many table. I have this working with a table.
However I need to connect to a WCF RIA service from the control. Currently using
public class WorksOrderTree
[Key()]
public int id { get; set; }
[Association("ProductPart", "id", "ParentID")]
public IEnumerable<WorksOrderTree> Children { get; set; }
[Association("ProductPart", "ParentID", "id", IsForeignKey = true)]
public WorksOrderTree Parent { get; set; }
public int ParentID { get; set; }
This gives the following error
Error 1
f0rmoum1..csdl(26,6) : error 0113: Multiplicity is not valid in Role 'WorksOrderTree' in relationship 'ProductPart'. Because all the properties in the Dependent Role are nullable, multiplicity of the Principal Role must be '0..1'.
Any idea to to how create zero-one to many in the ria service.
Thanks
SteveThanks for your reply Paul.
Yes I read your blog about the Telerik treeview and it was very helpful. the problem is that I want to use the Telerik RadTreeListView control instead, and It seem that it cannot be used with LightSwitch (for threading problems...)
So I am obliged to create a RIAService ( that I hope) it can return a hierarchical structure without any lazy loading, so the RadTreeListView can work....
but It seem that RIAService (Or LightSwitch) Insists on lazy load, and I don't know how to avoid it...
I know that I can create a service in my UserControl project as you say in your blog but I am trying to create a LightSwitch extention ....
AAK -
EnsureVisible in TreeView: how to ensure that horiz. scrollbar is aligned left
Hi,
I have a tree view with eg. following nodes
# People
|
+--# Custumers
|
+-- # Anne Charles, Hillroad 14, 7766 MyTown, My Country
|
+-- # Steve Jones, Forestroad 12, 7766 MyTown, My Country
With the command
Me.treeViewM.Nodes(0).Nodes(0).Nodes(0).EnsureVisible()
I can ensure that "Anne Charles" is visible within the treeview. My problem is: If the treeview is not wide enough to show the complete node text of this node, the horizontal scroll bar is automatically moved to the right so that node structure shown left from the "A" in the text "Anne Charles" is not visible any more. Thus
Anne Charles, Hillroad 14, 7766 MyTown, My Country
Steve Jones, Forestroad 12, 7766 MyTown, My Country
is visible and the node structure is hidden.
Question: How can I ensure that the node "Anne Charles" is visible and also the horizontal scrollbar is aligned to the left, which means that the node structure left from the text is still visible?
Best wishes
Michael
[Visual Basic .net 2005]Look at following code project also: http://www.codeproject.com/KB/tree/NoScrollingTree.aspx
You need PInvoke.
At Top
Imports System.Runtime.InteropServices
And Following Functtion
Private Const WM_HSCROLL As Integer = 276
Private Const SB_LEFT As Integer = 6
<DllImport("user32.dll")> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
After Ensure Visible call the above Function
Me.treeViewM.Nodes(0).Nodes(0).Nodes(0).EnsureVisible()
SendMessage(treeViewM.Handle, WM_HSCROLL, SB_LEFT, 0)
Arjun Paudel
Maybe you are looking for
-
I'm using windows Vista and i have a very bad internet connection that makes it impossible to download the update as my internet disconnects almost every 3 minutes and if the 634 MB update stops at any point it restarts, I have been trying since IOs
-
Problem while Posting Assets through BAPI
Hi, I am using BAPI_ACC_DOCUMENT_POST to handle assets postings in SAP.Here whenever i am running BAPI from SE37 using asset_no with regular length which is 6digits[730011] bapi is giving me correct results and documents gets posted successfully with
-
How to Create more than one Sales order
Hi All Is it possible that at Va01 initial screen i have a field with name Group and when i select the group in that field sales order for alll the customer in that group may be created automatically Regards, Ammad
-
Removing Accounts From Mail, Contacts & Calendars
So, I have a problem with something that's just idly bothering me. Recently I've deleted my Twitter account and have no idea how to remove the account from the list of accounts I have linked with my laptop in the Mail, Contacts & Calendars. It's prob
-
Hi Guys, I am tried to use the delete a line function in BI 7.0. but it was not working. Here is what I have done: step 1: create the delete function with condition which was define by variables. step 2: in the web add those variable with the Appear