Exemplo n.º 1
0
      @Override
      protected void removePoint(PipeCADToolContext context, InputEvent event, int numPoints) {
        PipeCADTool ctxt = context.getOwner();

        if (numPoints > 1) {
          PipeCADToolState endState = context.getState();

          context.clearState();
          try {
            ctxt.removePoint(event);
          } finally {
            context.setState(endState);
            (context.getState()).Entry(context);
          }
        } else if (numPoints == 1) {

          (context.getState()).Exit(context);
          context.clearState();
          try {
            ctxt.removePoint(event);
          } finally {
            context.setState(Polyline.FirstPoint);
            (context.getState()).Entry(context);
          }
        } else {
          super.removePoint(context, event, numPoints);
        }

        return;
      }
Exemplo n.º 2
0
 @Override
 protected void Entry(PipeCADToolContext context) {
   PipeCADTool ctxt = context.getOwner();
   ctxt.setQuestion(PluginServices.getText(this, "insert_next_point_or_line"));
   ctxt.setDescription(getDescription());
   return;
 }
Exemplo n.º 3
0
      @Override
      protected void addPoint(
          PipeCADToolContext context, double pointX, double pointY, InputEvent event) {
        PipeCADTool ctxt = context.getOwner();

        PipeCADToolState endState = context.getState();

        context.clearState();
        try {
          ctxt.addPoint(pointX, pointY, event);
        } finally {
          if (validStartEnd(pointX, pointY)) {
            try {
              ctxt.endGeometry();
              ctxt.end();
              ctxt.fireEndGeometry();
            } finally {
              context.setState(Polyline.FirstPoint);
              (context.getState()).Entry(context);
            }
          } else {
            context.setState(endState);
            (context.getState()).Entry(context);
          }
        }
        return;
      }
Exemplo n.º 4
0
      @Override
      protected void addOption(PipeCADToolContext context, String s) {
        PipeCADTool ctxt = context.getOwner();

        if (s.equals("A") || s.equals("a") || s.equals(PluginServices.getText(this, "inter_arc"))) {

          (context.getState()).Exit(context);
          context.clearState();
          try {
            ctxt.addOption(s);
          } finally {
            context.setState(Polyline.NextPointOrLine);
            (context.getState()).Entry(context);
          }
        } else {
          super.addOption(context, s);
        }

        return;
      }
Exemplo n.º 5
0
 @Override
 protected void Entry(PipeCADToolContext context) {
   PipeCADTool ctxt = context.getOwner();
   boolean deleteButton3 = CADStatus.getCADStatus().isDeleteButtonActivated();
   if (deleteButton3) {
     ctxt.setQuestion(PluginServices.getText(this, "insert_next_point_arc_or_del"));
   } else {
     ctxt.setQuestion(PluginServices.getText(this, "insert_next_point_or_arc"));
   }
   ctxt.setDescription(getDescription());
   return;
 }
Exemplo n.º 6
0
      @Override
      protected void addPoint(
          PipeCADToolContext context, double pointX, double pointY, InputEvent event) {
        PipeCADTool ctxt = context.getOwner();

        if (validStartEnd(pointX, pointY)) {
          (context.getState()).Exit(context);
          context.clearState();
          try {
            ctxt.addPoint(pointX, pointY, event);
          } finally {
            context.setState(Polyline.NextPointOrArc);
            (context.getState()).Entry(context);
          }
        } else {
          JOptionPane.showMessageDialog(
              null,
              PluginServices.getText(this, "invalid_line_start"),
              PluginServices.getText(this, "error_title"),
              JOptionPane.ERROR_MESSAGE);
        }
        return;
      }
Exemplo n.º 7
0
    @Override
    protected void removePoint(PipeCADToolContext context, InputEvent event, int numPoints) {
      PipeCADTool ctxt = context.getOwner();

      boolean loopbackFlag = context.getState().getName().equals(Polyline.FirstPoint.getName());

      if (loopbackFlag == false) {
        (context.getState()).Exit(context);
      }

      context.clearState();
      try {
        ctxt.throwNoPointsException(PluginServices.getText(this, "no_points"));
      } finally {
        context.setState(Polyline.FirstPoint);

        if (loopbackFlag == false) {
          (context.getState()).Entry(context);
        }
      }
      return;
    }
Exemplo n.º 8
0
    @Override
    protected void addValue(PipeCADToolContext context, double d) {
      PipeCADTool ctxt = context.getOwner();

      boolean loopbackFlag = context.getState().getName().equals(Polyline.FirstPoint.getName());

      if (loopbackFlag == false) {
        (context.getState()).Exit(context);
      }

      context.clearState();
      try {
        ctxt.throwValueException(PluginServices.getText(this, "incorrect_value"), d);
      } finally {
        context.setState(Polyline.FirstPoint);

        if (loopbackFlag == false) {
          (context.getState()).Entry(context);
        }
      }
      return;
    }
Exemplo n.º 9
0
    @Override
    protected void addOption(PipeCADToolContext context, String s) {
      PipeCADTool ctxt = context.getOwner();

      if (s.equals(PluginServices.getText(this, "cancel"))) {
        boolean loopbackFlag = context.getState().getName().equals(Polyline.FirstPoint.getName());

        if (loopbackFlag == false) {
          (context.getState()).Exit(context);
        }

        context.clearState();
        try {
          ctxt.cancel();
        } finally {
          context.setState(Polyline.FirstPoint);

          if (loopbackFlag == false) {
            (context.getState()).Entry(context);
          }
        }
      } else if (s.equals("")) {
        boolean loopbackFlag = context.getState().getName().equals(Polyline.FirstPoint.getName());

        if (loopbackFlag == false) {
          (context.getState()).Exit(context);
        }

        context.clearState();
        try {
          ctxt.endGeometry();
        } finally {
          context.setState(Polyline.FirstPoint);

          if (loopbackFlag == false) {
            (context.getState()).Entry(context);
          }
        }
      } else {
        ctxt.throwOptionException(PluginServices.getText(this, "incorrect_option"), s);
      }

      return;
    }
Exemplo n.º 10
0
 protected void Default(PipeCADToolContext context) {
   throw (new statemap.TransitionUndefinedException(
       "State: " + context.getState().getName() + ", Transition: " + context.getTransition()));
 }