- 浏览: 25592 次
- 性别:
- 来自: 重庆
文章分类
最新评论
1: /*******************************************************************************
2: * Copyright (c) 2004, 2006 IBM Corporation and others.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * IBM Corporation - initial API and implementation
10: *******************************************************************************/
11: package org.eclipse.jface.commands;
12:
13: import org.eclipse.core.commands.AbstractHandler;
14: import org.eclipse.core.commands.ExecutionEvent;
15: import org.eclipse.core.commands.ExecutionException;
16: import org.eclipse.core.commands.HandlerEvent;
17: import org.eclipse.core.commands.IHandlerListener;
18: import org.eclipse.jface.action.IAction;
19: import org.eclipse.jface.util.IPropertyChangeListener;
20: import org.eclipse.jface.util.PropertyChangeEvent;
21: import org.eclipse.swt.widgets.Event;
22:
23: /**
24: * <p>
25: * This class adapts instances of <code>IAction</code> to
26: * <code>IHandler</code>.
27: * </p>
28: *
29: * @since 3.1
30: */
31: public final class ActionHandler extends AbstractHandler {
32:
33: /**
34: * The wrapped action. This value is never <code>null</code>.
35: */
36: private final IAction action;
37:
38: /**
39: * The property change listener hooked on to the action. This is initialized
40: * when the first listener is attached to this handler, and is removed when
41: * the handler is disposed or the last listener is removed.
42: */
43: private IPropertyChangeListener propertyChangeListener;
44:
45: /**
46: * Creates a new instance of this class given an instance of
47: * <code>IAction</code>.
48: *
49: * @param action
50: * the action. Must not be <code>null</code>.
51: */
52: public ActionHandler(final IAction action) {
53: if (action == null) {
54: throw new NullPointerException();
55: }
56:
57: this.action = action;
58: }
59:
60: public final void addHandlerListener(final IHandlerListener handlerListener) {
61: if (!hasListeners()) {
62: attachListener();
63: }
64:
65: super.addHandlerListener(handlerListener);
66: }
67:
68: /**
69: * When a listener is attached to this handler, then this registers a
70: * listener with the underlying action.
71: *
72: * @since 3.1
73: */
74: private final void attachListener() {
75: if (propertyChangeListener == null) {
76: propertyChangeListener = new IPropertyChangeListener() {
77: public final void propertyChange(
78: final PropertyChangeEvent propertyChangeEvent) {
79: final String property = propertyChangeEvent.getProperty();
80: fireHandlerChanged(new HandlerEvent(ActionHandler.this,
81: IAction.ENABLED.equals(property), IAction.HANDLED
82: .equals(property)));
83: }
84: };
85: }
86:
87: this.action.addPropertyChangeListener(propertyChangeListener);
88: }
89:
90: /**
91: * When no more listeners are registered, then this is used to removed the
92: * property change listener from the underlying action.
93: */
94: private final void detachListener() {
95: this.action.removePropertyChangeListener(propertyChangeListener);
96: propertyChangeListener = null;
97: }
98:
99: /**
100: * Removes the property change listener from the action.
101: *
102: * @see org.eclipse.core.commands.IHandler#dispose()
103: */
104: public final void dispose() {
105: if (hasListeners()) {
106: action.removePropertyChangeListener(propertyChangeListener);
107: }
108: }
109:
110: public final Object execute(final ExecutionEvent event)
111: throws ExecutionException {
112: if ((action.getStyle() == IAction.AS_CHECK_BOX)
113: || (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
114: action.setChecked(!action.isChecked());
115: }
116: final Object trigger = event.getTrigger();
117: try {
118: if (trigger instanceof Event) {
119: action.runWithEvent((Event) trigger);
120: } else {
121: action.runWithEvent(new Event());
122: }
123: } catch (Exception e) {
124: throw new ExecutionException(
125: "While executing the action, an exception occurred", e); //$NON-NLS-1$
126: }
127: return null;
128: }
129:
130: /**
131: * Returns the action associated with this handler
132: *
133: * @return the action associated with this handler (not null)
134: * @since 3.1
135: */
136: public final IAction getAction() {
137: return action;
138: }
139:
140: public final boolean isEnabled() {
141: return action.isEnabled();
142: }
143:
144: public final boolean isHandled() {
145: return action.isHandled();
146: }
147:
148: public final void removeHandlerListener(
149: final IHandlerListener handlerListener) {
150: super.removeHandlerListener(handlerListener);
151:
152: if (!hasListeners()) {
153: detachListener();
154: }
155: }
156:
157: public final String toString() {
158: final StringBuffer buffer = new StringBuffer();
159:
160: buffer.append("ActionHandler("); //$NON-NLS-1$
161: buffer.append(action);
162: buffer.append(')');
163:
164: return buffer.toString();
165: }
166:}
2: * Copyright (c) 2004, 2006 IBM Corporation and others.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * IBM Corporation - initial API and implementation
10: *******************************************************************************/
11: package org.eclipse.jface.commands;
12:
13: import org.eclipse.core.commands.AbstractHandler;
14: import org.eclipse.core.commands.ExecutionEvent;
15: import org.eclipse.core.commands.ExecutionException;
16: import org.eclipse.core.commands.HandlerEvent;
17: import org.eclipse.core.commands.IHandlerListener;
18: import org.eclipse.jface.action.IAction;
19: import org.eclipse.jface.util.IPropertyChangeListener;
20: import org.eclipse.jface.util.PropertyChangeEvent;
21: import org.eclipse.swt.widgets.Event;
22:
23: /**
24: * <p>
25: * This class adapts instances of <code>IAction</code> to
26: * <code>IHandler</code>.
27: * </p>
28: *
29: * @since 3.1
30: */
31: public final class ActionHandler extends AbstractHandler {
32:
33: /**
34: * The wrapped action. This value is never <code>null</code>.
35: */
36: private final IAction action;
37:
38: /**
39: * The property change listener hooked on to the action. This is initialized
40: * when the first listener is attached to this handler, and is removed when
41: * the handler is disposed or the last listener is removed.
42: */
43: private IPropertyChangeListener propertyChangeListener;
44:
45: /**
46: * Creates a new instance of this class given an instance of
47: * <code>IAction</code>.
48: *
49: * @param action
50: * the action. Must not be <code>null</code>.
51: */
52: public ActionHandler(final IAction action) {
53: if (action == null) {
54: throw new NullPointerException();
55: }
56:
57: this.action = action;
58: }
59:
60: public final void addHandlerListener(final IHandlerListener handlerListener) {
61: if (!hasListeners()) {
62: attachListener();
63: }
64:
65: super.addHandlerListener(handlerListener);
66: }
67:
68: /**
69: * When a listener is attached to this handler, then this registers a
70: * listener with the underlying action.
71: *
72: * @since 3.1
73: */
74: private final void attachListener() {
75: if (propertyChangeListener == null) {
76: propertyChangeListener = new IPropertyChangeListener() {
77: public final void propertyChange(
78: final PropertyChangeEvent propertyChangeEvent) {
79: final String property = propertyChangeEvent.getProperty();
80: fireHandlerChanged(new HandlerEvent(ActionHandler.this,
81: IAction.ENABLED.equals(property), IAction.HANDLED
82: .equals(property)));
83: }
84: };
85: }
86:
87: this.action.addPropertyChangeListener(propertyChangeListener);
88: }
89:
90: /**
91: * When no more listeners are registered, then this is used to removed the
92: * property change listener from the underlying action.
93: */
94: private final void detachListener() {
95: this.action.removePropertyChangeListener(propertyChangeListener);
96: propertyChangeListener = null;
97: }
98:
99: /**
100: * Removes the property change listener from the action.
101: *
102: * @see org.eclipse.core.commands.IHandler#dispose()
103: */
104: public final void dispose() {
105: if (hasListeners()) {
106: action.removePropertyChangeListener(propertyChangeListener);
107: }
108: }
109:
110: public final Object execute(final ExecutionEvent event)
111: throws ExecutionException {
112: if ((action.getStyle() == IAction.AS_CHECK_BOX)
113: || (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
114: action.setChecked(!action.isChecked());
115: }
116: final Object trigger = event.getTrigger();
117: try {
118: if (trigger instanceof Event) {
119: action.runWithEvent((Event) trigger);
120: } else {
121: action.runWithEvent(new Event());
122: }
123: } catch (Exception e) {
124: throw new ExecutionException(
125: "While executing the action, an exception occurred", e); //$NON-NLS-1$
126: }
127: return null;
128: }
129:
130: /**
131: * Returns the action associated with this handler
132: *
133: * @return the action associated with this handler (not null)
134: * @since 3.1
135: */
136: public final IAction getAction() {
137: return action;
138: }
139:
140: public final boolean isEnabled() {
141: return action.isEnabled();
142: }
143:
144: public final boolean isHandled() {
145: return action.isHandled();
146: }
147:
148: public final void removeHandlerListener(
149: final IHandlerListener handlerListener) {
150: super.removeHandlerListener(handlerListener);
151:
152: if (!hasListeners()) {
153: detachListener();
154: }
155: }
156:
157: public final String toString() {
158: final StringBuffer buffer = new StringBuffer();
159:
160: buffer.append("ActionHandler("); //$NON-NLS-1$
161: buffer.append(action);
162: buffer.append(')');
163:
164: return buffer.toString();
165: }
166:}
发表评论
-
CoolBar CoolBarManager应用到任何ViewForm
2012-07-03 10:44 1544ViewForm viewForm = new ViewFor ... -
eclipse 透视图切换监听 和 视图激活监听
2012-06-28 16:24 1992<extension point=&q ... -
动态更新或者删除菜单
2012-06-08 12:42 899@Override public void postWind ... -
网址收集
2012-06-07 15:05 604http://wiki.eclipse.org/Platfor ... -
Toggle & Radio menu contributions
2012-06-07 15:04 967转载于:http://blog.eclipse-tips.co ... -
eclilpse check 菜单 --Toggle Handler for Eclipse Commands_1
2012-06-07 14:59 1140转载:http://eclipsesource.com/blo ... -
eclilpse check 菜单 --Toggle Handler for Eclipse Commands
2012-06-07 14:55 1287转载:http://www.ralfebert.de/blog ... -
RCP3.5版本 help所需的依赖包
2012-05-15 15:05 7921. org.apache.lucene 2. ...
相关推荐
- `src`目录:包含了所有的Java源代码文件,可能有主类(如`Main.java`)、绘图工具类(如`DrawTools.java`)、图形类(如`Shape.java`)以及事件处理器(如`ActionHandler.java`)等。 - `lib`目录:可能包含了一些...
【Java课程设计报告】 在本次Java课程设计中,学生苗志强设计并实现了一个基于GUI的猜数字游戏。这个游戏的核心机制是让玩家猜测由程序随机生成的四个0到9之间不重复的整数。游戏的反馈机制是A表示位置和数字都正确...
- `MessageActionHandler`: 自动生成的ActionHandler,可根据需求保留或删除。 - `ehcache.xml`: 缓存配置文件,内置详细英文说明,无需修改除非有特殊需求。 - `hibernate.cfg.xml`: jBPM使用Hibernate进行数据...
- `MessageActionHandler`: 自动生成的ActionHandler,可根据需要保留或删除。 - `ehcache.xml`: 缓存配置文件。 - `hibernate.cfg.xml`: Hibernate配置文件,用于配置数据存储。 - `jbpm.cfg.xml`: JBPM配置...
一个Java客户端和处理框架,用于使用Google助手创建转换。 API版本2中Webhook请求和响应的序列化/反序列化 不错的api,可在以下支持下定义对话 ssml 文本 建议筹码 基本卡 带注释的处理框架可实现清晰的代码分离 ...
- `com.jfinal.handler`:这里是HTTP请求的处理器,比如`ActionHandler`负责将请求映射到相应的Controller方法。 - `com.jfinal.render`:渲染模块,负责将处理结果转化为最终的HTTP响应,支持多种视图技术。 - `...
而动作则是对这些事件做出响应的一段代码,它可以是Java类(通常实现`ActionHandler`接口),也可以是简单的脚本代码(如Beanshell)。通过编写不同的动作,我们可以在流程的不同阶段执行特定的任务。 ##### 1.1 ...
JFinal 是一个轻量级的Java Web开发框架,它的设计目标是使开发更加高效和简单。JFinal 采用微内核全方位扩展架构,允许开发者在各个层面上进行自定义,以满足不同项目的需求。 在空间架构上,JFinal 由五个主要...
public class MyActionHandler implements ActionHandler { public void execute(ExecutionContext executionContext) { System.out.println("MyActionHandler has executed: " + executionContext); } } ``` ...
JFinal 是一个基于Java语言的轻量级Web开发框架,其设计目标是高效、易用、足够小。本文将深入解析JFinal的技术架构,帮助理解其核心机制。 **1. 空间架构** JFinal 的空间架构由五个主要部分组成:Handler、...
jBPM是一个强大的开源工作流管理系统,专注于Java平台上的业务流程管理。...在实际应用中,开发者可以根据需求编写自定义的ActionHandler类,实现特定的业务逻辑,例如在员工解雇流程中更新数据库记录的操作。
jbpm3.2是流行的Java业务流程管理(BPM)平台的一个版本,可用于设计、执行和管理企业级业务流程。本文主要围绕jbpm3.2在开发过程中的关键概念、组件、API使用以及配置等知识点进行总结。 首先,了解jbpm3.2需要...
public class MyActionHandler implements ActionHandler { public void execute(ExecutionContext executionContext) { System.out.println("MyActionHandler has executed: " + executionContext); } } ``` ...
1. `src/main/java` - 存放Java源代码,可能有`com.example.actiontest`或其他命名空间下的类,比如`ActionHandler`,用于处理用户动作。 2. `src/test/java` - 测试代码通常放在这里,使用JUnit或其他测试框架编写...
JFinal是一个基于Java语言的Web开发框架,具有轻量级、灵活、可扩展等特点。本文将对JFinal技术架构进行浅析,并对其空间架构、逻辑架构、代码架构和运作原理进行详细介绍。 空间架构 JFinal框架采用微内核全方位...
一个Task instance(任务实例)可以被分配给一个actorId (java.lang.String)。所有的Task instance都被保存在数据库中的表jbpm_taskinstance里。当你想得到特定用户的任务清单时,你就可以通过一个与用户关联的...
PlayerEngine接口不对外开放,防止出现错误的调用,外部想进行播放,暂停,上下切换等操作时,需要通过调用ActionHandler中的execute接口, 并传入对应的枚举类型来执行。 注:MediaBase是准备作为一个jar包存在的,...