1   /**
2    * QJ-Pro
3    * Copyright (c) 2004, http://qjpro.sourceforge.net
4    *
5    * This program is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU General Public License as published by the
7    * Free Software Foundation; either version 2 of the License, or
8    * (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful, but WITHOUT
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13   * details.
14   *
15   * You should have received a copy of the GNU General Public License along with
16   * this program; if not, write to the Free Software Foundation, Inc.,
17   * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18   */
19  package com.qasystems.qstudio.java.integration.eclipse.actions;
20  
21  import com.qasystems.qstudio.java.integration.eclipse.EclipsePropertiesPanel;
22  
23  import org.eclipse.jdt.core.IJavaProject;
24  import org.eclipse.jface.action.IAction;
25  import org.eclipse.jface.viewers.ISelectionProvider;
26  import org.eclipse.jface.viewers.StructuredSelection;
27  import org.eclipse.ui.IObjectActionDelegate;
28  import org.eclipse.ui.IWorkbenchPage;
29  import org.eclipse.ui.IWorkbenchPart;
30  import org.eclipse.ui.IWorkbenchPartSite;
31  import org.eclipse.ui.actions.ActionDelegate;
32  
33  /**
34   * This class implements the ProjectProperties action.
35   */
36  public class ProjectPropertiesAction extends ActionDelegate
37    implements IObjectActionDelegate {
38    /** The page containing the part target. */
39    private IWorkbenchPage page;
40  
41    /** The part target. */
42    private IWorkbenchPart part;
43  
44    /**
45     * DOCUMENT ME!
46     *
47     * @param iAction DOCUMENT ME!
48     * @param iWorkbenchPart DOCUMENT ME!
49     */
50    public void setActivePart(IAction iAction, IWorkbenchPart iWorkbenchPart) {
51      part = iWorkbenchPart;
52      page = part.getSite().getPage();
53    }
54  
55    /**
56     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
57     */
58    public void run(final IAction action) {
59      final IWorkbenchPartSite site = part.getSite();
60      final ISelectionProvider provider = site.getSelectionProvider();
61      final StructuredSelection selection =
62        (StructuredSelection) provider.getSelection();
63      final Object project = selection.getFirstElement();
64  
65      if (project instanceof IJavaProject) {
66        new EclipsePropertiesPanel().run((IJavaProject) project);
67      }
68    }
69  }
70