KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > wizards > buildpaths > newsourcepage > RemoveLinkedFolderDialog


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 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.ui.wizards.buildpaths.newsourcepage;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.core.resources.IFolder;
16
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.events.SelectionAdapter;
19 import org.eclipse.swt.events.SelectionEvent;
20 import org.eclipse.swt.events.SelectionListener;
21 import org.eclipse.swt.layout.GridLayout;
22 import org.eclipse.swt.widgets.Button;
23 import org.eclipse.swt.widgets.Composite;
24 import org.eclipse.swt.widgets.Control;
25 import org.eclipse.swt.widgets.Shell;
26
27 import org.eclipse.jface.dialogs.IDialogConstants;
28 import org.eclipse.jface.dialogs.MessageDialog;
29
30 import org.eclipse.jdt.internal.corext.util.Messages;
31
32 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
33 import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.ClasspathModifierQueries.IRemoveLinkedFolderQuery;
34
35 /**
36  * Dialog to prompt whether a linked folder should be deleted.
37  *
38  */

39 class RemoveLinkedFolderDialog extends MessageDialog {
40
41     /** The remove status */
42     private int fRemoveStatus= IRemoveLinkedFolderQuery.REMOVE_BUILD_PATH_AND_FOLDER;
43
44     /** The remove build path and folder button */
45     private Button fRemoveBuildPathAndFolder;
46
47     /** The remove build path button */
48     private Button fRemoveBuildPath;
49
50     /**
51      * Creates a new remove linked folder dialog.
52      *
53      * @param shell the parent shell to use
54      * @param folder the linked folder to remove
55      */

56     RemoveLinkedFolderDialog(final Shell shell, final IFolder folder) {
57         super(shell, NewWizardMessages.ClasspathModifierQueries_confirm_remove_linked_folder_label, null, Messages.format(NewWizardMessages.ClasspathModifierQueries_confirm_remove_linked_folder_message, new Object JavaDoc[] { folder.getFullPath()}), MessageDialog.QUESTION, new String JavaDoc[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 0); // yes is the default
58
Assert.isTrue(folder.isLinked());
59     }
60
61     protected Control createCustomArea(final Composite parent) {
62
63         final Composite composite= new Composite(parent, SWT.NONE);
64         composite.setLayout(new GridLayout());
65
66         fRemoveBuildPathAndFolder= new Button(composite, SWT.RADIO);
67         fRemoveBuildPathAndFolder.addSelectionListener(selectionListener);
68
69         fRemoveBuildPathAndFolder.setText(NewWizardMessages.ClasspathModifierQueries_delete_linked_folder);
70         fRemoveBuildPathAndFolder.setFont(parent.getFont());
71
72         fRemoveBuildPath= new Button(composite, SWT.RADIO);
73         fRemoveBuildPath.addSelectionListener(selectionListener);
74
75         fRemoveBuildPath.setText(NewWizardMessages.ClasspathModifierQueries_do_not_delete_linked_folder);
76         fRemoveBuildPath.setFont(parent.getFont());
77
78         fRemoveBuildPathAndFolder.setSelection(fRemoveStatus == IRemoveLinkedFolderQuery.REMOVE_BUILD_PATH_AND_FOLDER);
79         fRemoveBuildPath.setSelection(fRemoveStatus == IRemoveLinkedFolderQuery.REMOVE_BUILD_PATH);
80
81         return composite;
82     }
83
84     private SelectionListener selectionListener= new SelectionAdapter() {
85
86         public final void widgetSelected(final SelectionEvent event) {
87             final Button button= (Button) event.widget;
88             if (button.getSelection())
89                 fRemoveStatus= (button == fRemoveBuildPathAndFolder) ? IRemoveLinkedFolderQuery.REMOVE_BUILD_PATH_AND_FOLDER : IRemoveLinkedFolderQuery.REMOVE_BUILD_PATH;
90         }
91     };
92
93     /**
94      * Returns the remove status.
95      *
96      * @return the remove status, one of IRemoveLinkedFolderQuery#REMOVE_XXX
97      */

98     public final int getRemoveStatus() {
99         return fRemoveStatus;
100     }
101 }
Popular Tags