Package jsyntaxpane

Examples of jsyntaxpane.DefaultSyntaxKit


        Color orange = new Color(0xf5871f);
        Color yellow = new Color(0xeab700);


       
        DefaultSyntaxKit kit = (DefaultSyntaxKit) editorKit;
        pane.setBackground(background);
        //0 = default style
        //2 = italic
        //1 = bold
        kit.setProperty("Style.COMMENT", toHex(comment,2))//block and line comments
        kit.setProperty("Style.COMMENT2", toHex(Color.PINK,0)); //??
        kit.setProperty("Style.DEFAULT", toHex(foreground,0));
        kit.setProperty("Style.DELIMITER", toHex(Color.PINK,1));
        kit.setProperty("Style.ERROR", toHex(Color.PINK,3));
        kit.setProperty("Style.IDENTIFIER", toHex(blue,0)); //everything?
        kit.setProperty("Style.KEYWORD", toHex(purple,1)); //
        kit.setProperty("Style.KEYWORD2", toHex(purple,1)); // #include
        kit.setProperty("Style.NUMBER", toHex(red,1)); //number literals
        kit.setProperty("Style.OPERATOR", toHex(foreground,0)); //plus, dot, comma, asterix, etc
        kit.setProperty("Style.REGEX", toHex(foreground,0));
        kit.setProperty("Style.STRING", toHex(green,0)); //string literals
        kit.setProperty("Style.STRING2", toHex(Color.PINK,0));
        kit.setProperty("Style.TYPE", toHex(green,0)); //void, int
        kit.setProperty("Style.TYPE2", toHex(Color.PINK,0));
        kit.setProperty("Style.TYPE3", toHex(Color.PINK,0));
        kit.setProperty("Style.WARNING", toHex(Color.PINK,0));
       
        kit.setProperty("CaretColor", toHex(red));
        kit.setProperty("SelectionColor", toHex(selection));
        kit.setProperty("PairMarker.Color",toHex(yellow));
        kit.setProperty("TokenMarker.Color",toHex(yellow));
        kit.setProperty("LineNumbers.Background",toHex(currentLine));
        kit.setProperty("LineNumbers.CurrentBack",toHex(selection));
        kit.setProperty("LineNumbers.Foreground",toHex(Color.BLACK));
        kit.setProperty("LineNumbers.RightMargin","7");
       
        /*
        Style.COMMENT 0x339933, 2
Style.COMMENT2 0x339933, 3
Style.DEFAULT 0x000000, 0
View Full Code Here


        return parent != null ? (myui.getPreferredSize(this).width <= parent.getSize().width) : true;
    }

    public void init(String contentType) {
        setContentType(contentType);
        DefaultSyntaxKit kit = (DefaultSyntaxKit) getEditorKit();
        kit.deinstallComponent(this, "jsyntaxpane.components.LineNumbersRuler");
        kit.installComponent(this, "com.qspin.qtaste.ui.jedit.LineNumberPanel");
        installAdditionalPopup();
        setFont(new Font("monospaced", Font.PLAIN, 12));
        setTabs(4);
        ActionMap actions = this.getActionMap();
        // remove the default behaviour
View Full Code Here

    {
      /* Workaround to configure jsyntaxpane */
      JEditorPane e = new JEditorPane();
      new JScrollPane(e);
      e.setContentType("text/c");
      DefaultSyntaxKit kit = (DefaultSyntaxKit) e.getEditorKit();
      kit.setProperty("Action.addbreakpoint", JSyntaxAddBreakpoint.class.getName());
      kit.setProperty("Action.removebreakpoint", JSyntaxRemoveBreakpoint.class.getName());
      kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,addbreakpoint,removebreakpoint");
    }

    setLayout(new BorderLayout());
    codeEditor = new JEditorPane();
    add(new JScrollPane(codeEditor), BorderLayout.CENTER);
    doLayout();

    codeEditorLines = new HashMap<Integer, Integer>();
    codeEditor.setContentType("text/c");
    DefaultSyntaxKit kit = (DefaultSyntaxKit) codeEditor.getEditorKit();
    kit.setProperty("Action.addbreakpoint", JSyntaxAddBreakpoint.class.getName());
    kit.setProperty("Action.removebreakpoint", JSyntaxRemoveBreakpoint.class.getName());
    kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,addbreakpoint,removebreakpoint");

    JPopupMenu p = codeEditor.getComponentPopupMenu();
    for (Component c: p.getComponents()) {
      if (c instanceof JMenuItem) {
        if (((JMenuItem) c).getAction() != null &&
View Full Code Here

      /* XXX Workaround to configure jsyntaxpane */
      JEditorPane e = new JEditorPane();
      new JScrollPane(e);
      e.setContentType("text/javascript");
      if (e.getEditorKit() instanceof DefaultSyntaxKit) {
        DefaultSyntaxKit kit = (DefaultSyntaxKit) e.getEditorKit();
        kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,linkfile");
        kit.setProperty("Action.linkfile", JSyntaxLinkFile.class.getName());
        kit.setProperty("Action.execute-script", "jsyntaxpane.actions.ScriptRunnerAction");
      }
    }

    /* Script area */
    setLayout(new BorderLayout());
    codeEditor = new JEditorPane();

    logTextArea = new JTextArea(12,50);
    logTextArea.setMargin(new Insets(5,5,5,5));
    logTextArea.setEditable(true);
    logTextArea.setCursor(null);

    final JCheckBoxMenuItem activateMenuItem = new JCheckBoxMenuItem("Activate");
    activateMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ev) {
        try {
          setScriptActive(!isActive());
        } catch (Exception e) {
          logger.fatal("Error: " + e.getMessage(), e);
        }
      }
    });
    runMenu.add(activateMenuItem);

    final JMenuItem runTestMenuItem = new JMenuItem("Save simulation and run with script");
    runMenu.add(runTestMenuItem);
    runTestMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        exportAndRun();
      }
    });

    doLayout();
    centerPanel = new JSplitPane(
        JSplitPane.VERTICAL_SPLIT,
        new JScrollPane(codeEditor),
        new JScrollPane(logTextArea)
    );

    MenuListener toggleMenuItems = new MenuListener() {
      public void menuSelected(MenuEvent e) {
        activateMenuItem.setSelected(isActive());
        runTestMenuItem.setEnabled(!isActive());
        examplesMenu.setEnabled(!isActive());
      }
      public void menuDeselected(MenuEvent e) {
      }
      public void menuCanceled(MenuEvent e) {
      }
    };
    fileMenu.addMenuListener(toggleMenuItems);
    editMenu.addMenuListener(toggleMenuItems);
    runMenu.addMenuListener(toggleMenuItems);


    codeEditor.setContentType("text/javascript");
    if (codeEditor.getEditorKit() instanceof DefaultSyntaxKit) {
      DefaultSyntaxKit kit = (DefaultSyntaxKit) codeEditor.getEditorKit();
      kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,linkfile");
      kit.setProperty("Action.linkfile", JSyntaxLinkFile.class.getName());
      kit.setProperty("Action.execute-script", "jsyntaxpane.actions.ScriptRunnerAction");
    }

    JPopupMenu p = codeEditor.getComponentPopupMenu();
    if (p != null) {
      for (Component c: p.getComponents()) {
View Full Code Here

      /* XXX Workaround to configure jsyntaxpane */
      JEditorPane e = new JEditorPane();
      new JScrollPane(e);
      e.setContentType("text/javascript");
      if (e.getEditorKit() instanceof DefaultSyntaxKit) {
        DefaultSyntaxKit kit = (DefaultSyntaxKit) e.getEditorKit();
        kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,linkfile");
        kit.setProperty("Action.linkfile", JSyntaxLinkFile.class.getName());
        kit.setProperty("Action.execute-script", "jsyntaxpane.actions.ScriptRunnerAction");
      }
    }

    /* Script area */
    setLayout(new BorderLayout());
    codeEditor = new JEditorPane();

    logTextArea = new JTextArea(12,50);
    logTextArea.setMargin(new Insets(5,5,5,5));
    logTextArea.setEditable(true);
    logTextArea.setCursor(null);

    final JCheckBoxMenuItem activateMenuItem = new JCheckBoxMenuItem("Activate");
    activateMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ev) {
        try {
          setScriptActive(!isActive());
        } catch (Exception e) {
          logger.fatal("Error: " + e.getMessage(), e);
        }
      }
    });
    runMenu.add(activateMenuItem);

    final JMenuItem runTestMenuItem = new JMenuItem("Save simulation and run with script");
    runMenu.add(runTestMenuItem);
    runTestMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        exportAndRun();
      }
    });

    doLayout();
    centerPanel = new JSplitPane(
        JSplitPane.VERTICAL_SPLIT,
        new JScrollPane(codeEditor),
        new JScrollPane(logTextArea)
    );

    MenuListener toggleMenuItems = new MenuListener() {
      public void menuSelected(MenuEvent e) {
        activateMenuItem.setSelected(isActive());
        runTestMenuItem.setEnabled(!isActive());
        examplesMenu.setEnabled(!isActive());
      }
      public void menuDeselected(MenuEvent e) {
      }
      public void menuCanceled(MenuEvent e) {
      }
    };
    fileMenu.addMenuListener(toggleMenuItems);
    editMenu.addMenuListener(toggleMenuItems);
    runMenu.addMenuListener(toggleMenuItems);


    codeEditor.setContentType("text/javascript");
    if (codeEditor.getEditorKit() instanceof DefaultSyntaxKit) {
      DefaultSyntaxKit kit = (DefaultSyntaxKit) codeEditor.getEditorKit();
      kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,linkfile");
      kit.setProperty("Action.linkfile", JSyntaxLinkFile.class.getName());
      kit.setProperty("Action.execute-script", "jsyntaxpane.actions.ScriptRunnerAction");
    }

    JPopupMenu p = codeEditor.getComponentPopupMenu();
    if (p != null) {
      for (Component c: p.getComponents()) {
View Full Code Here

    {
      /* Workaround to configure jsyntaxpane */
      JEditorPane e = new JEditorPane();
      new JScrollPane(e);
      e.setContentType("text/c");
      DefaultSyntaxKit kit = (DefaultSyntaxKit) e.getEditorKit();
      kit.setProperty("Action.addbreakpoint", JSyntaxAddBreakpoint.class.getName());
      kit.setProperty("Action.removebreakpoint", JSyntaxRemoveBreakpoint.class.getName());
      kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,addbreakpoint,removebreakpoint");
    }

    setLayout(new BorderLayout());
    codeEditor = new JEditorPane();
    add(new JScrollPane(codeEditor), BorderLayout.CENTER);
    doLayout();

    codeEditorLines = new HashMap<Integer, Integer>();
    codeEditor.setContentType("text/c");
    DefaultSyntaxKit kit = (DefaultSyntaxKit) codeEditor.getEditorKit();
    kit.setProperty("Action.addbreakpoint", JSyntaxAddBreakpoint.class.getName());
    kit.setProperty("Action.removebreakpoint", JSyntaxRemoveBreakpoint.class.getName());
    kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,addbreakpoint,removebreakpoint");

    JPopupMenu p = codeEditor.getComponentPopupMenu();
    for (Component c: p.getComponents()) {
      if (c instanceof JMenuItem) {
        if (((JMenuItem) c).getAction() != null &&
View Full Code Here

      /* XXX Workaround to configure jsyntaxpane */
      JEditorPane e = new JEditorPane();
      new JScrollPane(e);
      e.setContentType("text/javascript");
      if (e.getEditorKit() instanceof DefaultSyntaxKit) {
        DefaultSyntaxKit kit = (DefaultSyntaxKit) e.getEditorKit();
        kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,linkfile");
        kit.setProperty("Action.linkfile", JSyntaxLinkFile.class.getName());
        kit.setProperty("Action.execute-script", "jsyntaxpane.actions.ScriptRunnerAction");
      }
    }

    /* Script area */
    setLayout(new BorderLayout());
    codeEditor = new JEditorPane();

    logTextArea = new JTextArea(12,50);
    logTextArea.setMargin(new Insets(5,5,5,5));
    logTextArea.setEditable(true);
    logTextArea.setCursor(null);

    final JCheckBoxMenuItem activateMenuItem = new JCheckBoxMenuItem("Activate");
    activateMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ev) {
        try {
          setScriptActive(!isActive());
        } catch (Exception e) {
          logger.fatal("Error: " + e.getMessage(), e);
        }
      }
    });
    runMenu.add(activateMenuItem);

    final JMenuItem runTestMenuItem = new JMenuItem("Save simulation and run with script");
    runMenu.add(runTestMenuItem);
    runTestMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        exportAndRun();
      }
    });

    doLayout();
    centerPanel = new JSplitPane(
        JSplitPane.VERTICAL_SPLIT,
        new JScrollPane(codeEditor),
        new JScrollPane(logTextArea)
    );

    MenuListener toggleMenuItems = new MenuListener() {
      public void menuSelected(MenuEvent e) {
        activateMenuItem.setSelected(isActive());
        runTestMenuItem.setEnabled(!isActive());
        examplesMenu.setEnabled(!isActive());
      }
      public void menuDeselected(MenuEvent e) {
      }
      public void menuCanceled(MenuEvent e) {
      }
    };
    fileMenu.addMenuListener(toggleMenuItems);
    editMenu.addMenuListener(toggleMenuItems);
    runMenu.addMenuListener(toggleMenuItems);


    codeEditor.setContentType("text/javascript");
    if (codeEditor.getEditorKit() instanceof DefaultSyntaxKit) {
      DefaultSyntaxKit kit = (DefaultSyntaxKit) codeEditor.getEditorKit();
      kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,linkfile");
      kit.setProperty("Action.linkfile", JSyntaxLinkFile.class.getName());
      kit.setProperty("Action.execute-script", "jsyntaxpane.actions.ScriptRunnerAction");
    }

    JPopupMenu p = codeEditor.getComponentPopupMenu();
    if (p != null) {
      for (Component c: p.getComponents()) {
View Full Code Here

        }
      }
    } );
   
    // turn off token highlighting (it's wrong most of the time anyway...)
    DefaultSyntaxKit kit = (DefaultSyntaxKit)m_editor.getEditorKit();
    kit.toggleComponent( m_editor, "jsyntaxpane.components.TokenMarker" );
   
    // init editor popup menu
    JPopupMenu popupMenu = new JPopupMenu();
    m_editor.setComponentPopupMenu( popupMenu );
    {
View Full Code Here

TOP

Related Classes of jsyntaxpane.DefaultSyntaxKit

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.