Java Code Examples for org.fife.ui.rtextarea.RTextScrollPane#setLineNumbersEnabled()

The following examples show how to use org.fife.ui.rtextarea.RTextScrollPane#setLineNumbersEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DesktopSourceCodeEditor.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
protected RSyntaxTextArea createTextComponentImpl() {
    RSyntaxTextArea impl = new RSyntaxTextArea();

    int height = (int) impl.getPreferredSize().getHeight();
    impl.setMinimumSize(new Dimension(0, height));

    RTextScrollPane scrollPane = new RTextScrollPane(impl);
    scrollPane.setLineNumbersEnabled(showGutter);

    composition = scrollPane;
    composition.setPreferredSize(new Dimension(150, height));
    composition.setMinimumSize(new Dimension(0, height));

    doc.putProperty("filterNewlines", false);

    return impl;
}
 
Example 2
Source File: HttpPanelJsonView.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
public HttpPanelJsonView(AbstractStringHttpPanelViewModel model) {
    httpPanelJsonArea = new HttpPanelJsonArea();
    RTextScrollPane scrollPane = new RTextScrollPane(httpPanelJsonArea);
    scrollPane.setLineNumbersEnabled(false);
    mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(scrollPane, BorderLayout.CENTER);
    this.model = model;
    model.addHttpPanelViewModelListener(this);

    httpPanelJsonArea.setComponentPopupMenu(
            new JPopupMenu() {

                private static final long serialVersionUID = 1L;

                @Override
                public void show(Component invoker, int x, int y) {
                    if (!httpPanelJsonArea.isFocusOwner()) {
                        httpPanelJsonArea.requestFocusInWindow();
                    }
                    View.getSingleton().getPopupMenu().show(httpPanelJsonArea, x, y);
                }
            });
}
 
Example 3
Source File: CodeEditorOption.java    From JPPF with Apache License 2.0 5 votes vote down vote up
/**
 * Create the UI components for this option.
 */
@Override
public void createUI() {
  textArea = new RSyntaxTextArea();
  textArea.setSyntaxEditingStyle(language);
  textArea.setCodeFoldingEnabled(false);
  textArea.setCloseCurlyBraces(false);
  textArea.setCloseMarkupTags(false);
  textArea.setTabsEmulated(true);
  textArea.setTabSize(2);
  textArea.setUseFocusableTips(false);
  textArea.setMarginLineEnabled(false);
  textArea.setMarginLinePosition(0);
  textArea.setBorder(BorderFactory.createEmptyBorder());
  if (THEME != null) THEME.apply(textArea);
  if (toolTipText != null) textArea.setToolTipText(toolTipText);
  textArea.setEditable(editable);
  if (scrollable) {
    final RTextScrollPane scrollPane = new RTextScrollPane(textArea);
    GuiUtils.adjustScrollbarsThickness(scrollPane);
    scrollPane.setOpaque(false);
    scrollPane.setLineNumbersEnabled(false);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    if (!bordered) scrollPane.setBorder(BorderFactory.createEmptyBorder());
    UIComponent = scrollPane;
  } else {
    final JPanel mainPanel = GuiUtils.createBoxPanel(BoxLayout.Y_AXIS);
    mainPanel.setBorder(BorderFactory.createTitledBorder(label));
    mainPanel.add(textArea);
    if (!bordered) mainPanel.setBorder(BorderFactory.createEmptyBorder());
    UIComponent = mainPanel;
  }
  setupValueChangeNotifications();
}
 
Example 4
Source File: MainFrame.java    From jsflight with Apache License 2.0 5 votes vote down vote up
private void configureScriptTextArea(RSyntaxTextArea eventContent, RTextScrollPane scrollPane_2, String syntaxStyle)
{
    eventContent.setSyntaxEditingStyle(syntaxStyle);
    eventContent.getFoldManager().setCodeFoldingEnabled(true);
    eventContent.setFont(new Font("Hack", Font.PLAIN, 16));
    eventContent.setRows(3);
    eventContent.setMarkOccurrences(true);
    eventContent.setLineWrap(true);
    eventContent.setWrapStyleWord(true);

    scrollPane_2.setLineNumbersEnabled(true);
    scrollPane_2.setFoldIndicatorEnabled(true);
}
 
Example 5
Source File: ViewMenu.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    JTextComponent textComponent = getTextComponent(e);
    if (textComponent instanceof SyntaxHighlightTextArea) {
        SyntaxHighlightTextArea httpPanelTextArea = (SyntaxHighlightTextArea) textComponent;
        Component c = httpPanelTextArea.getParent();
        if (c instanceof JViewport) {
            c = c.getParent();
            if (c instanceof RTextScrollPane) {
                final RTextScrollPane scrollPane = (RTextScrollPane) c;
                scrollPane.setLineNumbersEnabled(!scrollPane.getLineNumbersEnabled());
            }
        }
    }
}
 
Example 6
Source File: FlatThemeEditorPane.java    From FlatLaf with Apache License 2.0 4 votes vote down vote up
FlatThemeEditorPane() {
		super( new BorderLayout() );

		// register FlatLaf token maker
		AbstractTokenMakerFactory tmf = (AbstractTokenMakerFactory) TokenMakerFactory.getDefaultInstance();
		tmf.putMapping( FLATLAF_STYLE, FlatThemeTokenMaker.class.getName() );

		// create text area
		textArea = new FlatSyntaxTextArea();
		textArea.setSyntaxEditingStyle( FLATLAF_STYLE );
		textArea.setMarkOccurrences( true );
		textArea.addParser( new FlatThemeParser() );
//		textArea.setUseColorOfColorTokens( true );

		// theme
		try {
			Theme theme = Theme.load( getClass().getResourceAsStream( "light.xml" ) );
			theme.apply( textArea );
		} catch( IOException ex ) {
			ex.printStackTrace();
		}

		// use semitransparent token background because token background
		// is painted over mark occurrences background
		SyntaxScheme scheme = textArea.getSyntaxScheme();
		scheme.getStyle( FlatThemeTokenMaker.TOKEN_COLOR ).background = new Color( 0x0a000000, true );
		scheme.getStyle( FlatThemeTokenMaker.TOKEN_VARIABLE ).background = new Color( 0x1800cc00, true );

		// create overlay layer
		JLayer<FlatSyntaxTextArea> overlay = new JLayer<>( textArea, new FlatThemeEditorOverlay() );

		// create scroll pane
		scrollPane = new RTextScrollPane( overlay );
		scrollPane.setLineNumbersEnabled( true );

		// scale fonts
		if( UIScale.getUserScaleFactor() != 1 )
			textArea.setFont( scaleFont( textArea.getFont() ) );

		// use same font for line numbers as in editor
		scrollPane.getGutter().setLineNumberFont( textArea.getFont() );

		add( scrollPane, BorderLayout.CENTER );
	}
 
Example 7
Source File: JWTViewTab.java    From JWT4B with GNU General Public License v3.0 4 votes vote down vote up
private void drawPanel() {
	GridBagLayout gridBagLayout = new GridBagLayout();
	gridBagLayout.columnWidths = new int[] { 10, 447, 0, 0 };
	gridBagLayout.rowHeights = new int[] { 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
	gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
	gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
	setLayout(gridBagLayout);
	
	keyLabel = new JLabel(" ");
	keyLabel.setFont(new Font("Tahoma", Font.BOLD, 12));
	GridBagConstraints gbc_inputLabel1 = new GridBagConstraints();
	gbc_inputLabel1.fill = GridBagConstraints.VERTICAL;
	gbc_inputLabel1.insets = new Insets(0, 0, 5, 5);
	gbc_inputLabel1.anchor = GridBagConstraints.WEST;
	gbc_inputLabel1.gridx = 1;
	gbc_inputLabel1.gridy = 1;
	add(keyLabel, gbc_inputLabel1);

	jwtKeyArea = new JTextArea();
	GridBagConstraints gbc_inputField1 = new GridBagConstraints();
	gbc_inputField1.insets = new Insets(0, 0, 5, 5);
	gbc_inputField1.fill = GridBagConstraints.HORIZONTAL;
	gbc_inputField1.gridx = 1;
	gbc_inputField1.gridy = 2;
	add(jwtKeyArea, gbc_inputField1);
	jwtKeyArea.setColumns(10);
	
	verificationIndicator = new JButton("");
	Dimension preferredSize = new Dimension(400, 30);
	verificationIndicator.setPreferredSize(preferredSize);
	GridBagConstraints gbc_validIndicator = new GridBagConstraints();
	gbc_validIndicator.insets = new Insets(0, 0, 5, 5);
	gbc_validIndicator.gridx = 1;
	gbc_validIndicator.gridy = 4;
	add(verificationIndicator, gbc_validIndicator);

	outputField = new RSyntaxTextArea();
	SyntaxScheme scheme = outputField.getSyntaxScheme();
	Style style = new Style();
	style.foreground = new Color(222,133,10);
	scheme.setStyle(Token.LITERAL_STRING_DOUBLE_QUOTE, style);
	outputField.revalidate();
	outputField.setHighlightCurrentLine(false);
	outputField.setCurrentLineHighlightColor(Color.WHITE);
	outputField.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
	outputField.setEditable(false);
	outputField.setPopupMenu(new JPopupMenu()); // no context menu on right-click
	
	outputLabel = new JLabel("JWT");
	outputLabel.setFont(new Font("Tahoma", Font.BOLD, 12));
	GridBagConstraints gbc_outputLabel = new GridBagConstraints();
	gbc_outputLabel.anchor = GridBagConstraints.WEST;
	gbc_outputLabel.insets = new Insets(0, 0, 5, 5);
	gbc_outputLabel.gridx = 1;
	gbc_outputLabel.gridy = 5;
	add(outputLabel, gbc_outputLabel);
	
	lbRegisteredClaims = new JLabel();
	lbRegisteredClaims.setBackground(SystemColor.controlHighlight);
	GridBagConstraints gbc_lbRegisteredClaims = new GridBagConstraints();
	gbc_lbRegisteredClaims.fill = GridBagConstraints.BOTH;
	gbc_lbRegisteredClaims.insets = new Insets(0, 0, 5, 5);
	gbc_lbRegisteredClaims.gridx = 1;
	gbc_lbRegisteredClaims.gridy = 8;
	add(lbRegisteredClaims, gbc_lbRegisteredClaims);
	
	lblCookieFlags = new JLabel(" ");
	lblCookieFlags.setFont(new Font("Tahoma", Font.BOLD, 12));
	GridBagConstraints gbc_lblCookieFlags = new GridBagConstraints();
	gbc_lblCookieFlags.anchor = GridBagConstraints.SOUTHWEST;
	gbc_lblCookieFlags.insets = new Insets(0, 0, 5, 5);
	gbc_lblCookieFlags.gridx = 1;
	gbc_lblCookieFlags.gridy = 9;
	add(lblCookieFlags, gbc_lblCookieFlags);
	
	RTextScrollPane sp = new RTextScrollPane(outputField);
	sp.setLineNumbersEnabled(false);
	
	GridBagConstraints gbc_outputfield = new GridBagConstraints();
	gbc_outputfield.insets = new Insets(0, 0, 5, 5);
	gbc_outputfield.fill = GridBagConstraints.BOTH;
	gbc_outputfield.gridx = 1;
	gbc_outputfield.gridy = 6;
	add(sp, gbc_outputfield);
}
 
Example 8
Source File: SyntaxHighlightTextArea.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
public void loadConfiguration(String key, FileConfiguration fileConfiguration) {
    setAntiAliasingEnabled(
            fileConfiguration.getBoolean(key + ANTI_ALIASING, this.getAntiAliasingEnabled()));

    Component c = getParent();
    if (c instanceof JViewport) {
        c = c.getParent();
        if (c instanceof RTextScrollPane) {
            final RTextScrollPane scrollPane = (RTextScrollPane) c;
            scrollPane.setLineNumbersEnabled(
                    fileConfiguration.getBoolean(
                            key + SHOW_LINE_NUMBERS, scrollPane.getLineNumbersEnabled()));

            setCodeFoldingEnabled(
                    fileConfiguration.getBoolean(
                            key + CODE_FOLDING, this.isCodeFoldingEnabled()));
            scrollPane.setFoldIndicatorEnabled(this.isCodeFoldingEnabled());
        }
    }

    setLineWrap(fileConfiguration.getBoolean(key + WORD_WRAP, this.getLineWrap()));

    setHighlightCurrentLine(
            fileConfiguration.getBoolean(
                    key + HIGHLIGHT_CURRENT_LINE, this.getHighlightCurrentLine()));
    setFadeCurrentLineHighlight(
            fileConfiguration.getBoolean(
                    key + FADE_CURRENT_HIGHLIGHT_LINE, this.getFadeCurrentLineHighlight()));

    setWhitespaceVisible(
            fileConfiguration.getBoolean(
                    key + SHOW_WHITESPACE_CHARACTERS, this.isWhitespaceVisible()));
    setEOLMarkersVisible(
            fileConfiguration.getBoolean(
                    key + SHOW_NEWLINE_CHARACTERS, this.getEOLMarkersVisible()));

    setMarkOccurrences(
            fileConfiguration.getBoolean(key + MARK_OCCURRENCES, this.getMarkOccurrences()));

    setRoundedSelectionEdges(
            fileConfiguration.getBoolean(
                    key + ROUNDED_SELECTION_EDGES, this.getRoundedSelectionEdges()));

    setBracketMatchingEnabled(
            fileConfiguration.getBoolean(
                    key + BRACKET_MATCHING, this.isBracketMatchingEnabled()));
    setAnimateBracketMatching(
            fileConfiguration.getBoolean(
                    key + ANIMATED_BRACKET_MATCHING, this.getAnimateBracketMatching()));
}