周洪
新手
新手
  • UID203
  • 粉丝1
  • 关注0
  • 发帖数5
阅读:40073回复:0

ued

楼主#
更多 发布于:2016-08-25 17:08
[img]file:///C:\Users\zhou\AppData\Roaming\Tencent\Users\846297343\QQ\WinTemp\RichOle\(MVSVJPH3~~7GLLC[JA3PV2.png[/img]Ued 双击弹出框实现
1.part中重新performRequest方法,单双击都会进入这个方法

public class TestServiceEditPart extends PanelEditPart{

//单双击事件
public void performRequest(Request req) {

if (req.getType().equals(RequestConstants.REQ_OPEN)) {
SSuedEditor editor = (SSuedEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.getActiveEditor();
IEditorInput input = editor.getEditorInput();
if (input instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) input).getFile();
IFolder folder = SSuedUtils.getCurrentFolder(file);
TestService testService = (TestService) getModel();
if (testService instanceof TestService)
DialogUtils.TestServiceDialog( testService, getViewer().getControl().getShell(), folder);
}
}
super.performRequest(req);
}
。。。。。。。。。。。。。。。。。。。。。。。。
}
2.在相应包下添加如下方法testService.xmls是配置显示窗口的文件
//testService
//设置testService参数
public static void setTestServiceParams(TestService form, Map<String, Object> params) {
setPanelParams(form, params);
params.put("autoScroll", form.isAutoScroll() ? "true" : "false");
params.put("rootText", form.getRootText());
//params.put("labelAlignIsLeft", form.() ? "true" : "false");
}
public static void TestServiceDialog(TestService testService, Shell shell, IFolder folder) {
Map<String, Object> params = new HashMap<String, Object>();
setTestServiceParams(testService, params);
params.put("folder", folder);

Map<String, Object> oldParams = copyParams(params);
showDialog(testService, "testService.xml", params, shell, "测试 属性设置");
if ("true".equals(((String) params.get("flag"))) && !oldParams.equals(params)) {
TestServiceCommand command = new TestServiceCommand(testService, params);
doExecute(command);
}
}
command代码
public class TestServiceCommand extends PanelCommand{
public boolean oldAutoScroll;
public String oldRootText;
public TestServiceCommand(TestService model, Map<String, Object> params) {
super(model, params);
// TODO 自动生成的构造函数存根
oldRootText=model.getRootText();
}
@Override
public void execute() {
// TODO Auto-generated method stub
super.execute();
}

@Override
public void redo() {
// TODO Auto-generated method stub
super.redo();

((TestService) this.model).setRootText(params.get("rootText").toString());
}

@Override
public void undo() {
// TODO Auto-generated method stub
super.undo();
((TestService) this.model).setRootText(oldRootText);
}
}
3 testService.xmls配置 部分代码 label是显示名称。key是实际值
onClick 是点击确定后执行方法

<?xml version="1.0" encoding="UTF-8"?>
<tabFolder title="测试 属性设置" message="配置'测试'信息" width="600" height="500" titleImg="icons/common/title.png"  onClick="com.sunsheen.jfids.studio.ued.dialog.OKListener.panel.TestServiceOKListener">
<button id="0" name="确定"></button>
<button id="1" name="取消"></button>
<tab name="基本设置" icon="icons/common/set.png">
<label text="文字设置">
<gridData method="setLayoutData" methodArg="java.lang.Object" horizontalAlignment="FILL"/>
</label>
<text key="rootText" >
<gridData method="setLayoutData" methodArg="java.lang.Object" horizontalAlignment="FILL" verticalAlignment="FILL"
grabExcessHorizontalSpace="true"/>
</text>

4.点击后的执行方法设置新值最终在第二步command 命令中执行更新视图
public class TestServiceOKListener extends PanelOKListener{
@Override
public void run(Map<String, Widget> coms, Map<String, Object> params, Event event, String currentKey) {
super.run(coms, params, event, currentKey);
//Text labelWidth = (Text) coms.get("labelWidth");
// Text inputWidth=(Text)coms.get("inputWidth");
Text rootText=(Text) coms.get("rootText");
Combo autoScroll = (Combo) coms.get("autoScroll");
params.put("rootText", rootText.getText().trim());
// params.put("inputWidth", inputWidth.getText().trim());

}
}



最新喜欢:

周进周进
游客

返回顶部