📄 verbtoolbaraction.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.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.PlatformUI;
import au.com.swz.swttocom.example.win32explorer.shell.FolderItemVerb;
public class VerbToolbarAction extends Action {
private String verbName;
private FolderItemVerb folderItemVerb;
VerbToolbarAction(String verbName, int shellImageIndex) {
this.verbName = verbName;
setText(verbName);
setToolTipText(verbName);
if (shellImageIndex > 0) {
Image image = Utils.extractShell32Image(shellImageIndex);
if (image != null) {
setImageDescriptor(ImageDescriptor.createFromImage(image));
image.dispose();
}
}
}
VerbToolbarAction(String verbName, String sharedImageName) {
this.verbName = verbName;
setText(verbName);
setToolTipText(verbName);
if (sharedImageName != null) {
setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(sharedImageName));
}
}
public void reset() {
folderItemVerb = null;
}
public void setFolderItemVerb(String name, FolderItemVerb verb) {
if (name.equalsIgnoreCase(verbName)) {
folderItemVerb = verb;
}
}
public void determineEnabled() {
if (folderItemVerb == null) {
setEnabled(false);
} else {
setEnabled(true);
}
}
public void run() {
if (folderItemVerb != null) {
folderItemVerb.doIt();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -