]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.document.ui/src/org/simantics/document/ui/DocumentView.java
0d7973f6af728ddf0fa02096e6d08a91ecd8fd03
[simantics/platform.git] / bundles / org.simantics.document.ui / src / org / simantics / document / ui / DocumentView.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2012 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.document.ui;
13
14 import org.eclipse.jface.action.Action;
15 import org.eclipse.jface.action.IAction;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.ui.IWorkbenchPart;
18 import org.simantics.ui.workbench.IPropertyPage;
19 import org.simantics.utils.ui.BundleUtils;
20 import org.simantics.views.swt.ModelledView;
21
22 /**
23  * @author Antti Villberg
24  */
25 public class DocumentView extends ModelledView {
26
27     private boolean pinSelection = false;
28
29     @Override
30     protected String configurationURI() {
31         return DocumentUIResource.URIs.View;
32     }
33
34     @Override
35     protected IPropertyPage getPropertyPage() {
36         return null;
37     }
38
39     @Override
40     protected void inputChanged(IWorkbenchPart provider, Object input) {
41         if (pinSelection)
42             return;
43         super.inputChanged(provider, input);
44     }
45
46     @Override
47     public void createPartControl(Composite parent) {
48         super.createPartControl(parent);
49         getViewSite().getActionBars().getToolBarManager().add(new PinSelection());
50     }
51
52     private class PinSelection extends Action {
53         public PinSelection() {
54             super("Pin Selection", IAction.AS_CHECK_BOX);
55             setImageDescriptor(
56                     BundleUtils.getImageDescriptorFromPlugin(
57                             "org.eclipse.ui",
58                             "icons/full/etool16/pin_editor.png"));
59         }
60
61         @Override
62         public void run() {
63             pinSelection = isChecked();
64         }
65     }
66
67 }