@Override public void run() { Command actualCommand = null; for (ProcessNode node : editor.getModel().getChildren()) { boolean minimize = type == MINIMIZE; if (node.isMinimized() == minimize) continue; ChangeStateCommand newCommand = new ChangeStateCommand(node); actualCommand = CommandUtil.chain(newCommand, actualCommand); } if (actualCommand == null) return; editor.getCommandStack().execute(actualCommand); }