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.tools.edit.impl;
16:
17: import net.refractions.udig.core.IProvider;
18: import net.refractions.udig.tools.edit.EditState;
19: import net.refractions.udig.tools.edit.EditToolHandler;
20:
21: /**
22: * Returns one message when creating and another in other edit states.
23: * @author Jesse
24: * @since 1.1.0
25: */
26: public class ConditionalProvider implements IProvider<String> {
27:
28: private EditToolHandler handler;
29: private String creatingMessage;
30: private String defaultMessage;
31:
32: public ConditionalProvider(EditToolHandler handler,
33: String defaultMessage, String creatingMessage) {
34: this .handler = handler;
35: this .creatingMessage = creatingMessage;
36: this .defaultMessage = defaultMessage;
37: }
38:
39: public String get() {
40: if (handler.getCurrentState() == EditState.CREATING)
41: return creatingMessage;
42: return defaultMessage;
43: }
44:
45: }
|