コード例 #1
0
 void save(PrintWriter out) {
   out.println("<division>");
   out.println("<loperand>");
   WorkspaceObject c = leftSink.getContainedPart();
   if (c != null) c.save(out);
   out.println("</loperand>");
   out.println("<roperand>");
   c = rightSink.getContainedPart();
   if (c != null) c.save(out);
   out.println("</roperand>");
   out.println("</division>");
 }
コード例 #2
0
  public WorkspaceObject getWorkspaceObjectForPart(Object part) // EEH
      {
    if (part == op) return this;

    WorkspaceObject wo = null;
    wo = leftSink.getContainedPart().getWorkspaceObjectForPart(part);
    if (wo != null) return wo;
    wo = rightSink.getContainedPart().getWorkspaceObjectForPart(part);
    if (wo != null) return wo;

    return null;
  }
コード例 #3
0
  JPanel createCustomPanel() {
    Box p = new Box(BoxLayout.PAGE_AXIS);

    // left operand sink
    leftSink = new PartSink(PartType.EXPRESSION_PART);
    leftSink.addCombineListener(
        new CombineListener() {
          public void combined() {
            WorkspaceObject c = leftSink.getContainedPart();
            Object o = c.getPart();
            Expression exp = (Expression) o;
            op.setLeftOperand(exp);
          }

          public void split() {
            op.setLeftOperand(null);
          }
        });
    p.add(leftSink);

    JLabel eqLab = new JLabel("<html><b>&divide;</b></html>");
    p.add(eqLab);

    // right operand sink
    rightSink = new PartSink(PartType.EXPRESSION_PART);
    rightSink.addCombineListener(
        new CombineListener() {
          public void combined() {
            WorkspaceObject c = rightSink.getContainedPart();
            Object o = c.getPart();
            Expression exp = (Expression) o;
            op.setRightOperand(exp);
          }

          public void split() {
            op.setRightOperand(null);
          }
        });
    p.add(rightSink);

    JPanel retPanel = new JPanel();
    retPanel.setLayout(new BorderLayout());
    retPanel.add(p, BorderLayout.CENTER);
    return retPanel;
  }
コード例 #4
0
  public WorkspaceObject getWorkspaceObjectForPart(Object part) // EEH
      {
    if (part == randInt) return this;

    WorkspaceObject wo = null;
    wo = sink.getContainedPart().getWorkspaceObjectForPart(part);
    if (wo != null) return wo;

    return null;
  }
コード例 #5
0
  JPanel createCustomPanel() {
    JPanel p = new JPanel();
    p.setLayout(new GridLayout(1, 1));
    sink = new PartSink(PartType.EXPRESSION_PART);
    sink.addCombineListener(
        new CombineListener() {
          public void combined() {
            WorkspaceObject c = sink.getContainedPart();
            Object o = c.getPart(); // we know this is an expression because of our sink restriction
            Expression exp = (Expression) o;
            randInt.setMax(exp);
          }

          public void split() {
            randInt.setMax(null);
          }
        });
    sink.setToolTipText("Maximum possible value of the random number");
    p.add(sink);
    return p;
  }
コード例 #6
0
 void save(PrintWriter out) {
   out.println("<randint>");
   WorkspaceObject c = sink.getContainedPart();
   if (c != null) c.save(out);
   out.println("</randint>");
 }