Fix bug #1646
A regression was introduced when adding filtering for the WBS screen. Instead of being associated to the original TreeModel, the tree is associated to a newly created one based on the current filtering predicate. So any changes to the original TreeModel aren't automatically shown in the Tree UI. A method must be called to associate a new TreeModel, with the new changes incorporated, to the tree. The method `filterByPredicateIfAny` implemented this functionality, but it was renamed to `reloadTreeUIAfterChanges` to convey better its purpose. Now when adding a new template, `reloadTreeUIAfterChanges` is called and the newly created element is shown.
This commit is contained in:
parent
8ada055b3a
commit
cbd195791d
3 changed files with 16 additions and 29 deletions
|
|
@ -32,17 +32,12 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Filter;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.aspectj.weaver.ICrossReferenceHandler;
|
||||
import org.libreplan.business.common.IAdHocTransactionService;
|
||||
import org.libreplan.business.common.IOnTransaction;
|
||||
import org.libreplan.business.common.Registry;
|
||||
import org.libreplan.business.common.daos.IConfigurationDAO;
|
||||
import org.libreplan.business.common.daos.IConnectorDAO;
|
||||
import org.libreplan.business.common.entities.Connector;
|
||||
import org.libreplan.business.common.entities.EntitySequence;
|
||||
|
|
@ -226,23 +221,15 @@ public class OrderElementTreeController extends TreeController<OrderElement> {
|
|||
.getRoot();
|
||||
orderModel.createFrom(parent, template);
|
||||
getModel().addNewlyAddedChildrenOf(parent);
|
||||
// Force reload bindings after adding the new nodes
|
||||
Util.reloadBindings(tree);
|
||||
|
||||
reloadTreeUIAfterChanges();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void filterByPredicateIfAny() {
|
||||
if (predicate != null) {
|
||||
filterByPredicate();
|
||||
}
|
||||
}
|
||||
|
||||
private void filterByPredicate() {
|
||||
OrderElementTreeModel orderElementTreeModel = orderModel
|
||||
.getOrderElementsFilteredByPredicate(predicate);
|
||||
tree.setModel(orderElementTreeModel.asTree());
|
||||
@Override
|
||||
protected void reloadTreeUIAfterChanges() {
|
||||
tree.setModel(getFilteredTreeModel());
|
||||
tree.invalidate();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ public class TemplatesTreeController extends
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void filterByPredicateIfAny() {
|
||||
protected void reloadTreeUIAfterChanges() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
|||
public void indent(T element) {
|
||||
viewStateSnapshot = TreeViewStateSnapshot.takeSnapshot(tree);
|
||||
getModel().indent(element);
|
||||
filterByPredicateIfAny();
|
||||
reloadTreeUIAfterChanges();
|
||||
updateControlButtons();
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
|||
public void unindent(T element) {
|
||||
viewStateSnapshot = TreeViewStateSnapshot.takeSnapshot(tree);
|
||||
getModel().unindent(element);
|
||||
filterByPredicateIfAny();
|
||||
reloadTreeUIAfterChanges();
|
||||
updateControlButtons();
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
|||
public void up(T element) {
|
||||
viewStateSnapshot = TreeViewStateSnapshot.takeSnapshot(tree);
|
||||
getModel().up(element);
|
||||
filterByPredicateIfAny();
|
||||
reloadTreeUIAfterChanges();
|
||||
updateControlButtons();
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
|||
public void down(T element) {
|
||||
viewStateSnapshot = TreeViewStateSnapshot.takeSnapshot(tree);
|
||||
getModel().down(element);
|
||||
filterByPredicateIfAny();
|
||||
reloadTreeUIAfterChanges();
|
||||
updateControlButtons();
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
|||
|
||||
getModel().move(fromNode, toNode);
|
||||
}
|
||||
filterByPredicateIfAny();
|
||||
reloadTreeUIAfterChanges();
|
||||
}
|
||||
|
||||
public void addElement() {
|
||||
|
|
@ -217,7 +217,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
|||
} else {
|
||||
getModel().addElement();
|
||||
}
|
||||
filterByPredicateIfAny();
|
||||
reloadTreeUIAfterChanges();
|
||||
} catch (IllegalStateException e) {
|
||||
LOG.warn("exception ocurred adding element", e);
|
||||
messagesForUser.showMessage(Level.ERROR, e.getMessage());
|
||||
|
|
@ -252,7 +252,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
|||
|
||||
// Moved here in order to have items already renderer in order
|
||||
// to select the proper element to focus
|
||||
filterByPredicateIfAny();
|
||||
reloadTreeUIAfterChanges();
|
||||
|
||||
if (node.isLeaf() && !node.isEmptyLeaf()) {
|
||||
// Then a new container will be created
|
||||
|
|
@ -267,7 +267,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
|||
|
||||
// This is needed in both parts of the if, but it's repeated in
|
||||
// order to simplify the code
|
||||
filterByPredicateIfAny();
|
||||
reloadTreeUIAfterChanges();
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
LOG.warn("exception ocurred adding element", e);
|
||||
|
|
@ -284,7 +284,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
|||
}
|
||||
}
|
||||
|
||||
protected abstract void filterByPredicateIfAny();
|
||||
protected abstract void reloadTreeUIAfterChanges();
|
||||
|
||||
protected static class TreeViewStateSnapshot {
|
||||
private final Set<Object> all;
|
||||
|
|
@ -344,7 +344,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
|||
for (Treeitem treeItem : selectedItems) {
|
||||
remove(type.cast(treeItem.getValue()));
|
||||
}
|
||||
filterByPredicateIfAny();
|
||||
reloadTreeUIAfterChanges();
|
||||
}
|
||||
|
||||
public void remove(T element) {
|
||||
|
|
@ -1156,7 +1156,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
|||
@Override
|
||||
public void onEvent(Event event) {
|
||||
remove(currentElement);
|
||||
filterByPredicateIfAny();
|
||||
reloadTreeUIAfterChanges();
|
||||
}
|
||||
};
|
||||
final Button result;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue