svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.swing / org.gvsig.fmap.dal.swing.impl / src / main / java / org / gvsig / fmap / dal / swing / impl / actions / ShowFormForOpenStoreParametersAction.java @ 47049
History | View | Annotate | Download (2.98 KB)
1 |
/*
|
---|---|
2 |
* To change this license header, choose License Headers in Project Properties.
|
3 |
* To change this template file, choose Tools | Templates
|
4 |
* and open the template in the editor.
|
5 |
*/
|
6 |
package org.gvsig.fmap.dal.swing.impl.actions; |
7 |
|
8 |
import java.awt.event.ActionEvent; |
9 |
import javax.swing.AbstractAction; |
10 |
import javax.swing.Action; |
11 |
import org.gvsig.featureform.swing.FeaturesFormContext; |
12 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_REPOSITORY_PARAMETERS; |
13 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_REPOSITORY_NAME; |
14 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
15 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
16 |
import org.gvsig.tools.dynform.JDynFormField; |
17 |
import org.gvsig.tools.dynform.spi.DynFormSPILocator; |
18 |
import org.gvsig.tools.dynform.spi.DynFormSPIManager; |
19 |
import org.gvsig.tools.dynform.spi.DynFormSPIManager.PopupMenuActionFactory; |
20 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
21 |
import org.slf4j.Logger; |
22 |
import org.slf4j.LoggerFactory; |
23 |
|
24 |
/**
|
25 |
*
|
26 |
* @author jjdelcerro
|
27 |
*/
|
28 |
public class ShowFormForOpenStoreParametersAction |
29 |
extends AbstractAction { |
30 |
|
31 |
private static final Logger LOGGER = LoggerFactory.getLogger(ShowFormForOpenStoreParametersAction.class); |
32 |
|
33 |
public static final class ShowFormForOpenStoreParametersActionFactory |
34 |
implements PopupMenuActionFactory {
|
35 |
|
36 |
@Override
|
37 |
public String getName() { |
38 |
return "ShowFormForOpenStoreParametersAction"; |
39 |
} |
40 |
|
41 |
@Override
|
42 |
public boolean isApplicable(JDynFormField jfield) { |
43 |
if (!(jfield.getForm().getContext() instanceof FeaturesFormContext)) { |
44 |
return false; |
45 |
} |
46 |
FeaturesFormContext context = (FeaturesFormContext) jfield.getForm().getContext(); |
47 |
if (!context.getFeatureStore().getName().equalsIgnoreCase(TABLE_REPOSITORY_NAME)) {
|
48 |
return false; |
49 |
} |
50 |
return jfield.getDefinition().getName().equals(FIELD_REPOSITORY_PARAMETERS);
|
51 |
} |
52 |
|
53 |
@Override
|
54 |
public Action create(JDynFormField jfield) { |
55 |
return new ShowFormForOpenStoreParametersAction(jfield); |
56 |
} |
57 |
|
58 |
|
59 |
public static void selfRegister() { |
60 |
DataSwingManager dalSwingManager = DALSwingLocator.getSwingManager(); |
61 |
dalSwingManager.registerStoreAction(new ShowFormAction.ShowFormActionFactory());
|
62 |
} |
63 |
} |
64 |
|
65 |
private final JDynFormField jfield; |
66 |
|
67 |
public ShowFormForOpenStoreParametersAction(JDynFormField jfield) {
|
68 |
super("Show parameters"); |
69 |
this.jfield = jfield;
|
70 |
} |
71 |
|
72 |
@Override
|
73 |
public void actionPerformed(ActionEvent e) { |
74 |
Object value = this.jfield.getValue(); |
75 |
} |
76 |
|
77 |
public static final void selfRegister() { |
78 |
DynFormSPIManager manager; |
79 |
try {
|
80 |
manager = DynFormSPILocator.getDynFormSPIManager(); |
81 |
} catch(ReferenceNotRegisteredException ex) {
|
82 |
return;
|
83 |
} |
84 |
manager.addPopupMenuAction(new ShowFormForOpenStoreParametersActionFactory());
|
85 |
} |
86 |
} |