1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.team.ui.handlers;
14 import org.eclipse.core.commands.ExecutionEvent;
15 import org.eclipse.core.commands.ExecutionException;
16 import org.simantics.Simantics;
17 import org.simantics.db.Resource;
18 import org.simantics.db.Session;
19 import org.simantics.db.WriteGraph;
20 import org.simantics.db.common.CommentMetadata;
21 import org.simantics.db.common.request.WriteRequest;
22 import org.simantics.db.exception.DatabaseException;
23 import org.simantics.db.service.XSupport;
24 import org.simantics.team.Activator;
25 import org.simantics.ui.workbench.handler.AbstractPreferenceHandler;
27 public class DebugHandler extends AbstractPreferenceHandler {
28 public DebugHandler() {
29 super(Activator.getDefault());
32 public Object execute(ExecutionEvent event) throws ExecutionException {
33 // ISelection sel = HandlerUtil.getCurrentSelection(event);
34 // IStructuredSelection ss = StructuredSelection.EMPTY;
35 // if (sel instanceof IStructuredSelection)
36 // ss = (IStructuredSelection) sel;
38 Session s = Simantics.getSession();
39 s.sync(new WriteRequest() {
41 public void perform(WriteGraph graph) throws DatabaseException {
42 XSupport xs = graph.getService(XSupport.class);
43 //Layer0 l0 = Layer0.getInstance(graph);
44 Resource r = graph.newResource();
45 String msg = "Corrupt cluster r=" + r;
46 System.out.println(msg);
47 CommentMetadata cm = graph.getMetadata(CommentMetadata.class);
50 Resource rr = graph.newResource();
51 msg = "Corrupt cluster rr=" + rr;
52 System.out.println(msg);
54 xs.corruptCluster(rr);
55 graph.addMetadata(cm); // Add comment to change set.
56 //graph.claim(l0.InstanceOf, l0.Inherits, l0.Entity);
59 } catch (DatabaseException e) {