Ejemplo n.º 1
0
 private void sourcesMenu() throws IOException {
   System.out.println("List of all known sources");
   for (int i = 0; i < repo.getSources().size(); i++) {
     System.out.println(repo.getSources().get(i));
   }
   System.out.println("Enter 1 or 'add' to add a source.");
   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 (input.equals("1") || input.equals("add")) {
     System.out.println("Please enter the URL or filepath to the source.");
     System.out.println("Enter 0 or 'back' to return to the source menu.");
     input = in.readLine();
     if (input.equals("0") || input.equals("back")) {
       return;
     }
     try {
       repo.getSources().add((new URL(input)));
       System.out.println("Source has been added to the repository.");
     } catch (MalformedURLException me) {
       System.out.println("Invalid URL or file path.");
     }
   }
 }
Ejemplo n.º 2
0
 private void addMenu() throws IOException {
   System.out.println("Please enter the classname of the component you want to add");
   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 {
     try {
       IComponent comp = repo.createComponent(input);
       manager.add(comp);
       System.out.println("Compnent has been added.");
       name = MenuName.MAIN;
     } catch (Exception e) {
       System.out.println("The specified component could not be found.");
     }
   }
 }