01: /*
02:
03: Derby - Class org.apache.derby.ui.actions.SysInfoAction
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derby.ui.actions;
23:
24: import org.apache.derby.ui.DerbyPlugin;
25: import org.apache.derby.ui.common.CommonNames;
26: import org.apache.derby.ui.common.Messages;
27: import org.apache.derby.ui.util.DerbyUtils;
28: import org.eclipse.core.resources.IProject;
29: import org.eclipse.core.runtime.CoreException;
30: import org.eclipse.jdt.core.IJavaProject;
31: import org.eclipse.jface.action.IAction;
32: import org.eclipse.jface.dialogs.MessageDialog;
33: import org.eclipse.jface.viewers.ISelection;
34: import org.eclipse.swt.widgets.Shell;
35: import org.eclipse.ui.IActionDelegate;
36: import org.eclipse.ui.IObjectActionDelegate;
37: import org.eclipse.ui.IWorkbenchPart;
38:
39: public class SysInfoAction implements IObjectActionDelegate {
40:
41: private IJavaProject currentJavaProject;
42: private IProject currentProject;
43:
44: /**
45: * Constructor for Action1.
46: */
47: public SysInfoAction() {
48: super ();
49: }
50:
51: /**
52: * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
53: */
54: public void setActivePart(IAction action, IWorkbenchPart targetPart) {
55: }
56:
57: /**
58: * @see IActionDelegate#run(IAction)
59: */
60: public void run(IAction action) {
61: Shell shell = new Shell();
62: DerbyPlugin plugin = DerbyPlugin.getDefault();
63: if (plugin == null) {
64: MessageDialog.openInformation(shell,
65: CommonNames.PLUGIN_NAME, Messages.NO_ACTION);
66: } else {
67: try {
68: if (currentJavaProject != null) {
69: DerbyUtils.runSysInfo(currentJavaProject
70: .getProject());
71: } else {
72: DerbyUtils.runSysInfo(currentProject);
73: }
74:
75: } catch (CoreException ce) {
76: ce.printStackTrace(System.err);
77: } catch (Exception e) {
78: e.printStackTrace();
79: }
80: }
81: }
82:
83: /**
84: * @see IActionDelegate#selectionChanged(IAction, ISelection)
85: */
86: public void selectionChanged(IAction action, ISelection selection) {
87: currentJavaProject = org.apache.derby.ui.util.SelectionUtil
88: .findSelectedJavaProject(selection);
89: if (currentJavaProject == null) {
90: currentProject = org.apache.derby.ui.util.SelectionUtil
91: .findSelectedProject(selection);
92: }
93: }
94:
95: }
|