Exemplo n.º 1
0
  private JPanel createCentrePanel(YDataStateException exception) {
    JPanel centrePanel = new JPanel(new GridLayout(1, 2));

    JPanel msgPanel = new JPanel(new BorderLayout());
    msgPanel.setBackground(YAdminGUI._apiColour);
    msgPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(
                BorderFactory.createEtchedBorder(), "Schema for completing task"),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    JTextPane msgTextPane = new JTextPane();
    msgTextPane.setContentType("text/plain");
    msgTextPane.setFont(new Font("courier", Font.PLAIN, 12));
    msgTextPane.setForeground(Color.RED);

    msgTextPane.setText(exception.getMessage());
    msgTextPane.setEditable(false);
    msgTextPane.setBackground(Color.LIGHT_GRAY);
    JPanel noWrapPanel = new JPanel();
    noWrapPanel.setLayout(new BorderLayout());
    noWrapPanel.add(msgTextPane);
    msgPanel.add(new JScrollPane(noWrapPanel));

    centrePanel.add(msgPanel, BorderLayout.NORTH);
    return centrePanel;
  }
Exemplo n.º 2
0
  private JPanel createTopPanel(YWorkItem item) {
    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.setBackground(YAdminGUI._apiColour);

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JTextArea explanatoryText = new JTextArea();
    explanatoryText.setText(
        "The data you submitted for this work item was \n"
            + "validated against a schema (see below).  For some reason the\n"
            + "this data did not succeed in passing the constrainst set\n"
            + "inside the schema.\n"
            + "Usage Note: If this is causing problems try using the Web server\n"
            + "version of YAWL, which supports automatic forms generation.\n"
            + "Otherwise you could copy the schema from this page and use it\n "
            + "to create a valid output document using an XML development tool.");
    explanatoryText.setEditable(false);
    explanatoryText.setFont(new Font("Arial", Font.BOLD, 12));
    explanatoryText.setForeground(Color.DARK_GRAY);
    explanatoryText.setBackground(YAdminGUI._apiColour);
    leftPanel.add(explanatoryText);
    topPanel.add(leftPanel, BorderLayout.WEST);

    JPanel rightPanel = new JPanel(new GridLayout(4, 2));

    rightPanel.setBackground(YAdminGUI._apiColour);
    rightPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(
                BorderFactory.createEtchedBorder(), "Work Item Details"),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    YTask task =
        YEngine.getInstance().getTaskDefinition(item.getSpecificationID(), item.getTaskID());
    String taskName = task.getName();

    String[] text = {
      item.getSpecificationID().toString(), taskName, item.getIDString(), item.getStartTimeStr()
    };
    String[] labels = {"Specification ID", "Task Name", "WorkItem ID", "Task Started"};
    for (int i = 0; i < text.length; i++) {
      String s = text[i];
      rightPanel.add(new JLabel(labels[i]));
      JTextField t = new JTextField(s);
      t.setEditable(false);
      rightPanel.add(t);
    }
    topPanel.add(rightPanel, BorderLayout.CENTER);
    return topPanel;
  }
Exemplo n.º 3
0
  private JPanel createCentrePanel(YDataStateException exception) {
    XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat());
    JPanel centrePanel = new JPanel(new GridLayout(1, 2));

    JPanel schemaPanel = new JPanel(new BorderLayout());
    schemaPanel.setBackground(YAdminGUI._apiColour);
    schemaPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(
                BorderFactory.createEtchedBorder(), "Schema for completing task"),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    JTextPane schemaTextPane = new JTextPane();
    schemaTextPane.setContentType("text/xml");
    schemaTextPane.setFont(new Font("courier", Font.PLAIN, 12));
    String schemaXML = xmlOut.outputString(exception.getSchema());

    /** AJH: Trap various XML format errors gracefully. */
    try {
      String xml =
          schemaXML.substring(schemaXML.indexOf('<'), schemaXML.lastIndexOf("</xsd:schema>") + 13);
      schemaTextPane.setText(xml);
    } catch (Exception e) {
      schemaTextPane.setText(schemaXML);
    }

    schemaTextPane.setEditable(false);
    schemaTextPane.setBackground(Color.LIGHT_GRAY);
    JPanel noWrapPanel = new JPanel();
    noWrapPanel.setLayout(new BorderLayout());
    noWrapPanel.add(schemaTextPane);
    schemaPanel.add(new JScrollPane(noWrapPanel));

    JPanel rightPanel = new JPanel(new GridLayout(2, 1));

    JPanel dataPanel = new JPanel(new BorderLayout());
    dataPanel.setBackground(YAdminGUI._apiColour);
    dataPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(
                BorderFactory.createEtchedBorder(), "The data that failed to validate"),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    JTextPane dataTextPane = new JTextPane();
    dataTextPane.setContentType("text/xml");
    dataTextPane.setFont(new Font("courier", Font.PLAIN, 12));
    String data = xmlOut.outputString(exception.get_dataInput());

    /** AJH: Trap various XML format errors gracefully. */
    try {
      String temp = data.substring(data.lastIndexOf("<?xml"), data.lastIndexOf('>'));
      dataTextPane.setText(temp);
    } catch (Exception e) {
      dataTextPane.setText(data);
    }

    dataTextPane.setEditable(false);
    dataTextPane.setBackground(Color.LIGHT_GRAY);
    JPanel noWrapPanel2 = new JPanel();
    noWrapPanel2.setLayout(new BorderLayout());
    noWrapPanel2.add(dataTextPane);
    dataPanel.add(new JScrollPane(noWrapPanel2));

    JPanel errorPanel = new JPanel(new BorderLayout());
    errorPanel.setBackground(YAdminGUI._apiColour);
    errorPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(
                BorderFactory.createEtchedBorder(), "The error message from validation engine"),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    JTextPane errorTextPane = new JTextPane();
    errorTextPane.setContentType("text/plain");
    errorTextPane.setFont(new Font("courier", Font.PLAIN, 12));

    /** AJH: Trap various XML format errors gracefully. */
    try {
      String error = schemaXML.substring(schemaXML.lastIndexOf("ERRORS ="), schemaXML.length());
      errorTextPane.setText(error);
    } catch (Exception e) {
      // null action !
    }

    errorTextPane.setText(exception.getErrors());

    errorTextPane.setEditable(false);
    errorTextPane.setBackground(Color.LIGHT_GRAY);
    JPanel noWrapPanel3 = new JPanel();
    noWrapPanel3.setLayout(new BorderLayout());
    noWrapPanel3.add(errorTextPane);
    errorPanel.add(new JScrollPane(noWrapPanel3));

    rightPanel.add(dataPanel);
    rightPanel.add(errorPanel);
    centrePanel.add(schemaPanel, BorderLayout.NORTH);
    centrePanel.add(rightPanel, BorderLayout.CENTER);
    return centrePanel;
  }