Statistics
| Revision:

svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / report / LayoutReportActionFactory.java @ 1594

History | View | Annotate | Download (1.97 KB)

1
package org.gvsig.app.project.documents.layout.report;
2

    
3
import javax.json.JsonObject;
4
import org.apache.commons.lang3.StringUtils;
5
import org.gvsig.fmap.dal.feature.FeatureQuery;
6
import org.gvsig.fmap.dal.feature.FeatureSelection;
7
import org.gvsig.fmap.dal.feature.FeatureStore;
8
import org.gvsig.fmap.dal.swing.DALSwingLocator;
9
import org.gvsig.fmap.dal.swing.DataSwingManager;
10
import org.gvsig.fmap.dal.swing.report.AbstractReportActionFactory;
11
import org.gvsig.fmap.dal.swing.report.ReportAction;
12
import org.gvsig.fmap.dal.swing.report.ReportActionFactory;
13
import org.gvsig.tools.future.FutureUtils;
14

    
15
/**
16
 *
17
 * @author jjdelcerro
18
 */
19
public class LayoutReportActionFactory extends AbstractReportActionFactory implements ReportActionFactory {
20

    
21
    public static final String LAYOUT_REPORT_ACTION_NAME = "Layout";
22
    
23
    public LayoutReportActionFactory() {
24
        super(LAYOUT_REPORT_ACTION_NAME);
25
    }
26

    
27
    @Override
28
    public ReportAction createReportAction(FeatureStore store, FeatureQuery query, FeatureSelection selecteds, JsonObject json) {
29
        String type = json.getString("type", "jasper").trim();
30
        if( !StringUtils.equalsIgnoreCase(type, LAYOUT_REPORT_ACTION_NAME) ) {
31
            return null;
32
        }
33
        ReportAction reportAction = new LayoutReportActionImpl(this, store, query, selecteds, json);
34
        return reportAction;
35
    }
36
    
37
    public static void selfRegister() {
38
        if(FutureUtils.use("LAYOUT_REPORT")){
39
            DataSwingManager dalSwingManager = DALSwingLocator.getSwingManager();
40
            dalSwingManager.registerReportAction(new LayoutReportActionFactory());
41
        }
42
    }
43

    
44
    @Override
45
    public boolean isApplicable(Object... args) {
46
        JsonObject json = (JsonObject) args[0];
47
        return isJsonApplicable(json);
48
    }
49
    
50
    public static boolean isJsonApplicable(JsonObject json) {
51
        String type = json.getString("type", "jasper").trim();
52
        return StringUtils.equalsIgnoreCase(type, LAYOUT_REPORT_ACTION_NAME);
53
    }
54
    
55
}