private void componentMenu() throws Exception { String state = "stopped"; String toggle = "start"; String temp; IComponent comp = manager.findByName(input); if (comp.getState() == ComponentState.Running) { state = "running"; toggle = "stop"; } System.out.println("Component name: " + comp.getName()); System.out.println("Component description: " + comp.getDescription()); System.out.println("Component state: " + state); System.out.println("\nEnter 1 or '" + toggle + "'to " + toggle + "the component"); System.out.println("Enter 2 or 'remove' to remove the component from the RTE"); System.out.println("Enter 0 or 'back' to return to the main Menu."); temp = input; input = in.readLine(); if (input.equals("0") || input.equals("back")) { name = MenuName.MAIN; } else if (input.equals("1") || input.equals(toggle)) { if (comp.getState() == ComponentState.Running) comp.stop(); else comp.start(new ComponentContext(manager)); input = temp; } else if (input.equals("2") || input.equals("remove")) { manager.remove(comp); System.out.println("Component " + comp.getName() + " has been removed from the RTE."); name = MenuName.MAIN; } else { System.out.println("Invalid input!"); } }
private void componentsMenu() throws IOException { if (running) { components = manager.getRunningComponents(); System.out.println("Currently running components."); } else { components = manager.getAllComponents(); System.out.println("List of all components."); } for (int i = 0; i < components.size(); i++) { System.out.println("Component " + (i + 1) + ": " + components.get(i).getName()); } System.out.println( "\nFor more information on a component " + "please enter the name or number of it."); System.out.println("Enter 0 or 'back' to return to the main Menu."); input = in.readLine(); if (input.equals("0") || input.equals("back")) { name = MenuName.MAIN; } else if (manager.findByName(input) != null) { name = MenuName.COMPONENT; } else { System.out.println("Invalid input!"); } }