Search in sources :

Example 1 with VisualItemAxis

use of org.sirix.gui.view.VisualItemAxis in project sirix by sirixdb.

the class TreeView method refreshUpdate.

@Override
public void refreshUpdate(final Optional<VisualItemAxis> pAxis) {
    // Use our sirix model and renderer.
    dispose();
    final ReadDB db = mGUI.getReadDB();
    mTree.setModel(new TreeModel(db));
    mTree.setCellRenderer(new TreeCellRenderer(db));
    if (mTree.getTreeSelectionListeners().length == 0) {
        // Listen for when the selection changes.
        mTree.addTreeSelectionListener(new TreeSelectionListener() {

            @Override
            public void valueChanged(final TreeSelectionEvent paramE) {
                if (paramE.getNewLeadSelectionPath() != null && paramE.getNewLeadSelectionPath() != paramE.getOldLeadSelectionPath()) {
                    /*
						 * Returns the last path element of the selection. This method is
						 * useful only when the selection model allows a single selection.
						 */
                    final Node node = (Node) paramE.getNewLeadSelectionPath().getLastPathComponent();
                    db.setKey(node.getNodeKey());
                    mNotifier.update(mView, Optional.<VisualItemAxis>absent());
                }
            }
        });
    }
}
Also used : VisualItemAxis(org.sirix.gui.view.VisualItemAxis) Node(org.sirix.node.interfaces.Node) TreeSelectionListener(javax.swing.event.TreeSelectionListener) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) ReadDB(org.sirix.gui.ReadDB)

Example 2 with VisualItemAxis

use of org.sirix.gui.view.VisualItemAxis in project sirix by sirixdb.

the class SunburstControl method notifyChanges.

/**
 * Notify other views of changes.
 *
 * @param pItems
 *          the new item list
 */
private void notifyChanges(final List<SunburstItem> pItems) {
    assert pItems != null;
    final SunburstView view = (SunburstView) ((Embedded) mSunburstGUI.mParent).getView();
    final ViewNotifier notifier = view.getNotifier();
    if (mModel instanceof SunburstModel) {
        notifier.update(view, Optional.<VisualItemAxis>absent());
    } else if (mModel instanceof SunburstCompareModel) {
        notifier.update(view, Optional.of(new VisualItemAxis(pItems)));
    }
}
Also used : VisualItemAxis(org.sirix.gui.view.VisualItemAxis) SunburstCompareModel(org.sirix.gui.view.sunburst.model.SunburstCompareModel) ViewNotifier(org.sirix.gui.view.ViewNotifier) SunburstModel(org.sirix.gui.view.sunburst.model.SunburstModel)

Aggregations

VisualItemAxis (org.sirix.gui.view.VisualItemAxis)2 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1 ReadDB (org.sirix.gui.ReadDB)1 ViewNotifier (org.sirix.gui.view.ViewNotifier)1 SunburstCompareModel (org.sirix.gui.view.sunburst.model.SunburstCompareModel)1 SunburstModel (org.sirix.gui.view.sunburst.model.SunburstModel)1 Node (org.sirix.node.interfaces.Node)1