1 11 package org.eclipse.team.internal.ccvs.ui; 12 13 import org.eclipse.jface.dialogs.Dialog; 14 import org.eclipse.jface.dialogs.IDialogSettings; 15 import org.eclipse.jface.util.IPropertyChangeListener; 16 import org.eclipse.jface.util.PropertyChangeEvent; 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.layout.GridData; 21 import org.eclipse.swt.widgets.Button; 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.IWorkingSet; 27 import org.eclipse.ui.help.WorkbenchHelp; 28 29 32 public class SynchronizeProjectsDialog extends Dialog { 33 34 private Button outgoingChangesButton; 35 36 private static final String SYNC_OUTGOING_CHANGES = "SyncOutgoingChanges"; 38 IWorkingSet workingSet; 39 boolean syncOutgoingChanges; 40 41 private IDialogSettings settings; 43 private WorkingSetSelectionArea workingSetArea; 44 45 55 public SynchronizeProjectsDialog(Shell parentShell) { 56 super(parentShell); 57 IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings(); 58 this.settings = workbenchSettings.getSection("SynchronizeProjectsDialog"); if (settings == null) { 60 this.settings = workbenchSettings.addNewSection("SynchronizeProjectsDialog"); } 62 } 63 64 69 protected Control createDialogArea(Composite parent) { 70 Composite composite = (Composite)super.createDialogArea(parent); 72 73 workingSetArea = new WorkingSetSelectionArea(this, Policy.bind("SynchronizeProjectsDialog.allSharedProjects"), Policy.bind("SynchronizeProjectsDialog.sharedWorkingSetProjects"), settings); setWorkingSet(workingSet); 75 workingSetArea.addPropertyChangeListener(new IPropertyChangeListener() { 76 public void propertyChange(PropertyChangeEvent event) { 77 workingSet = (IWorkingSet)event.getNewValue(); 78 } 79 }); 80 workingSetArea.createArea(composite); 81 82 outgoingChangesButton = createCheckbox(composite, Policy.bind("SynchronizeProjectsDialog.syncOutgoingChanges")); outgoingChangesButton.addSelectionListener(new SelectionAdapter() { 85 public void widgetSelected(SelectionEvent e) { 86 syncOutgoingChanges = outgoingChangesButton.getSelection(); 87 } 88 }); 89 if (settings != null) { 90 syncOutgoingChanges = settings.getBoolean(SYNC_OUTGOING_CHANGES); 91 outgoingChangesButton.setSelection(syncOutgoingChanges); 92 } 93 94 WorkbenchHelp.setHelp(composite, IHelpContextIds.SYNCHRONIZE_PROJECTS_DIALOG); 96 Dialog.applyDialogFont(parent); 97 98 return composite; 99 } 100 101 104 protected void configureShell(Shell newShell) { 105 super.configureShell(newShell); 106 newShell.setText(Policy.bind("SynchronizeProjectsDialog.title")); } 108 113 public IWorkingSet getWorkingSet() { 114 return workingSet; 115 } 116 117 122 protected void okPressed() { 123 workingSet = workingSetArea.getWorkingSet(); 124 if (workingSet != null) { 125 workingSetArea.useSelectedWorkingSet(); 126 } 127 if (settings != null) { 128 settings.put(SYNC_OUTGOING_CHANGES, outgoingChangesButton.getSelection()); 129 } 130 super.okPressed(); 131 } 132 141 public void setWorkingSet(IWorkingSet workingSet) { 142 this.workingSet = workingSet; 143 144 if (workingSetArea != null) { 145 workingSetArea.setWorkingSet(workingSet); 146 } 147 } 148 149 protected Button createCheckbox(Composite parent, String label) { 150 Button button = new Button(parent, SWT.CHECK | SWT.LEFT); 151 button.setText(label); 152 GridData data = new GridData(); 153 button.setLayoutData(data); 154 return button; 155 } 156 157 protected Label createLabel(Composite composite, String text) { 158 Label label = new Label(composite,SWT.NONE); 159 if (text != null) { 160 label.setText(text); 161 } 162 return label; 163 } 164 165 168 public boolean isSyncOutgoingChanges() { 169 return syncOutgoingChanges; 170 } 171 172 } 173 | Popular Tags |