01 /*
02 *
03 * Licensed to the Apache Software Foundation (ASF) under one
04 * or more contributor license agreements. See the NOTICE file
05 * distributed with this work for additional information
06 * regarding copyright ownership. The ASF licenses this file
07 * to you under the Apache License, Version 2.0 (the
08 * "License"); you may not use this file except in compliance
09 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.management.ui.actions;
22
23 import java.io.InputStream;
24 import java.util.Properties;
25
26 import org.apache.qpid.management.ui.Constants;
27 import org.apache.qpid.management.ui.jmx.MBeanUtility;
28 import org.eclipse.jface.action.Action;
29 import org.eclipse.jface.dialogs.MessageDialog;
30 import org.eclipse.ui.IWorkbenchWindow;
31
32 public class VersionAction extends Action
33 {
34 private IWorkbenchWindow _window;
35 public static final String VERSION_RESOURCE = "qpidversion.properties";
36
37 public static final String PRODUCT_NAME_PROPERTY = "qpid.name";
38 public static final String RELEASE_VERSION_PROPERTY = "qpid.version";
39 public static final String BUILD_VERSION_PROPERTY = "qpid.svnversion";
40
41 private static final String DEFAULT = "unknown";
42 private static String _releaseVersion;
43 private static String _buildVersion;
44 private static String _text;
45
46 static
47 {
48 Properties props = new Properties();
49 try
50 {
51 InputStream propertyStream = VersionAction.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE);
52 if (propertyStream != null)
53 {
54 props.load(propertyStream);
55 _releaseVersion = readPropertyValue(props, RELEASE_VERSION_PROPERTY);
56 _buildVersion = readPropertyValue(props, BUILD_VERSION_PROPERTY);
57 _text = "Build Version : " + _buildVersion + "\n" +
58 "Release Version : " + _releaseVersion;
59 }
60 else
61 {
62 _text = "Build Version : \n" +
63 "Release Version : ";
64 }
65 }
66 catch (Exception ex)
67 {
68 MBeanUtility.printStackTrace(ex);
69 }
70 }
71
72 public VersionAction(IWorkbenchWindow window)
73 {
74 _window = window;
75 setText("About " + Constants.APPLICATION_NAME);
76 setId("qpidmc.about");
77 setActionDefinitionId("qpidmc.about");
78 }
79
80 private static String readPropertyValue(Properties props, String propertyName)
81 {
82 String retVal = (String) props.get(propertyName);
83 if (retVal == null)
84 {
85 retVal = DEFAULT;
86 }
87 return retVal;
88 }
89
90 public void run()
91 {
92 MessageDialog.openInformation(_window.getShell(), Constants.APPLICATION_NAME, _text);
93 }
94 }
|