01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.project.ui.internal;
16:
17: import net.refractions.udig.project.internal.Map;
18:
19: import org.eclipse.jface.dialogs.IDialogConstants;
20: import org.eclipse.jface.dialogs.IconAndMessageDialog;
21: import org.eclipse.swt.graphics.Image;
22: import org.eclipse.swt.layout.GridLayout;
23: import org.eclipse.swt.widgets.Composite;
24: import org.eclipse.swt.widgets.Control;
25: import org.eclipse.swt.widgets.Shell;
26:
27: /**
28: * Queries user if they want to save. Return values are: {@link IDialogConstants#CANCEL_ID}
29: * {@link IDialogConstants#NO_ID} {@link IDialogConstants#YES_ID}
30: *
31: * @author Jesse
32: * @since 1.1.0
33: */
34: public class SaveDialog extends IconAndMessageDialog {
35:
36: private Map map;
37:
38: public SaveDialog(Shell activeShell, Map map) {
39: super (activeShell);
40: this .map = map;
41: }
42:
43: @Override
44: protected Control createDialogArea(Composite parent) {
45: message = Messages.MapEditor_saveQuestion
46: + " " + map.getName() + "?"; //$NON-NLS-1$//$NON-NLS-2$
47:
48: Composite composite = (Composite) super
49: .createDialogArea(parent);
50: ((GridLayout) composite.getLayout()).numColumns = 2;
51: ((GridLayout) composite.getLayout()).makeColumnsEqualWidth = false;
52:
53: createMessageArea(composite);
54:
55: return composite;
56: }
57:
58: @Override
59: protected void configureShell(Shell newShell) {
60: newShell.setText(Messages.MapEditor_saveTitle);
61: super .configureShell(newShell);
62: }
63:
64: @Override
65: protected void buttonPressed(int buttonId) {
66: if (buttonId == IDialogConstants.NO_ID) {
67: setReturnCode(IDialogConstants.NO_ID);
68: close();
69: } else if (buttonId == IDialogConstants.YES_ID) {
70: setReturnCode(IDialogConstants.YES_ID);
71: close();
72: } else {
73: setReturnCode(IDialogConstants.CANCEL_ID);
74: close();
75: }
76:
77: }
78:
79: @Override
80: protected void createButtonsForButtonBar(Composite parent) {
81: createButton(parent, IDialogConstants.CANCEL_ID,
82: IDialogConstants.CANCEL_LABEL, false);
83: createButton(parent, IDialogConstants.NO_ID,
84: IDialogConstants.NO_LABEL, false);
85: createButton(parent, IDialogConstants.YES_ID,
86: IDialogConstants.YES_LABEL, true);
87: }
88:
89: @Override
90: protected Image getImage() {
91: return getQuestionImage();
92: };
93: }
|