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.validation.ui;
16:
17: import net.refractions.udig.project.ILayer;
18: import net.refractions.udig.ui.operations.IOp;
19:
20: import org.eclipse.core.runtime.IProgressMonitor;
21: import org.eclipse.jface.dialogs.Dialog;
22: import org.eclipse.swt.widgets.Display;
23:
24: /**
25: * The dialog box used to select which validations to perform.
26: * <p>
27: *
28: * </p>
29: * @author chorner
30: * @since 1.0.1
31: */
32: public class ValidationDialogOp implements IOp {
33:
34: private Dialog dialog;
35: private ILayer[] layer;
36:
37: public void op(final Display display, Object target,
38: IProgressMonitor monitor) throws Exception {
39: // define the ILayer array (save it as a private var)
40: if (target.getClass().isArray()) {
41: layer = (ILayer[]) target;
42: } else {
43: layer = new ILayer[1];
44: layer[0] = (ILayer) target;
45: }
46: // create or find the dialog
47: display.asyncExec(new Runnable() {
48:
49: public void run() {
50: if (dialog == null) {
51: dialog = new ValidationDialog(display
52: .getActiveShell(), layer);
53: }
54: dialog.open();
55: }
56: });
57:
58: // done
59: monitor.done();
60: }
61: }
|