|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.xml.tree.editor; import java.io.IOException; import java.util.Enumeration; import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; import java.lang.ref.ReferenceQueue; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeSupport; import javax.swing.text.Document; import org.xml.sax.InputSource; import org.openide.loaders.OpenSupport; import org.openide.loaders.DataObject; import org.openide.loaders.MultiDataObject; import org.openide.cookies.*; import org.openide.windows.*; import org.openide.nodes.CookieSet; import org.openide.nodes.Node; import org.openide.util.*; import org.openide.*; import org.openide.awt.StatusDisplayer; import org.openide.filesystems.FileObject; import org.netbeans.tax.*; import org.netbeans.tax.event.TreeEvent; import org.netbeans.modules.xml.core.*; import org.netbeans.modules.xml.core.cookies.*; import org.netbeans.modules.xml.core.text.*; import org.netbeans.modules.xml.core.tree.*; import org.netbeans.modules.xml.core.sync.*; import org.netbeans.modules.xml.tax.cookies.TreeDocumentCookie; import org.netbeans.modules.xml.tax.cookies.TreeEditorCookie; /** * Reuse text editor logic, just provide additional component for OpenCookie. * allEditors then if it fails create new one
* and registers it with allEditors>/code>.
*/
protected final TreeEditorComponent openTreeEditorComponent () {
synchronized (getLock()) {
Enumeration enum = allEditors.getComponents();
while ( enum.hasMoreElements() ) {
CloneableTopComponent editor = (CloneableTopComponent)enum.nextElement();
if ( editor instanceof TreeEditorComponent ) {
editor.open();
return (TreeEditorComponent)editor;
}
}
// no opened editor
String msg = messageOpening();
if (msg != null) {
StatusDisplayer.getDefault().setStatusText (msg);
}
TreeEditorComponent editor = (TreeEditorComponent)createTreeEditorComponent();
editor.setReference (allEditors);
editor.open();
msg = messageOpened();
if (msg == null) {
msg = ""; // NOI18N
}
StatusDisplayer.getDefault().setStatusText (msg);
return editor;
}
}
/**
*/
protected TreeEditorComponent createTreeEditorComponent () {
return new TreeEditorComponent (this);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// class Env
//
/**
*
*/
protected static class Env extends TextEditorSupport.Env {
/** Serial Version UID */
private static final long serialVersionUID=-5223484399390072638L;
/** */
public Env (XMLDataObjectLook obj) {
super (obj);
}
/**
*/
public CloneableOpenSupport findCloneableOpenSupport () {
CloneableOpenSupport openSupport = (CloneableOpenSupport) getDataObject().getCookie (OpenCookie.class);
if ( openSupport == null ) {
openSupport = super.findCloneableOpenSupport();
}
return openSupport;
}
/**
*/
public TreeEditorSupport findTreeEditorSupport () {
return (TreeEditorSupport) getDataObject().getCookie (OpenCookie.class);
}
} // end: class Env
//
// class TreeEditorSupportFactory
//
public static class TreeEditorSupportFactory extends TextEditorSupport.TextEditorSupportFactory {
//
// init
//
/** Create new TreeEditorSupportFactory. */
public TreeEditorSupportFactory (XMLDataObjectLook dobj, String mime) {
super (dobj, mime);
}
/**
*/
protected Class[] supportedCookies () {
return new Class[] { EditorCookie.class,
EditCookie.class,
CloseCookie.class,
OpenCookie.class,
PrintCookie.class,
};
}
/**
*/
protected TextEditorSupport prepareEditor () {
if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("Initializing TreeEditorSupport ..."); // NOI18N
return new TreeEditorSupport (getDataObject(), getMIMEType());
}
} // end of class TreeEditorSupportFactory
//
// class TreeEditorSupportFactoryCreator
//
public static class TreeEditorSupportFactoryCreator implements TextEditorSupport.EditorSupportFactoryCreater {
/**
*/
public TextEditorSupportFactory createEditorSupportFactory (XMLDataObjectLook xmlDO, String mime) {
return new TreeEditorSupportFactory (xmlDO, mime);
}
} // end of class TreeEditorSupportFactory
//
// TreeLock
//
/** Subclass for better debugging. */
private class TreeLock {
}
}
|
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.