.
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / model / AbstractUtility.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.taxeditor.model;
12
13 import org.eclipse.jface.resource.ColorRegistry;
14 import org.eclipse.jface.resource.FontRegistry;
15 import org.eclipse.swt.widgets.Shell;
16 import org.eclipse.ui.IWorkbenchPage;
17 import org.eclipse.ui.themes.ITheme;
18 import org.eclipse.ui.themes.IThemeManager;
19
20 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
21
22 /**
23 * @author n.hoffmann
24 * @created 11.05.2009
25 * @version 1.0
26 */
27 public abstract class AbstractUtility {
28
29 /**
30 * @return
31 */
32 public static Shell getShell() {
33 return TaxeditorStorePlugin.getDefault().getWorkbench()
34 .getActiveWorkbenchWindow().getShell();
35 }
36
37 public static IWorkbenchPage getActivePage(){
38 return TaxeditorStorePlugin.getDefault().getWorkbench()
39 .getActiveWorkbenchWindow().getActivePage();
40 }
41
42 public static boolean closeAll() {
43 return getActivePage().closeAllEditors(true);
44 }
45
46 public static ITheme getCurrentTheme(){
47 IThemeManager themeManager = TaxeditorStorePlugin.getDefault().getWorkbench().getThemeManager();
48 return themeManager.getCurrentTheme();
49 }
50
51 /**
52 * Fonts registered to the plugin may be obtained with the Eclipse themeing functionality.
53 * Thus fonts are chooseable by the user via Preferences->General->Appearance->Colors and Fonts
54 *
55 * @return the FontRegistry for the current theme
56 */
57 public static FontRegistry getFontRegistry(){
58 return getCurrentTheme().getFontRegistry();
59 }
60
61 /**
62 * Color registered to the plugin may be obtained with the Eclipse themeing functionality.
63 * Thus colors are editable by the user via Preferences->General->Appearance->Colors and Fonts
64 *
65 * @return the ColorRegistry for the current theme
66 */
67 public static ColorRegistry getColorRegistry(){
68 return getCurrentTheme().getColorRegistry();
69 }
70
71 }