@Override public Component getEditorComponent() { FileObject file = EditorContextDispatcher.getDefault().getMostRecentFile(); int line = EditorContextDispatcher.getDefault().getMostRecentLineNumber(); if (file != null && line != -1) { DialogBinding.bindComponentToFile(file, line, 0, 0, pane); } return pane; }
public void init() { if (component == null || component.get() == null) { return; } DesignComponent _component = component.get(); javax.swing.text.Document swingDoc = textPane.getDocument(); if (swingDoc.getProperty(JavaSource.class) == null) { DataObjectContext context = ProjectUtils.getDataObjectContextForDocument(_component.getDocument()); swingDoc.putProperty(Document.StreamDescriptionProperty, context.getDataObject()); int offset = CodeUtils.getMethodOffset(context); String text = textPane.getText(); DialogBinding.bindComponentToFile(context.getDataObject().getPrimaryFile(), offset, 0, textPane); textPane.setText(text); } } }
public static JComponent[] createEditorComponent() { FileObject file = EditorContextDispatcher.getDefault().getMostRecentFile(); int line = EditorContextDispatcher.getDefault().getMostRecentLineNumber(); // Add JEditorPane and context // There is no need to define the mimetype here! JComponent[] editorComponents = Utilities.createSingleLineEditor("text/plain"); // NOI18N JTextComponent textComponent = (JTextComponent) editorComponents[1]; if (file != null && line >= 0) { DialogBinding.bindComponentToFile(file, line, 0, 0, textComponent); } return editorComponents; } }
private static void setupContext(final JEditorPane editorPane, Pair<Line.Part, FileObject> context) { assert SwingUtilities.isEventDispatchThread(); if (context != null) { final Line.Part lp = context.first(); final FileObject file = context.second(); //System.err.println("WatchPanel.setupContext("+file+", "+line+", "+offset+")"); // Do the binding for text files only: if (file != null && file.getMIMEType().startsWith("text/")) { // NOI18N String origText = editorPane.getText(); DialogBinding.bindComponentToFile(file, lp.getLine().getLineNumber(), lp.getColumn(), lp.getLength(), editorPane); Document editPaneDoc = editorPane.getDocument(); //editPaneDoc.putProperty("org.netbeans.modules.editor.java.JavaCompletionProvider.skipAccessibilityCheck", "true"); editorPane.setText(origText); } } setupUI(editorPane); }
public void initRetoucheStuff() { if (component == null || component.get() == null) { return; } DesignComponent _component = component.get(); javax.swing.text.Document swingDoc = userCodeEditorPane.getDocument(); if (swingDoc.getProperty(JavaSource.class) == null) { DataObjectContext context = ProjectUtils.getDataObjectContextForDocument(_component.getDocument()); swingDoc.putProperty(Document.StreamDescriptionProperty, context.getDataObject()); int offset = CodeUtils.getMethodOffset(context); DialogBinding.bindComponentToFile(context.getDataObject().getPrimaryFile(), offset, 0, userCodeEditorPane); PropertyEditorUserCode.setupTextUndoRedo(userCodeEditorPane); } if (getValue() instanceof PropertyValue) { PropertyValue value = (PropertyValue) getValue(); if (value.getKind() == PropertyValue.Kind.USERCODE) { setUserCodeText(value.getUserCode()); this.repaint(); } } }