Java Code Examples for org.fife.ui.rsyntaxtextarea.RSyntaxTextArea#setSyntaxEditingStyle()

The following examples show how to use org.fife.ui.rsyntaxtextarea.RSyntaxTextArea#setSyntaxEditingStyle() . 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: ScriptingExpressionEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public ScriptingExpressionEditor() {
  statusText = new JLabel();

  textArea = new RSyntaxTextArea();
  textArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );

  final JPanel queryContentHolder = new JPanel( new BorderLayout() );
  queryContentHolder.add( BorderLayout.NORTH,
    new JLabel( EditorExpressionsMessages.getString( "ScriptingExpressionEditor.Script" ) ) );
  queryContentHolder.add( BorderLayout.CENTER, new RTextScrollPane( 500, 300, textArea, true ) );


  panel = new JPanel();
  panel.setLayout( new BorderLayout() );
  panel.add( queryContentHolder, BorderLayout.CENTER );
}
 
Example 2
Source File: MainView.java    From HiJson with Apache License 2.0 6 votes vote down vote up
private RSyntaxTextArea newTextArea(){
//        JTextArea textArea = new JTextArea();
//        textArea.setAutoscrolls(true);
////      textArea.getDocument().addUndoableEditListener(undoMg);
//        textArea.addMouseListener(new TextAreaMouseListener());
        RSyntaxTextArea textArea = new RSyntaxTextArea();
        textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
        textArea.setCodeFoldingEnabled(true);
        textArea.setAntiAliasingEnabled(true);
        textArea.setAutoscrolls(true);

        SyntaxScheme scheme = textArea.getSyntaxScheme();
//        scheme.getStyle(Token.COMMENT_KEYWORD).foreground = Color.red;
//      scheme.getStyle(Token.DATA_TYPE).foreground = Color.blue;
        scheme.getStyle(Token.LITERAL_STRING_DOUBLE_QUOTE).foreground = Color.BLUE;
        scheme.getStyle(Token.LITERAL_NUMBER_DECIMAL_INT).foreground = new Color(164, 0, 0);
        scheme.getStyle(Token.LITERAL_NUMBER_FLOAT).foreground = new Color(164, 0, 0);
        scheme.getStyle(Token.LITERAL_BOOLEAN).foreground = Color.RED;
        scheme.getStyle(Token.OPERATOR).foreground = Color.BLACK;
        textArea.revalidate();
        textArea.addMouseListener(new TextAreaMouseListener());
       
        return textArea;
    }
 
Example 3
Source File: SyntaxPane.java    From otroslogviewer with Apache License 2.0 6 votes vote down vote up
public static RSyntaxTextArea propertiesTextArea(Theme theme) {
  final RSyntaxTextArea editorPane = new RSyntaxTextArea();
  editorPane.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE);
  SyntaxScheme scheme = editorPane.getSyntaxScheme();
  scheme.getStyle(Token.RESERVED_WORD).foreground = theme.getColor(ThemeKey.LOG_DETAILS_PROPERTY_KEY);
  scheme.getStyle(Token.OPERATOR).foreground = theme.getColor(ThemeKey.LOG_DETAILS_PROPERTY_KEY);
  scheme.getStyle(Token.VARIABLE).foreground = theme.getColor(ThemeKey.LOG_DETAILS_PROPERTY_VALUE);
  scheme.getStyle(Token.LITERAL_STRING_DOUBLE_QUOTE).foreground = theme.getColor(ThemeKey.LOG_DETAILS_PROPERTY_VALUE);
  scheme.getStyle(Token.COMMENT_EOL).foreground = theme.getColor(ThemeKey.LOG_DETAILS_STACKTRACE_COMMENT);
  editorPane.setBackground(new JTextArea().getBackground());

  Color highlightColor;
  if (theme.themeType().equals(Theme.Type.Light)){
    highlightColor = editorPane.getBackground().darker();
  } else {
    highlightColor = editorPane.getBackground().brighter();
  }
  editorPane.setCurrentLineHighlightColor(highlightColor);
  editorPane.revalidate();
  return editorPane;
}
 
Example 4
Source File: CommonSearchDialog.java    From jadx with Apache License 2.0 6 votes vote down vote up
private Component makeCell(JNode node, int column) {
	if (column == 0) {
		JLabel label = new JLabel(node.makeLongStringHtml() + "  ", node.getIcon(), SwingConstants.LEFT);
		label.setFont(font);
		label.setOpaque(true);
		label.setToolTipText(label.getText());
		return label;
	}
	if (!node.hasDescString()) {
		return emptyLabel;
	}
	RSyntaxTextArea textArea = AbstractCodeArea.getDefaultArea(mainWindow);
	textArea.setLayout(new GridLayout(1, 1));
	textArea.setEditable(false);
	textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
	textArea.setText("  " + node.makeDescString());
	textArea.setRows(1);
	textArea.setColumns(textArea.getText().length() + 1);
	if (highlightText != null) {
		SearchContext searchContext = new SearchContext(highlightText);
		searchContext.setMatchCase(!highlightTextCaseInsensitive);
		searchContext.setMarkAll(true);
		SearchEngine.markAll(textArea, searchContext);
	}
	return textArea;
}
 
Example 5
Source File: DyIOchannelWidget.java    From BowlerStudio with GNU General Public License v3.0 5 votes vote down vote up
private void setUpListenerPanel(){
	//Platform.runLater(()->{
		textArea = new RSyntaxTextArea(15, 80);
		textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_GROOVY);
		textArea.setCodeFoldingEnabled(true);
		textArea.setText("return new IChannelEventListener() { \n"+
			"\tpublic \n"
			+ "\tvoid onChannelEvent(DyIOChannelEvent dyioEvent){\n"+
			"\t\tprintln \"From Listener=\"+dyioEvent.getValue();\n"+
			"\t}\n"+
		"}"
			);
		sp = new RTextScrollPane(textArea);
		
		sn = new SwingNode();
		SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
            	sn.setContent(sp);
            }
        });
		
		Platform.runLater(()->listenerCodeBox.getChildren().setAll(sn));
		
		listenerCodeBox.setFocusTraversable(false);
		
		sn.setOnMouseEntered(mouseEvent -> {
			sn.requestFocus();
			SwingUtilities.invokeLater(new Runnable() {
	            @Override
	            public void run() {
	            	textArea.requestFocusInWindow();
	            }
	        });
		});
	//});
}
 
Example 6
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 7
Source File: TextAreaPropertyEditorDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected JTextArea createTextArea() {
  final RSyntaxTextArea textArea = new RSyntaxTextArea();
  textArea.setBracketMatchingEnabled( true );
  textArea.setSyntaxEditingStyle( RSyntaxTextArea.SYNTAX_STYLE_JAVA );
  textArea.setColumns( 60 );
  textArea.setRows( 20 );
  textArea.getDocument().addDocumentListener( new DocumentUpdateHandler() );
  return textArea;
}
 
Example 8
Source File: PopUpWindow.java    From SikuliNG with MIT License 5 votes vote down vote up
public PopUpWindow() {

    JPanel contentPane = new JPanel(new BorderLayout());
    RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
    textArea.addKeyListener(new KeyAdapter() {
      @Override
      public void keyTyped(KeyEvent e) {
        if (e.getExtendedKeyCode() == KeyEvent.VK_ESCAPE) {
          setVisible(false);
          int modifiers = e.getModifiers();
          if (modifiers == KeyEvent.CTRL_MASK) {
            cellText = textArea.getText();
            if (!checkText(cellText)) {
              cellText = resetText;
            }
            script.table.setValueAt(cellText, row, col + 1);
            script.table.setSelection(row, col + 1);
          }
          return;
        }
        super.keyTyped(e);
      }
    });
    textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
    textArea.setMarkOccurrences(true);
    contentPane.add(new RTextScrollPane(textArea));
    CompletionProvider provider = createCompletionProvider();
    AutoCompletion ac = new AutoCompletion(provider);
//    ((AbstractCompletionProvider)provider).setAutoActivationRules(true, null);
    ac.setAutoActivationEnabled(true);
    ac.install(textArea);
//    ac.setAutoCompleteSingleChoices(true);

    setContentPane(contentPane);
    setTitle("AutoComplete Demo");
    setUndecorated(true);
    setAlwaysOnTop(true);
    pack();
    cellTextArea = textArea;
  }
 
Example 9
Source File: TextAreaPropertyEditorDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void actionPerformed( final ActionEvent e ) {
  final Object o = syntaxModel.getSelectedKey();
  if ( o instanceof String ) {
    final RSyntaxTextArea textArea = (RSyntaxTextArea) getTextArea();
    textArea.setSyntaxEditingStyle( (String) o );
  }
}
 
Example 10
Source File: APKRepatcher.java    From APKRepatcher with MIT License 5 votes vote down vote up
public static RSyntaxTextArea getHtmlPane() {
	/*
	 * JEditorPane htmlPane = new JEditorPane();
	 * htmlPane.setBackground(Color.WHITE);
	 * htmlPane.setForeground(Color.BLACK); Font font = new
	 * Font(Font.SANS_SERIF, Font.PLAIN, 20); htmlPane.setFont(font);
	 */
	RSyntaxTextArea textArea = new RSyntaxTextArea();
	textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
	textArea.setCodeFoldingEnabled(true);
	Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 16);
	textArea.setFont(globalFont);
	return textArea;
}
 
Example 11
Source File: DefaultQueryEditorPanel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void initialize() {
  queryTextArea = new RSyntaxTextArea();
  queryTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_SQL );
  queryTextArea.setEnabled( false );
  queryTextArea.getDocument().addDocumentListener( new QueryDocumentListener() );
}
 
Example 12
Source File: QuerySelectorDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void init() {
  setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE );

  fieldList = new JList();
  fieldList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
  fieldList.setVisibleRowCount( 5 );
  fieldList.setCellRenderer( new FixDefaultListCellRenderer() );
  fieldList.addMouseListener( new MouseHandler() );

  syntaxModel = new KeyedComboBoxModel<String, String>();
  syntaxModel.add( ( SyntaxConstants.SYNTAX_STYLE_NONE ),
    UtilMessages.getInstance().getString( "RSyntaxAreaLanguages.None" ) );
  syntaxModel.add( ( SyntaxConstants.SYNTAX_STYLE_JAVA ),
    UtilMessages.getInstance().getString( "RSyntaxAreaLanguages.Java" ) );
  syntaxModel.add( ( SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT ),
    UtilMessages.getInstance().getString( "RSyntaxAreaLanguages.JavaScript" ) );
  syntaxModel.add( ( SyntaxConstants.SYNTAX_STYLE_GROOVY ),
    UtilMessages.getInstance().getString( "RSyntaxAreaLanguages.Groovy" ) );
  syntaxModel.add( ( SyntaxConstants.SYNTAX_STYLE_HTML ),
    UtilMessages.getInstance().getString( "RSyntaxAreaLanguages.Html" ) );
  syntaxModel
    .add( ( SyntaxConstants.SYNTAX_STYLE_CSS ), UtilMessages.getInstance().getString( "RSyntaxAreaLanguages.CSS" ) );
  syntaxModel
    .add( ( SyntaxConstants.SYNTAX_STYLE_SQL ), UtilMessages.getInstance().getString( "RSyntaxAreaLanguages.SQL" ) );
  syntaxModel
    .add( ( SyntaxConstants.SYNTAX_STYLE_XML ), UtilMessages.getInstance().getString( "RSyntaxAreaLanguages.XML" ) );
  syntaxModel.add( ( SyntaxConstants.SYNTAX_STYLE_PYTHON ),
    UtilMessages.getInstance().getString( "RSyntaxAreaLanguages.Python" ) );
  syntaxModel
    .add( ( SyntaxConstants.SYNTAX_STYLE_TCL ), UtilMessages.getInstance().getString( "RSyntaxAreaLanguages.TCL" ) );

  textArea = new RSyntaxTextArea();
  textArea.setBracketMatchingEnabled( true );
  textArea.setSyntaxEditingStyle( RSyntaxTextArea.SYNTAX_STYLE_JAVA );
  textArea.setColumns( 60 );
  textArea.setRows( 20 );

  final JPanel syntaxSelectionPane = new JPanel();
  syntaxSelectionPane.setLayout( new FlowLayout() );
  final JComboBox syntaxBox = new JComboBox( syntaxModel );
  syntaxBox.addActionListener( new SyntaxHighlightAction() );
  syntaxSelectionPane.add( syntaxBox );

  final JPanel contentPane = new JPanel();
  contentPane.setLayout( new BorderLayout() );
  contentPane.add( new RTextScrollPane( 500, 300, textArea, true ), BorderLayout.CENTER );
  contentPane.add( syntaxBox, BorderLayout.NORTH );

  tab = new JTabbedPane();
  tab.addTab( UtilMessages.getInstance().getString( "QuerySelectorDialog.DefinedQueries" ),
    new JScrollPane( fieldList ) );
  tab.addTab( UtilMessages.getInstance().getString( "QuerySelectorDialog.CustomQuery" ), contentPane );

  setTitle( UtilMessages.getInstance().getString( "QuerySelectorDialog.SelectQuery" ) );

  super.init();
}
 
Example 13
Source File: MondrianDataSourceEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void init( final DesignTimeContext context ) {
  if ( context == null ) {
    throw new NullPointerException();
  }

  securityDialog = new MondrianSecurityDialog( this, context );

  setModal( true );

  this.context = context;

  globalTemplateAction = new GlobalTemplateAction();
  queryTemplateAction = new QueryTemplateAction();

  final QueryNameTextFieldDocumentListener updateHandler = new QueryNameTextFieldDocumentListener();
  final ConfirmEnableHandler confirmAction = new ConfirmEnableHandler();

  dialogModel = new NamedDataSourceDialogModel();
  dialogModel.getQueries().addListDataListener( updateHandler );
  dialogModel.addPropertyChangeListener( confirmAction );

  maxPreviewRowsSpinner = new JSpinner( new SpinnerNumberModel( 10000, 1, Integer.MAX_VALUE, 1 ) );

  cubeConnectionNameField = new JTextField( null, 0 );
  cubeConnectionNameField.setColumns( 30 );
  cubeConnectionNameField.getDocument().addDocumentListener( confirmAction );

  filenameField = new JTextField( null, 0 );
  filenameField.setColumns( 30 );
  filenameField.getDocument().addDocumentListener( confirmAction );
  dialogModel.setSchemaFileNameField( filenameField );

  queryNameTextField = new JTextField( null, 0 );
  queryNameTextField.setColumns( 35 );
  queryNameTextField.setEnabled( dialogModel.isQuerySelected() );
  queryNameTextField.getDocument().addDocumentListener( updateHandler );

  queryTextArea = new JTextArea( (String) null );
  queryTextArea.setWrapStyleWord( true );
  queryTextArea.setLineWrap( true );
  queryTextArea.setRows( 5 );
  queryTextArea.getDocument().addDocumentListener( new QueryDocumentListener() );

  queryNameList = new JList( getDialogModel().getQueries() );
  queryNameList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
  queryNameList.setVisibleRowCount( 5 );
  queryNameList.addListSelectionListener( new QuerySelectedHandler() );

  globalScriptTextArea = new RSyntaxTextArea();
  globalScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );

  globalLanguageField = new SmartComboBox<ScriptEngineFactory>(
    new DefaultComboBoxModel( DataFactoryEditorSupport.getScriptEngineLanguages() ) );
  globalLanguageField.setRenderer( new QueryLanguageListCellRenderer() );
  globalLanguageField.addActionListener( new UpdateScriptLanguageHandler() );

  queryScriptTextArea = new RSyntaxTextArea();
  queryScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );
  queryScriptTextArea.getDocument().addDocumentListener( new QueryScriptDocumentListener() );

  queryLanguageListCellRenderer = new QueryLanguageListCellRenderer();

  queryLanguageField = new SmartComboBox<ScriptEngineFactory>(
    new DefaultComboBoxModel( DataFactoryEditorSupport.getScriptEngineLanguages() ) );
  queryLanguageField.setRenderer( queryLanguageListCellRenderer );
  queryLanguageField.addActionListener( new UpdateScriptLanguageHandler() );

  // Return the center panel
  super.init();
}
 
Example 14
Source File: ScriptableDataSourceEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void init( final DesignTimeContext designTimeContext ) {
  if ( designTimeContext == null ) {
    throw new NullPointerException();
  }
  this.designTimeContext = designTimeContext;

  setTitle( Messages.getString( "ScriptableDataSourceEditor.Title" ) );
  setModal( true );

  previewAction = new PreviewAction();

  queryNameTextField = new JTextField( null, 0 );
  queryNameTextField.setColumns( 35 );
  queryNameTextField.getDocument().addDocumentListener( new QueryNameTextFieldDocumentListener() );

  queryTextArea = new RSyntaxTextArea();
  queryTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );
  queryTextArea.getDocument().addDocumentListener( new QueryDocumentListener() );

  initScriptTextArea = new RSyntaxTextArea();
  initScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );

  shutdownScriptTextArea = new RSyntaxTextArea();
  shutdownScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );

  languageField = new JList( new DefaultComboBoxModel( InternalBSFManager.getRegisteredLanguages() ) );
  languageField.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
  languageField.getSelectionModel().addListSelectionListener( new UpdateLanguageHandler() );

  queryNameList = new JList();
  queryNameList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
  queryNameList.setVisibleRowCount( 5 );
  queryNameList.addListSelectionListener( new QueryNameListSelectionListener() );
  queryNameList.setCellRenderer( new QueryNameListCellRenderer() );

  final QueryRemoveAction removeQueryAction = new QueryRemoveAction();
  queryNameList.addListSelectionListener( removeQueryAction );


  super.init();
}
 
Example 15
Source File: JdbcDataSourceDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Creates the panel which holds the main content of the dialog
 */
private void initDialog( final DesignTimeContext designTimeContext ) {
  this.designTimeContext = designTimeContext;

  setTitle( Messages.getString( "JdbcDataSourceDialog.Title" ) );
  setModal( true );

  globalTemplateAction = new GlobalTemplateAction();
  queryTemplateAction = new QueryTemplateAction();

  dialogModel = new NamedDataSourceDialogModel();
  dialogModel.addPropertyChangeListener( new ConfirmValidationHandler() );

  connectionComponent = new JdbcConnectionPanel( dialogModel, designTimeContext );
  maxPreviewRowsSpinner = new JSpinner( new SpinnerNumberModel( 10000, 1, Integer.MAX_VALUE, 1 ) );

  final QueryNameTextFieldDocumentListener updateHandler = new QueryNameTextFieldDocumentListener();
  dialogModel.getQueries().addListDataListener( updateHandler );

  queryNameList = new JList( dialogModel.getQueries() );
  queryNameList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
  queryNameList.setVisibleRowCount( 5 );
  queryNameList.addListSelectionListener( new QuerySelectedHandler() );

  queryNameTextField = new JTextField();
  queryNameTextField.setColumns( 35 );
  queryNameTextField.setEnabled( dialogModel.isQuerySelected() );
  queryNameTextField.getDocument().addDocumentListener( updateHandler );

  queryTextArea = new RSyntaxTextArea();
  queryTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_SQL );
  queryTextArea.setEnabled( dialogModel.isQuerySelected() );
  queryTextArea.getDocument().addDocumentListener( new QueryDocumentListener() );

  globalScriptTextArea = new RSyntaxTextArea();
  globalScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );

  globalLanguageField = new SmartComboBox<ScriptEngineFactory>( new DefaultComboBoxModel( DataFactoryEditorSupport.getScriptEngineLanguages() ) );
  globalLanguageField.setRenderer( new QueryLanguageListCellRenderer() );
  globalLanguageField.addActionListener( new UpdateScriptLanguageHandler() );

  queryScriptTextArea = new RSyntaxTextArea();
  queryScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );
  queryScriptTextArea.getDocument().addDocumentListener( new QueryScriptDocumentListener() );

  queryLanguageListCellRenderer = new QueryLanguageListCellRenderer();

  queryLanguageField = new SmartComboBox<ScriptEngineFactory>( new DefaultComboBoxModel( DataFactoryEditorSupport.getScriptEngineLanguages() ) );
  queryLanguageField.setRenderer( queryLanguageListCellRenderer );
  queryLanguageField.addActionListener( new UpdateScriptLanguageHandler() );

  super.init();
}
 
Example 16
Source File: PmdDataSourceEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void init( final DesignTimeContext context ) {
  if ( context == null ) {
    throw new NullPointerException();
  }

  this.context = context;
  setModal( true );
  setTitle( Messages.getString( "PmdDataSourceEditor.Title" ) );

  maxPreviewRowsSpinner = new JSpinner( new SpinnerNumberModel( 10000, 1, Integer.MAX_VALUE, 1 ) );
  previewAction = new PreviewAction();
  globalTemplateAction = new GlobalTemplateAction();
  queryTemplateAction = new QueryTemplateAction();

  filenameField = new JTextField( null, 0 );
  filenameField.setColumns( 30 );
  filenameField.getDocument().addDocumentListener( new FilenameDocumentListener() );

  queryNameList = new JList();
  queryNameList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
  queryNameList.setVisibleRowCount( 5 );
  queryNameList.addListSelectionListener( new QueryNameListSelectionListener() );
  queryNameList.setCellRenderer( new QueryNameListCellRenderer() );

  queryAddButton = new BorderlessButton( new AddQueryAction() );
  queryRemoveButton = new BorderlessButton( new RemoveQueryAction() );

  queryNameTextField = new JTextField( null, 0 );
  queryNameTextField.setColumns( 35 );
  queryNameTextField.getDocument().addDocumentListener( new QueryNameTextFieldDocumentListener() );

  domainIdTextField = new JTextField( null, 0 );
  domainIdTextField.setColumns( 35 );
  domainIdTextField.getDocument().addDocumentListener( new DomainTextFieldDocumentListener() );

  queryTextArea = new RSyntaxTextArea();
  queryTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_XML );
  queryTextArea.setWrapStyleWord( true );
  queryTextArea.setLineWrap( true );
  queryTextArea.setRows( 5 );
  queryTextArea.getDocument().addDocumentListener( new QueryDocumentListener() );

  queryDesignerButton = new JButton( new QueryDesignerAction() );
  queryDesignerButton.setEnabled( false );
  queryDesignerButton.setBorder( new EmptyBorder( 0, 0, 0, 0 ) );

  globalScriptTextArea = new RSyntaxTextArea();
  globalScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );

  globalLanguageField = new SmartComboBox( new DefaultComboBoxModel( getScriptEngineLanguages() ) );
  globalLanguageField.setRenderer( new QueryLanguageListCellRenderer() );
  globalLanguageField.addActionListener( new UpdateScriptLanguageHandler() );

  queryScriptTextArea = new RSyntaxTextArea();
  queryScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );
  queryScriptTextArea.getDocument().addDocumentListener( new QueryScriptDocumentListener() );

  queryLanguageListCellRenderer = new QueryLanguageListCellRenderer();

  queryLanguageField = new SmartComboBox( new DefaultComboBoxModel( getScriptEngineLanguages() ) );
  queryLanguageField.setRenderer( queryLanguageListCellRenderer );
  queryLanguageField.addActionListener( new UpdateScriptLanguageHandler() );

  super.init();
}
 
Example 17
Source File: Olap4JDataSourceEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void init( final DesignTimeContext designTimeContext ) {
  setModal( true );

  this.context = designTimeContext;

  final QueryNameTextFieldDocumentListener updateHandler = new QueryNameTextFieldDocumentListener();

  globalTemplateAction = new GlobalTemplateAction();
  queryTemplateAction = new QueryTemplateAction();

  dialogModel = new NamedDataSourceDialogModel
    ( new JdbcConnectionDefinitionManager( "org/pentaho/reporting/ui/datasources/olap4j/Settings" ) );
  dialogModel.addPropertyChangeListener( NamedDataSourceDialogModel.CONNECTION_SELECTED, new ConfirmEnableHandler() );
  dialogModel.getQueries().addListDataListener( updateHandler );

  connectionComponent = new OlapConnectionPanel( dialogModel, designTimeContext );
  connectionComponent.setBorder( BorderFactory.createEmptyBorder( 0, 8, 0, 8 ) );

  maxPreviewRowsSpinner = new JSpinner( new SpinnerNumberModel( 10000, 1, Integer.MAX_VALUE, 1 ) );

  queryNameTextField = new JTextField();
  queryNameTextField.setColumns( 35 );
  queryNameTextField.setEnabled( dialogModel.isQuerySelected() );
  queryNameTextField.getDocument().addDocumentListener( updateHandler );

  queryTextArea = new JTextArea( (String) null );
  queryTextArea.setWrapStyleWord( true );
  queryTextArea.setLineWrap( true );
  queryTextArea.setRows( 10 );
  queryTextArea.setColumns( 50 );
  queryTextArea.setEnabled( dialogModel.isQuerySelected() );
  queryTextArea.getDocument().addDocumentListener( new QueryDocumentListener() );

  queryNameList = new JList( dialogModel.getQueries() );
  queryNameList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
  queryNameList.setVisibleRowCount( 5 );
  queryNameList.addListSelectionListener( new QuerySelectedHandler() );

  globalScriptTextArea = new RSyntaxTextArea();
  globalScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );

  globalLanguageField = new SmartComboBox<ScriptEngineFactory>(
    new DefaultComboBoxModel( DataFactoryEditorSupport.getScriptEngineLanguages() ) );
  globalLanguageField.setRenderer( new QueryLanguageListCellRenderer() );
  globalLanguageField.addActionListener( new UpdateScriptLanguageHandler() );

  queryScriptTextArea = new RSyntaxTextArea();
  queryScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );
  queryScriptTextArea.getDocument().addDocumentListener( new QueryScriptDocumentListener() );

  queryLanguageListCellRenderer = new QueryLanguageListCellRenderer();

  queryLanguageField = new SmartComboBox<ScriptEngineFactory>(
    new DefaultComboBoxModel( DataFactoryEditorSupport.getScriptEngineLanguages() ) );
  queryLanguageField.setRenderer( queryLanguageListCellRenderer );
  queryLanguageField.addActionListener( new UpdateScriptLanguageHandler() );

  super.init();
  // Return the center panel
}
 
Example 18
Source File: XMLQueryView.java    From importer-exporter with Apache License 2.0 4 votes vote down vote up
private void init() {
    component = new JPanel();
    component.setLayout(new GridBagLayout());

    xmlText = new RSyntaxTextArea("", 5, 1);
    try (InputStream in = getClass().getResourceAsStream("/org/fife/ui/rsyntaxtextarea/themes/idea.xml")) {
        Theme.load(in).apply(xmlText);
    } catch (IOException e) {
        throw new IllegalStateException("Failed to initialize XML editor.", e);
    }

    xmlText.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
    xmlText.setAutoIndentEnabled(true);
    xmlText.setHighlightCurrentLine(true);
    xmlText.setCodeFoldingEnabled(true);
    xmlText.setTabSize(2);
    RTextScrollPane scrollPane = new RTextScrollPane(xmlText);

    newButton = new JButton();
    ImageIcon add = new ImageIcon(getClass().getResource("/org/citydb/gui/images/common/query_new.png"));
    newButton.setIcon(add);
    newButton.setMargin(new Insets(0, 0, 0, 0));

    duplicateButton = new JButton();
    ImageIcon duplicate = new ImageIcon(getClass().getResource("/org/citydb/gui/images/common/query_duplicate.png"));
    duplicateButton.setIcon(duplicate);
    duplicateButton.setMargin(new Insets(0, 0, 0, 0));

    validateButton = new JButton();
    ImageIcon validate = new ImageIcon(getClass().getResource("/org/citydb/gui/images/common/done.png"));
    validateButton.setIcon(validate);
    validateButton.setMargin(new Insets(0, 0, 0, 0));

    JPanel buttons = new JPanel();
    buttons.setLayout(new GridBagLayout());
    buttons.add(newButton, GuiUtil.setConstraints(0,0,0,0,GridBagConstraints.NONE,0,5,5,0));
    buttons.add(duplicateButton, GuiUtil.setConstraints(0,1,0,0,GridBagConstraints.NONE,0,5,5,0));
    buttons.add(validateButton, GuiUtil.setConstraints(0,2,0,0,GridBagConstraints.NONE,0,5,0,0));

    component.add(scrollPane, GuiUtil.setConstraints(0,0,1,1,GridBagConstraints.BOTH,10,5,5,0));
    component.add(buttons, GuiUtil.setConstraints(1,0,0,0,GridBagConstraints.NORTH,GridBagConstraints.NONE,10,0,5,5));

    newButton.addActionListener(e -> SwingUtilities.invokeLater(this::setEmptyQuery));
    duplicateButton.addActionListener(e -> SwingUtilities.invokeLater(this::setSimpleSettings));
    validateButton.addActionListener(e -> SwingUtilities.invokeLater(this::validate));

    PopupMenuDecorator.getInstance().decorate(xmlText);
}
 
Example 19
Source File: GroovyConsoleSlide.java    From COMP6237 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Component getComponent(int width, int height) throws IOException {
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new BorderLayout());

	final JPanel controls = new JPanel();
	final JButton runBtn = new JButton("Run");
	runBtn.setActionCommand("run");
	runBtn.addActionListener(this);
	controls.add(runBtn);

	base.add(controls, BorderLayout.NORTH);

	textArea = new RSyntaxTextArea(20, 60);
	Font font = textArea.getFont();
	font = font.deriveFont(font.getStyle(), 18);
	textArea.setFont(font);
	textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_GROOVY);
	textArea.setCodeFoldingEnabled(true);

	textArea.setText(initialScript);

	final RTextScrollPane inputScrollPane = new RTextScrollPane(textArea);

	outputPane = new JTextPane();
	outputPane.setEditable(false);
	outputPane.setFont(new Font("Monospaced", Font.PLAIN, 18));
	outputPane.setBorder(new EmptyBorder(4, 4, 4, 4));
	final JScrollPane outputScrollPane = new JScrollPane(outputPane);

	splitPane = new JSplitPane(orientation, inputScrollPane, outputScrollPane);
	splitPane.setOneTouchExpandable(true);
	splitPane.setDividerLocation(width / 2);

	final Dimension minimumSize = new Dimension(100, 50);
	inputScrollPane.setMinimumSize(minimumSize);
	outputScrollPane.setMinimumSize(minimumSize);

	final JPanel body = new JPanel();
	body.setBackground(Color.RED);
	body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS));
	body.add(splitPane);
	base.add(body, BorderLayout.CENTER);

	installInterceptors();

	return base;
}
 
Example 20
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);
}