?? 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 + -