|
Lines 12-17
Link Here
|
| 12 |
|
12 |
|
| 13 |
import java.io.File; |
13 |
import java.io.File; |
| 14 |
import java.io.IOException; |
14 |
import java.io.IOException; |
|
|
15 |
|
| 15 |
import org.eclipse.core.resources.IProject; |
16 |
import org.eclipse.core.resources.IProject; |
| 16 |
import org.eclipse.core.resources.IResource; |
17 |
import org.eclipse.core.resources.IResource; |
| 17 |
import org.eclipse.core.resources.IResourceRuleFactory; |
18 |
import org.eclipse.core.resources.IResourceRuleFactory; |
|
Lines 22-33
Link Here
|
| 22 |
import org.eclipse.core.runtime.IStatus; |
23 |
import org.eclipse.core.runtime.IStatus; |
| 23 |
import org.eclipse.core.runtime.Platform; |
24 |
import org.eclipse.core.runtime.Platform; |
| 24 |
import org.eclipse.core.runtime.Status; |
25 |
import org.eclipse.core.runtime.Status; |
| 25 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
|
|
| 26 |
import org.eclipse.core.runtime.preferences.InstanceScope; |
| 27 |
import org.eclipse.jdt.core.IPackageFragment; |
26 |
import org.eclipse.jdt.core.IPackageFragment; |
| 28 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
27 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
| 29 |
import org.eclipse.jface.dialogs.Dialog; |
|
|
| 30 |
import org.eclipse.jface.dialogs.IDialogConstants; |
28 |
import org.eclipse.jface.dialogs.IDialogConstants; |
|
|
29 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 31 |
import org.eclipse.jface.resource.JFaceResources; |
30 |
import org.eclipse.jface.resource.JFaceResources; |
| 32 |
import org.eclipse.jface.resource.LocalResourceManager; |
31 |
import org.eclipse.jface.resource.LocalResourceManager; |
| 33 |
import org.eclipse.jface.resource.ResourceManager; |
32 |
import org.eclipse.jface.resource.ResourceManager; |
|
Lines 53-69
Link Here
|
| 53 |
import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; |
52 |
import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; |
| 54 |
import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; |
53 |
import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; |
| 55 |
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; |
54 |
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; |
|
|
55 |
import org.eclipse.jpt.jpa.ui.internal.dialogs.OptionalMessageDialog; |
| 56 |
import org.eclipse.osgi.util.NLS; |
56 |
import org.eclipse.osgi.util.NLS; |
| 57 |
import org.eclipse.swt.SWT; |
|
|
| 58 |
import org.eclipse.swt.events.SelectionEvent; |
| 59 |
import org.eclipse.swt.events.SelectionListener; |
| 60 |
import org.eclipse.swt.layout.GridData; |
| 61 |
import org.eclipse.swt.layout.GridLayout; |
| 62 |
import org.eclipse.swt.widgets.Button; |
| 63 |
import org.eclipse.swt.widgets.Composite; |
57 |
import org.eclipse.swt.widgets.Composite; |
| 64 |
import org.eclipse.swt.widgets.Control; |
|
|
| 65 |
import org.eclipse.swt.widgets.Display; |
58 |
import org.eclipse.swt.widgets.Display; |
| 66 |
import org.eclipse.swt.widgets.Label; |
|
|
| 67 |
import org.eclipse.swt.widgets.Shell; |
59 |
import org.eclipse.swt.widgets.Shell; |
| 68 |
import org.eclipse.ui.INewWizard; |
60 |
import org.eclipse.ui.INewWizard; |
| 69 |
import org.eclipse.ui.IWorkbench; |
61 |
import org.eclipse.ui.IWorkbench; |
|
Lines 73-80
Link Here
|
| 73 |
|
65 |
|
| 74 |
public static final String HELP_CONTEXT_ID = JptJpaUiPlugin.PLUGIN_ID + ".GenerateEntitiesFromSchemaWizard"; //$NON-NLS-1$ |
66 |
public static final String HELP_CONTEXT_ID = JptJpaUiPlugin.PLUGIN_ID + ".GenerateEntitiesFromSchemaWizard"; //$NON-NLS-1$ |
| 75 |
|
67 |
|
| 76 |
private static final String DONT_SHOW_OVERWRITE_WARNING_DIALOG = "DONT_SHOW_OVERWRITE_WARNING_DIALOG"; //$NON-NLS-1$ |
|
|
| 77 |
|
| 78 |
private JpaProject jpaProject; |
68 |
private JpaProject jpaProject; |
| 79 |
|
69 |
|
| 80 |
private IStructuredSelection selection; |
70 |
private IStructuredSelection selection; |
|
Lines 251-259
Link Here
|
| 251 |
} |
241 |
} |
| 252 |
|
242 |
|
| 253 |
public static boolean showOverwriteWarning(){ |
243 |
public static boolean showOverwriteWarning(){ |
| 254 |
IEclipsePreferences pref = new InstanceScope().getNode(JptJpaUiPlugin.PLUGIN_ID); |
244 |
return OptionalMessageDialog.isDialogEnabled(OverwriteConfirmerDialog.ID); |
| 255 |
boolean ret = ! pref.getBoolean( DONT_SHOW_OVERWRITE_WARNING_DIALOG, false) ; |
|
|
| 256 |
return ret; |
| 257 |
} |
245 |
} |
| 258 |
|
246 |
|
| 259 |
// ********** overwrite confirmer ********** |
247 |
// ********** overwrite confirmer ********** |
|
Lines 312-366
Link Here
|
| 312 |
|
300 |
|
| 313 |
// ********** overwrite dialog ********** |
301 |
// ********** overwrite dialog ********** |
| 314 |
|
302 |
|
| 315 |
static class OverwriteConfirmerDialog extends Dialog { |
303 |
static class OverwriteConfirmerDialog extends OptionalMessageDialog { |
| 316 |
private final String className; |
|
|
| 317 |
private boolean yes = false; |
304 |
private boolean yes = false; |
| 318 |
private boolean yesToAll = false; |
305 |
private boolean yesToAll = false; |
| 319 |
private boolean no = false; |
306 |
private boolean no = false; |
| 320 |
private boolean noToAll = false; |
307 |
private boolean noToAll = false; |
| 321 |
|
308 |
|
| 322 |
OverwriteConfirmerDialog(Shell parent, String className) { |
309 |
private static final String ID= "dontShowOverwrite.warning"; //$NON-NLS-1$ |
| 323 |
super(parent); |
|
|
| 324 |
this.className = className; |
| 325 |
} |
| 326 |
|
310 |
|
| 327 |
@Override |
311 |
OverwriteConfirmerDialog(Shell parent, String className) { |
| 328 |
protected void configureShell(Shell shell) { |
312 |
super(ID, parent, |
| 329 |
super.configureShell(shell); |
313 |
JptUiMessages.OverwriteConfirmerDialog_title, |
| 330 |
shell.setText(JptUiMessages.OverwriteConfirmerDialog_title); |
314 |
NLS.bind(JptUiMessages.OverwriteConfirmerDialog_text, className), |
|
|
315 |
MessageDialog.WARNING, |
| 316 |
new String[] {IDialogConstants.YES_LABEL, |
| 317 |
IDialogConstants.YES_TO_ALL_LABEL, |
| 318 |
IDialogConstants.NO_LABEL, |
| 319 |
IDialogConstants.NO_TO_ALL_LABEL, |
| 320 |
IDialogConstants.CANCEL_LABEL}, |
| 321 |
2); |
| 331 |
} |
322 |
} |
| 332 |
|
323 |
|
| 333 |
@Override |
|
|
| 334 |
protected Control createDialogArea(Composite parent) { |
| 335 |
Composite composite = (Composite) super.createDialogArea(parent); |
| 336 |
GridLayout gridLayout = (GridLayout) composite.getLayout(); |
| 337 |
gridLayout.numColumns = 1; |
| 338 |
|
| 339 |
Label text = new Label(composite, SWT.LEFT); |
| 340 |
text.setText(NLS.bind(JptUiMessages.OverwriteConfirmerDialog_text, this.className)); |
| 341 |
text.setLayoutData(new GridData()); |
| 342 |
|
| 343 |
createDontShowControl(composite); |
| 344 |
|
| 345 |
return composite; |
| 346 |
} |
| 347 |
|
| 348 |
protected Control createDontShowControl(Composite composite) { |
| 349 |
final Button checkbox = new Button( composite, SWT.CHECK ); |
| 350 |
checkbox.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_doNotShowWarning ); |
| 351 |
checkbox.setSelection(false); |
| 352 |
final IEclipsePreferences pref = new InstanceScope().getNode( JptJpaUiPlugin.PLUGIN_ID); |
| 353 |
checkbox.setLayoutData( new GridData(GridData.FILL_BOTH) ); |
| 354 |
checkbox.addSelectionListener(new SelectionListener (){ |
| 355 |
public void widgetDefaultSelected(SelectionEvent e) {} |
| 356 |
public void widgetSelected(SelectionEvent e) { |
| 357 |
boolean b = checkbox.getSelection(); |
| 358 |
pref.putBoolean( DONT_SHOW_OVERWRITE_WARNING_DIALOG, b); |
| 359 |
} |
| 360 |
}); |
| 361 |
return checkbox; |
| 362 |
} |
| 363 |
|
| 364 |
@Override |
324 |
@Override |
| 365 |
protected void createButtonsForButtonBar(Composite parent) { |
325 |
protected void createButtonsForButtonBar(Composite parent) { |
| 366 |
this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false); |
326 |
this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false); |