/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mobi.chenwei.nbm.explorer;
import java.awt.BorderLayout;
import java.io.Serializable;
import java.util.logging.Logger;
import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils;
import org.openide.explorer.view.BeanTreeView;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
//import org.openide.util.Utilities;
/**
* @author Chen Wei
* @website www.chenwei.mobi
* @email chenweionline@hotmail.com
*/
final class ExplorerTopComponent extends TopComponent implements ExplorerManager.Provider{
private static ExplorerTopComponent instance;
/** path to the icon used by the component and its open action */
// static final String ICON_PATH = "SET/PATH/TO/ICON/HERE";
private static final String PREFERRED_ID = "ExplorerTopComponent";
private BeanTreeView fileTree;
private ExplorerManager explorerMgr;
private ExplorerTopComponent() {
initComponents();
setName(NbBundle.getMessage(ExplorerTopComponent.class, "CTL_ExplorerTopComponent"));
setToolTipText(NbBundle.getMessage(ExplorerTopComponent.class, "HINT_ExplorerTopComponent"));
// setIcon(Utilities.loadImage(ICON_PATH, true));
myInit();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setLayout(new java.awt.BorderLayout());
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
/**
* Gets default instance. Do not use directly: reserved for *.settings files only,
* i.e. deserialization routines; otherwise you could get a non-deserialized instance.
* To obtain the singleton instance, use {@link findInstance}.
*/
public static synchronized ExplorerTopComponent getDefault() {
if (instance == null) {
instance = new ExplorerTopComponent();
}
return instance;
}
/**
* Obtain the ExplorerTopComponent instance. Never call {@link #getDefault} directly!
*/
public static synchronized ExplorerTopComponent findInstance() {
TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
if (win == null) {
Logger.getLogger(ExplorerTopComponent.class.getName()).warning(
"Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
return getDefault();
}
if (win instanceof ExplorerTopComponent) {
return (ExplorerTopComponent) win;
}
Logger.getLogger(ExplorerTopComponent.class.getName()).warning(
"There seem to be multiple components with the '" + PREFERRED_ID +
"' ID. That is a potential source of errors and unexpected behavior.");
return getDefault();
}
@Override
public int getPersistenceType() {
return TopComponent.PERSISTENCE_ALWAYS;
}
@Override
public void componentOpened() {
// TODO add custom code on component opening
}
@Override
public void componentClosed() {
// TODO add custom code on component closing
}
/** replaces this in object stream */
@Override
public Object writeReplace() {
return new ResolvableHelper();
}
@Override
protected String preferredID() {
return PREFERRED_ID;
}
final static class ResolvableHelper implements Serializable {
private static final long serialVersionUID = 1L;
public Object readResolve() {
return ExplorerTopComponent.getDefault();
}
}
private void myInit() {
fileTree = new BeanTreeView();
explorerMgr = new ExplorerManager();
add(fileTree, BorderLayout.CENTER);
this.associateLookup(ExplorerUtils.createLookup(explorerMgr, getActionMap()));
explorerMgr.setRootContext(FileNode.createHomeNode(new DirFilter()));
// m_ExplorerMgr.setRootContext(FileNode.createHomeNode(null));
}
public ExplorerManager getExplorerManager() {
return explorerMgr;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
NBM_Explorer_build20080119.zip (18个子文件)
NBM_Explorer
test
unit
src
manifest.mf 249B
src
mobi
chenwei
nbm
explorer
ExplorerTopComponentSettings.xml 579B
ExplorerAction.java 889B
ExplorerTopComponentWstcref.xml 423B
Bundle.properties 158B
FileNode.java 2KB
ExplorerTopComponent.java 4KB
layer.xml 1KB
FileChildren.java 1KB
ExplorerTopComponent.form 1KB
DirFilter.java 969B
build.xml 513B
nbproject
build-impl.xml 1KB
private
platform-private.properties 89B
project.properties 76B
platform.properties 27B
project.xml 3KB
genfiles.properties 455B
共 18 条
- 1
资源评论
- pm17842014-01-14这方面资料比较少,赞一个
- oboooa2015-02-15还不错,正是我需要的。
- kitlover2013-07-18提供了一些参考方向
- A_free_I2013-12-11学习了,不错场景刚好够用
chenweionline
- 粉丝: 1163
- 资源: 17
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功