Package org.tinyuml.util

Examples of org.tinyuml.util.MethodCall


   * Tests usage of the MethodCall class.
   * @throws Exception if error occurred
   */
  public void testMethodCall() throws Exception {
    MyObject myobj = new MyObject();
    MethodCall mycall = new MethodCall(myobj.getClass().getMethod("mymethod",
      String.class), "wascalled");
    mycall.call(myobj);
    assertEquals("wascalled", myobj.callparam);
  }
View Full Code Here


   * than a switch. I put it in here anyways and see if there is anything
   * better as I extend the app, maybe I can pull it out of this class.
   */
  private void initSelectorMap() {
    try {
      selectorMap.put(AppCommand.CREATE_PACKAGE, new MethodCall(
        getClass().getMethod("setCreationMode", ElementType.class),
          ElementType.PACKAGE));
      selectorMap.put(AppCommand.CREATE_COMPONENT, new MethodCall(
        getClass().getMethod("setCreationMode", ElementType.class),
          ElementType.COMPONENT));
      selectorMap.put(AppCommand.CREATE_CLASS, new MethodCall(
        getClass().getMethod("setCreationMode", ElementType.class),
          ElementType.CLASS));
      selectorMap.put(AppCommand.CREATE_NOTE, new MethodCall(
        getClass().getMethod("setCreationMode", ElementType.class),
          ElementType.NOTE));
      selectorMap.put(AppCommand.CREATE_DEPENDENCY, new MethodCall(
        getClass().getMethod("setCreateConnectionMode", RelationType.class),
          RelationType.DEPENDENCY));
      selectorMap.put(AppCommand.CREATE_NOTE_CONNECTION, new MethodCall(
        getClass().getMethod("setCreateConnectionMode", RelationType.class),
          RelationType.NOTE_CONNECTOR));
      selectorMap.put(AppCommand.CREATE_ASSOCIATION, new MethodCall(
        getClass().getMethod("setCreateConnectionMode", RelationType.class),
          RelationType.ASSOCIATION));
      selectorMap.put(AppCommand.CREATE_COMPOSITION, new MethodCall(
        getClass().getMethod("setCreateConnectionMode", RelationType.class),
          RelationType.COMPOSITION));
      selectorMap.put(AppCommand.CREATE_AGGREGATION, new MethodCall(
        getClass().getMethod("setCreateConnectionMode", RelationType.class),
          RelationType.AGGREGATION));
      selectorMap.put(AppCommand.CREATE_INHERITANCE, new MethodCall(
        getClass().getMethod("setCreateConnectionMode", RelationType.class),
          RelationType.INHERITANCE));
      selectorMap.put(AppCommand.CREATE_INTERFACE_REALIZATION, new MethodCall(
        getClass().getMethod("setCreateConnectionMode", RelationType.class),
          RelationType.INTERFACE_REALIZATION));
      selectorMap.put(AppCommand.RESET_POINTS, new MethodCall(
        getClass().getMethod("resetConnectionPoints")));
      selectorMap.put(AppCommand.RECT_TO_DIRECT, new MethodCall(
        getClass().getMethod("rectilinearToDirect")));
      selectorMap.put(AppCommand.DIRECT_TO_RECT, new MethodCall(
        getClass().getMethod("directToRectilinear")));
      selectorMap.put(AppCommand.NAVIGABLE_TO_SOURCE, new MethodCall(
        getClass().getMethod("setNavigability", RelationEndType.class),
        RelationEndType.SOURCE));
      selectorMap.put(AppCommand.NAVIGABLE_TO_TARGET, new MethodCall(
        getClass().getMethod("setNavigability", RelationEndType.class),
        RelationEndType.TARGET));
    } catch (NoSuchMethodException ex) {
      ex.printStackTrace();
    }
View Full Code Here

  /**
   * Handles the specified AppCommand.
   * @param command the command
   */
  public void handleCommand(AppCommand command) {
    MethodCall methodCall = selectorMap.get(command);
    if (methodCall != null) {
      methodCall.call(this);
    }
  }
View Full Code Here

  /**
   * Initializes the selector map.
   */
  private void initSelectorMap() {
    try {
      selectorMap.put("NEW_MODEL", new MethodCall(
        getClass().getMethod("newModel")));
      selectorMap.put("OPEN_MODEL", new MethodCall(
        getClass().getMethod("openModel")));
      selectorMap.put("SAVE_AS", new MethodCall(
        getClass().getMethod("saveAs")));
      selectorMap.put("SAVE", new MethodCall(
        getClass().getMethod("save")));
      selectorMap.put("EXPORT_GFX", new MethodCall(
        getClass().getMethod("exportGfx")));
      selectorMap.put("DELETE", new MethodCall(
        getClass().getMethod("delete")));
      selectorMap.put("EDIT_SETTINGS", new MethodCall(
        getClass().getMethod("editSettings")));
      selectorMap.put("QUIT", new MethodCall(
        getClass().getMethod("quitApplication")));
      selectorMap.put("ABOUT", new MethodCall(
        getClass().getMethod("about")));
      selectorMap.put("HELP_CONTENTS", new MethodCall(
        getClass().getMethod("displayHelpContents")));
    } catch (NoSuchMethodException ex) {
      ex.printStackTrace();
    }
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public void handleCommand(String command) {
    MethodCall methodcall = selectorMap.get(command);
    if (methodcall != null) {
      methodcall.call(this);
    } else {
      System.out.println("not handled: " + command);
    }
  }
View Full Code Here

  /**
   * Initializes the selector map.
   */
  private void initSelectorMap() {
    try {
      selectorMap.put("SELECT_MODE", new MethodCall(
        DiagramEditor.class.getMethod("setSelectionMode")));
      selectorMap.put("REDO", new MethodCall(
        DiagramEditor.class.getMethod("redo")));
      selectorMap.put("UNDO", new MethodCall(
        DiagramEditor.class.getMethod("undo")));
      selectorMap.put("REDRAW", new MethodCall(
        DiagramEditor.class.getMethod("redraw")));
      selectorMap.put("ZOOM_50", new MethodCall(
        DiagramEditor.class.getMethod("setScaling", Scaling.class),
          Scaling.SCALING_50));
      selectorMap.put("ZOOM_75", new MethodCall(
        DiagramEditor.class.getMethod("setScaling", Scaling.class),
          Scaling.SCALING_75));
      selectorMap.put("ZOOM_100", new MethodCall(
        DiagramEditor.class.getMethod("setScaling", Scaling.class),
          Scaling.SCALING_100));
      selectorMap.put("ZOOM_150", new MethodCall(
        DiagramEditor.class.getMethod("setScaling", Scaling.class),
          Scaling.SCALING_150));
      selectorMap.put("BRING_TO_FRONT", new MethodCall(
        DiagramEditor.class.getMethod("bringToFront")));
      selectorMap.put("PUT_TO_BACK", new MethodCall(
        DiagramEditor.class.getMethod("putToBack")));
      selectorMap.put("EDIT_PROPERTIES", new MethodCall(
        DiagramEditor.class.getMethod("editProperties")));

      selectorMap.put("CREATE_PACKAGE", new MethodCall(
        DiagramEditor.class.getMethod("setCreationMode", ElementType.class),
          ElementType.PACKAGE));
      selectorMap.put("CREATE_COMPONENT", new MethodCall(
        DiagramEditor.class.getMethod("setCreationMode", ElementType.class),
          ElementType.COMPONENT));
      selectorMap.put("CREATE_CLASS", new MethodCall(
        DiagramEditor.class.getMethod("setCreationMode", ElementType.class),
          ElementType.CLASS));
      selectorMap.put("CREATE_NOTE", new MethodCall(
        DiagramEditor.class.getMethod("setCreationMode", ElementType.class),
          ElementType.NOTE));
      selectorMap.put("CREATE_DEPENDENCY", new MethodCall(
        DiagramEditor.class.getMethod("setCreateConnectionMode",
        RelationType.class), RelationType.DEPENDENCY));
      selectorMap.put("CREATE_NOTE_CONNECTION", new MethodCall(
        DiagramEditor.class.getMethod("setCreateConnectionMode",
        RelationType.class), RelationType.NOTE_CONNECTOR));
      selectorMap.put("CREATE_ASSOCIATION", new MethodCall(
        DiagramEditor.class.getMethod("setCreateConnectionMode",
        RelationType.class), RelationType.ASSOCIATION));
      selectorMap.put("CREATE_COMPOSITION", new MethodCall(
        DiagramEditor.class.getMethod("setCreateConnectionMode",
        RelationType.class), RelationType.COMPOSITION));
      selectorMap.put("CREATE_AGGREGATION", new MethodCall(
        DiagramEditor.class.getMethod("setCreateConnectionMode",
        RelationType.class), RelationType.AGGREGATION));
      selectorMap.put("CREATE_INHERITANCE", new MethodCall(
        DiagramEditor.class.getMethod("setCreateConnectionMode",
        RelationType.class), RelationType.INHERITANCE));
      selectorMap.put("CREATE_INTERFACE_REALIZATION", new MethodCall(
        DiagramEditor.class.getMethod("setCreateConnectionMode",
        RelationType.class), RelationType.INTERFACE_REALIZATION));
      selectorMap.put("RESET_POINTS", new MethodCall(
        DiagramEditor.class.getMethod("resetConnectionPoints")));
      selectorMap.put("RECT_TO_DIRECT", new MethodCall(
        DiagramEditor.class.getMethod("rectilinearToDirect")));
      selectorMap.put("DIRECT_TO_RECT", new MethodCall(
        DiagramEditor.class.getMethod("directToRectilinear")));
      selectorMap.put("NAVIGABLE_TO_SOURCE", new MethodCall(
        DiagramEditor.class.getMethod("setNavigability", RelationEndType.class),
        RelationEndType.SOURCE));
      selectorMap.put("NAVIGABLE_TO_TARGET", new MethodCall(
        DiagramEditor.class.getMethod("setNavigability", RelationEndType.class),
        RelationEndType.TARGET));

      // Self-calls
      selectorMap.put("SHOW_GRID", new MethodCall(
        getClass().getMethod("showGrid")));
      selectorMap.put("SNAP_TO_GRID", new MethodCall(
        getClass().getMethod("snapToGrid")));
    } catch (NoSuchMethodException ex) {
      ex.printStackTrace();
    }
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public void handleCommand(String command) {
    MethodCall methodcall = selectorMap.get(command);
    if (methodcall != null) {
      Object target = getCurrentEditor();
      // in order to catch the self calling methods
      if (methodcall.getMethod().getDeclaringClass()
        == EditorCommandDispatcher.class) {
        target = this;
      }
      methodcall.call(target);
    } else {
      System.out.println("not handled: " + command);
    }
  }
View Full Code Here

   * Tests usage of the MethodCall class.
   * @throws Exception if error occurred
   */
  public void testMethodCall() throws Exception {
    MyObject myobj = new MyObject();
    MethodCall mycall = new MethodCall(myobj.getClass().getMethod("mymethod",
      String.class), "wascalled");
    mycall.call(myobj);
    assertEquals(myobj.getClass().getMethod("mymethod", String.class),
      mycall.getMethod());
    assertEquals("wascalled", myobj.callparam);
  }
View Full Code Here

   * Initializes the selector map.
   */
  private void initSelectorMap() {
    try {
      // Self-calls
      selectorMap.put("SHOW_GRID", new MethodCall(
        getClass().getMethod("showGrid")));
      selectorMap.put("SNAP_TO_GRID", new MethodCall(
        getClass().getMethod("snapToGrid")));
    } catch (NoSuchMethodException ex) {
      ex.printStackTrace();
    }
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public void handleCommand(String command) {
    MethodCall methodcall = selectorMap.get(command);
    if (methodcall != null) {
      methodcall.call(this);
    } else {
      DiagramEditor editor = getCurrentEditor();
      if (editor != null) editor.handleCommand(command);
    }
  }
View Full Code Here

TOP

Related Classes of org.tinyuml.util.MethodCall

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.