KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > sourcelookup > AddContainerAction


1 /*******************************************************************************
2  * Copyright (c) 2003, 2005 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.debug.internal.ui.sourcelookup;
12
13 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
14 import org.eclipse.jface.viewers.IStructuredSelection;
15
16 /**
17  * The action to add a new source container.
18  * Used by the CommonSourceNotFoundEditor, the launch configuration source tab,
19  * and the EditSourceLookupPathDialog.
20  */

21 public class AddContainerAction extends SourceContainerAction {
22     
23     private ISourceLookupDirector fDirector;
24     
25     public AddContainerAction() {
26         super(SourceLookupUIMessages.sourceTab_addButton);
27     }
28     
29     /**
30      * Prompts for a project to add.
31      *
32      * @see org.eclipse.jface.action.IAction#run()
33      */

34     public void run() {
35         AddSourceContainerDialog dialog = new AddSourceContainerDialog(getShell(), getViewer(), fDirector);
36         dialog.open();
37     }
38     
39     public void setSourceLookupDirector(ISourceLookupDirector director) {
40         fDirector = director;
41     }
42     
43     /* (non-Javadoc)
44      * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
45      */

46     protected boolean updateSelection(IStructuredSelection selection) {
47         if(selection == null || selection.isEmpty()) {
48             return true;
49         }
50         return getViewer().getTree().getSelection()[0].getParentItem()==null;
51     }
52 }
53
Popular Tags