KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > actions > OpenDialogAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.jdt.internal.debug.ui.actions;
12
13
14 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
15 import org.eclipse.jdt.internal.debug.ui.launcher.IClasspathViewer;
16 import org.eclipse.jface.dialogs.IDialogSettings;
17
18 /**
19  * Abstract action that opens a dialog. Contains a prefix for dialog preference
20  * settings.
21  */

22 public abstract class OpenDialogAction extends RuntimeClasspathAction {
23     
24     /**
25      * Attribute name for the last path used to open a file/directory chooser
26      * dialog.
27      */

28     protected static final String JavaDoc LAST_PATH_SETTING = "LAST_PATH_SETTING"; //$NON-NLS-1$
29

30     /**
31      * Dialog settings prefix/qualifier
32      */

33     private String JavaDoc fPrefix = null;
34
35     /**
36      * Constructs an action that opens a dialog.
37      */

38     public OpenDialogAction(String JavaDoc label, IClasspathViewer viewer, String JavaDoc dialogSettingsPrefix) {
39         super(label, viewer);
40         fPrefix = dialogSettingsPrefix;
41     }
42     
43     /**
44      * Returns the prefix of the identifier used to store dialog settings for
45      * this action.
46      */

47     protected String JavaDoc getDialogSettingsPrefix() {
48         return fPrefix;
49     }
50     
51     /**
52      * Returns the value of the dialog setting, associated with the given
53      * settingName, resolved by the dialog setting prefix associated with this
54      * action.
55      *
56      * @param settingName unqualified setting name
57      * @return value or <code>null</code> if none
58      */

59     protected String JavaDoc getDialogSetting(String JavaDoc settingName) {
60         return getDialogSettings().get(getDialogSettingsPrefix() + "." + settingName); //$NON-NLS-1$
61
}
62     
63     /**
64      * Sets the value of the dialog setting, associated with the given
65      * settingName, resolved by the dialog setting prefix associated with this
66      * action.
67      *
68      * @param settingName unqualified setting name
69      * @return value or <code>null</code> if none
70      */

71     protected void setDialogSetting(String JavaDoc settingName, String JavaDoc value) {
72         getDialogSettings().put(getDialogSettingsPrefix() + "." + settingName, value); //$NON-NLS-1$
73
}
74
75     /**
76      * Returns this plug-in's dialog settings.
77      *
78      * @return IDialogSettings
79      */

80     protected IDialogSettings getDialogSettings() {
81         IDialogSettings settings = JDIDebugUIPlugin.getDefault().getDialogSettings();
82         return settings;
83     }
84     
85     protected int getActionType() {
86         return ADD;
87     }
88 }
89
Popular Tags