forked from FR-Global/plugin-event-manager
15 changed files with 241 additions and 160 deletions
@ -1,69 +0,0 @@ |
|||||||
package com.fr.plugin.event.manager.core; |
|
||||||
|
|
||||||
import com.fr.base.BaseUtils; |
|
||||||
import com.fr.design.DesignModelAdapter; |
|
||||||
import com.fr.design.actions.JTemplateAction; |
|
||||||
import com.fr.design.dialog.FineJOptionPane; |
|
||||||
import com.fr.design.dialog.UIDialog; |
|
||||||
import com.fr.design.mainframe.DesignerContext; |
|
||||||
import com.fr.design.mainframe.JTemplate; |
|
||||||
import com.fr.design.mainframe.WidgetPropertyPane; |
|
||||||
import com.fr.form.main.Form; |
|
||||||
import com.fr.plugin.event.manager.ui.EventManagerDialog; |
|
||||||
import com.fr.plugin.event.manager.ui.EventManagerPane; |
|
||||||
import com.fr.plugin.event.manager.utils.KeySetUtils; |
|
||||||
import com.fr.plugin.transform.ExecuteFunctionRecord; |
|
||||||
import com.fr.plugin.transform.FunctionRecorder; |
|
||||||
|
|
||||||
import javax.swing.JOptionPane; |
|
||||||
import java.awt.event.ActionEvent; |
|
||||||
import java.awt.event.WindowAdapter; |
|
||||||
import java.awt.event.WindowEvent; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author Joe |
|
||||||
* Created by Joe on 12/11/2020 |
|
||||||
*/ |
|
||||||
@FunctionRecorder |
|
||||||
public abstract class EventManager extends JTemplateAction<JTemplate<?, ?>> { |
|
||||||
|
|
||||||
public EventManager(JTemplate<?, ?> jTemplate) { |
|
||||||
super(jTemplate); |
|
||||||
this.setMenuKeySet(KeySetUtils.EVENT_MANAGER); |
|
||||||
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); |
|
||||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
|
||||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/plugin/event/manager/images/icon_event_manager.png")); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
@ExecuteFunctionRecord |
|
||||||
public void actionPerformed(ActionEvent e) { |
|
||||||
JTemplate jt = getEditingComponent(); |
|
||||||
if (jt == null) { |
|
||||||
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "无法获取模板对象!", |
|
||||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.ERROR_MESSAGE); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
final Object target = jt.getTarget(); |
|
||||||
final EventManagerPane eventManagerPane = initEventManager(target); |
|
||||||
UIDialog dialog = new EventManagerDialog(DesignerContext.getDesignerFrame(), eventManagerPane); |
|
||||||
|
|
||||||
dialog.addWindowListener(new WindowAdapter() { |
|
||||||
@Override |
|
||||||
public void windowClosed(WindowEvent e) { |
|
||||||
eventManagerPane.update(); |
|
||||||
// 刷新一下右侧面板,避免事件显示不同步
|
|
||||||
if (target instanceof Form) { |
|
||||||
WidgetPropertyPane.getInstance().refreshDockingView(); |
|
||||||
} |
|
||||||
// 触发正在编辑的模板改变事件
|
|
||||||
DesignModelAdapter.getCurrentModelAdapter().fireTargetModified(); |
|
||||||
super.windowClosed(e); |
|
||||||
} |
|
||||||
}); |
|
||||||
dialog.setVisible(true); |
|
||||||
} |
|
||||||
|
|
||||||
protected abstract EventManagerPane initEventManager(Object target); |
|
||||||
} |
|
@ -1,32 +1,75 @@ |
|||||||
package com.fr.plugin.event.manager.core; |
package com.fr.plugin.event.manager.core; |
||||||
|
|
||||||
import com.fr.design.dialog.BasicPane; |
import com.fr.base.BaseUtils; |
||||||
import com.fr.design.mainframe.JTemplate; |
import com.fr.design.DesignModelAdapter; |
||||||
|
import com.fr.design.actions.JTemplateAction; |
||||||
|
import com.fr.design.dialog.FineJOptionPane; |
||||||
|
import com.fr.design.dialog.UIDialog; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.mainframe.JForm; |
||||||
|
import com.fr.design.mainframe.WidgetPropertyPane; |
||||||
import com.fr.form.main.Form; |
import com.fr.form.main.Form; |
||||||
|
import com.fr.plugin.event.manager.ui.EventManagerDialog; |
||||||
import com.fr.plugin.event.manager.ui.EventManagerPane; |
import com.fr.plugin.event.manager.ui.EventManagerPane; |
||||||
import com.fr.plugin.event.manager.ui.FormEventManagerPane; |
import com.fr.plugin.event.manager.ui.FormEventManagerPane; |
||||||
|
import com.fr.plugin.event.manager.utils.KeySetUtils; |
||||||
|
import com.fr.plugin.transform.ExecuteFunctionRecord; |
||||||
|
|
||||||
|
import javax.swing.JOptionPane; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.WindowAdapter; |
||||||
|
import java.awt.event.WindowEvent; |
||||||
|
|
||||||
|
|
||||||
/** |
/** |
||||||
* @author Joe |
* @author Joe |
||||||
* Created by Joe on 9/3/2020 |
* Created by Joe on 9/3/2020 |
||||||
*/ |
*/ |
||||||
public class FormEventManager extends EventManager { |
public class FormEventManager extends JTemplateAction<JForm> { |
||||||
|
|
||||||
public FormEventManager(JTemplate<?, ?> jTemplate) { |
public FormEventManager(JForm form) { |
||||||
super(jTemplate); |
super(form); |
||||||
|
this.setMenuKeySet(KeySetUtils.EVENT_MANAGER); |
||||||
|
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); |
||||||
|
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/plugin/event/manager/images/icon_event_manager.png")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@ExecuteFunctionRecord |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
JForm jf = getEditingComponent(); |
||||||
|
if (jf == null) { |
||||||
|
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "无法获取模板对象!", |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.ERROR_MESSAGE); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
final Form form = jf.getTarget(); |
||||||
|
final EventManagerPane eventManagerPane = initEventManager(form); |
||||||
|
UIDialog dialog = new EventManagerDialog(DesignerContext.getDesignerFrame(), eventManagerPane); |
||||||
|
|
||||||
|
dialog.addWindowListener(new WindowAdapter() { |
||||||
|
@Override |
||||||
|
public void windowClosed(WindowEvent e) { |
||||||
|
eventManagerPane.update(); |
||||||
|
// 触发正在编辑的模板改变事件
|
||||||
|
DesignModelAdapter.getCurrentModelAdapter().fireTargetModified(); |
||||||
|
// 刷新一下右侧面板,避免事件显示不同步
|
||||||
|
WidgetPropertyPane.getInstance().refreshDockingView(); |
||||||
|
super.windowClosed(e); |
||||||
|
} |
||||||
|
}); |
||||||
|
dialog.setVisible(true); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* @param target |
* @param form |
||||||
* @return |
* @return |
||||||
*/ |
*/ |
||||||
@Override |
private EventManagerPane initEventManager(Form form) { |
||||||
protected EventManagerPane initEventManager(Object target) { |
|
||||||
FormEventManagerPane eventManagerPane = new FormEventManagerPane(); |
FormEventManagerPane eventManagerPane = new FormEventManagerPane(); |
||||||
if (target instanceof Form) { |
eventManagerPane.setTarget(form); |
||||||
eventManagerPane.setTarget((Form) target); |
|
||||||
} |
|
||||||
return eventManagerPane; |
return eventManagerPane; |
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue