구성 GMF Diagram 마우스 오른쪽 버튼 클릭 메뉴
1. org.autumn.bpm.diagram 플러그인에 확장점 추가
<extension
point="org.eclipse.gmf.runtime.common.ui.services.action.contributionItemProviders">
<contributionItemProvider
checkPluginLoaded="true"
class="org.autumn.bpm.diagram.providers.DiagramActionProvider">
<Priority
name="Low">
</Priority>
<popupContribution
class="org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider">
<popupAction
id="SetInterruptingAction"
path="/additionsGroup">
</popupAction>
<popupStructuredContributionCriteria
objectClass="org.autumn.bpm.model.diagram.edit.parts.BoundaryEventEditPart"
objectCount="1">
</popupStructuredContributionCriteria>
</popupContribution>
<popupContribution
class="org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider">
<popupAction
id="SetInterruptingAction"
path="/additionsGroup">
</popupAction>
<popupStructuredContributionCriteria
objectClass="org.autumn.bpm.model.diagram.edit.parts.BoundaryEvent2EditPart"
objectCount="1">
</popupStructuredContributionCriteria>
</popupContribution>
</contributionItemProvider>
</extension>
Diagram ActionProvider에서 SetInterruptingAction을 생성합니다.
package org.autumn.bpm.diagram.providers;
import org.autumn.bpm.diagram.action.SetInterruptingAction;
import org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider;
import org.eclipse.gmf.runtime.common.ui.util.IWorkbenchPartDescriptor;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.IWorkbenchPage;
/**
* Provide Action for Diagram context menu.
*
* @author sunny
*
*/
public class DiagramActionProvider extends AbstractContributionItemProvider {
@Override
protected IAction createAction(String actionId, IWorkbenchPartDescriptor partDescriptor) {
IWorkbenchPage workbenchPage = partDescriptor.getPartPage();
if (SetInterruptingAction.ID.equals(actionId)) {
return new SetInterruptingAction(workbenchPage);
}
return super.createAction(actionId, partDescriptor);
}
}
확장자에SetInterruptingAction에서 다이어그램으로 가는 오른쪽 단추 메뉴를 등록하고 Boundary Event Edit Part, Boundary Event 2 Edit Part와 연결합니다.
SetInterruptingAction은 init 방법에서 등록된 ID를 설정하고 오른쪽 단추 메뉴에 대응하는 아이콘을 설정할 수 있습니다.SetInterruptingAction은refresh 방법에서 오른쪽 키 메뉴에 Action 표시의 Label과Action을 사용할 수 있는지 설정합니다.SetInterruptingAction은 Dorun 방법에서 Action과 관련된 명령을 실행합니다. 예를 들어 Boundary Event의 cancelActivity 속성을 설정합니다.
package org.autumn.bpm.diagram.action;
import org.autumn.bpm.model.BoundaryEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
/**
* Sets the cancelActivity property of Boundary Event. Repaints the Boundary
* Event figure.
*
* @author sunny
*
*/
public class SetInterruptingAction extends AbstractActionHandler {
public static final String ID = "SetInterruptingAction"; //$NON-NLS-1$
public SetInterruptingAction(IWorkbenchPart workbenchPart) {
super(workbenchPart);
}
public SetInterruptingAction(IWorkbenchPage workbenchPage) {
super(workbenchPage);
}
@Override
public void init() {
super.init();
setId(ID);
setDescription("Sets the cancelActivity property of the selected element");
setToolTipText(getDescription());
}
@Override
public void refresh() {
IStructuredSelection selection = getStructuredSelection();
if (selection == null || (selection.isEmpty())) {
setEnabled(false);
return;
}
if (selection.getFirstElement() instanceof IGraphicalEditPart) {
EObject object = ((IGraphicalEditPart) selection.getFirstElement()).getNotationView().getElement();
if (object instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) object;
String name = boundaryEvent.getName() == null ? "BoundaryEvent" : boundaryEvent.getName();
if (boundaryEvent.isCancelActivity()) {
setText("Set " + name + " as Non-Interrupting");
} else {
setText("Set " + name + " as Interrupting");
}
setEnabled(true);
return;
}
}
setText("Sets the interrupting property");
setEnabled(false);
}
@Override
protected void doRun(IProgressMonitor progressMonitor) {
IStructuredSelection selection = getStructuredSelection();
if (selection == null || (selection.isEmpty())) {
return;
}
if (selection.getFirstElement() instanceof IGraphicalEditPart) {
IGraphicalEditPart part = (IGraphicalEditPart) selection.getFirstElement();
final EObject object = ((IGraphicalEditPart) selection.getFirstElement()).getNotationView().getElement();
if (object instanceof BoundaryEvent) {
part.getDiagramEditDomain().getDiagramCommandStack().execute(new ICommandProxy(new MyCommand(object) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
if (object instanceof BoundaryEvent) {
((BoundaryEvent) object).setCancelActivity(!(((BoundaryEvent) object).isCancelActivity()));
}
return CommandResult.newOKCommandResult();
}
}), progressMonitor);
}
}
}
private abstract class MyCommand extends AbstractTransactionalCommand {
public MyCommand(EObject elt) {
super((TransactionalEditingDomain) AdapterFactoryEditingDomain.getEditingDomainFor(elt),
"SetInterruptingAction", getWorkspaceFiles(elt));
}
}
}
2. Boundary EventEdit Part의 감청 이벤트 처리
/**
* @author sunny
*/
@Override
protected void handleNotificationEvent(Notification notification) {
if (notification.getEventType() == Notification.SET || notification.getEventType() == Notification.UNSET) {
if (ModelPackage.eINSTANCE.getBoundaryEvent_CancelActivity().equals(notification.getFeature())) {
getPrimaryShape().setInterrupting(notification.getNewBooleanValue());
}
}
super.handleNotificationEvent(notification);
}
cancelActivity의 속성에서 set 또는 unset 이벤트가 발생한 후 Boundary Event 그래픽을 다시 그립니다
/**
* @author sunny
*/
public void setInterrupting(boolean isInterrupting) {
this.isInterrupting = isInterrupting;
revalidate();
repaint();
}
@Override
protected void paintOuter(Graphics graphics) {
ActivityPainter.paintEventIntermediate(graphics, this.getBoundsForHandle(), isInterrupting);
}
Boundary Event를 만들 때 Boundary Event 모형의 cancelActivity를 Boundary Event 도형의 isInterrupting 속성에 값을 부여합니다
/**
* @generated NOT
* @author sunny
*/
private void createContents() {
createContentsGen();
if (resolveSemanticElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) resolveSemanticElement();
isInterrupting = boundaryEvent.isCancelActivity();
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
m1 이클립스에 oracle cloud (오라클 클라우드)연결하기m1에는 oracle이 설치되지 않는다.... 큰맘먹고 지른 m1인데 oracle이 설치되지 않는다니... 하지만 이뻐서 용서가 된다. 이거 때문에 웹 개발 국비수업을 듣는 도중에 몇번 좌절하고 스트레스를 크게 받았...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.