Skip to content

Commit

Permalink
MONDRIAN: corrected a few bugs: classloading of resources, adding pro…
Browse files Browse the repository at this point in the history
…perties, removed the menu view not used for the moment

[git-p4: depot-paths = "//open/mondrian/": change = 863]
  • Loading branch information
ebengtso committed Oct 7, 2003
1 parent be5966c commit d4a93c3
Show file tree
Hide file tree
Showing 4 changed files with 909 additions and 727 deletions.
68 changes: 42 additions & 26 deletions src/main/mondrian/gui/JTreeUpdater.java
Expand Up @@ -11,54 +11,70 @@
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;

/**
* Helper to enable update the tree and keep expanded nodes expanded after reloading the tree
*
* @author erik
*
*/
public class JTreeUpdater
implements TreeExpansionListener, TreeSelectionListener {
public class JTreeUpdater implements TreeExpansionListener, TreeSelectionListener
{

private JTree tree = null;
private Set expandedTreePaths = new HashSet();
private TreePath[] selectedTreePaths = new TreePath[0];
private boolean nodeWasSelected = false;

public JTreeUpdater(JTree p_tree) {
tree = p_tree;
tree.addTreeExpansionListener(this);
tree.addTreeSelectionListener(this);
/**
* Constructor
*
* @param tree The tree to track
*/
public JTreeUpdater(JTree tree)
{
this.tree = tree;
this.tree.addTreeExpansionListener(this);
this.tree.addTreeSelectionListener(this);
}

/**
* updates the tree
* Call this method whenever you update the tree and needs it reloaded
*/
public synchronized void update() {
tree.removeTreeExpansionListener(this);
tree.removeTreeSelectionListener(this);

((DefaultTreeModel) tree.getModel()).reload();
Iterator keys = expandedTreePaths.iterator();
while (keys.hasNext()) {
TreePath l_path = (TreePath) keys.next();
tree.expandPath(l_path);
public synchronized void update()
{
synchronized(this.tree)
{
this.tree.removeTreeExpansionListener(this);
this.tree.removeTreeSelectionListener(this);

((DefaultTreeModel) this.tree.getModel()).reload();
Iterator keys = expandedTreePaths.iterator();
while (keys.hasNext())
{
TreePath path = (TreePath) keys.next();
this.tree.expandPath(path);
}
this.tree.getSelectionModel().setSelectionPaths(selectedTreePaths);
this.tree.addTreeExpansionListener(this);
this.tree.addTreeSelectionListener(this);
}
tree.getSelectionModel().setSelectionPaths(selectedTreePaths);
tree.addTreeExpansionListener(this);
tree.addTreeSelectionListener(this);
}

public void treeExpanded(TreeExpansionEvent treeExpansionEvent) {
public void treeExpanded(TreeExpansionEvent treeExpansionEvent)
{
expandedTreePaths.add(treeExpansionEvent.getPath());
}

public void treeCollapsed(TreeExpansionEvent treeExpansionEvent) {
public void treeCollapsed(TreeExpansionEvent treeExpansionEvent)
{
expandedTreePaths.remove(treeExpansionEvent.getPath());
}

public void valueChanged(TreeSelectionEvent treeSelectionEvent) {
if (tree.getSelectionPaths() != null
&& tree.getSelectionPaths().length > 0) {
selectedTreePaths = tree.getSelectionModel().getSelectionPaths();
public void valueChanged(TreeSelectionEvent treeSelectionEvent)
{
if (this.tree.getSelectionPaths() != null && this.tree.getSelectionPaths().length > 0)
{
selectedTreePaths = this.tree.getSelectionModel().getSelectionPaths();
}
}
}

0 comments on commit d4a93c3

Please sign in to comment.