📄 linktreeobject.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.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.TCHAR;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import au.com.swz.swttocom.example.win32explorer.shell.FolderItem;
import au.com.swz.swttocom.example.win32explorer.shell.impl.IShellLinkDual2Impl;
import au.com.swz.swttocom.swt.types.pointer.StringPointer;
public class LinkTreeObject extends AbstractTreeObject {
private IShellLinkDual2Impl link;
public LinkTreeObject(FolderItem folderItem, IShellLinkDual2Impl link, AbstractTreeObject parent) {
super(folderItem, parent);
this.link = link;
}
public String getText() {
return getFolderItem().getName();
}
public Object[] getChildren() {
return null;
}
public boolean hasChildren() {
return false;
}
public Image getImage() {
try {
StringPointer iconPath = new StringPointer();
int nIconIndex = link.getIconLocation(iconPath);
TCHAR lpszFile = new TCHAR (0, iconPath.getValue(), true);
int [] phiconSmall = new int[1], phiconLarge = null;
OS.ExtractIconEx (lpszFile, nIconIndex, phiconLarge, phiconSmall, 1);
if (phiconSmall [0] != 0) {
return Image.win32_new (null, SWT.ICON, phiconSmall[0]);
}
String path = link.getPath();
if (path != null) {
Image image = Utils.getAssociatedImage(path);
if (image != null) {
return image;
}
FolderItem folderItem = link.getTarget();
if (folderItem != null) {
image = Utils.extractFileImage(folderItem.getPath(), 1);
if (image != null) {
return image;
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -