Refine search
textArea = new RSyntaxTextArea(25, 70); textArea.setCaretPosition(0); textArea.requestFocusInWindow(); textArea.setMarkOccurrences(true); textArea.setClearWhitespaceLinesEnabled(false); textArea.setEditable(false); textArea.setAntiAliasingEnabled(true); textArea.setCodeFoldingEnabled(true); if (name.toLowerCase().endsWith(".class") || name.toLowerCase().endsWith(".java")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_JAVA); else if (name.toLowerCase().endsWith(".xml") || name.toLowerCase().endsWith(".rss") || name.toLowerCase().endsWith(".project") || name.toLowerCase().endsWith(".classpath")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_XML); else if (name.toLowerCase().endsWith(".h")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_C); else if (name.toLowerCase().endsWith(".sql")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_SQL); else if (name.toLowerCase().endsWith(".js")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_JAVASCRIPT); else if (name.toLowerCase().endsWith(".php") || name.toLowerCase().endsWith(".php5") || name.toLowerCase().endsWith(".phtml")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_PHP); else if (name.toLowerCase().endsWith(".html") || name.toLowerCase().endsWith(".htm") || name.toLowerCase().endsWith(".xhtm") || name.toLowerCase().endsWith(".xhtml")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_HTML); else if (name.toLowerCase().endsWith(".js")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_JAVASCRIPT); else if (name.toLowerCase().endsWith(".lua")) textArea.setSyntaxEditingStyle(SYNTAX_STYLE_LUA);
private void search(int direction) { String searchText = searchField.getText(); if (searchText == null || searchText.length() == 0 || rTextArea.getText() == null) { return; if (direction == 0 && !COLOR_BG_ERROR.equals(searchField.getBackground())) { try { int caretPos = rTextArea.getCaretPosition(); int lineNum = rTextArea.getLineOfOffset(caretPos) - 1; if (lineNum > 1) { rTextArea.setCaretPosition(rTextArea.getLineStartOffset(lineNum)); int pos = SearchEngine.getNextMatchPos(searchText, rTextArea.getText(), forward, matchCase, wholeWord); if (pos != -1) { rTextArea.setCaretPosition(forward ? 0 : rTextArea.getDocument().getLength() - 1); search(direction); searchField.setBackground(COLOR_BG_WARN); return;
public void onSelectAllMenu() { try { RSyntaxTextArea pane = this.getModel().getCurrentTextArea(); if (pane != null) { pane.requestFocusInWindow(); pane.setSelectionStart(0); pane.setSelectionEnd(pane.getText().length()); } } catch (Exception e) { Luyten.showExceptionDialog("Exception!", e); } }
private Component makeCell(JNode node, int column) { if (column == 0) { JLabel label = new JLabel(node.makeLongString() + " ", node.getIcon(), SwingConstants.LEFT); label.setFont(font); label.setOpaque(true); label.setToolTipText(label.getText()); return label; } if (!node.hasDescString()) { return emptyLabel; } RSyntaxTextArea textArea = CodeArea.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; }
public static void loadCommonSettings(MainWindow mainWindow, RSyntaxTextArea area) { area.setAntiAliasingEnabled(true); mainWindow.getEditorTheme().apply(area); JadxSettings settings = mainWindow.getSettings(); area.setFont(settings.getFont()); }
dateFormatRadio = new JXComboBox(dateFormats); addLabel("Date format", 'd', dateFormatRadio, panel); final JTextField exampleTextField = new JTextField(20); exampleTextField.setEditable(false); addLabel("Format example", 'e', exampleTextField, panel); dateFormatRadio.addActionListener(e -> exampleTextField.setText(new SimpleDateFormat(dateFormatRadio.getSelectedItem().toString()).format(new Date()))); dateFormatRadio.setSelectedIndex(0); radioGroup = new JXRadioGroup(LevelRenderer.Mode.values()); packageAbbreviationTa.setText(DEFAULT_ABBREVIATION_HEADER); packageAbbreviationTa.setLineWrap(true); packageAbbreviationTa.setPreferredSize(new Dimension(500, 200)); packageAbbreviationTa.setToolTipText(DEFAULT_ABBREVIATION_HEADER); columnLayoutListModel = new MutableListModel<>(); columnLayoutsList = new JList(columnLayoutListModel); columnLayoutsList.setToolTipText("Click right mouse button to edit or delete"); columnLayoutsList.setMinimumSize(new Dimension(100, 40)); columnLayoutsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); columnLayoutsList.setCellRenderer(new ColumnLayoutRenderer());
queryTemplateAction = new QueryTemplateAction( this, dialogModel ); queryNameList = new JList( dialogModel.getQueries() ); queryNameList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); queryNameList.setVisibleRowCount( 5 ); queryNameList.setCellRenderer( new QueryListCellRenderer() ); queryNameList.addListSelectionListener( new QuerySelectedHandler( dialogModel, queryNameList ) ); queryNameTextField = new JTextField(); queryNameTextField.setColumns( 35 ); queryNameTextField.setEnabled( dialogModel.isQuerySelected() ); queryNameTextField.getDocument().addDocumentListener( new QueryNameUpdateHandler() ); globalScriptTextArea = new RSyntaxTextArea(); globalScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE ); globalScriptTextArea.getDocument().addDocumentListener( new GlobalScriptUpdateHandler() ); globalLanguageField.addActionListener( new UpdateGlobalScriptLanguageHandler() ); queryScriptTextArea = new RSyntaxTextArea(); queryScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE ); queryScriptTextArea.getDocument().addDocumentListener( new QueryScriptUpdateHandler() );
jLabel4 = new javax.swing.JLabel(); finalPayloadScrollPane = new org.fife.ui.rtextarea.RTextScrollPane(); finalPayload = new org.fife.ui.rsyntaxtextarea.RSyntaxTextArea(); payloadComboBox = new javax.swing.JComboBox(); jScrollPane1 = new javax.swing.JScrollPane(); attackDescriptionTextArea = new org.fife.ui.rsyntaxtextarea.RSyntaxTextArea(); rTextScrollPane1 = new org.fife.ui.rtextarea.RTextScrollPane(); payloadValue = new org.fife.ui.rsyntaxtextarea.RSyntaxTextArea(); finalPayload.setColumns(20); finalPayload.setLineWrap(true); finalPayload.setRows(5); finalPayload.setSyntaxEditingStyle("text/xml"); finalPayloadScrollPane.setViewportView(finalPayload); attackDescriptionTextArea.setEditable(false); attackDescriptionTextArea.setBackground(getBackground()); attackDescriptionTextArea.setColumns(20); attackDescriptionTextArea.setRows(5); jScrollPane1.setViewportView(attackDescriptionTextArea); payloadValue.setColumns(20); payloadValue.setLineWrap(true); payloadValue.setRows(5); payloadValue.setSyntaxEditingStyle("text/xml"); payloadValue.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { payloadValueKeyReleased(evt);
private boolean add() { if(StringUtil.isEmpty(jtf_name.getText())) { JOptionPane.showMessageDialog(this, "Name must be present!", "Validation: name empty!", JOptionPane.ERROR_MESSAGE); jtf_name.requestFocus(); return false; final String name = jtf_name.getText(); final ContentType ct = jp_contentType.getContentType(); final String body = jta_part.getText(); ReqEntityStringPart part = new ReqEntityStringPartBean( name, ct, body);
textArea = new RSyntaxTextArea(20, 60); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); textArea.setCodeFoldingEnabled(true); RTextScrollPane sp = new RTextScrollPane(textArea); cp.add(sp); searchField = new JTextField(30); toolBar.add(searchField); final JButton nextButton = new JButton("Find Next"); nextButton.addActionListener(this); toolBar.add(nextButton); searchField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) {
/** * Constructor. * * @param delay The delay between the last key press and when the document * is parsed. * @param textArea The text area whose document the parser will be * parsing. */ ParserManager(int delay, RSyntaxTextArea textArea) { this.textArea = textArea; textArea.getDocument().addDocumentListener(this); textArea.addPropertyChangeListener("document", this); parsers = new ArrayList<Parser>(1); // Usually small timer = new Timer(delay, this); timer.setRepeats(false); running = true; }
private RTextScrollPane getCenterPanel() { if (centerPanel == null) { scriptPanel = new RSyntaxTextArea(); scriptPanel.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_SQL); scriptPanel.setLineWrap(true); scriptPanel.setClearWhitespaceLinesEnabled(true); scriptPanel.setMarkOccurrences(false); scriptPanel.setTabsEmulated(true); scriptPanel.setTabSize(4); actions.setAccelerators(scriptPanel); //TODO track language support bundles codeReformator = new CodeReformator(";", COMMENT_SPECS); scriptPanel.addCaretListener(EventHandler.create(CaretListener.class,this,"onScriptPanelCaretUpdate")); scriptPanel.getDocument().addDocumentListener(EventHandler.create(DocumentListener.class, this, "onUserSelectionChange")); //Add custom actions scriptPanel.getPopupMenu().addSeparator(); actions.registerContainer(scriptPanel.getPopupMenu()); centerPanel = new RTextScrollPane(scriptPanel); onUserSelectionChange(); } return centerPanel; } /**
throws BadLocationException { Document doc = textArea.getDocument(); Element line = getLineElem(doc, offs); if (line == null) { throw new BadLocationException("No word at " + offs, offs); int endOffs = Math.min(offs+1, doc.getLength()); String s = doc.getText(lineStart, endOffs-lineStart); if(s != null && s.length() > 0) { int i = s.length() - 1;
/** * Returns the last visible offset in this text area. This may not be the * length of the document if code folding is enabled. * * @return The last visible offset in this text area. */ public int getLastVisibleOffset() { if (isCodeFoldingEnabled()) { int lastVisibleLine = foldManager.getLastVisibleLine(); if (lastVisibleLine<getLineCount()-1) { // Not the last line try { return getLineEndOffset(lastVisibleLine) - 1; } catch (BadLocationException ble) { // Never happens ble.printStackTrace(); } } } return getDocument().getLength(); }
int caretPos = sta.getCaretPosition(); Document doc = sta.getDocument(); Element map = doc.getDefaultRootElement(); int lineNum = map.getElementIndex(caretPos); Element line = map.getElement(lineNum); int end = line.getEndOffset()-1; // Why always "-1"? int len = end-start; String s = doc.getText(start, len); if (nonWhitespacePos==-1) { if (leadingWS.length()==len && sta.isClearWhitespaceLinesEnabled()) { sta.setSelectionStart(start); sta.setSelectionEnd(end); sta.replaceSelection(sb.toString()); sta.replaceRange(sb.toString(), caretPos, end); sta.setCaretPosition(caretPos + leadingWS.length()+1); if (sta.getShouldIndentNextLine(lineNum)) { sta.replaceSelection("\t"); sta.replaceSelection("\n"); ble.printStackTrace();
@Test public void testGetPreviousWord_manyLinesInBetween() throws Exception { DumbCompleteWordAction action = new DumbCompleteWordAction(); RSyntaxDocument doc = new RSyntaxDocument( SyntaxConstants.SYNTAX_STYLE_JAVA); RSyntaxTextArea textArea = new RSyntaxTextArea(doc); textArea.setText("aaron arthur aardvark\nfoo bar\n// bad code\namazing\n a"); Assert.assertEquals(textArea.getDocument().getLength()-1, action.getPreviousWord(textArea, textArea.getDocument().getLength())); Assert.assertEquals("aaron arthur aardvark\nfoo bar\n// bad code\n".length(), action.getPreviousWord(textArea, textArea.getDocument().getLength()-2)); Assert.assertEquals("aaron arthur ".length(), action.getPreviousWord(textArea, 22)); Assert.assertEquals("aaron ".length(), action.getPreviousWord(textArea, 8)); }
/** * Returns the template that should be inserted at the current caret * position, assuming the trigger character was pressed. * * @param textArea The text area that's getting text inserted into it. * @return A template that should be inserted, if appropriate, or * <code>null</code> if no template should be inserted. */ public synchronized CodeTemplate getTemplate(RSyntaxTextArea textArea) { int caretPos = textArea.getCaretPosition(); int charsToGet = Math.min(caretPos, maxTemplateIDLength); try { Document doc = textArea.getDocument(); doc.getText(caretPos-charsToGet, charsToGet, s); @SuppressWarnings("unchecked") int index = Collections.binarySearch(templates, s, comparator); return index>=0 ? (CodeTemplate)templates.get(index) : null; } catch (BadLocationException ble) { ble.printStackTrace(); throw new InternalError("Error in CodeTemplateManager"); } }
@Override public void loadConfiguration(Configuration configuration) { LevelRenderer.Mode mode = LevelRenderer.Mode.valueOf(configuration.getString(LOG_TABLE_FORMAT_LEVEL_RENDERER, LevelRenderer.Mode.IconsOnly.name())); radioGroup.setSelectedValue(mode); String dateFormat = StringUtils.defaultIfBlank(configuration.getString(LOG_TABLE_FORMAT_DATE_FORMAT), dateFormats[1]); dateFormatRadio.setSelectedItem(dateFormat); packageAbbreviationTa.setText(configuration.getString(LOG_TABLE_FORMAT_PACKAGE_ABBREVIATIONS, DEFAULT_ABBREVIATION_HEADER)); packageAbbreviationTa.setCaretPosition(packageAbbreviationTa.getText().length()); columnLayoutListModel = new MutableListModel<>(); columnLayoutsList.setModel(columnLayoutListModel); loadColumnLayouts(configuration).forEach(columnLayoutListModel::add); }
private String getCurrentLineText() { int caretPosition = textArea.getCaretPosition(); Element root = textArea.getDocument().getDefaultRootElement(); int line= root.getElementIndex(caretPosition); Element elem = root.getElement(line); int endOffset = elem.getEndOffset(); int lineStart = elem.getStartOffset(); String text = ""; try { text = textArea.getText(lineStart, endOffset-lineStart).trim(); } catch (BadLocationException e) { e.printStackTrace(); } return text; }