EzDevInfo.com

graphiti

An alternate JavaScript and Ruby front-end and graph storage application for the Graphite Real-time graphing engine.

Saving graphiti diagram as image from command line

I want to run the entire graphiti project from command line .The result should be an image from an existing graphiti diagram in the project which the program already does from eclipse.Is it possible i could do this from command line. I would like people who don't have access to eclipse but the code in unix box be able to acquire jpeg from command line.

Any thoughts how i could do it?


Source: (StackOverflow)

Eclipse Graphiti Grid and Flow Layouts

I have designed a graphical editor using Spray in Eclipse. Now, I want to implement a Grid and Flow Layout inside some shapes. Spray doesn't support this but I have read here that Graphiti does. I have been trying to implement this though, using the procedure described in the link but my shape is now not visible in the pictogram. I don't know what I'm doing wrong. Does somebody have an example maybe which could help me out? I'll be much obliged to you.

Cheers!


Source: (StackOverflow)

Advertisements

Error on creating a BPMN diagram with BPMN2 and Graphiti

I'm trying to use Drools Gorm plugin to build process in my Grails application. Therefore, it is needed to use bpmn diagrams in order to instanciate a process. For this, i'm started to use two eclipse plugins: the BPMN2 and Graphiti (that is required for the first one).

But, when i try to create a .bpmn file on src/diagrams, i'm getting this error on output alert screen: Error org/eclipse/graphiti/ui/editor/diagrameditorfactory

I looked everywhere and i don't find any reasonable solutions. Any help is welcome!


Source: (StackOverflow)

how to create Graphiti shapes with scroll bar

My Graphiti editor has shape that represents db table with it rows.. i am looking for a way to add scroll bar to my shape. any one know how to do that? enter image description here


Source: (StackOverflow)

org.eclipse.swt.SWTException: Graphic in Eclipse Graphiti when executing feature

I was working with graphiti application and implemented a feature that modifies an attribute of a resource. Upon changing, it notifies my implemented ResourceSetListener class and updates the respective shape in the diagram editor. It is doing fine and exactly what i want it to do, except that it display a popup error saying "Graphic is disposed".

org.eclipse.swt.SWTException: Graphic is disposed
at org.eclipse.swt.SWT.error(SWT.java:4441)
at org.eclipse.swt.SWT.error(SWT.java:4356)
at org.eclipse.swt.SWT.error(SWT.java:4327)
at org.eclipse.swt.graphics.Font.getFontData(Font.java:184)
at org.eclipse.draw2d.ScaledGraphics.getCachedFontData(ScaledGraphics.java:533)
at org.eclipse.draw2d.ScaledGraphics.zoomFont(ScaledGraphics.java:922)
at org.eclipse.draw2d.ScaledGraphics.setLocalFont(ScaledGraphics.java:848)
at org.eclipse.draw2d.ScaledGraphics.setFont(ScaledGraphics.java:767)
at org.eclipse.draw2d.Figure.paint(Figure.java:1111)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1167)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1202)
at org.eclipse.draw2d.Figure.paint(Figure.java:1117)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1167)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1202)
at org.eclipse.draw2d.Figure.paint(Figure.java:1117)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1167)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1206)
at org.eclipse.draw2d.Figure.paint(Figure.java:1117)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1167)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1202)
at org.eclipse.draw2d.Figure.paint(Figure.java:1117)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1167)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1202)
at org.eclipse.draw2d.Figure.paint(Figure.java:1117)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1167)
at org.eclipse.graphiti.ui.internal.fixed.FixedScalableFreeformLayeredPane.paintClientArea(FixedScalableFreeformLayeredPane.java:53)
at org.eclipse.draw2d.Figure.paint(Figure.java:1117)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1167)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1202)
at org.eclipse.draw2d.Figure.paint(Figure.java:1117)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1167)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1197)
at org.eclipse.draw2d.Viewport.paintClientArea(Viewport.java:160)
at org.eclipse.draw2d.Figure.paint(Figure.java:1117)
at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1167)
at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1202)
at org.eclipse.draw2d.Figure.paint(Figure.java:1117)
at org.eclipse.draw2d.DeferredUpdateManager.paint(DeferredUpdateManager.java:165)
at org.eclipse.draw2d.LightweightSystem.paint(LightweightSystem.java:203)
at org.eclipse.draw2d.LightweightSystem$2.handleEvent(LightweightSystem.java:110)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1491)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4667)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5036)
at org.eclipse.swt.internal.win32.OS.RedrawWindow(Native Method)
at org.eclipse.swt.widgets.Control.update(Control.java:4436)
at org.eclipse.swt.widgets.Control.update(Control.java:4426)
at org.eclipse.jface.fieldassist.ExampleControlDecoration.update(ExampleControlDecoration.java:1060)
at org.eclipse.jface.fieldassist.ExampleControlDecoration.setImage(ExampleControlDecoration.java:947)
at com.myproject.example.common.control.ExampleDecoratedField.showDecoration(ExampleDecoratedField.java:215)
at com.myproject.example.common.control.ExampleDecoratedField.setContentAssistMessage(ExampleDecoratedField.java:160)
at com.myproject.example.common.control.ExampleTextField.setFieldMessage(ExampleTextField.java:113)
at com.myproject.example.common.control.ExampleTextField.<init>(ExampleTextField.java:95)
at com.myproject.example.common.properties.ExampleAbstractPropertyPage.createTextField2(ExampleAbstractPropertyPage.java:725)
at com.myproject.example.common.properties.ExampleAbstractPropertyPage.createTextField(ExampleAbstractPropertyPage.java:649)
at com.myproject.example.common.properties.ExampleAbstractPropertyPage.createField(ExampleAbstractPropertyPage.java:516)
at com.myproject.example.propertypages.ExampleCommonDescriptionPP.createControl(ExampleCommonDescriptionPP.java:81)
at com.myproject.example.common.properties.ExampleAbstractPropertyPage.createControls(ExampleAbstractPropertyPage.java:273)
at org.eclipse.ui.views.properties.tabbed.TabContents$1.run(TabContents.java:109)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:178)
at org.eclipse.ui.views.properties.tabbed.TabContents.createControls(TabContents.java:112)
at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage$SelectionChangedListener.selectionChanged(TabbedPropertySheetPage.java:206)
at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java:163)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:178)
at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:160)
at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:2171)
at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:1202)
at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:1231)
at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:242)
at org.eclipse.jface.util.OpenStrategy.access$4(OpenStrategy.java:236)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:408)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:782)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.select(TabbedPropertyList.java:864)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyViewer.setSelectionToWidget(TabbedPropertyViewer.java:122)
at org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:1749)
at org.eclipse.jface.viewers.StructuredViewer.setSelection(StructuredViewer.java:1705)
at org.eclipse.jface.viewers.Viewer.setSelection(Viewer.java:388)
at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage.setInput(TabbedPropertySheetPage.java:748)
at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage.selectionChanged(TabbedPropertySheetPage.java:556)
at org.eclipse.ui.views.properties.PropertySheet.selectionChanged(PropertySheet.java:365)
at org.eclipse.ui.internal.e4.compatibility.SelectionService.notifyListeners(SelectionService.java:218)
at org.eclipse.ui.internal.e4.compatibility.SelectionService.handlePostSelectionChanged(SelectionService.java:122)
at org.eclipse.ui.internal.e4.compatibility.SelectionService.access$1(SelectionService.java:112)
at org.eclipse.ui.internal.e4.compatibility.SelectionService$3.selectionChanged(SelectionService.java:80)
at org.eclipse.e4.ui.internal.workbench.SelectionAggregator$4.run(SelectionAggregator.java:166)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.e4.ui.internal.workbench.SelectionAggregator.notifyPostListeners(SelectionAggregator.java:163)
at org.eclipse.e4.ui.internal.workbench.SelectionAggregator.access$8(SelectionAggregator.java:160)
at org.eclipse.e4.ui.internal.workbench.SelectionAggregator$8$1.run(SelectionAggregator.java:272)
at org.eclipse.e4.core.contexts.RunAndTrack.runExternalCode(RunAndTrack.java:56)
at org.eclipse.e4.ui.internal.workbench.SelectionAggregator$8.changed(SelectionAggregator.java:269)
at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:110)
at org.eclipse.e4.core.internal.contexts.EclipseContext.processScheduled(EclipseContext.java:338)
at org.eclipse.e4.core.internal.contexts.EclipseContext.set(EclipseContext.java:352)
at org.eclipse.e4.ui.internal.workbench.SelectionServiceImpl.setPostSelection(SelectionServiceImpl.java:36)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart$3.selectionChanged(CompatibilityPart.java:127)
at org.eclipse.gef.ui.parts.AbstractEditPartViewer.fireSelectionChanged(AbstractEditPartViewer.java:247)
at org.eclipse.gef.ui.parts.AbstractEditPartViewer$1.run(AbstractEditPartViewer.java:131)
at org.eclipse.gef.SelectionManager.fireSelectionChanged(SelectionManager.java:144)
at org.eclipse.gef.SelectionManager.deselect(SelectionManager.java:118)
at org.eclipse.gef.ui.parts.AbstractEditPartViewer.deselect(AbstractEditPartViewer.java:202)
at org.eclipse.gef.editparts.AbstractEditPart.removeNotify(AbstractEditPart.java:942)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.removeNotify(AbstractGraphicalEditPart.java:823)
at org.eclipse.gef.editparts.AbstractEditPart.removeChild(AbstractEditPart.java:880)
at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.deleteChildAndRefresh(ShapeEditPart.java:153)
at org.eclipse.graphiti.ui.internal.parts.PictogramElementDelegate.refreshFigureForEditPart(PictogramElementDelegate.java:357)
at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refreshVisuals(ShapeEditPart.java:699)
at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:725)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:644)
at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refresh(ShapeEditPart.java:594)
at org.eclipse.graphiti.ui.internal.parts.PictogramElementDelegate.refreshEditPartsForModelChildrenAndSourceConnections(PictogramElementDelegate.java:313)
at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refreshChildren(ShapeEditPart.java:680)
at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:726)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:644)
at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refresh(ShapeEditPart.java:594)
at org.eclipse.graphiti.ui.internal.parts.PictogramElementDelegate.refreshEditPartsForModelChildrenAndSourceConnections(PictogramElementDelegate.java:313)
at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refreshChildren(ShapeEditPart.java:680)
at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:726)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:644)
at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refresh(ShapeEditPart.java:594)
at org.eclipse.graphiti.ui.internal.parts.DiagramEditPart.refresh(DiagramEditPart.java:187)
at org.eclipse.graphiti.ui.editor.DefaultRefreshBehavior.internalRefreshEditPart(DefaultRefreshBehavior.java:262)
at org.eclipse.graphiti.ui.editor.DefaultRefreshBehavior.refresh(DefaultRefreshBehavior.java:175)
at org.eclipse.graphiti.ui.editor.DiagramBehavior.refresh(DiagramBehavior.java:771)
at org.eclipse.graphiti.ui.internal.editor.DiagramRefreshJob.runInUIThread(DiagramRefreshJob.java:103)
at org.eclipse.graphiti.ui.internal.editor.DiagramChangeListener.resourceSetChanged(DiagramChangeListener.java:151)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl$1.run(TransactionalEditingDomainImpl.java:781)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.postcommit(TransactionalEditingDomainImpl.java:771)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.deactivate(TransactionalEditingDomainImpl.java:543)
at org.eclipse.emf.transaction.impl.TransactionImpl.close(TransactionImpl.java:712)
at org.eclipse.emf.transaction.impl.TransactionImpl.commit(TransactionImpl.java:474)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:155)
at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:208)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
at org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl.execute(GFWorkspaceCommandStackImpl.java:84)
at org.eclipse.graphiti.ui.internal.editor.GFCommandStack.execute(GFCommandStack.java:138)
at org.eclipse.graphiti.ui.editor.DiagramBehavior.executeFeature(DiagramBehavior.java:1088)
at com.myproject.example.screen.diagram.ExampleModelChangeListener$1.run(ExampleModelChangeListener.java:135)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4147)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3764)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)

Source: (StackOverflow)

Rotating coordinates

I am working with shapes, that are defined in the Graphiti-Framework. It supports the following:

  • Rectangle(int x, int y, int width, int height), whereas x/y defines the lower-left point,
  • Text (which is a rectangle as well),
  • Ellipse(int x, int y, int width, int height), so the same as the rectangle,
  • Line (int[] points), so an array with points as parameter
  • Polygon(int[] points), basically the same as line but the first and last point are connected.

My purpose is to rotate this elements. Unfortunately the framework I am using does not support rotation.

What in you opinion is the best solution to realise that?


Source: (StackOverflow)

CDO Transaction Issue

I am trying to deposit an EClass object which I have retrieved from a graphiti diagram to the CDO repository but I receive a write transaction error. The error doesn't appear if I create a new empty EClass object and store it to the CDO repository. I have included my code and the error message to this post.

Thank you in advance for any help you can provide in this problem. John Anderson

Source code:

package uk.man.ac.graphiti.toolbarbuttons;

import java.util.List;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.net4j.CDONet4jSession;
import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.util.ConcurrentAccessException;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.platform.IDiagramContainer;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.net4j.Net4jUtil;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.tcp.TCPUtil;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.lifecycle.ILifecycle;
import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;

public class Deposit extends AbstractHandler {

private static CDONet4jSession cdoSession;

public static CDONet4jSession openSession(String repoName) {
CDONet4jSession session = null;
try {
final IConnector connector = (IConnector) IPluginContainer.INSTANCE
.getElement( //
"org.eclipse.net4j.connectors", // Product group
"tcp", // Type
"localhost"); // Description

CDONet4jSessionConfiguration config = CDONet4jUtil
.createNet4jSessionConfiguration();
config.setConnector(connector);
config.setRepositoryName(repoName);

session = config.openNet4jSession();


} catch (Exception e) {
return null;
}

return session;
}

@Override
public Object execute(ExecutionEvent event) {
String msg = null;
EClass eclass = null;
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
IEditorPart editor = page.getActiveEditor();
if (editor instanceof IDiagramContainer) {
IDiagramContainer graphitiEditor = (IDiagramContainer) editor;
System.out.println("total.pe.elements="+graphitiEditor.getSelectedPictogramElements().length);
PictogramElement pe = graphitiEditor.getSelectedPictogramElements()[0];
Object bo = Graphiti.getLinkService()
.getBusinessObjectForLinkedPictogramElement(pe);
System.out.println("in1");
if (bo == null) {
msg = "You must select an EClass object";
sendMessage(event, msg);
System.out.println("in2");
} else {
if (bo instanceof EClass) {
eclass = (EClass) bo;

try {
System.out.println("in3");
Net4jUtil.prepareContainer(IPluginContainer.INSTANCE);
TCPUtil.prepareContainer(IPluginContainer.INSTANCE);
cdoSession = openSession("graphiti");

if (cdoSession != null) {
CDOTransaction transaction = cdoSession
.openTransaction();
CDOResource resource = transaction
.getOrCreateResource("/depositUsingButtonResource");

List<EObject> eclasslist = resource.getContents();
Boolean exists = false;
EClass temp = null;
for (int i = 0; i < eclasslist.size(); i++) {
temp = (EClass) eclasslist.get(i);
if (temp.getName().matches(eclass.getName())) {
exists = true;
break;
}
}
if (exists == true) {
msg = "Object already exists in repository";
} else {
resource.getContents().add(eclass);
transaction.commit();
msg = "Successful Deposit";
}

sendMessage(event, msg);
} else {
msg = "Deposit failed";
sendMessage(event, msg);
}
cdoSession.close();
} catch (ConcurrentAccessException e) {
msg = "Deposit failed";
sendMessage(event, msg);
} catch (CommitException e) {
msg = "Deposit failed";
sendMessage(event, msg);
}

}
}
}
return null;
}

private void sendMessage(ExecutionEvent event, String msg) {
MessageDialog.openInformation(
HandlerUtil.getActiveWorkbenchWindow(event).getShell(),
"Result", msg);
}
}

Error Message:

!ENTRY org.eclipse.ui 4 0 2014-03-19 12:00:04.847
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:243)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:224)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:167)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:850)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:743)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:727)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:662)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.assertWriting(TransactionChangeRecorder.java:348)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.appendNotification(TransactionChangeRecorder.java:302)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.processResourceNotification(TransactionChangeRecorder.java:272)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.notifyChanged(TransactionChangeRecorder.java:238)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1027)
at org.eclipse.emf.common.notify.impl.DelegatingNotifyingListImpl.addUnique(DelegatingNotifyingListImpl.java:305)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:303)
at uk.man.ac.graphiti.toolbarbuttons.Deposit.execute(Deposit.java:113)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
... 37 more

Source: (StackOverflow)

Eclipse graphiti tutorials [closed]

From where can I get the Eclipse Graphiti tutorials?

For more information on this software you can get here.

Also please let me know the knowledge of Eclipse plugin development and EMF is mandatory in better understanding of Graphiti?

Eclipse Graphiti Link


Source: (StackOverflow)

Eclipse Graphiti on RCP Application

I have an existing Eclipse RCP application with several views. The idea is to create an application where I can drag and drop objects from one view to another (for instance like Microsoft Visio).

My questions

  1. How do I instantiate an empty (grid) canvas with Graphiti on one of my views (if I could) ?

  2. Can / Should I still utilize the drag and drop functionality of RCP with Graphiti altogether ?

Any pointers are greatly appreciated.


Source: (StackOverflow)

Is it possible to read and parse graphiti diagram file in standalone app?

I am doing some research before putting my hand on a project.i need to implement an app that needs to read a diagram file generated by graphiti and parse the file as a standalone app without running in eclipse as plugin.

As I understand , graphiti is a plugin in eclipse,so lots of things are inited by eclipse , so is it possible? Could u plz point me to the right place?

Thanks


Source: (StackOverflow)

Eclipse Graphiti, How to create "CustomFeature's create & get all Elements"?

I have 2 questions, maybe somebody can give me an idea how i can do this

I've created new "testFeature" extended from AbstractCustomFeature and can call it in my Diagram. How can i get a List which contains all Elements from the Diagram?(i want to update their names and colors at start and later)

My second question is: I'm trying to add some Elements to the Diagram without drag and drop them from the palette.

For example i have some Elements saved in the Diagram and my "model say i miss 3 Elements in the Diagram". I want to write an Custom Feature, which draw/put missing Elements in the Graphiti Diagram with just one/two clicks, maybe i need to use Zest at this part? but at the beginning i just want to put few elements without drop them from the Palette, how can i do this?

Maybe somebody can give me direction?

Thanks for your help!


Source: (StackOverflow)

how to create an image of a GEF diagram on a server

I would like to create an image of an Eclipse GEF diagram on the server side without having to load the entire editor environment.

The diagram is designed using eclipse bpmn2-modeler which is based on eclipse graphiti which is based on GEF.

The idea would be:

  1. load BPMN model
  2. generate diagram information
  3. export diagram as image

This snippet should do step 1, load the BPMN model:

    URI modelUri = URI.createFileURI("D:/temp/data.bpmn");
    ResourceSet resourceSet = new Bpmn2ModelerResourceSetImpl();
    resourceSet.setURIConverter(new ProxyURIConverterImplExtension(modelUri));
    Bpmn2ResourceImpl resource = (Bpmn2ResourceImpl) resourceSet.createResource(modelUri, Bpmn2ModelerResourceImpl.BPMN2_CONTENT_TYPE_ID);
    ModelHandler modelHandler = ModelHandlerLocator.createModelHandler(modelUri, resource);
  1. to generate the diagram information I found org.eclipse.bpmn2.modeler.core.di.DIImport.
    The problem here is that the constructor requires a org.eclipse.graphiti.ui.editor.DiagramEditor and on the server I don't have one, no running UI environment.
    Is there some other util or handler that can generate the diagram for me?

  2. I took a look at the org.eclipse.graphiti.ui.features.DefaultSaveImageFeature and org.eclipse.graphiti.ui.internal.util.ui.print.AbstractFigureSelectionDialog (initScaledImage()).
    But I need to first get passed the step 2 issue, before digging deeper into this.

Maybe I'm on the wrong way and there is a much easier approach?


Source: (StackOverflow)

automatic update of graphiti diagrams in case of changes in the datamodel

I have an EMF Datamodel and represent it with the framework "Graphiti". In case of changes in the datamodel the method "updateNeeded()" in my UpdateFeature is randomly called or not. Therefor I have a listener. This listener calls the method "update()" in case of changes. In the method update I can define the differences between datamodel and diagram. But if I want to add or change anything to the diagram an exception is thrown.

Has anyone an idea how I could autoupdate the diagram?

Here is my examplecode in the listener:

UpdateContext updateContext = new UpdateContext(getDiagram().getChildren().get(0).getGraphicsAlgorithm().getPictogramElement());
IUpdateFeature updateFeature = getFeatureProvider().getUpdateFeature(updateContext);
updateFeature.update(updateContext);

and the exception:

!ENTRY org.eclipse.ui 4 0 2013-07-11 13:36:43.886 !MESSAGE Unhandled event loop exception !STACK 0

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.IllegalStateException: Cannot modify resource set without a write transaction)

Caused by: java.lang.IllegalStateException: Cannot modify resource set without a write transaction at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.assertWriting

Regards, Juliane


Source: (StackOverflow)

How do I disable/remove the Palette of an Eclipse Graphiti editor?

Trying to remove the palette of a Eclipse Graphiti editor.

org.eclipse.graphiti.ui.editor.DiagramBehavior has a createPaletteBehaviour() to override but if I return null, the editor crashes.

I also tried this in the diagram behavior, but I actually don't want it collapsed but removed:

@Override
protected DefaultPaletteBehavior createPaletteBehaviour() {
    return new DefaultPaletteBehavior(this) {
        @Override
        public FlyoutPreferences getPalettePreferences() {
            FlyoutPreferences palettePreferences = super.getPalettePreferences();
            palettePreferences.setPaletteState(FlyoutPaletteComposite.STATE_COLLAPSED);
            return palettePreferences;
        }
    };
}

I would also prefer to use some API instead of manipulating the preferences.


Source: (StackOverflow)

How to reset dirty state in a graphiti diagram?

After opening an Eclipse Graphiti editor I want to do some initialization changes on the diagram. Doing that, using transactions, the editor turns dirty.
I didn't find a way to reset the dirty state, I don't want to save the diagram at this point.

BasicCommandStack commandStack = (BasicCommandStack) getEditingDomain().getCommandStack();
commandStack.execute(new RecordingCommand(getEditingDomain()) {
    @Override
    protected void doExecute() {
        // do some change
    }
});

If I use flush() on the command stack, my init changes are undone as well:

BasicCommandStack commandStack = (BasicCommandStack) getEditingDomain().getCommandStack();
commandStack.flush();

Is there a way to reset the dirty state?
Maybe there is a way to disable transaction handling or command stack recording?


Source: (StackOverflow)