]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.team.ui/src/org/simantics/team/ui/RedoView.java
dcbafcb3559ff5f25c6d92968c9b7edd28554101
[simantics/platform.git] / bundles / org.simantics.team.ui / src / org / simantics / team / ui / RedoView.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.team.ui;
13
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.team.Activator;
24 import org.simantics.ui.SimanticsUI;
25
26 /**
27  * @author Kalle Kondelin
28  */
29 public class RedoView extends TreeView {
30     @Override
31     public void createPartControl(Composite parent) {
32         this.parent = 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();
36         parent.setLayout(ad);
37         treeViewer.getTree().setHeaderVisible(true);
38         //treeViewer.getTree().setLinesVisible(true);
39         //treeViewer.setUseHashlookup(true);
40         //treeViewer.setAutoExpandLevel(3);
41
42         TreeViewerColumn idColumn = new TreeViewerColumn(treeViewer, SWT.LEFT);
43         TreeViewerColumn dateColumn = new TreeViewerColumn(treeViewer, SWT.LEFT);
44         TreeViewerColumn commentColumn = new TreeViewerColumn(treeViewer, SWT.LEFT);
45
46         idColumn.setLabelProvider(new IdColumnLabelProvider());
47         dateColumn.setLabelProvider(new DateColumnLabelProvider());
48         commentColumn.setLabelProvider(new CommentColumnLabelProvider());
49
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));
59
60         final RedoContentProvider contentProvider = new RedoContentProvider(SimanticsUI.getSession());
61           treeViewer.setContentProvider(contentProvider);
62           treeViewer.setInput(this);
63           getViewSite().getActionBars().getToolBarManager().add(new Action("Remove All", Activator.REMOVE_ALL_ICON) {
64               @Override
65               public void run() {
66                   contentProvider.removeAll();
67               }
68           });
69           getViewSite().getActionBars().getToolBarManager().add(new Action("Get Redo History", Activator.REFRESH_ICON) {
70               @Override
71               public void run() {
72                   treeViewer.setContentProvider(contentProvider);
73               }
74           });
75           new ItemDetailToolTip(treeViewer, treeViewer.getTree(), null);
76     }
77
78 }