📄 viewcontentprovider.java
字号:
/* * Created on 2003-5-16 * */package com.tanghan.plugin.dbviews.elements;import java.util.ResourceBundle;import org.eclipse.core.resources.ResourcesPlugin;import org.eclipse.jface.viewers.IStructuredContentProvider;import org.eclipse.jface.viewers.ITreeContentProvider;import org.eclipse.jface.viewers.Viewer;import com.tanghan.plugin.TanghanPlugin;/** * 用来为视图提供内容 * @author Jerry Tang * @version v0.1.0 * @copyright (C) 2003 Tanghan工作组 * */public class ViewContentProvider implements IStructuredContentProvider, ITreeContentProvider { /**资源文件*/ private static ResourceBundle res = TanghanPlugin.getDefault().getResourceBundle(); private TreeParent invisibleRoot; public void inputChanged(Viewer v, Object oldInput, Object newInput) { } public void dispose() { } public Object[] getElements(Object parent) { if (parent.equals(ResourcesPlugin.getWorkspace())) { if (invisibleRoot == null) initialize(); return getChildren(invisibleRoot); } return getChildren(parent); } public Object getParent(Object child) { if (child instanceof TreeObject) { return ((TreeObject) child).getParent(); } return null; } public Object[] getChildren(Object parent) { if (parent instanceof TreeParent) { return ((TreeParent) parent).getChildren(); } return new Object[0]; } public boolean hasChildren(Object parent) { if (parent instanceof TreeParent) return ((TreeParent) parent).hasChildren(); return false; } /* * We will set up a dummy model to initialize tree heararchy. * In a real code, you will connect to a real model and * expose its hierarchy. */ private void initialize() { //TO DO 修改添加数据库的方式 已完成 invisibleRoot = new TreeParent("", TreeObject.DEFAULT_ITEM); TreeParent root = new TreeParent( res.getString("Tree.View.Database"), TreeObject.DATABASE_NOTE_ITEM); invisibleRoot.addChild(root); root = new TreeParent( res.getString("Tree.View.Drivers"), TreeObject.DRIVERS_NOTE_ITEM); invisibleRoot.addChild(root); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -