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 * Semantum Oy - index based searching and graph manipulation (#4255)
12 *******************************************************************************/
13 package org.simantics.modeling.ui.view;
15 import org.eclipse.jface.action.Action;
16 import org.eclipse.jface.action.IAction;
17 import org.eclipse.jface.action.IToolBarManager;
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.ui.IActionBars;
21 import org.eclipse.ui.part.ViewPart;
22 import org.simantics.Simantics;
23 import org.simantics.db.Resource;
24 import org.simantics.db.Session;
25 import org.simantics.db.exception.DatabaseException;
26 import org.simantics.ui.SimanticsUI;
27 import org.simantics.ui.workbench.ResourceInput;
28 import org.simantics.utils.ui.BundleUtils;
29 import org.simantics.utils.ui.ErrorLogger;
30 import org.simantics.utils.ui.LayoutUtils;
32 public class ChangeInformationView extends ViewPart {
34 public static final String VIEW_ID = "org.simantics.modeling.changeInformation";
36 private ResourceInput input;
38 private Session session;
40 private ChangeInformationComposite composite;
42 private IAction refreshAction;
45 public void createPartControl(Composite parent) {
47 session = Simantics.getSession();
50 String sid = getViewSite().getSecondaryId();
53 input = ResourceInput.unmarshall(sid);
55 r = input.toResource(session);
56 } catch (DatabaseException e) {
57 ErrorLogger.defaultLogError(e);
62 parent.setLayout(LayoutUtils.createNoBorderGridLayout(1));
63 composite = new ChangeInformationComposite(parent, SWT.NONE, session, r, getSite());
64 composite.defaultInitializeUI();
68 contributeActions(getViewSite().getActionBars());
72 private void makeActions() {
73 refreshAction = new RefreshAction();
76 private void contributeActions(IActionBars actionBars) {
77 IToolBarManager toolBar = actionBars.getToolBarManager();
78 toolBar.add(refreshAction);
82 public void setFocus() {
83 if (composite != null)
87 class RefreshAction extends Action {
88 public RefreshAction() {
90 BundleUtils.getImageDescriptorFromPlugin(SimanticsUI.PLUGIN_ID,
91 "icons/refresh.gif"));
92 setToolTipText("Refresh");