- 浏览: 195862 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
carlosfu:
需要这么多资料。。
广州买房二三事 -
cutesunshineriver:
砺雪凝霜 写道看好喜欢思考的人,加油!前辈~谢谢鼓励!
2015年终盘点 -
砺雪凝霜:
看好喜欢思考的人,加油!前辈~
2015年终盘点 -
MM22:
能问下,为什么,在eclipse ACVTIVE之后,在浏览器 ...
osgi入门 -
icarus11:
我现在用的BPMsuite是11.1.1.7 但开发工具用的是 ...
Oracle BPM Suite和JDeveloper打补丁
1、在之前library的model、edit、editor基础上,增加一个Validator插件。
2、增加如下扩展点。
3、增加以下类。
ValidationDelegateClientSelector
LiveValidationContentAdapter
UniqueBookNameConstriant
4、在editor插件的LibraryEditor类中注册LiveValidationContentAdapter。
修改createModel方法
5、跑起应用,对Library模型进行修改时,如果book重名,则会在Problems视图提示错误。
2、增加如下扩展点。
<?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin> <extension point="org.eclipse.emf.validation.constraintProviders"> <category id="library.constriants" mandatory="false" name="Library Constriants"> </category> <constraintProvider cache="true"> <package namespaceUri="http://www.eclipse.library"> </package> <constraints categories="library.constriants"> <constraint class="constriants.UniqueBookNameConstriant" id="UniqueBookNameConstriant" lang="java" mode="Live" name="UniqueBookNameConstriant" severity="ERROR" statusCode="1"> <message> Book must have the unique name. </message> <target class="Book"> <event name="Set"> <feature name="name"> </feature> </event> <event name="Unset"> <feature name="name"> </feature> </event> </target> </constraint> </constraints> </constraintProvider> </extension> <extension point="org.eclipse.emf.validation.constraintBindings"> <clientContext id="library.validator.clientContext"> <selector class="library.validator.ValidationDelegateClientSelector"> </selector> </clientContext> <binding category="library.constriants" constraint="UniqueBookNameConstriant" context="library.validator.clientContext"> </binding> </extension> <extension id="libraryMarker" point="org.eclipse.core.resources.markers"> <super type="org.eclipse.core.resources.problemmarker"> </super> <persistent value="true"> </persistent> <attribute name="targetClassName"> </attribute> <attribute name="targetContainer"> </attribute> </extension> </plugin>
3、增加以下类。
ValidationDelegateClientSelector
package library.validator; import org.eclipse.emf.validation.model.IClientSelector; public class ValidationDelegateClientSelector implements IClientSelector { public static boolean running = false; @Override public boolean selects(Object object) { return running; } }
LiveValidationContentAdapter
package library.validator; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.util.BasicDiagnostic; import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.common.util.DiagnosticChain; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EValidator; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.util.EContentAdapter; import org.eclipse.emf.ecore.util.EObjectValidator; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.edit.ui.action.ValidateAction; import org.eclipse.emf.validation.model.EvaluationMode; import org.eclipse.emf.validation.model.IConstraintStatus; import org.eclipse.emf.validation.service.ILiveValidator; import org.eclipse.emf.validation.service.ModelValidationService; public class LiveValidationContentAdapter extends EContentAdapter { private ILiveValidator validator = null; public LiveValidationContentAdapter() { } public void notifyChanged(final Notification notification) { super.notifyChanged(notification); if (validator == null) { validator = (ILiveValidator) ModelValidationService.getInstance() .newValidator(EvaluationMode.LIVE); validator.setReportSuccesses(true); } ValidationDelegateClientSelector.running = true; IStatus status = validator.validate(notification); final IConstraintStatus constraintStatus = status instanceof IConstraintStatus ? (IConstraintStatus) status : null; if (constraintStatus != null) { processStatus(constraintStatus); } ValidationDelegateClientSelector.running = false; } private void processStatus(final IConstraintStatus constraintStatus) { final BasicDiagnostic diagnostic = new BasicDiagnostic( EObjectValidator.DIAGNOSTIC_SOURCE, 0, "", constraintStatus .getTarget().eResource().getContents().toArray()); if (!constraintStatus.isOK()) { appendDiagnostics(constraintStatus, diagnostic); } WorkspaceJob workspaceJob = new WorkspaceJob("markerUitl") { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { ValidateAction.EclipseResourcesUtil eclipseResourcesUtil = new ValidateAction.EclipseResourcesUtil(); deleteResourceMarker(constraintStatus); for (Diagnostic childDiagnostic : diagnostic.getChildren()) { eclipseResourcesUtil.createMarkers(constraintStatus .getTarget().eResource(), childDiagnostic); } return Status.OK_STATUS; } }; workspaceJob.schedule(); } private void appendDiagnostics(IStatus status, DiagnosticChain diagnostics) { if (status.isMultiStatus()) { IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) { appendDiagnostics(children[i], diagnostics); } } else if (status instanceof IConstraintStatus) { diagnostics.add(new BasicDiagnostic(status.getSeverity(), status .getPlugin(), status.getCode(), status.getMessage(), ((IConstraintStatus) status).getResultLocus().toArray())); } } private void deleteResourceMarker(IConstraintStatus status) { Resource resource = status.getTarget().eResource(); if (resource == null) { return; } URI uri = resource.getURI(); StringBuffer platformResourcePath = new StringBuffer(); for (int j = 1, size = uri.segmentCount(); j < size; ++j) { platformResourcePath.append('/'); platformResourcePath.append(URI.decode(uri.segment(j))); } IFile file = ResourcesPlugin.getWorkspace().getRoot() .getFile(new Path(platformResourcePath.toString())); try { IMarker[] markers = file.findMarkers(EValidator.MARKER, false, IResource.DEPTH_INFINITE); for (IMarker m : markers) { if (m.exists() && m.getAttribute(EValidator.URI_ATTRIBUTE, "") .equals(EcoreUtil.getURI(status.getTarget()) .toString())) { m.delete(); } } } catch (CoreException e1) { e1.printStackTrace(); } } }
UniqueBookNameConstriant
package constriants; import org.eclipse.core.runtime.IStatus; import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.validation.AbstractModelConstraint; import org.eclipse.emf.validation.IValidationContext; import org.eclipse.library.Book; public class UniqueBookNameConstriant extends AbstractModelConstraint { @Override public IStatus validate(IValidationContext ctx) { System.out.println(ctx.getEventType()); EObject target = ctx.getTarget(); String targetName = ((Book) target).getName(); if (targetName == null || targetName.isEmpty()) { return ctx.createSuccessStatus(); } TreeIterator<EObject> ite = target.eResource().getAllContents(); while (ite.hasNext()) { EObject obj = ite.next(); if (obj instanceof Book) { Book book = (Book) obj; if (book == null || book == target) { continue; } if (targetName.equals(book.getName())) { return ctx.createFailureStatus(); } } } return ctx.createSuccessStatus(); } }
4、在editor插件的LibraryEditor类中注册LiveValidationContentAdapter。
修改createModel方法
/** * This is the method called to load a resource into the editing domain's resource set based on the editor's input. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void createModel() { URI resourceURI = EditUIUtil.getURI(getEditorInput()); Exception exception = null; Resource resource = null; try { // Load the resource through the editing domain. // resource = editingDomain.getResourceSet().getResource(resourceURI, true); } catch (Exception e) { exception = e; resource = editingDomain.getResourceSet().getResource(resourceURI, false); } Diagnostic diagnostic = analyzeResourceProblems(resource, exception); if (diagnostic.getSeverity() != Diagnostic.OK) { resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); } editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter); // XXX if (!resourceHasLiveAdapter(resource)) { EContentAdapter liveValidationContentAdapter = new LiveValidationContentAdapter(); resource.eAdapters().add(liveValidationContentAdapter); } } private boolean resourceHasLiveAdapter(Resource r) { for (Adapter next : r.eAdapters()) { if (next instanceof LiveValidationContentAdapter) { return true; } } return false; }
5、跑起应用,对Library模型进行修改时,如果book重名,则会在Problems视图提示错误。
发表评论
-
利用JavaDoc制作windows的CHM文档
2012-03-12 17:10 1102使用了开源的一个ruby脚本来利用JavaDoc制作windo ... -
在eclipse中制作API参考文档
2012-02-15 13:26 2438具体可参考IBM的文章:http://www.ibm.com/ ... -
使用 Eclipse 插件开发环境构建模板
2012-02-09 09:42 1408关于怎么用Eclipse 插件开发环境构建模板,可以参考IBM ... -
构造GMF Diagram右键菜单
2011-11-02 15:22 1484在BPM Diagram中实现Boundary Event的中 ... -
STP和BOS的特性总结
2011-10-28 13:48 965一、 STP 1) 图形阴影 2) 图形上定制的Handle以 ... -
GMF生成图形编辑器的一些注意事项
2011-09-27 10:47 945一、Gmfgraph文件的配置事项 # Diagram La ... -
EMF学习--CompoundCommand
2011-09-26 09:24 11651、新建插件工程graph,建立ecore文件。 2、由e ... -
EMF学习--属性可以选择的对象集的过滤
2011-09-25 16:17 10111、先在新建的library插件工程中建立ecore模型。 ... -
GMF学习笔记
2011-09-23 18:06 14021.带阴影 重写Figure的paintFigure方法,先画 ... -
用Draw2d画一个静止的时钟
2011-08-10 12:59 2434package org.autumn.draw2d.examp ... -
Eclipse RCP入门(创建一个日期选择器)
2011-06-30 10:42 3486直接上代码。 package org.autumn.rcp. ...
相关推荐
emf-sdo-xsd-SDK-2.3.2.zip
GUI设计,emf,gef,visual editor
struts emf-sdo-xsd-SDK-2.0.1.zip
图形界面插件 emf-sdo-runtime-2.2.0.zip
emf-sdo-SDK-2.2.0(2) eclipse 可视化 界面设计。 因为size太大,所以分成了2部分,另一部分在 emf-sdo-SDK-2.2.0(1)里面。 emf-sdo-SDK-2.2.0(1)的下载地址: http://download.csdn.net/source/1002774
emf-sdo-xsd-SDK-2.4.0.zip emf是Eclipse modeling framework组建框架的缩写;SDO是服务数据对象的缩写,它是Java程序的一种数据编程框架;emf-sdo-xsd-SDK-2.4.0.zip是Eclipse编程器的组成员之一。
Eclipse 3.6.1(Helios)的插件。emf-runtime-2.6.1.7z。
myeclipse ,swing ,chajian,解压,添加
emf-runtime-2.6.1开源IDE Eclipse VE的相关组件
eclipse可视化插件安装必备插件之一:emf-sdo-runtime-2.2.0。eclipse全部可视化插件正确配置是eclipse-SDK-3.2-win32,emf-sdo-runtime-2.2.0,GEF-runtime-3.2,VE-runtime-1.2,VE-SDK-1.2
LAS2emf convert LAS--standard industrial Logging curve data into EMF format Graphics.
EMF,安装eclipse插件所需要jar包 含xsd等完整包
emf-sdo-SDK-2.2.0(1) eclipse 可视化插件。 因为size太大,所以分成了2部分。还有一部分在 emf-sdo-SDK-2.2.0(2)。 emf-sdo-SDK-2.2.0(2)的下载地址: http://download.csdn.net/source/1002804
Eclipse 插件Eclipse 插件Eclipse 插件Eclipse 插件Eclipse 插件Eclipse 插件
这是一款实现java可视化的软件,有了它才能安装你想要的Visual Editor
EMF你可以下载emf-runtime-2.7.1.zip这个 GEF你可以下载GEF-runtime-3.7.1.zip这个
emf-sdo-xsd-Examples
emf-sdo-runtime-2.1.zip