KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > apacheds > configuration > Activator


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20 package org.apache.directory.ldapstudio.apacheds.configuration;
21
22
23 import org.eclipse.jface.dialogs.Dialog;
24 import org.eclipse.jface.dialogs.IDialogConstants;
25 import org.eclipse.jface.resource.JFaceResources;
26 import org.eclipse.swt.graphics.FontMetrics;
27 import org.eclipse.swt.graphics.GC;
28 import org.eclipse.swt.widgets.Control;
29 import org.eclipse.ui.plugin.AbstractUIPlugin;
30 import org.osgi.framework.BundleContext;
31
32
33 /**
34  * The activator class controls the plug-in life cycle.
35  *
36  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
37  * @version $Rev$, $Date$
38  */

39 public class Activator extends AbstractUIPlugin
40 {
41     /** The plug-in ID */
42     public static final String JavaDoc PLUGIN_ID = "org.apache.directory.ldapstudio.apacheds.configuration"; //$NON-NLS-1$
43

44     /** The shared instance */
45     private static Activator plugin;
46
47
48     /**
49      * Creates a new instance of Activator.
50      */

51     public Activator()
52     {
53         plugin = this;
54     }
55
56
57     /*
58      * (non-Javadoc)
59      * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
60      */

61     public void start( BundleContext context ) throws Exception JavaDoc
62     {
63         super.start( context );
64     }
65
66
67     /*
68      * (non-Javadoc)
69      * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
70      */

71     public void stop( BundleContext context ) throws Exception JavaDoc
72     {
73         super.stop( context );
74     }
75
76
77     /**
78      * Returns the shared instance.
79      *
80      * @return
81      * the shared instance
82      */

83     public static Activator getDefault()
84     {
85         return plugin;
86     }
87     
88     /**
89      * Returns the button with respect to the font metrics.
90      *
91      * @param control a control
92      * @return the button width
93      */

94     public static int getButtonWidth( Control control )
95     {
96         GC gc = new GC( control );
97         gc.setFont( JFaceResources.getDialogFont() );
98         FontMetrics fontMetrics = gc.getFontMetrics();
99         gc.dispose();
100
101         int width = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH );
102         return width;
103     }
104 }
105
Popular Tags