KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > registry > StickyViewDescriptor


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.registry;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IConfigurationElement;
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.ui.IPageLayout;
18 import org.eclipse.ui.views.IStickyViewDescriptor;
19
20 /**
21  * @since 3.0
22  */

23 public class StickyViewDescriptor implements IStickyViewDescriptor {
24
25     private IConfigurationElement configurationElement;
26
27     private String JavaDoc id;
28
29     /**
30      * Folder constant for right sticky views.
31      */

32     public static final String JavaDoc STICKY_FOLDER_RIGHT = "stickyFolderRight"; //$NON-NLS-1$
33

34     /**
35      * Folder constant for left sticky views.
36      */

37     public static final String JavaDoc STICKY_FOLDER_LEFT = "stickyFolderLeft"; //$NON-NLS-1$
38

39     /**
40      * Folder constant for top sticky views.
41      */

42     public static final String JavaDoc STICKY_FOLDER_TOP = "stickyFolderTop"; //$NON-NLS-1$
43

44     /**
45      * Folder constant for bottom sticky views.
46      */

47     public static final String JavaDoc STICKY_FOLDER_BOTTOM = "stickyFolderBottom"; //$NON-NLS-1$
48

49     /**
50      * @param element
51      * @throws CoreException
52      */

53     public StickyViewDescriptor(IConfigurationElement element)
54             throws CoreException {
55         this.configurationElement = element;
56         id = configurationElement.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
57         if (id == null) {
58             throw new CoreException(new Status(IStatus.ERROR, element
59                     .getNamespace(), 0,
60                     "Invalid extension (missing id) ", null));//$NON-NLS-1$
61
}
62     }
63     
64     /**
65      * Return the configuration element.
66      *
67      * @return the configuration element
68      */

69     public IConfigurationElement getConfigurationElement() {
70         return configurationElement;
71     }
72
73     /* (non-Javadoc)
74      * @see org.eclipse.ui.views.IStickyViewDescriptor#getLocation()
75      */

76     public int getLocation() {
77         int direction = IPageLayout.RIGHT;
78         
79         String JavaDoc location = configurationElement.getAttribute(IWorkbenchRegistryConstants.ATT_LOCATION);
80         if (location != null) {
81             if (location.equalsIgnoreCase("left")) { //$NON-NLS-1$
82
direction = IPageLayout.LEFT;
83             } else if (location.equalsIgnoreCase("top")) { //$NON-NLS-1$
84
direction = IPageLayout.TOP;
85             } else if (location.equalsIgnoreCase("bottom")) { //$NON-NLS-1$
86
direction = IPageLayout.BOTTOM;
87             //no else for right - it is the default value;
88
}
89         }
90         return direction;
91     }
92
93     /* (non-Javadoc)
94      * @see org.eclipse.ui.internal.registry.IStickyViewDescriptor#getId()
95      */

96     public String JavaDoc getId() {
97         return id;
98     }
99
100     /* (non-Javadoc)
101      * @see org.eclipse.ui.internal.registry.IStickyViewDescriptor#isFixed()
102      */

103     public boolean isCloseable() {
104         boolean closeable = true;
105         String JavaDoc closeableString = configurationElement.getAttribute(IWorkbenchRegistryConstants.ATT_CLOSEABLE);
106         if (closeableString != null) {
107             closeable = !closeableString.equals("false"); //$NON-NLS-1$
108
}
109         return closeable;
110     }
111
112     /* (non-Javadoc)
113      * @see org.eclipse.ui.internal.registry.IStickyViewDescriptor#isMoveable()
114      */

115     public boolean isMoveable() {
116         boolean moveable = true;
117         String JavaDoc moveableString = configurationElement.getAttribute(IWorkbenchRegistryConstants.ATT_MOVEABLE);
118         if (moveableString != null) {
119             moveable = !moveableString.equals("false"); //$NON-NLS-1$
120
}
121         return moveable;
122     }
123 }
124
Popular Tags