| 1 | |
package org.jtheque.primary; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
import org.jtheque.core.managers.Managers; |
| 20 | |
import org.jtheque.core.managers.feature.Feature; |
| 21 | |
import org.jtheque.core.managers.feature.IFeatureManager; |
| 22 | |
import org.jtheque.core.managers.feature.Menu; |
| 23 | |
import org.jtheque.core.managers.language.ILanguageManager; |
| 24 | |
import org.jtheque.core.managers.schema.ISchemaManager; |
| 25 | |
import org.jtheque.core.managers.schema.Schema; |
| 26 | |
import org.jtheque.primary.od.able.SimpleData; |
| 27 | |
import org.jtheque.primary.utils.DataTypeManager; |
| 28 | |
|
| 29 | |
import java.util.List; |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
public final class PrimaryUtils { |
| 37 | |
private static final String BASE_NAME = "classpath:/org/jtheque/primary/i18n/utils"; |
| 38 | |
|
| 39 | |
private static Schema schema; |
| 40 | |
|
| 41 | |
private static Menu menu; |
| 42 | |
|
| 43 | |
private static String primaryImpl; |
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
private PrimaryUtils(){ |
| 49 | 0 | super(); |
| 50 | 0 | } |
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
public static void prePlug(){ |
| 56 | 0 | schema = new PrimaryUtilsSchema(); |
| 57 | |
|
| 58 | 0 | Managers.getManager(ISchemaManager.class).registerSchema(schema); |
| 59 | |
|
| 60 | 0 | Managers.getManager(ILanguageManager.class).addBaseName(BASE_NAME); |
| 61 | 0 | } |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
public static void plug(){ |
| 67 | 0 | DataTypeManager.bindDataTypeToKey(PrimaryConstants.BORROWERS, "data.titles.borrower"); |
| 68 | 0 | DataTypeManager.bindDataTypeToKey(SimpleData.DataType.COUNTRY.getDataType(), "data.titles.country"); |
| 69 | 0 | DataTypeManager.bindDataTypeToKey(SimpleData.DataType.LANGUAGE.getDataType(), "data.titles.language"); |
| 70 | 0 | DataTypeManager.bindDataTypeToKey(SimpleData.DataType.TYPE.getDataType(), "data.titles.type"); |
| 71 | 0 | DataTypeManager.bindDataTypeToKey(SimpleData.DataType.KIND.getDataType(), "data.titles.kind"); |
| 72 | 0 | DataTypeManager.bindDataTypeToKey(SimpleData.DataType.SAGA.getDataType(), "data.titles.saga"); |
| 73 | 0 | } |
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
public static void unplug(){ |
| 79 | 0 | DataTypeManager.unbindDataType(PrimaryConstants.BORROWERS); |
| 80 | 0 | DataTypeManager.unbindDataType(SimpleData.DataType.COUNTRY.getDataType()); |
| 81 | 0 | DataTypeManager.unbindDataType(SimpleData.DataType.LANGUAGE.getDataType()); |
| 82 | 0 | DataTypeManager.unbindDataType(SimpleData.DataType.TYPE.getDataType()); |
| 83 | 0 | DataTypeManager.unbindDataType(SimpleData.DataType.KIND.getDataType()); |
| 84 | 0 | DataTypeManager.unbindDataType(SimpleData.DataType.SAGA.getDataType()); |
| 85 | |
|
| 86 | 0 | Managers.getManager(ISchemaManager.class).unregisterSchema(schema); |
| 87 | |
|
| 88 | 0 | Managers.getManager(ILanguageManager.class).removeBaseName(BASE_NAME); |
| 89 | |
|
| 90 | 0 | if (menu != null){ |
| 91 | 0 | Managers.getManager(IFeatureManager.class).removeMenu(menu); |
| 92 | |
} |
| 93 | 0 | } |
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
public static String getPrimaryImpl(){ |
| 101 | 0 | return primaryImpl; |
| 102 | |
} |
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
public static void setPrimaryImpl(String primaryImpl){ |
| 110 | 0 | PrimaryUtils.primaryImpl = primaryImpl; |
| 111 | 0 | } |
| 112 | |
|
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
public static void enableMenu(List<Feature> addFeatures, List<Feature> removeFeatures, List<Feature> editFeatures){ |
| 121 | 0 | menu = new PrimaryMenu(addFeatures, removeFeatures, editFeatures); |
| 122 | 0 | Managers.getManager(IFeatureManager.class).addMenu(menu); |
| 123 | 0 | } |
| 124 | |
} |