/** Helper method that'll display the ordering of the stack and a helpful debug message! */ private void inspectStack(String msg) { if (!DEBUG) { return; } StringBuilder sb = new StringBuilder(this.hashCode()).append(": ").append(msg).append(": ["); for (ViewManager vm : previousVMs) { sb.append(vm.hashCode()).append(','); } logger.trace(sb.append("] Size=").append(previousVMs.size()).toString()); }
/** * Sets the active tab of the dashboard to the layer controls and makes the first layer (TODO: fix * that!) of the given ViewManager the active layer. * * @param vm The ViewManager to make active. * @param doShow Whether or not the layer controls should become the active tab in the dashboard. */ private void focusLayerControlsOn(ViewManager vm, boolean doShow) { List<DisplayControlImpl> controls = vm.getControlsForLegend(); if (controls != null && !controls.isEmpty()) { DisplayControlImpl control = controls.get(0); if (doShow) { GuiUtils.showComponentInTabs(control.getOuterContents(), false); } } }
// TODO: when you start removing the debug stuff, just convert the messages // to comments. @Override public void setLastActiveViewManager(ViewManager vm) { String debugMsg = "created new vm"; if (vm != null) { if (previousVMs.search(vm) >= 0) { debugMsg = "reset active vm"; previousVMs.remove(vm); focusLayerControlsOn(vm, false); } previousVMs.push(vm); } else { debugMsg = "removed active vm"; ViewManager lastActive = getLastActiveViewManager(); if (lastActive == null) return; lastActive.setLastActive(false); previousVMs.pop(); // if there are no more VMs, make sure the IDV code knows about it // by setting the last active VM to null. if (previousVMs.isEmpty()) { super.setLastActiveViewManager(null); return; } lastActive = previousVMs.peek(); lastActive.setLastActive(true); focusLayerControlsOn(lastActive, false); } inspectStack(debugMsg); super.setLastActiveViewManager(previousVMs.peek()); // start active tab testing ComponentHolder holder = uiManager.getViewManagerHolder(previousVMs.peek()); if ((holder != null) && (holder instanceof McvComponentHolder)) { ((McvComponentHolder) holder).setAsActiveTab(); } // stop active tab testing }
/** * Turns off layer visibility animation for all {@code ViewManager}s. This is typically only * useful for when the user has removed all layers <i>without</i> turning off the layer animation * setting. */ protected void disableAllLayerVizAnimations() { for (ViewManager vm : getViewManagers()) { vm.setAnimatedVisibilityCheckBox(false); } }