@Override
 public String getCommandName(UIContext context, UICommand cmd) {
   String name = null;
   try {
     UICommandMetadata metadata = cmd.getMetadata(context);
     name = metadata.getName();
     if (!context.getProvider().isGUI()) {
       name = shellifyName(name);
     }
   } catch (Exception e) {
     log.log(Level.SEVERE, "Error while getting command name for " + cmd.getClass(), e);
   }
   return name;
 }
Exemple #2
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((commands == null) ? 0 : commands.hashCode());
   result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
   return result;
 }
 @Test
 public void checkCommandMetadata() throws Exception {
   try (CommandController controller =
       uiTestHarness.createCommandController(
           CDIAddObserverMethodCommand.class, project.getRoot())) {
     controller.initialize();
     // Checks the command metadata
     assertTrue(controller.getCommand() instanceof CDIAddObserverMethodCommand);
     UICommandMetadata metadata = controller.getMetadata();
     assertEquals("CDI: Add Observer Method", metadata.getName());
     assertEquals("Java EE", metadata.getCategory().getName());
     assertEquals("CDI", metadata.getCategory().getSubCategory().getName());
     assertEquals(4, controller.getInputs().size());
     assertTrue(controller.hasInput("named"));
     assertTrue(controller.hasInput("targetClass"));
     assertTrue(controller.hasInput("eventType"));
   }
 }
Exemple #4
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   CompositeCommand other = (CompositeCommand) obj;
   if (commands == null) {
     if (other.commands != null) return false;
   } else if (!commands.equals(other.commands)) return false;
   if (metadata == null) {
     if (other.metadata != null) return false;
   } else if (!metadata.equals(other.metadata)) return false;
   return true;
 }
 @Test
 public void checkCommandMetadata() throws Exception {
   try (CommandController controller =
       uiTestHarness.createCommandController(JPANewEntityCommand.class, project.getRoot())) {
     controller.initialize();
     // Checks the command metadata
     assertTrue(controller.getCommand() instanceof JPANewEntityCommand);
     UICommandMetadata metadata = controller.getMetadata();
     assertEquals("JPA: New Entity", metadata.getName());
     assertEquals("Java EE", metadata.getCategory().getName());
     assertEquals("JPA", metadata.getCategory().getSubCategory().getName());
     assertFalse(
         "Project is created, shouldn't have targetLocation",
         controller.hasInput("targetLocation"));
     assertEquals(5, controller.getInputs().size());
     assertTrue(controller.hasInput("named"));
     assertTrue(controller.hasInput("targetPackage"));
     assertTrue(controller.hasInput("idStrategy"));
     assertTrue(controller.hasInput("tableName"));
     assertTrue(controller.hasInput("overwrite"));
     assertTrue(
         controller.getValueFor("targetPackage").toString().endsWith(DEFAULT_ENTITY_PACKAGE));
   }
 }