📄 foldertreeobject.java
字号:
/*
* 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.swt.graphics.Image;
import org.eclipse.swt.ole.win32.Variant;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import au.com.swz.swttocom.example.win32explorer.shell.Folder;
import au.com.swz.swttocom.example.win32explorer.shell.FolderItem;
import au.com.swz.swttocom.example.win32explorer.shell.FolderItems;
import au.com.swz.swttocom.example.win32explorer.shell.impl.IShellLinkDual2Impl;
public class FolderTreeObject extends AbstractTreeObject {
private Folder folder;
public FolderTreeObject(FolderItem folderItem, Folder folder, AbstractTreeObject parent) {
super(folderItem, parent);
this.folder = folder;
}
public String getText() {
return folder.getTitle();
}
public Object[] getChildren() {
try {
FolderItems items = folder.items();
int itemCount = items.getCount();
Object[] children = new Object[itemCount];
for (int i=0; i<itemCount; i++ ) {
FolderItem folderItem = items.item(new Variant(i));
if (folderItem.getIsFolder()) {
Folder folder = (Folder) folderItem.getGetFolder();
children[i] = new FolderTreeObject(folderItem, folder, this);
} else if (folderItem.getIsLink()) {
IShellLinkDual2Impl link = (IShellLinkDual2Impl) folderItem.getGetLink();
children[i] = new LinkTreeObject(folderItem, link, this);
} else {
children[i] = new FolderItemTreeObject(folderItem, this);
}
}
return children;
} catch (Exception e) {
e.printStackTrace();
return new Object[0];
}
}
public boolean hasChildren() {
return (folder.items().getCount() > 0);
}
public Image getImage() {
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -