Example #1
0
 private void updateDisplay() {
   // first, set block colours
   textView.setBackground(getColour(backgroundColour("text-background-colour")));
   textView.setForeground(getColour(foregroundColour("text-foreground-colour")));
   textView.setCaretColor(getColour(foregroundColour("text-caret-colour")));
   problemsView.setBackground(getColour(backgroundColour("problems-background-colour")));
   problemsView.setForeground(getColour(foregroundColour("problems-foreground-colour")));
   consoleView.setBackground(getColour(backgroundColour("console-background-colour")));
   consoleView.setForeground(getColour(foregroundColour("console-foreground-colour")));
   // second, set colours on the code!
   java.util.List<Lexer.Token> tokens = Lexer.tokenise(textView.getText(), true);
   int pos = 0;
   for (Lexer.Token t : tokens) {
     int len = t.toString().length();
     if (t instanceof Lexer.RightBrace || t instanceof Lexer.LeftBrace) {
       highlightArea(pos, len, foregroundColour("text-brace-colour"));
     } else if (t instanceof Lexer.Strung) {
       highlightArea(pos, len, foregroundColour("text-string-colour"));
     } else if (t instanceof Lexer.Comment) {
       highlightArea(pos, len, foregroundColour("text-comment-colour"));
     } else if (t instanceof Lexer.Quote) {
       highlightArea(pos, len, foregroundColour("text-quote-colour"));
     } else if (t instanceof Lexer.Comma) {
       highlightArea(pos, len, foregroundColour("text-comma-colour"));
     } else if (t instanceof Lexer.Identifier) {
       highlightArea(pos, len, foregroundColour("text-identifier-colour"));
     } else if (t instanceof Lexer.Integer) {
       highlightArea(pos, len, foregroundColour("text-integer-colour"));
     }
     pos += len;
   }
 }
Example #2
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;
  }
Example #3
0
  public Container CreateContentPane() {
    // Create the content-pane-to-be.
    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setOpaque(true);

    // the log panel
    log = new JTextPane();
    log.setEditable(false);
    log.setBackground(Color.BLACK);
    logPane = new JScrollPane(log);
    kit = new HTMLEditorKit();
    doc = new HTMLDocument();
    log.setEditorKit(kit);
    log.setDocument(doc);
    DefaultCaret c = (DefaultCaret) log.getCaret();
    c.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    ClearLog();

    // the preview panel
    previewPane = new DrawPanel();
    previewPane.setPaperSize(paper_top, paper_bottom, paper_left, paper_right);

    // status bar
    statusBar = new StatusBar();
    Font f = statusBar.getFont();
    statusBar.setFont(f.deriveFont(Font.BOLD, 15));
    Dimension d = statusBar.getMinimumSize();
    d.setSize(d.getWidth(), d.getHeight() + 30);
    statusBar.setMinimumSize(d);

    // layout
    Splitter split = new Splitter(JSplitPane.VERTICAL_SPLIT);
    split.add(previewPane);
    split.add(logPane);
    split.setDividerSize(8);

    contentPane.add(statusBar, BorderLayout.SOUTH);
    contentPane.add(split, BorderLayout.CENTER);

    // open the file
    if (recentFiles[0].length() > 0) {
      OpenFileOnDemand(recentFiles[0]);
    }

    // connect to the last port
    ListSerialPorts();
    if (Arrays.asList(portsDetected).contains(recentPort)) {
      OpenPort(recentPort);
    }

    return contentPane;
  }
Example #4
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;
  }