1 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 39 class RemoveLinkedFolderDialog extends MessageDialog { 40 41 42 private int fRemoveStatus= IRemoveLinkedFolderQuery.REMOVE_BUILD_PATH_AND_FOLDER; 43 44 45 private Button fRemoveBuildPathAndFolder; 46 47 48 private Button fRemoveBuildPath; 49 50 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 [] { folder.getFullPath()}), MessageDialog.QUESTION, new String [] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 0); 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 98 public final int getRemoveStatus() { 99 return fRemoveStatus; 100 } 101 } | Popular Tags |