viewcontentprovider.java

来自「SWT开发的Java调用COM的工具集」· Java 代码 · 共 63 行

JAVA
63
字号
/*
 * Copyright (c) 2007 Software Wizards Pty Ltd, Victoria, Australia.
 * mailto:enquires@swz.com.au. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted. See the GNU General Public License
 * for more details.
 *
 * Redistribution of the SWTtoCOM software is not permitted as part of any
 * commercial product. Licensing terms for such distribution may be
 * obtained from the copyright holder.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package au.com.swz.swttocom.example.win32explorer.views;

import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

public class ViewContentProvider
	implements IStructuredContentProvider, ITreeContentProvider
{

	public void inputChanged(Viewer v, Object oldInput, Object newInput) {
	}

	public void dispose() {
	}

	public Object[] getElements(Object parent) {
		return getChildren(parent);
	}

	public Object getParent(Object child) {
		if (child instanceof AbstractTreeObject) {
			return ((AbstractTreeObject) child).getParent();
		}
		return null;
	}

	public Object[] getChildren(Object parent) {
		if (parent instanceof AbstractTreeObject) {
			return ((AbstractTreeObject) parent).getChildren();
		}
		return new Object[0];
	}

	public boolean hasChildren(Object parent) {
		if (parent instanceof AbstractTreeObject) {
			return ((AbstractTreeObject) parent).hasChildren();
		}
		return false;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?