1 /* 2 * This file is a part of CAST project. 3 * (c) Copyright 2007, AGH University of Science & Technology 4 * https://caribou.iisg.agh.edu.pl/trac/cast 5 * 6 * Licensed under the Eclipse Public License, Version 1.0 (the "License"). 7 * You may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * http://www.eclipse.org/legal/epl-v10.html 10 */ 11 /* 12 * File: AbstractConfigurableView.java 13 * Created: 2005-11-29 14 * Author: apohllo 15 * $Id: AbstractConfigurableView.java 2312 2009-01-12 22:53:55Z tmilos $ 16 */ 17 18 package pl.edu.agh.cast.ui; 19 20 import org.apache.log4j.Logger; 21 import org.eclipse.ui.IMemento; 22 import org.eclipse.ui.IViewSite; 23 import org.eclipse.ui.PartInitException; 24 import org.eclipse.ui.part.ViewPart; 25 26 import pl.edu.agh.cast.Activator; 27 28 /** 29 * This abstract class is to be implemented by classes which want to store their state across system start-stop cycles. 30 * This class implements the basic persistency scheme using IMemento object, which is maintained by the Eclipse 31 * Platform. 32 * 33 * @author AGH CAST Team 34 */ 35 public abstract class AbstractConfigurableView extends ViewPart { 36 37 /** 38 * The configuration of the view stored in IMemento object. 39 */ 40 protected IMemento configuration = null; 41 42 /** 43 * Logger 44 */ 45 protected static Logger log = Activator.getLogger(); 46 47 /** 48 * This init method restores the configuration of this view using the IMemento object. 49 * 50 * {@inheritDoc} 51 * 52 * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento) 53 */ 54 @Override 55 public void init(IViewSite site, IMemento memento) throws PartInitException { 56 super.init(site, memento); 57 // log.debug("init "+memento); 58 if (memento != null) { 59 this.configuration = memento; 60 } 61 } 62 63 /** 64 * Save the configuration of the view in IMemento object. 65 * 66 * @param memento 67 * The IMemento object, which is used to store the configuration of the view. 68 */ 69 @Override 70 public void saveState(IMemento memento) { 71 if (memento != null && configuration != null) { 72 memento.putMemento(configuration); 73 } 74 } 75 76 /** 77 * Returns the configuration of the view. 78 * 79 * @return IMemento The configuration of the view. 80 */ 81 public IMemento getConfiguration() { 82 return configuration; 83 } 84 85 /** 86 * Create actions which are used in this view. 87 * 88 */ 89 protected abstract void makeActions(); 90 91 /** 92 * Add actions and action groups to context menu. 93 * 94 */ 95 protected abstract void hookContextMenu(); 96 97 /** 98 * Provide action for double click. 99 * 100 */ 101 protected abstract void hookDoubleClickAction(); 102 103 /** 104 * Fill action bars with view specific actions. 105 * 106 */ 107 protected abstract void contributeToActionBars(); 108 109 /** 110 * Activate the view, e.g. register listeners, etc. 111 * 112 */ 113 protected abstract void activate(); 114 115 }