1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 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;
14 import org.eclipse.jface.action.Action;
15 import org.eclipse.jface.layout.TreeColumnLayout;
16 import org.eclipse.jface.resource.JFaceResources;
17 import org.eclipse.jface.resource.LocalResourceManager;
18 import org.eclipse.jface.viewers.ColumnWeightData;
19 import org.eclipse.jface.viewers.TreeViewer;
20 import org.eclipse.jface.viewers.TreeViewerColumn;
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.widgets.Composite;
23 import org.simantics.Simantics;
24 import org.simantics.team.Activator;
27 * @author Kalle Kondelin
29 public class RedoView extends TreeView {
31 public void createPartControl(Composite parent) {
33 this.treeViewer = new TreeViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION);
34 this.resourceManager = new LocalResourceManager(JFaceResources.getResources(parent.getDisplay()), treeViewer.getTree());
35 TreeColumnLayout ad = new TreeColumnLayout();
37 treeViewer.getTree().setHeaderVisible(true);
38 //treeViewer.getTree().setLinesVisible(true);
39 //treeViewer.setUseHashlookup(true);
40 //treeViewer.setAutoExpandLevel(3);
42 TreeViewerColumn idColumn = new TreeViewerColumn(treeViewer, SWT.LEFT);
43 TreeViewerColumn dateColumn = new TreeViewerColumn(treeViewer, SWT.LEFT);
44 TreeViewerColumn commentColumn = new TreeViewerColumn(treeViewer, SWT.LEFT);
46 idColumn.setLabelProvider(new IdColumnLabelProvider());
47 dateColumn.setLabelProvider(new DateColumnLabelProvider());
48 commentColumn.setLabelProvider(new CommentColumnLabelProvider());
50 idColumn.getColumn().setText("Id");
51 idColumn.getColumn().setWidth(20);
52 ad.setColumnData(idColumn.getColumn(), new ColumnWeightData(50, 20));
53 dateColumn.getColumn().setText("Date");
54 dateColumn.getColumn().setWidth(20);
55 ad.setColumnData(dateColumn.getColumn(), new ColumnWeightData(50, 40));
56 commentColumn.getColumn().setText("Comment");
57 commentColumn.getColumn().setWidth(20);
58 ad.setColumnData(commentColumn.getColumn(), new ColumnWeightData(50, 50));
60 final RedoContentProvider contentProvider = new RedoContentProvider(Simantics.getSession());
61 treeViewer.setContentProvider(contentProvider);
62 treeViewer.setInput(this);
63 getViewSite().getActionBars().getToolBarManager().add(new Action("Remove All", Activator.REMOVE_ALL_ICON) {
66 contentProvider.removeAll();
69 getViewSite().getActionBars().getToolBarManager().add(new Action("Get Redo History", Activator.REFRESH_ICON) {
72 treeViewer.setContentProvider(contentProvider);
75 new ItemDetailToolTip(treeViewer, treeViewer.getTree(), null);