[919] | 1 | /**
|
---|
| 2 | * FunctionSetting.java
|
---|
| 3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
| 4 | *
|
---|
| 5 | * This program is free software: you can redistribute it and/or modify
|
---|
| 6 | * it under the terms of the GNU General Public License as published by
|
---|
| 7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 8 | * (at your option) any later version.
|
---|
| 9 | *
|
---|
| 10 | * This program 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
|
---|
| 13 | * GNU General Public License for more details.
|
---|
| 14 | *
|
---|
| 15 | * You should have received a copy of the GNU General Public License
|
---|
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 17 | */
|
---|
| 18 |
|
---|
[655] | 19 | package org.expeditee.setting;
|
---|
| 20 |
|
---|
| 21 | import org.expeditee.gui.AttributeValuePair;
|
---|
| 22 | import org.expeditee.items.Text;
|
---|
| 23 |
|
---|
| 24 | public abstract class FunctionSetting extends Setting {
|
---|
| 25 |
|
---|
[1242] | 26 | public FunctionSetting(String tooltip, String name) {
|
---|
| 27 | super(tooltip, name);
|
---|
[655] | 28 | }
|
---|
| 29 |
|
---|
| 30 | /**
|
---|
| 31 | * The code to run
|
---|
| 32 | * Must be overridden
|
---|
| 33 | */
|
---|
| 34 | protected abstract void run();
|
---|
| 35 |
|
---|
| 36 | /**
|
---|
| 37 | * runs the setting specific code if the text item has a value of true
|
---|
| 38 | */
|
---|
| 39 | public boolean setSetting(Text text) {
|
---|
| 40 | AttributeValuePair avp = new AttributeValuePair(text.getText(), false);
|
---|
| 41 | if(avp.getValue() != null && avp.getValue().trim().length() != 0 && avp.getBooleanValue()) {
|
---|
| 42 | run();
|
---|
| 43 | return true;
|
---|
| 44 | }
|
---|
| 45 | return false;
|
---|
| 46 | }
|
---|
[1242] | 47 |
|
---|
| 48 | @Override
|
---|
| 49 | public Text generateRepresentation(String label, String frameset) {
|
---|
| 50 | Text text = new Text(label + ": false");
|
---|
| 51 | return text;
|
---|
| 52 | }
|
---|
[655] | 53 | }
|
---|