public void setCurrentDiff(Difference[] currentDiff) { this.currentDiff = currentDiff; editorPane.setDifferences(currentDiff); linesActions.onDiffSetChanged(); fireHilitingChanged(); // revalidate(); }
void onUISettingsChanged() { editorPane.repaint(); linesActions.onUISettingsChanged(); actionsScrollPane.revalidate(); actionsScrollPane.repaint(); revalidate(); repaint(); }
public DiffContentPanel(EditableDiffView master, boolean isFirst) { this.master = master; this.isFirst = isFirst; setLayout(new BorderLayout()); editorPane = new DecoratedEditorPane(this); editorPane.setEditable(false); scrollPane = new JScrollPane(editorPane); add(scrollPane); linesActions = new LineNumbersActionsBar(this, master.isActionsEnabled()); actionsScrollPane = new JScrollPane(linesActions); actionsScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); actionsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); actionsScrollPane.setBorder(null); add(actionsScrollPane, isFirst ? BorderLayout.LINE_END : BorderLayout.LINE_START); editorPane.putClientProperty(DiffHighlightsLayerFactory.HIGHLITING_LAYER_ID, this); if (!isFirst) { // disable focus traversal, but permit just the up-cycle on ESC key editorPane.setFocusTraversalKeys( KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET); editorPane.setFocusTraversalKeys( KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET); editorPane.setFocusTraversalKeys( KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, Collections.singleton(KeyStroke.getAWTKeyStroke(KeyEvent.VK_ESCAPE, 0))); editorPane.putClientProperty("errorStripeOnly", Boolean.TRUE); editorPane.putClientProperty("code-folding-enable", false); } }
void initActions() { // TODO: copied from CloneableEditor - this has no effect ActionMap paneMap = editorPane.getActionMap(); ActionMap am = getActionMap(); am.setParent(paneMap); paneMap.put(DefaultEditorKit.cutAction, getAction(DefaultEditorKit.cutAction)); paneMap.put(DefaultEditorKit.copyAction, getAction(DefaultEditorKit.copyAction)); paneMap.put("delete", getAction(DefaultEditorKit.deleteNextCharAction)); // NOI18N paneMap.put(DefaultEditorKit.pasteAction, getAction(DefaultEditorKit.pasteAction)); }
public void setCustomEditor(JComponent c) { remove(scrollPane); // The present editorPane will already be wrapped with the new custom editor // including the new scrollpane that needs to be re-assigned Component viewPort = editorPane.getParent(); if (viewPort instanceof JViewport) { viewPort = viewPort.getParent(); if (viewPort instanceof JScrollPane) { scrollPane = (JScrollPane) viewPort; add(c); c.setFocusTraversalKeysEnabled(false); c.setFocusTraversalPolicyProvider(true); } } }
private Action getAction(String key) { if (key == null) { return null; } // Try to find the action from kit. EditorKit kit = editorPane.getEditorKit(); if (kit == null) { // kit is cleared in closeDocument() return null; } Action[] actions = kit.getActions(); for (int i = 0; i < actions.length; i++) { if (key.equals(actions[i].getValue(Action.NAME))) { return actions[i]; } } return null; }
public AccessibleContext getAccessibleContext() { return editorPane.getAccessibleContext(); }