1 13 package org.eclipse.ui.dialogs; 14 15 import java.util.ArrayList ; 16 17 import org.eclipse.core.resources.IProject; 18 import org.eclipse.jface.resource.JFaceColors; 19 import org.eclipse.swt.SWT; 20 import org.eclipse.swt.layout.GridData; 21 import org.eclipse.swt.layout.GridLayout; 22 import org.eclipse.swt.widgets.Composite; 23 import org.eclipse.swt.widgets.Control; 24 import org.eclipse.swt.widgets.Label; 25 import org.eclipse.swt.widgets.Shell; 26 import org.eclipse.ui.PlatformUI; 27 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; 28 import org.eclipse.ui.internal.ide.IIDEHelpContextIds; 29 import org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea; 30 import org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea.IErrorMessageReporter; 31 32 36 public class ProjectLocationMoveDialog extends SelectionDialog { 37 private IProject project; 38 39 private Label statusMessageLabel; 40 41 private static String PROJECT_LOCATION_SELECTION_TITLE = IDEWorkbenchMessages.ProjectLocationSelectionDialog_selectionTitle; 42 43 44 private ProjectContentsLocationArea locationArea; 45 46 53 public ProjectLocationMoveDialog(Shell parentShell, IProject existingProject) { 54 super(parentShell); 55 setTitle(PROJECT_LOCATION_SELECTION_TITLE); 56 this.project = existingProject; 57 } 58 59 64 public void setMessage(String message) { 65 super.setMessage(message); 66 if (statusMessageLabel != null) { 67 if (message == null) { 68 statusMessageLabel.setText(""); statusMessageLabel.setToolTipText(""); getOkButton().setEnabled(true); 71 } else { 72 statusMessageLabel.setForeground(JFaceColors 73 .getErrorText(statusMessageLabel.getDisplay())); 74 statusMessageLabel.setText(message); 75 statusMessageLabel.setToolTipText(message); 76 getOkButton().setEnabled(false); 77 } 78 } 79 } 80 81 84 protected void configureShell(Shell shell) { 85 super.configureShell(shell); 86 PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, 87 IIDEHelpContextIds.PROJECT_LOCATION_SELECTION_DIALOG); 88 } 89 90 93 protected Control createContents(Composite parent) { 94 Control content = super.createContents(parent); 95 getOkButton().setEnabled(false); 96 return content; 97 } 98 99 102 protected Control createDialogArea(Composite parent) { 103 Composite composite = (Composite) super.createDialogArea(parent); 105 106 composite.setLayout(new GridLayout()); 107 composite.setLayoutData(new GridData(GridData.FILL_BOTH)); 108 109 locationArea = new ProjectContentsLocationArea(getErrorReporter(), composite, 110 this.project); 111 112 setButtonLayoutData(locationArea.getBrowseButton()); 114 115 statusMessageLabel = new Label(composite, SWT.WRAP); 117 statusMessageLabel.setLayoutData(new GridData(GridData.FILL_BOTH)); 118 statusMessageLabel.setFont(parent.getFont()); 119 statusMessageLabel.setText(" \n "); 122 applyDialogFont(composite); 123 return composite; 124 } 125 126 127 131 private IErrorMessageReporter getErrorReporter() { 132 return new IErrorMessageReporter(){ 133 136 public void reportError(String errorMessage) { 137 setMessage(errorMessage); 138 139 } 140 }; 141 } 142 143 146 private IProject getProject() { 147 return this.project; 148 } 149 150 155 protected void okPressed() { 156 157 ArrayList list = new ArrayList (); 158 list.add(getProject().getName()); 159 list.add(locationArea.getProjectLocation()); 160 setResult(list); 161 super.okPressed(); 162 } 163 164 } 165 | Popular Tags |