1 | /**
|
---|
2 | * MagneticConstraintAction.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 |
|
---|
19 | package org.expeditee.items.MagneticConstraint;
|
---|
20 |
|
---|
21 | import java.util.List;
|
---|
22 |
|
---|
23 | import org.expeditee.gui.Frame;
|
---|
24 | import org.expeditee.items.Item;
|
---|
25 |
|
---|
26 | public abstract class MagneticConstraintAction {
|
---|
27 | protected MagneticConstraintAction callbackAction;
|
---|
28 |
|
---|
29 | abstract public boolean exec(final Item item);
|
---|
30 |
|
---|
31 | abstract public boolean invert(final Item item);
|
---|
32 |
|
---|
33 | public void callback(final Item item) {
|
---|
34 | callbackAction.exec(item);
|
---|
35 | }
|
---|
36 |
|
---|
37 | public void setCallbackAction(final MagneticConstraintAction action) {
|
---|
38 | callbackAction = action;
|
---|
39 | }
|
---|
40 |
|
---|
41 | protected boolean isSpIDERCodePage(final Frame frame) {
|
---|
42 | if(frame.getTitleItem() == null) return false;
|
---|
43 | final List<String> data = frame.getTitleItem().getData();
|
---|
44 | boolean hasProjectTag = false;
|
---|
45 | boolean hasPackageTag = false;
|
---|
46 | boolean hasClassTag = false;
|
---|
47 | if(data == null) return false;
|
---|
48 | for(final String s : data) {
|
---|
49 | if(s.startsWith("Project:")) hasProjectTag = true;
|
---|
50 | else if(s.startsWith("Package:")) hasPackageTag = true;
|
---|
51 | else if(s.startsWith("Class:")) hasClassTag = true;
|
---|
52 | }
|
---|
53 | return hasProjectTag && hasPackageTag && hasClassTag;
|
---|
54 | }
|
---|
55 | }
|
---|