package commons.command; import java.util.ArrayList; import java.util.List; import basics.unexpected.Problem; import basics.utl.Empty; import basics.utl.SUtl; import commons.application.Manager; import commons.engine.Command; import commons.ui.UIController; import commons.ui.dtabgui.UIControllerWithDynamicTabs; public class view extends Command { private static final String ARGS = "ARGS: \n\tdel:,... (for Pane T1 enter pane del:1), \n\terrors:show|hide, status:show|hide, \n\taddvar: ;delvar:, delvar:* removes all. "; public void process () throws Exception { UIController ui = Manager.ui(); UIControllerWithDynamicTabs xui = null; if (ui instanceof UIControllerWithDynamicTabs) xui = (UIControllerWithDynamicTabs) ui; String del = ctx.consume("del", ""); if (!Empty.is(del)) { if (del.equals("*")) { int i = 1; if (xui != null) while (xui.getTabCount() > 1) xui.deleteTablePane(i++); } else { String[] unset = SUtl.split(del, ","); if (xui != null) for (String k : unset) xui.deleteTablePane(SUtl.toInt(k, -1)); } } String errors = ctx.consume("errors", ""); String status = ctx.consume("status", ""); if (!Empty.is(errors) && xui != null) { if (errors.equals("show")) xui.errors(true); else if (errors.equals("hide")) xui.errors(false); else throw new Problem("Unknown arg(" + errors + "). Known are: " + ARGS); } if (!Empty.is(status) && xui != null) { if (status.equals("show")) xui.status(true); else if (status.equals("hide")) xui.status(false); else throw new Problem("Unknown arg(" + status + "). Known are: " + ARGS); } String[] addvar = SUtl.split(ctx.consume("addvar", ""), ","); String[] delvar = SUtl.split(ctx.consume("delvar", ""), ","); if (xui != null) { List inspects = xui.getInspectedFields(); for (String k : delvar) { if (k.equals("*")) { inspects = new ArrayList(); break; } if (!Empty.is(k) && inspects.contains(k)) inspects.remove(k); } for (String k : addvar) if (!Empty.is(k) && !inspects.contains(k)) inspects.add(k); xui.setInspectedFields(inspects); } } public void signContract () {} public String description () { return implName() + " removes one or more panels, and shows or hide error and status messages, and lets you inspect variables. " + ARGS; } }