@Override protected JPopupMenu createPopupMenu(Component component) { JPopupMenu menu = super.createPopupMenu(component); JMenu formatMenu = new JMenu(TextUtils.getText("simplyhtml.formatLabel")); menu.add(formatMenu); if (textfield.getSelectionStart() == textfield.getSelectionEnd()){ formatMenu.setEnabled(false); return menu; } formatMenu.add(boldAction); formatMenu.add(italicAction); formatMenu.add(underlineAction); formatMenu.add(redAction); formatMenu.add(greenAction); formatMenu.add(blueAction); formatMenu.add(blackAction); formatMenu.add(defaultColorAction); formatMenu.add(removeFormattingAction); return menu; }
private static String getSelectedExpr(JEditorPane ep, int offset) { if ((ep.getSelectionStart() <= offset) && (offset <= ep.getSelectionEnd())) { return ep.getSelectedText(); } return null; }
private boolean isSelected() { int selectionStart = Math.min(getEditor().getSelectionStart(), getEditor().getSelectionEnd()); int selectionEnd = Math.max(getEditor().getSelectionStart(), getEditor().getSelectionEnd()); return selectionStart != selectionEnd; }
/** * Copies from the description text area, if it is visible and there is * a selection. * * @return Whether a copy occurred. */ public boolean copy() { if (isVisible() && descArea.getSelectionStart()!=descArea.getSelectionEnd()) { descArea.copy(); return true; } return false; }
private void removeSelection() { try { int selectionStart = Math.min(getEditor().getSelectionStart(), getEditor().getSelectionEnd()); int selectionEnd = Math.max(getEditor().getSelectionStart(), getEditor().getSelectionEnd()); getEditor().getDocument().remove(selectionStart, selectionEnd); } catch (BadLocationException ex) { // Logger.getLogger(ShellView.class.getName()). // log(Level.SEVERE, null, ex); } }
public void actionPerformed(ActionEvent e) { final JEditorPane editor = getEditor(e); if(editor == null){ return; } final int selectionStart = editor.getSelectionStart(); final int selectionEnd = editor.getSelectionEnd(); if(selectionStart == selectionEnd){ return; } SHTMLEditorKit.removeCharacterAttributes((StyledDocument) editor.getDocument(), attribute, selectionStart, selectionEnd - selectionStart); } }
if ( (ep.getSelectionStart () <= offset) && (offset <= ep.getSelectionEnd ()) ) {
public static String getELIdentifier(StyledDocument doc, JEditorPane ep, int offset) { String t = null; if ( (ep.getSelectionStart () <= offset) && (offset <= ep.getSelectionEnd ()) ) t = ep.getSelectedText ();
if ( (ep.getSelectionStart () <= offset) && (offset <= ep.getSelectionEnd ()) ) {
public static String getJavaIdentifier(StyledDocument doc, JEditorPane ep, int offset) { String t = null; if ( (ep.getSelectionStart() <= offset) && (offset <= ep.getSelectionEnd())) { t = ep.getSelectedText();
) { String t = null; if ( (ep.getSelectionStart () <= offset) && (offset <= ep.getSelectionEnd ()) ) t = ep.getSelectedText ();
if ( (ep.getSelectionStart () <= offset) && (offset <= ep.getSelectionEnd ()) ) {
if ( (ep.getSelectionStart () <= offset) && (offset <= ep.getSelectionEnd ()) ) {
int selectionStart = Math.min(getEditor().getSelectionStart(), getEditor().getSelectionEnd()); int selectionEnd = Math.max(getEditor().getSelectionStart(), getEditor().getSelectionEnd());
int iStart = jepEditor.getSelectionStart(); int iEnd = jepEditor.getSelectionEnd(); String selText = htmlDoc.getText(iStart, iEnd - iStart);
if( !editor.hasFocus() || editor.getSelectionStart() != editor.getSelectionEnd() )
if( !editor.hasFocus() || editor.getSelectionStart() != editor.getSelectionEnd() )
s = ep.getSelectedText (); currentOffset = ep.getCaretPosition(); if (ep.getSelectionStart() > currentOffset || ep.getSelectionEnd() < currentOffset) {
String s = ep.getSelectedText (); currentOffset = ep.getCaretPosition(); if (ep.getSelectionStart() > currentOffset || ep.getSelectionEnd() < currentOffset) {
String s = ep.getSelectedText(); currentOffset = ep.getCaretPosition(); if (ep.getSelectionStart() > currentOffset || ep.getSelectionEnd() < currentOffset) {