Java Code Examples for org.openide.text.CloneableEditorSupport#Pane
The following examples show how to use
org.openide.text.CloneableEditorSupport#Pane .
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: SQLEditorSupport.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected Pane createPane() { Pane pane; if(getDataObject().getPrimaryFile().toURL().toExternalForm().startsWith("nbfs://")) { pane = new SQLCloneableEditor(Lookups.fixed(this, getDataObject())); } else { pane = (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView( SQLDataLoader.SQL_MIME_TYPE, getDataObject()); } return pane; }
Example 2
Source File: GotoOppositeAction.java From netbeans with Apache License 2.0 | 5 votes |
private FileObject getApplicableFileObject(int[] caretPosHolder) { if (!EventQueue.isDispatchThread()) { // Unsafe to ask for an editor pane from a random thread. // E.g. org.netbeans.lib.uihandler.LogRecords.write asking for getName(). Collection<? extends FileObject> dobs = Utilities.actionsGlobalContext().lookupAll(FileObject.class); return dobs.size() == 1 ? dobs.iterator().next() : null; } // TODO: Use the new editor library to compute this: // JTextComponent pane = EditorRegistry.lastFocusedComponent(); TopComponent comp = TopComponent.getRegistry().getActivated(); if(comp == null) { return null; } Node[] nodes = comp.getActivatedNodes(); if (nodes != null && nodes.length == 1) { if (comp instanceof CloneableEditorSupport.Pane) { //OK. We have an editor EditorCookie ec = nodes[0].getLookup().lookup(EditorCookie.class); if (ec != null) { JEditorPane editorPane = NbDocument.findRecentEditorPane(ec); if (editorPane != null) { if (editorPane.getCaret() != null) { caretPosHolder[0] = editorPane.getCaret().getDot(); } Document document = editorPane.getDocument(); return Source.create(document).getFileObject(); } } } else { return UICommonUtils.getFileObjectFromNode(nodes[0]); } } return null; }
Example 3
Source File: GsfDataObject.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected Pane createPane() { if(language.useMultiview()) { return (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(language.getMimeType(), getDataObject()); } else { return super.createPane(); } }
Example 4
Source File: XMLJ2eeEditorSupport.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected Pane createPane() { if (dataObject.getEditorMimeType() != null) { return (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(dataObject.getEditorMimeType(), getDataObject()); } return (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView("text/xml", getDataObject()); }
Example 5
Source File: MultiViewEditorElementTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testLookupProvidersAreConsistent() throws Exception { InstanceContent ic = new InstanceContent(); Lookup context = new AbstractLookup(ic); CloneableEditorSupport ces = createSupport(context); ic.add(ces); ic.add(10); final CloneableTopComponent tc = MultiViews.createCloneableMultiView("text/plaintest", new LP(context)); final CloneableEditorSupport.Pane p = (CloneableEditorSupport.Pane) tc; EventQueue.invokeAndWait(new Runnable() { @Override public void run() { tc.open(); tc.requestActive(); p.updateName(); } }); assertNull("No icon yet", tc.getIcon()); MultiViewHandler handler = MultiViews.findMultiViewHandler(tc); final MultiViewPerspective[] one = handler.getPerspectives(); assertEquals("Two elements only" + Arrays.asList(one), 2, handler.getPerspectives().length); assertEquals("First one is source", "source", one[0].preferredID()); assertEquals("Second one is also source", "source", one[1].preferredID()); handler.requestVisible(one[0]); List<Lookup.Provider> arr = new ArrayList<Provider>(); findProviders(tc, arr); assertEquals("Two providers: " + arr, 2, arr.size()); assertSame("Both return same lookup", arr.get(0).getLookup(), arr.get(1).getLookup()); }
Example 6
Source File: MultiViewCloneableTopComponent.java From netbeans with Apache License 2.0 | 5 votes |
private MultiViewElement findPaneElement() { MultiViewElement el = peer.model.getActiveElement(false); if (el != null && el.getVisualRepresentation() instanceof CloneableEditorSupport.Pane) { return el; } // now try a best guess.. iterate the already created elements and check if any of // them is a Pane Collection col = peer.model.getCreatedElements(); Iterator<MultiViewElement> it = col.iterator(); while (it.hasNext()) { el = it.next(); if (el.getVisualRepresentation() instanceof CloneableEditorSupport.Pane) { // fingers crossed and hope for the best... could result in bad results once // we have multiple editors in the multiview component. return el; } } MultiViewDescription[] descs = peer.model.getDescriptions(); for (MultiViewDescription desc : descs) { if (isSourceView(desc)) { el = peer.model.getElementForDescription(desc); if (el.getVisualRepresentation() instanceof CloneableEditorSupport.Pane) { return el; } else { Logger.getLogger(getClass().getName()).info("MultiViewDescription " + desc.getDisplayName() + "(" + desc.getClass() + ") claimed to contain sources, but it's MutliViewElement.getVisualRepresentation() didn't return a valid CloeanbleEditorSupport.Pane instance."); } } } // hopeless case, don't try to create new elements. it's users responsibility to // switch to the editor element before getEditorPane() return null; }
Example 7
Source File: MultiViewCloneableTopComponent.java From netbeans with Apache License 2.0 | 5 votes |
public javax.swing.JEditorPane getEditorPane() { if (peer == null || peer.model == null) { return null; } MultiViewElement paneEl = findPaneElement(); if (paneEl != null) { CloneableEditorSupport.Pane pane = (CloneableEditorSupport.Pane)paneEl.getVisualRepresentation(); return pane.getEditorPane(); } // hopeless case, don't try to create new elements. it's users responsibility to // switch to the editor element before getEditorPane() return null; }
Example 8
Source File: CPActionsImplementationProvider.java From netbeans with Apache License 2.0 | 5 votes |
private static boolean isFromEditor(EditorCookie ec) { if (ec != null && ec.getOpenedPanes() != null) { TopComponent activetc = TopComponent.getRegistry().getActivated(); if (activetc instanceof CloneableEditorSupport.Pane) { return true; } } return false; }
Example 9
Source File: FixAction.java From netbeans with Apache License 2.0 | 5 votes |
@Override public boolean isEnabled() { TopComponent activetc = TopComponent.getRegistry().getActivated(); if (activetc instanceof CloneableEditorSupport.Pane) { return true; } return false; }
Example 10
Source File: FormEditorSupport.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected CloneableEditorSupport.Pane createPane() { if (!formDataObject.isValid()) { return super.createPane(); // Issue 110249 } CloneableTopComponent mvtc = MultiViews.createCloneableMultiView("text/x-form", getDataObject()); // #45665 - dock into editor mode if possible.. Mode editorMode = WindowManager.getDefault().findMode(CloneableEditorSupport.EDITOR_MODE); if (editorMode != null) { editorMode.dockInto(mvtc); } return (CloneableEditorSupport.Pane)mvtc; }
Example 11
Source File: RefactoringUtils.java From netbeans with Apache License 2.0 | 5 votes |
public static boolean isFromEditor(EditorCookie ec) { if (ec != null && NbDocument.findRecentEditorPane(ec) != null) { TopComponent activetc = TopComponent.getRegistry().getActivated(); if (activetc instanceof CloneableEditorSupport.Pane) { return true; } } return false; }
Example 12
Source File: HtmlEditorSupport.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected Pane createPane() { return (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(HtmlLoader.HTML_MIMETYPE, getDataObject()); }
Example 13
Source File: POMDataObject.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected Pane createPane() { return (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(Constants.POM_MIME_TYPE, getDataObject()); }
Example 14
Source File: TplEditorSupport.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected Pane createPane() { return (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(TplDataLoader.MIME_TYPE, getDataObject()); }
Example 15
Source File: GradleDataObject.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected CloneableEditorSupport.Pane createPane() { return (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(MIME_TYPE, getDataObject()); }
Example 16
Source File: JShellDataObject.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected CloneableEditorSupport.Pane createPane() { return createPane0(); }
Example 17
Source File: TLDEditorSupport.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected Pane createPane() { return (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(TLDLoader.TLD_MIMETYPE, getDataObject()); }
Example 18
Source File: BaseJspEditorSupport.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected Pane createPane() { return (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(getDataObject().getPrimaryFile().getMIMEType(), getDataObject()); }
Example 19
Source File: JShellDataObject.java From netbeans with Apache License 2.0 | 4 votes |
private CloneableEditorSupport.Pane createPane0() { CloneableEditorSupport cls = (CloneableEditorSupport)getLookup().lookup(EditorCookie.class); CloneableEditor cle = new ConsoleEditor(cls, getLookup()); return cle; }
Example 20
Source File: StrutsConfigEditorSupport.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected Pane createPane() { return (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(StrutsConfigLoader.MIME_TYPE, getDataObject()); }