Start Editing an Tree-Node programmatically
Hello there!
I have a JTree which the user can edit by clicking on the nodes three times. This I did setting "tree.setEditable(true);". Now i want a selected node to switch to editing-mode when the user clicks on a menu.
So how can I programmatically start editing?
Thanks a lot, DreamiX.
JTree has method
startEditingAtPath(TreePath path)
best regards
Stas
Similar Messages
-
Add/Edit/Delete Tree Nodes using CL_GUI_ALV_TREE
Hi All,
I am looking for an example of program with CL_GUI_ALV_TREE that have a functionality of add a tree node, edit a tree node, and delete a tree node.
I have already looked the BCALV_TREE* demo program but could not able to find a program to add/edit/delete node tree elements.
Any info on this.
Thanks
aRsHello aRs
Here is a sample report showing how to delete nodes in an ALV tree. The report was copied from BCALV_TREE_01. Search for added code:
*$ADDED: begin
*$ADDED: end[/code]
When you display the tree expand the first folder completely. When entering 'DELETE' into the command field directly the first flight date node will be deleted.
REPORT ZUS_SDN_BCALV_TREE_01_DELNODE.
based on: REPORT bcalv_tree_01.
Purpose:
~~~~~~~~
This report shows the essential steps to build up a hierarchy
using an ALV Tree Control (class CL_GUI_ALV_TREE).
Note that it is not possible to build up this hierarchy
using a simple ALV Tree Control (class CL_GUI_ALV_TREE_SIMPLE).
To check program behavior
~~~~~~~~~~~~~~~~~~~~~~~~~
Start this report. The hierarchy tree consists of nodes for each
month on top level (this level can not be build by a simple ALV Tree
because there is no field for months in our output table SFLIGHT.
Thus, you can not define this hierarchy by sorting).
Nor initial calculations neither a special layout has been applied
(the lines on the right do not show anything).
Note also that this example does not build up and change the
fieldcatalog of the output table. For this reason, all fields
of the output table are shown in the columns although the fields
CARRID and FLDATE are already placed in the tree on the left.
(Of course, this is not a good style. See BCALV_TREE_02 on how to
hide columns).
Essential steps (Search for '§')
~~~~~~~~~~~~~~~
1.Usual steps when using control technology.
1a. Define reference variables.
1b. Create ALV Tree Control and corresponding container.
2.Create Hierarchy-header
3.Create empty Tree Control
4.Create hierarchy (nodes and leaves)
4a. Select data
4b. Sort output table according to your conceived hierarchy
4c. Add data to tree
5.Send data to frontend.
6.Call dispatch to process toolbar functions
*$ADDED: begin
DATA:
gd_del_nkey TYPE lvc_nkey.
*$ADDED: end
§1a. Define reference variables
DATA: g_alv_tree TYPE REF TO cl_gui_alv_tree,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA: gt_sflight TYPE sflight OCCURS 0, "Output-Table
ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm, "OK-Code
g_max TYPE i VALUE 255.
END-OF-SELECTION.
CALL SCREEN 100.
*& Module PBO OUTPUT
process before output
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAINTITLE'.
IF g_alv_tree IS INITIAL.
PERFORM init_tree.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'Automation Queue failure'(801)
txt1 = 'Internal error:'(802)
txt2 = 'A method in the automation queue'(803)
txt3 = 'caused a failure.'(804).
ENDIF.
ENDIF.
ENDMODULE. " PBO OUTPUT
*& Module PAI INPUT
process after input
MODULE pai INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'EXIT' OR 'BACK' OR 'CANC'.
PERFORM exit_program.
*$ADDED: begin
WHEN 'DELETE'.
CALL METHOD g_alv_tree->delete_subtree
EXPORTING
i_node_key = gd_del_nkey
I_UPDATE_PARENTS_EXPANDER = SPACE
i_update_parents_folder = 'X'
EXCEPTIONS
node_key_not_in_model = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD g_alv_tree->frontend_update.
*$ADDED: end
WHEN OTHERS.
§6. Call dispatch to process toolbar functions
CALL METHOD cl_gui_cfw=>dispatch.
ENDCASE.
CALL METHOD cl_gui_cfw=>flush.
ENDMODULE. " PAI INPUT
*& Form init_tree
text
--> p1 text
<-- p2 text
FORM init_tree.
§1b. Create ALV Tree Control and corresponding Container.
create container for alv-tree
DATA: l_tree_container_name(30) TYPE c.
l_tree_container_name = 'CCONTAINER1'.
CREATE OBJECT g_custom_container
EXPORTING
container_name = l_tree_container_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'(100).
ENDIF.
create tree control
CREATE OBJECT g_alv_tree
EXPORTING
parent = g_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
no_html_header = 'X'
no_toolbar = ''
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
§2. Create Hierarchy-header
The simple ALV Tree uses the text of the fields which were used
for sorting to define this header. When you use
the 'normal' ALV Tree the hierarchy is build up freely
by the programmer this is not possible, so he has to define it
himself.
DATA l_hierarchy_header TYPE treev_hhdr.
PERFORM build_hierarchy_header CHANGING l_hierarchy_header.
§3. Create empty Tree Control
IMPORTANT: Table 'gt_sflight' must be empty. Do not change this table
(even after this method call). You can change data of your table
by calling methods of CL_GUI_ALV_TREE.
Furthermore, the output table 'gt_outtab' must be global and can
only be used for one ALV Tree Control.
CALL METHOD g_alv_tree->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
is_hierarchy_header = l_hierarchy_header
CHANGING
it_outtab = gt_sflight. "table must be empty !
§4. Create hierarchy (nodes and leaves)
PERFORM create_hierarchy.
§5. Send data to frontend.
CALL METHOD g_alv_tree->frontend_update.
wait for automatic flush at end of pbo
ENDFORM. " init_tree
*& Form build_hierarchy_header
build hierarchy-header-information
-->P_L_HIERARCHY_HEADER strucxture for hierarchy-header
FORM build_hierarchy_header CHANGING
p_hierarchy_header TYPE treev_hhdr.
p_hierarchy_header-heading = 'Month/Carrier/Date'(300).
p_hierarchy_header-tooltip = 'Flights in a month'(400).
p_hierarchy_header-width = 30.
p_hierarchy_header-width_pix = ' '.
ENDFORM. " build_hierarchy_header
*& Form exit_program
free object and leave program
FORM exit_program.
CALL METHOD g_custom_container->free.
LEAVE PROGRAM.
ENDFORM. " exit_program
*& Form create_hierarchy
text
--> p1 text
<-- p2 text
FORM create_hierarchy.
DATA: ls_sflight TYPE sflight,
lt_sflight TYPE sflight OCCURS 0,
l_yyyymm(6) TYPE c, "year and month of sflight-fldate
l_yyyymm_last(6) TYPE c,
l_carrid LIKE sflight-carrid,
l_carrid_last LIKE sflight-carrid.
DATA: l_month_key TYPE lvc_nkey,
l_carrid_key TYPE lvc_nkey,
l_last_key TYPE lvc_nkey.
§4a. Select data
SELECT * FROM sflight INTO TABLE lt_sflight UP TO g_max ROWS.
§4b. Sort output table according to your conceived hierarchy
We sort in this order:
year and month (top level nodes, yyyymm of DATS)
carrier id (next level)
day of month (leaves, dd of DATS)
SORT lt_sflight BY fldate0(6) carrid fldate6(2).
Note: The top level nodes do not correspond to a field of the
output table. Instead we use data of the table to invent another
hierarchy level above the levels that can be build by sorting.
§4c. Add data to tree
LOOP AT lt_sflight INTO ls_sflight.
Prerequesite: The table is sorted.
You add a node everytime the values of a sorted field changes.
Finally, the complete line is added as a leaf below the last
node.
l_yyyymm = ls_sflight-fldate+0(6).
l_carrid = ls_sflight-carrid.
Top level nodes:
IF l_yyyymm <> l_yyyymm_last. "on change of l_yyyymm
l_yyyymm_last = l_yyyymm.
*Providing no key means that the node is added on top level:
PERFORM add_month USING l_yyyymm
CHANGING l_month_key.
The month changed, thus, there is no predecessor carrier
CLEAR l_carrid_last.
ENDIF.
Carrier nodes:
(always inserted as child of the last month
which is identified by 'l_month_key')
IF l_carrid <> l_carrid_last. "on change of l_carrid
l_carrid_last = l_carrid.
PERFORM add_carrid_line USING ls_sflight
l_month_key
CHANGING l_carrid_key.
ENDIF.
Leaf:
(always inserted as child of the last carrier
which is identified by 'l_carrid_key')
PERFORM add_complete_line USING ls_sflight
l_carrid_key
CHANGING l_last_key.
ENDLOOP.
ENDFORM. " create_hierarchy
*& Form add_month
FORM add_month USING p_yyyymm TYPE c
p_relat_key TYPE lvc_nkey
CHANGING p_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value,
ls_sflight TYPE sflight,
l_month(15) TYPE c. "output string for month
get month name for node text
PERFORM get_month USING p_yyyymm
CHANGING l_month.
l_node_text = l_month.
add node:
ALV Tree firstly inserts this node as a leaf if you do not provide
IS_NODE_LAYOUT with field ISFOLDER set. In form 'add_carrid_line'
the leaf gets a child and thus ALV converts it to a folder
automatically.
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_sflight
IMPORTING
e_new_node_key = p_node_key.
ENDFORM. " add_month
FORM add_carrid_line USING ps_sflight TYPE sflight
p_relat_key TYPE lvc_nkey
CHANGING p_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value,
ls_sflight TYPE sflight.
add node
ALV Tree firstly inserts this node as a leaf if you do not provide
IS_NODE_LAYOUT with field ISFOLDER set. In form 'add_carrid_line'
the leaf gets a child and thus ALV converts it to a folder
automatically.
l_node_text = ps_sflight-carrid.
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_sflight
IMPORTING
e_new_node_key = p_node_key.
ENDFORM. " add_carrid_line
*& Form add_complete_line
FORM add_complete_line USING ps_sflight TYPE sflight
p_relat_key TYPE lvc_nkey
CHANGING p_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value.
WRITE ps_sflight-fldate TO l_node_text MM/DD/YYYY.
add leaf:
ALV Tree firstly inserts this node as a leaf if you do not provide
IS_NODE_LAYOUT with field ISFOLDER set.
Since these nodes will never get children they stay leaves
(as intended).
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = ps_sflight
i_node_text = l_node_text
IMPORTING
e_new_node_key = p_node_key.
*$ADDED: begin
IF ( ps_sflight-fldate = '20040522' ). " first flight date
IF ( gd_del_nkey IS INITIAL ). " collect only first date
gd_del_nkey = p_node_key.
ENDIF.
ENDIF.
*$ADDED: end
ENDFORM. " add_complete_line
*& Form GET_MONTH
text
-->P_P_YYYYMM text
<--P_L_MONTH text
FORM get_month USING p_yyyymm
CHANGING p_month.
Returns the name of month according to the digits in p_yyyymm
DATA: l_monthdigits(2) TYPE c.
l_monthdigits = p_yyyymm+4(2).
CASE l_monthdigits.
WHEN '01'.
p_month = 'January'(701).
WHEN '02'.
p_month = 'February'(702).
WHEN '03'.
p_month = 'March'(703).
WHEN '04'.
p_month = 'April'(704).
WHEN '05'.
p_month = 'May'(705).
WHEN '06'.
p_month = 'June'(706).
WHEN '07'.
p_month = 'July'(707).
WHEN '08'.
p_month = 'August'(708).
WHEN '09'.
p_month = 'September'(709).
WHEN '10'.
p_month = 'October'(710).
WHEN '11'.
p_month = 'November'(711).
WHEN '12'.
p_month = 'December'(712).
ENDCASE.
CONCATENATE p_yyyymm+0(4) '->' p_month INTO p_month.
ENDFORM. " GET_MONTH
/code
Regards
Uwe -
How to highlight a tree node programmatically
Problem
=====
Just like a typical management software, I have a navigation tree presenting a list of objects (let's say toasters) on the left panel. The content panel on the right side presents the details of a toaster, when the user selects the toaster on the navigation tree. On the toaster details panel, I would like to have a hyper link referring to another toaster - associated to the selected toaster. On clicking on the hyperlink, I would like to display the details of the associated toaster and the navigation tree node for the associated toaster being highlighted.
For example, BUI presents the following now:
+ Toasters | Toaster 1 Details [Refresh]
+ <toaster1> |
+ toaster2 | ... toaster3
+ toaster3 |
toaster1 is selected on the navigation tree. The contents panel displays Toaster 1 details, which has a hyper link for toaster3.
When the user click on toster3 on the contents panel, I would like to see the following
+ Toasters | Toaster 3 Details [Refresh]
+ toaster1 |
+ toaster2 | ...
+ <toaster3> |
My Trial
=====
ADF Rich Client 11.1.2.3 is used for my development.
Jspx code for the navigation tree looks like this:
<af:tree id="navTree" ...>
<f:facet name="nodeStamp">
<af:panelGroupLayout id="nodePgl">
<af:switcher facetName="#{stamp.outcome!=null?'actnode':'noactnode'}" ...>
<f:facet name="actnode">
<af:commandLink id="leafLink" text="#{stamp.label}" action="#{stamp.actionOutcome}">
<af:setActionListener from="#{stamp.key}" to="#{treeHandler.selectedMenuItem}"/>
</af:commandLink>
</f:facet>
<f:facet name="noactnode">
<af:outputText id="notLeafText" value="#{stamp.label}"/>
</f:facet>
</af:switcher>
</af:panelGroupLayout>
</f:facet>
</af:tree>
The hyper link on the contents panel looks like this:
<af:iterator var="toaster" value="#{toastData.toasters}">
<af:commandLink text="#{toaster}" action="#{toasterHandler.goToToaster}">
<f:param name="toasterId" value="#{toaster}"/>
<af:setActionListener from="#{toaster}" to="#{treeHandler.selectedToaster}"/>
</af:commandLink>
</af:iterator>
I got some tips from this forum (cannot find thread at the moment) and implemented the treeHandler.selectedToaster method as follows:
// getSelectionState returns selStat, which is instantiated like the following:
// RowKeySet selStat = new RowKeySetTreeImpl();
// TreeModel model = (TreeModel) menuModel.getWrappedData();
// selStat.setCollectionModel(model);
// selStat.setContained(true);
RowKeySet rowKeySet = getSelectionState();
rowKeySet.removeAll();
// synthesize the rowKey for the selected toaster
// if the toaster found in the toaster node list,
// rowKey should look like [0, <rowIdx of toaster>]
ArrayList<Integer> rowKey = new ArrayList<Integer>();
rowKey.add(0);
rowKey.add(new Integer(rowIdx));
TreeModel model = (TreeModel) menuModel.getWrappedData();
model.setRowKey(rowKey);
model.setRowIndex(rowIdx);
rowKeySet.add();
This seems to work most of times except when I refresh the contents details panel using partial page rendering.
I get NullPointerException on the call to rowKeySet.removeAll().
Caused by: java.lang.NullPointerException
at org.apache.myfaces.trinidad.model.RowKeySetTreeImpl._selectAll(RowKeySetTreeImpl.java:459)
at org.apache.myfaces.trinidad.model.RowKeySetTreeImpl.removeAll(RowKeySetTreeImpl.java:146)
In my observation, this NPE happens when rowKeySet.size() returns 1 but rowKeySet.iterator() does not return any entries.
I suspect this is a bug on RowKeySetTreeImpl but not sure.
Help Need
=======
1. What is the reasonably right way to highlight the tree node for my problem?
2. If my trial is one way to do it, how can I get around the NPE? I cannot change ADF Rich Client library at this point.
Any help/suggestion/advise would be appreciated.
Thanks,
JeongtaeI did this, to programmatically expand a tree node, you can try the same and set the row key to highlight.
private RowKeySet disclosedTreeRowKeySet = new RowKeySetImpl();
public void rowDisclosureListener(RowDisclosureEvent rowDisclosureEvent)
Iterator added = rowDisclosureEvent.getAddedSet().iterator();
if (added!=null)
while (added.hasNext())
Object rowKey = added.next();
//disclosedTreeRowKeySet.clear();
List path = (List)rowKey;
for( int i=0; i< path.size(); i++ )
List<Object> nodePath = new ArrayList<Object>();
for( int j=0; j<i; j++ )
nodePath.add( path.get( j ) );
disclosedTreeRowKeySet.add( nodePath );
disclosedTreeRowKeySet.add( rowKey );
System.out.println( "disclosed Keys...... " + disclosedTreeRowKeySet );
private void expandSelectedNode(RowKeySet addedObj) {
if (sourceTreeTable != null) {
Iterator added = (Iterator)addedObj.iterator();
if (added!=null)
while (added.hasNext())
Object rowKey = added.next();
List path = (List)rowKey;
for( int i=0; i< path.size(); i++ )
List<Object> nodePath = new ArrayList<Object>();
for( int j=0; j<i; j++ )
nodePath.add( path.get( j ) );
disclosedTreeRowKeySet.add( nodePath );
disclosedTreeRowKeySet.add( rowKey );
sourceTreeTable.setDisclosedRowKeys(disclosedTreeRowKeySet);
} -
Want to select a tree node Programmatically
Hi all,
I have a tree which is acting as a menu and by deafult which nodes are collapsed. Now what I need is I want to select a tree node(which node value or node label is known) by clicking a button. Pls help me. Bye.
BR
Tarik.Is it about this one?
FTREE.SET_TREE_SELECTION(tree, node, FTREE.SELECT_ON)
If another node is already selected, first unselect it:
FTREE.SET_TREE_SELECTION(tree, FTREE.GET_TREE_SELECTION(tree, 1), FTREE.SELECT_OFF); -
JTreeTable problem editing tree node
Hi,
Iam using the swing JTreeTable component and facing a problem. Iam displaying hierarchical data in the JTreeTable. Now I would like to provide the facility to edit a tree node. I have a TreeSelectionListener registered on the tree and a TreeModelListener registered on the DefaultTreeModel. Wheneve, I start editing a node by double clicking it the valueChanged method is called but I do not see the new value the user types in this method. I have another method setValueAt which is where I can see the new value the user has entered.
I can set this new value to the treenode using
node.setUserObject(newValue);However, if I do this, the next time I try to edit the same node, the editor component is painted over the tree node thus displaying an empty textfield that occupies the entire cell.
How can I make the editor appear above the tree node with the contents loaded in it always.
Any help is appreciated.
cheers,
vidyutYou bind a mouselistener to the tree, so it has to be handled there.
When clicking once (method should be "mouseReleased" or something, treenodes name (toString) should be .setText("");
regards
marco -
Help for Activating Editing Mode on F2 Keyboard Click for a Tree Node
I have a Jtree with several Nodes on the Left Pane. On the Right Pane I have a nodes corresponding Screen with many properties. There is a way to change the Node Name by editing the Name Field property on the Right.
I want to Edit the tree Node name by Clicking F2 on the selected Node, Get it in the Editable Mode, Change the name and press enter. How Do I activate this editable Mode on Click of Keyboard F2 Button.tree.setEditable( true );
-
How can I edit the selected tree node immediately?
I have completed a popup menu ,which appeares when I have a mouse rightclicked event
over the selected tree node.when I selected the popup menu item,i can edit the tree node ,but
I feel that the tree celleditor appear slowly ,what should i do? the following is my code:
menuItemRenameNode.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent ae)
renameNode_ActionPerformed(ae);
void renameNode_ActionPerformed(ActionEvent ae){
setEditable(true);
this.getCellEditor().addCellEditorListener(new CellEditorListener(){
public void editingCanceled(ChangeEvent e){
CellEditor cellEditor =(CellEditor)e.getSource();
System.out.println("editing canceled:"+cellEditor.getCellEditorValue().toString());
protected boolean canEditImmediately(EventObject e){
return true;
public void editingStopped(ChangeEvent e){
CellEditor cellEditor =(CellEditor)e.getSource();
System.out.println("editing stopped:"+cellEditor.getCellEditorValue().toString());Please check the suggestions in the thread: https://forums.adobe.com/thread/692020?tstart=0
Regards,
| T. Ravi Kumar -
How do we get tree node infomation in an App Engine
I want to write an app engine to get accounts that are under various tree nodes. How do I write this in an App Engine.. I just need help getting started
you can use start with connect by clause in a SQL step to link data in a hierarchy
something on the lines of :
+SELECT *+
FROM pstreenode
WHERE setid = '<YourSetID>'
AND tree_name = '<YourTreeName>'
AND EFFDT='<YourEFFDT>'
START WITH tree_node = '<Tree Node for which you wish to find all the child nodes>'
CONNECT BY PRIOR tree_node = parent_node_name -
Hi, I am able to edit the name of a tree node. However, when the editor comes up, it is in append mode. So, I have to backspace on the existing text then type my new name. How do I open the editor in overwrite mode so that I can just start typing the new name.
Thanks!You bind a mouselistener to the tree, so it has to be handled there.
When clicking once (method should be "mouseReleased" or something, treenodes name (toString) should be .setText("");
regards
marco -
How-to synchronize edit forms for a single View Object tree node entrie
Hi all,
I created a tree from a single View Object,
follow this [http://www.oracle.com/technetwork/developer-tools/adf/learnmore/32-tree-table-from-single-vo-169174.pdf]
then i want to create and synchronize edit forms for tree node entries,
follow this [http://www.oracle.com/technetwork/developer-tools/adf/learnmore/50-synchromize-form-treeselection-169192.pdf]
but it not working when i click child node!!
i found the latter tree from many View Object ,but the former tree from single View Object.
what should i do?
Thanks in advanceHi,
say the tree is built from ViewObject1. In the AM model, create a second View Object instance for this. Say ViewObject2. Create the form from ViewObject2 and the tree from ViewObject1. When creating the tree, use the"Target Data Source" option at the bottom to reference the iterator of ViewObject2. Then create a PartialTrigger on the paneFormLayout that holds the synch form. In the partial trigger property, reference the tree so that when the tree selection changes, the form is updated. Then create a PartialTrigger property on the tree and point it to the submit button of the form so you can show updated values in the tree.
Frank -
Tree node images changes.. with start and stop button
I create the animator extends JPanel, which start and stop can be controlled with Swing Timer. It works fine with animation control over the panel.
Now, I have a tree with each image at each node.
when the start button clicks, one node image should be animated.
It is implementable. If animation.gif would have worked, I did't have to do this, but animation gif has fatal error with time interval.
any words would be appreciated. Thanks =Damn !
With version 1.2.1 I think you'll have to create a new class that extends PositionPathInterpolator and add a pause() anr resume() method to it.
i suggest something like:
public class MyPositionPathInterpolator() extends PositionPathInterpolator {
// add some constructors if necessary
private float pauseAlphaValue = 0;
// override computeTransform method
public void computeTransform(float alphaValue, Transform3D transform) {
float newAlphaValue = alphaValue + pauseAlphaValue; // calculate new alpha value
if(newAlphaValue > 1) // modify it if it is out of bounds
newAlphaValue -= 1;
else if (newAlphaValue < 0)
newAlphaValue += 1;
super.computeTransform(newAlphaValue, transform); // computeTransform with the right alpha value
public void pause() {
this.setEnable(false); // it won't compute transform anymore
pauseAlphaValue = this.getAlpha().value(); // retrieve current alphavalue
public void resume() {
pauseAlphaValue -= this.getAlpha().value();
this.setEnable(true) // restart computing transform
}Now you invoke pause and resume methods on your myPositionPathInterpolator object when user clicks on the buttons.
Of course it is a trick and it will work only with increasing alpha.
c ya
GnG -
Hierarchical tree node editable
hi,
is there a property to make a tree node label editable? it would be kind to click on the label, change it and save to DB, instead of copying its value into a text field.
thanksNot directly as Andreas said but alternately you can do by
You can set the label of NODE and update into the BASE table block and re-populate the tree
- on Double click the label call custom Stack canvas contains new label in text item and user will press OK
- Sets the Label of the Tree node
- Update the new label to the base table block
- Commit and re-populate the tree
if responses are helpful or correct please mark it
Baig,
http://baigsorcl.blogspot.com -
Programmatically selecting a Tree node
Hi there,
Given a TreePath object, I need to know how to programmatically select a tree node on a JTree.
Here's the situation:
I have a simple text editor project which has a JTree on its interface representing the local file system. The program has a SaveAs dialog box which also has a duplicate JTree as the one on the main interface (directories only). As the user selects the directory in which they wish to save the open file in the SaveAs dialog box, I need somehow to programmatically cause the JTree on the main interface to correspondingly select the same directory. How is this done?
The whole point of this is so that I can then add a new leaf node to the tree at the specified directory location. I've tried simply setting the jTree1.setSelectionPath(...) method and even tried to call the valueChanged(...) method of the TreeSelectionListener object as you can see from the code snippet below, but none of these approaches have been successful.
Please advise,
Alan
public void createLeafNode()
jTree1.repaint();
if(path == null)
return;
jTree1.setSelectionPath(path);
//SelectionListener.valueChanged(new TreeSelectionEvent(jTree1, path, true, oldLeadPath, newLeadPath));
//System.out.println("path is: " + path.toString());
DefaultTreeNode parent = getTreeNode(path);
//System.out.println("parent is " + parent.toString());
//Create the child node
IconData idata = new IconData(ICON_LEAF, new FileNode(new SpecialFile(ref.FileOpen)));
DefaultTreeNode node = new DefaultTreeNode(idata);
parent.add(node);
//Tell the model that the tree structure has changed
model.nodeStructureChanged(parent);
path = path.pathByAddingChild(node);
jTree1.scrollPathToVisible(path);
//jTree1.repaint();Yes, I've tried setSelectionPath(TreePath path) numerous times, but it does nothing to select the node on the tree! You can see from the code I submitted that it is there commented out.
Ordinarily, when you click on a node on the tree it becomes the "active" node, evident because it becomes highlighted. But when I use setSelectionPath(TreePath path) method, giving it the path it needs, the node on the tree doesn't become the "active" node, therefore, not selected! Furthermore and subsequently, the rest of the code in the method createLeafNode() doesn't add a new node to the tree in the location specified by the TreePath object!
If you have used setSelectionPath(TreePath path) before successfully I would be interested in seeing a small sample program demonstrating its use. It would have to prove to me that you can select a node in the tree without physically clicking on any node in the tree with the mouse cursor, and add a new child node to that selected node.
I submit to you a small test program I put together that demonstrates the "typical setup". It requires the user to physically click on a node of the tree, then click on a button that adds a new node in the location of the selected node. If you can alter this program demonstrating that you can add a new node to the tree without my having to click on any node of the tree with my cursor, then I'll assign you the Duke Dollars and be forever humbled by your programming prowess.
Thanks for keeping on top of this thread as I've tried everything I can think of to try and make my program work. If you need to ask any questions please ask away. Perhaps there is something about my program that I've not explained yet that you're not aware of that I should have included. At this point I can't see the forest for the trees.
Alan
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JTree;
import javax.swing.event.*;
import javax.swing.tree.*;
public class AddNodeExample extends JFrame implements ActionListener
JTree jTree1 = null;
DefaultTreeModel model = null;
DefaultMutableTreeNode rootNode = null;
JScrollPane jScrollPane1 = null;
JLabel status = new JLabel("Status:");
TreePath path = null;
JButton add = new JButton("Add new node");
public static void main(String[] args)
AddNodeExample example = new AddNodeExample();
example.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
public AddNodeExample()
super("Add Node To JTree Example");
setSize(400, 300);
jScrollPane1 = new JScrollPane();
add.addActionListener(this);
DefaultMutableTreeNode[] boys = new DefaultMutableTreeNode[6];
boys[0] = new DefaultMutableTreeNode("Harry");
boys[1] = new DefaultMutableTreeNode("Tom");
boys[2] = new DefaultMutableTreeNode("Jake");
boys[3] = new DefaultMutableTreeNode("Brian");
boys[4] = new DefaultMutableTreeNode("Alan");
boys[5] = new DefaultMutableTreeNode("Guy");
DefaultMutableTreeNode[] girls = new DefaultMutableTreeNode[6];
girls[0] = new DefaultMutableTreeNode("Debbie");
girls[1] = new DefaultMutableTreeNode("Jane");
girls[2] = new DefaultMutableTreeNode("Sally");
girls[3] = new DefaultMutableTreeNode("Jessica");
girls[4] = new DefaultMutableTreeNode("MoonUnit");
girls[5] = new DefaultMutableTreeNode("Sara");
rootNode = new DefaultMutableTreeNode("Students");
DefaultMutableTreeNode Boys = new DefaultMutableTreeNode("Boys");
DefaultMutableTreeNode Girls = new DefaultMutableTreeNode("Girls");
//Fill up the node for boys
for(int i = 0; i < boys.length; i++)
Boys.add(boys);
//Fill up the node for girls
for(int i = 0; i < girls.length; i++)
Girls.add(girls[i]);
//add Boys and Girls to rootNode
rootNode.add(Boys);
rootNode.add(Girls);
model = new DefaultTreeModel(rootNode);
jTree1 = new JTree(model);
jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
jTree1.putClientProperty("JTree.lineStyle", "Angled");
jTree1.addTreeSelectionListener(new TreeSelectionListener()
public void valueChanged(TreeSelectionEvent event)
path = event.getPath();
DefaultMutableTreeNode node = getTreeNode(path);
status.setText("Selected: " + (String)node.getUserObject());
jScrollPane1.getViewport().add(jTree1, null);
getContentPane().add(jScrollPane1, BorderLayout.CENTER);
getContentPane().add(add, BorderLayout.NORTH);
getContentPane().add(status, BorderLayout.SOUTH);
setVisible(true);
public DefaultMutableTreeNode getTreeNode(TreePath path)
return (DefaultMutableTreeNode)(path.getLastPathComponent());
public void actionPerformed(ActionEvent e)
jTree1.repaint();
if (path == null || path.getPathCount() < 1)
return;
DefaultMutableTreeNode treeNode = getTreeNode(path);
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode("My New Node");
treeNode.add(newNode);
model.nodeStructureChanged(treeNode);
path = path.pathByAddingChild(newNode);
jTree1.scrollPathToVisible(path); -
Invalid B tree node size- Computer won't start up anymore
Get the kernel panic/restart messsage - when I restart same thing.... Tried all of the solutions Apple suggest- re-setting PRAM, holding the "X" key, holding the "option" key... nothing seems to work. Ran the OSX install CD and went to utilites, tried to repair the disk that way- but get the message- " Invalid B Tree node size, volume check failed. Error: The underlying task reported failure on exit. IHFS Volume checked - Volume could not be repaired beause of an error.
CD would also not let me re- install OS X
Currently using OS X 10.4.9 on a G4 iMacOwen:
Thank you for posting back with an update of your situation. I am glad you were able to work your way through your issues and secure your Users Folder. Data Resuce II is a great tool.
I have been using different versions of TechTool Pro since OS 9 and have found it to be a great tool. It has saved me from disaster several times. I use TechTool Pro 4.5.2 on Tiger. I am not sure what version you were using, but if, indeed, TTP damaged your data, and I have serious doubts about that, it could be that you were using the wrong version.
Having a good backup strategy is very important. You will find some good hints in Dr. Smoke's FAQ Backup and Recovery. My main difference with Dr. Smoke is the he insists on using Retrospect as his backup software, whereas I have never been able to get it to work. Besides, you will find that SuperDuper is much friendlier and efficient. Indeed, SuperDuper was rated the best backup software in tests. And no need to wait for Leopard to do scheduled backups. SuperDuper will do that, too.
Again, I am glad your issue has been resolved. Use Disk Warrior regularly to rebuild your directories and follow a regular maintenance schedule such as the one Gulliver suggests in his article Mac OS X System Maintenance.
Happy Mac Computing.
cornelius
Message was edited by: cornelius -
How to programmatically click a tree node(make it selected)?
in my program, i want to make a tree node "clicked" by codes, so that the valueChanged(TreeSelectionEvent tse e) method of the TreeSelectionListener can be invoked.
thanks a lot!!private Robot robot;
private void triggerMouseClick(TreePath treePath) {
if (robot == null) {
try {
robot = new Robot();
robot.setAutoDelay(60);
catch (AWTException e) {
e.printStackTrace();
Rectangle rect = this.getPathBounds(treePath);
Point point = new Point(rect.x+1, rect.y+1);
SwingUtilities.convertPointToScreen(point, this);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
Maybe you are looking for
-
Systems are not visiable in monitoring graphic
Hi friends, I am not able to view systems under monitoring graphic. the screen is showing blank. One of our PC is showing systems and self diagnostic screen, i made my system same as that system(GUI, IE, host entries, JRE) but still i am not able to
-
mixer.exe uses 872k of memory according to task manager. It shows up on the taskbar whenever I open firefox 3.6.13. It has an icon of a little rectangle with two white arrows attached to the side of the rectangle pointing inward. When I left click or
-
Design Objects with some common attribute/behavior. Is inheritance correct?
Hi, In an application I am working on the domain/business layer has lots of domain objects. many of these domin objects aggregate to form other domain objects. Also in the application we have a class "User" that has the user information and privilege
-
Work Hours Threshold changing ,what effects?
Hi Gurus, We are planning to change the threshold of Payperiod hours from 80 to 86 hours. Please suggest me how this affect present configuration in Time and Payroll. The present configuration is for 80hours bi-weekly. Anything greater than 86 hours
-
FED UP with dropped Airport connections!
Okay, a little history here. I've been a Mac user for 20+ years. I know my way around these machines. I have a Mac Pro and a Mac Book, and when they were running Tiger I had zero problems with Airport connections in either case. However, since I upgr