Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe
Commits:
9 changed files:
- + client/src/main/java/fr/ird/observe/client/ui/actions/admin/ObtainLeftSourceUIAction.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/admin/ObtainRightSourceUIAction.java
- + client/src/main/java/fr/ird/observe/client/ui/admin/AdminTabUIInitializer.java
- client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigModel.java
- client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUI.jaxx
- client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUI.jcss
- client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/ObserveActionMap.java
- client/src/main/java/fr/ird/observe/client/ui/storage/StorageUIModel.java
Changes:
| 1 |
+package fr.ird.observe.client.ui.actions.admin;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
|
| 26 |
+import fr.ird.observe.client.ui.ObserveMainUI;
|
|
| 27 |
+import fr.ird.observe.client.ui.actions.UIActionSupport;
|
|
| 28 |
+import fr.ird.observe.client.ui.admin.AdminUIModel;
|
|
| 29 |
+import fr.ird.observe.client.ui.admin.config.ConfigUI;
|
|
| 30 |
+import fr.ird.observe.client.ui.storage.StorageUILauncher;
|
|
| 31 |
+import fr.ird.observe.client.ui.storage.StorageUIModel;
|
|
| 32 |
+import org.apache.logging.log4j.LogManager;
|
|
| 33 |
+import org.apache.logging.log4j.Logger;
|
|
| 34 |
+ |
|
| 35 |
+import java.awt.Window;
|
|
| 36 |
+import java.awt.event.ActionEvent;
|
|
| 37 |
+ |
|
| 38 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 39 |
+ |
|
| 40 |
+/**
|
|
| 41 |
+ * Created by tchemit on 21/09/2018.
|
|
| 42 |
+ *
|
|
| 43 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 44 |
+ */
|
|
| 45 |
+public class ObtainLeftSourceUIAction extends UIActionSupport {
|
|
| 46 |
+ |
|
| 47 |
+ public static final String ACTION_NAME = ObtainLeftSourceUIAction.class.getName();
|
|
| 48 |
+ private static final Logger log = LogManager.getLogger(ObtainLeftSourceUIAction.class);
|
|
| 49 |
+ |
|
| 50 |
+ private final ConfigUI ui;
|
|
| 51 |
+ |
|
| 52 |
+ public ObtainLeftSourceUIAction(ObserveMainUI mainUI, ConfigUI ui) {
|
|
| 53 |
+ super(mainUI, ACTION_NAME, n("observe.action.configure"), null, "config", ObserveKeyStrokes.KEY_STROKE_CONFIGURE_LOCAL_SOURCE, true);
|
|
| 54 |
+ this.ui = ui;
|
|
| 55 |
+ }
|
|
| 56 |
+ |
|
| 57 |
+ @Override
|
|
| 58 |
+ public void actionPerformed(ActionEvent e) {
|
|
| 59 |
+ log.info("start obtain left connexion");
|
|
| 60 |
+ StorageUIModel sourceModel = ui.getLocalSourceModel();
|
|
| 61 |
+ StorageUILauncher.obtainConnexion(ui, ui.getParentContainer(Window.class), sourceModel);
|
|
| 62 |
+ log.debug("After modifiy source model isValid : " + sourceModel.isValid() + " / " + sourceModel.isValidStep());
|
|
| 63 |
+ |
|
| 64 |
+ AdminUIModel model = ui.getModel();
|
|
| 65 |
+ model.getConfigModel().removeLocalSource();
|
|
| 66 |
+ model.getConfigModel().getLocalSourceModel().validate();
|
|
| 67 |
+ model.validate();
|
|
| 68 |
+ }
|
|
| 69 |
+}
|
| 1 |
+package fr.ird.observe.client.ui.actions.admin;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
|
| 26 |
+import fr.ird.observe.client.ui.ObserveMainUI;
|
|
| 27 |
+import fr.ird.observe.client.ui.actions.UIActionSupport;
|
|
| 28 |
+import fr.ird.observe.client.ui.admin.AdminUIModel;
|
|
| 29 |
+import fr.ird.observe.client.ui.admin.config.ConfigUI;
|
|
| 30 |
+import fr.ird.observe.client.ui.storage.StorageStep;
|
|
| 31 |
+import fr.ird.observe.client.ui.storage.StorageUILauncher;
|
|
| 32 |
+import fr.ird.observe.client.ui.storage.StorageUIModel;
|
|
| 33 |
+import org.apache.logging.log4j.LogManager;
|
|
| 34 |
+import org.apache.logging.log4j.Logger;
|
|
| 35 |
+ |
|
| 36 |
+import java.awt.Window;
|
|
| 37 |
+import java.awt.event.ActionEvent;
|
|
| 38 |
+ |
|
| 39 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 40 |
+ |
|
| 41 |
+/**
|
|
| 42 |
+ * Created by tchemit on 21/09/2018.
|
|
| 43 |
+ *
|
|
| 44 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 45 |
+ */
|
|
| 46 |
+public class ObtainRightSourceUIAction extends UIActionSupport {
|
|
| 47 |
+ |
|
| 48 |
+ public static final String ACTION_NAME = ObtainRightSourceUIAction.class.getName();
|
|
| 49 |
+ private static final Logger log = LogManager.getLogger(ObtainRightSourceUIAction.class);
|
|
| 50 |
+ |
|
| 51 |
+ private final ConfigUI ui;
|
|
| 52 |
+ |
|
| 53 |
+ public ObtainRightSourceUIAction(ObserveMainUI mainUI, ConfigUI ui) {
|
|
| 54 |
+ super(mainUI, ACTION_NAME, n("observe.action.configure"), null, "config", ObserveKeyStrokes.KEY_STROKE_CONFIGURE_REMOTE_SOURCE, true);
|
|
| 55 |
+ this.ui = ui;
|
|
| 56 |
+ }
|
|
| 57 |
+ |
|
| 58 |
+ @Override
|
|
| 59 |
+ public void actionPerformed(ActionEvent e) {
|
|
| 60 |
+ log.info("start obtain right connexion");
|
|
| 61 |
+ StorageUIModel sourceModel = ui.getCentralSourceModel();
|
|
| 62 |
+ StorageUILauncher.obtainConnexion(ui, ui.getParentContainer(Window.class), sourceModel);
|
|
| 63 |
+ AdminUIModel model = ui.getModel();
|
|
| 64 |
+ model.getConfigModel().removeCentralSource();
|
|
| 65 |
+ model.getConfigModel().getCentralSourceModel().validate(StorageStep.CONFIG);
|
|
| 66 |
+ model.validate();
|
|
| 67 |
+ }
|
|
| 68 |
+}
|
| 1 |
+package fr.ird.observe.client.ui.admin;
|
|
| 2 |
+ |
|
| 3 |
+/*
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import com.google.common.collect.ImmutableMap;
|
|
| 26 |
+import fr.ird.observe.client.ObserveSwingApplicationContext;
|
|
| 27 |
+import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
|
| 28 |
+import fr.ird.observe.client.ui.actions.UIActionSupport;
|
|
| 29 |
+import fr.ird.observe.client.ui.actions.content.GoToSubTab1UIAction;
|
|
| 30 |
+import fr.ird.observe.client.ui.actions.content.GoToSubTab2UIAction;
|
|
| 31 |
+import fr.ird.observe.client.ui.actions.content.GoToSubTab3UIAction;
|
|
| 32 |
+import fr.ird.observe.client.ui.actions.content.GoToTab1UIAction;
|
|
| 33 |
+import fr.ird.observe.client.ui.actions.content.GoToTab2UIAction;
|
|
| 34 |
+import fr.ird.observe.client.ui.actions.content.GoToTab3UIAction;
|
|
| 35 |
+import fr.ird.observe.client.ui.actions.content.GoToTab4UIAction;
|
|
| 36 |
+import fr.ird.observe.client.ui.actions.content.GoToTab5UIAction;
|
|
| 37 |
+import fr.ird.observe.client.ui.actions.content.GoToTab6UIAction;
|
|
| 38 |
+import fr.ird.observe.client.ui.actions.content.GoToTabUIActionSupport;
|
|
| 39 |
+import fr.ird.observe.client.ui.content.ObserveActionMap;
|
|
| 40 |
+import fr.ird.observe.client.ui.util.UIHelper;
|
|
| 41 |
+import fr.ird.observe.dto.I18nEnumHelper;
|
|
| 42 |
+import fr.ird.observe.dto.decoration.DecoratorService;
|
|
| 43 |
+import fr.ird.observe.dto.decoration.ObserveI18nLabelsBuilder;
|
|
| 44 |
+import org.apache.commons.lang3.BooleanUtils;
|
|
| 45 |
+import org.apache.commons.lang3.StringUtils;
|
|
| 46 |
+import org.apache.logging.log4j.LogManager;
|
|
| 47 |
+import org.apache.logging.log4j.Logger;
|
|
| 48 |
+import org.nuiton.jaxx.runtime.swing.editor.EnumEditor;
|
|
| 49 |
+import org.nuiton.jaxx.runtime.swing.renderer.EnumEditorRenderer;
|
|
| 50 |
+import org.nuiton.jaxx.widgets.datetime.DateTimeEditor;
|
|
| 51 |
+import org.nuiton.jaxx.widgets.datetime.TimeEditor;
|
|
| 52 |
+import org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditor;
|
|
| 53 |
+import org.nuiton.jaxx.widgets.select.BeanComboBox;
|
|
| 54 |
+import org.nuiton.jaxx.widgets.select.BeanFilterableComboBox;
|
|
| 55 |
+import org.nuiton.jaxx.widgets.select.BeanListHeader;
|
|
| 56 |
+import org.nuiton.jaxx.widgets.select.FilterableDoubleList;
|
|
| 57 |
+import org.nuiton.jaxx.widgets.text.BigTextEditor;
|
|
| 58 |
+ |
|
| 59 |
+import javax.swing.AbstractButton;
|
|
| 60 |
+import javax.swing.InputMap;
|
|
| 61 |
+import javax.swing.JComponent;
|
|
| 62 |
+import javax.swing.JFormattedTextField;
|
|
| 63 |
+import javax.swing.JLabel;
|
|
| 64 |
+import javax.swing.JSpinner;
|
|
| 65 |
+import javax.swing.JTabbedPane;
|
|
| 66 |
+import javax.swing.JTextField;
|
|
| 67 |
+import javax.swing.KeyStroke;
|
|
| 68 |
+import javax.swing.SwingUtilities;
|
|
| 69 |
+import java.awt.Component;
|
|
| 70 |
+import java.awt.Dimension;
|
|
| 71 |
+import java.awt.event.FocusAdapter;
|
|
| 72 |
+import java.awt.event.FocusEvent;
|
|
| 73 |
+import java.awt.event.KeyEvent;
|
|
| 74 |
+import java.text.ParseException;
|
|
| 75 |
+import java.text.SimpleDateFormat;
|
|
| 76 |
+import java.util.Date;
|
|
| 77 |
+import java.util.EnumSet;
|
|
| 78 |
+import java.util.HashSet;
|
|
| 79 |
+import java.util.Objects;
|
|
| 80 |
+import java.util.Set;
|
|
| 81 |
+ |
|
| 82 |
+/**
|
|
| 83 |
+ * To initialize ui.
|
|
| 84 |
+ * <p>
|
|
| 85 |
+ * Created on 9/26/14.
|
|
| 86 |
+ *
|
|
| 87 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 88 |
+ * @since 3.7
|
|
| 89 |
+ */
|
|
| 90 |
+public class AdminTabUIInitializer<UI extends AdminTabUI> {
|
|
| 91 |
+ |
|
| 92 |
+ public static final String OBSERVE_ACTION = "observeAction";
|
|
| 93 |
+ |
|
| 94 |
+ public static final String GLOBAL_ACTION = "globalAction";
|
|
| 95 |
+ |
|
| 96 |
+ private static final String CLIENT_PROPERTY_PROPERTY_NAME = "propertyName";
|
|
| 97 |
+ |
|
| 98 |
+ private static final String CLIENT_PROPERTY_RESET_PROPERTY_NAME = "resetPropertyName";
|
|
| 99 |
+ |
|
| 100 |
+ private static final String CLIENT_PROPERTY_NOT_BLOCKING = "notBlocking";
|
|
| 101 |
+ |
|
| 102 |
+ /** Logger. */
|
|
| 103 |
+ private static final Logger log = LogManager.getLogger(AdminTabUIInitializer.class);
|
|
| 104 |
+ |
|
| 105 |
+ protected final UI ui;
|
|
| 106 |
+ |
|
| 107 |
+ protected final DecoratorService decoratorService;
|
|
| 108 |
+ |
|
| 109 |
+ public AdminTabUIInitializer(UI ui) {
|
|
| 110 |
+ this.ui = ui;
|
|
| 111 |
+ this.decoratorService = ObserveSwingApplicationContext.get().getDecoratorService();
|
|
| 112 |
+ }
|
|
| 113 |
+ |
|
| 114 |
+ public void initUI() {
|
|
| 115 |
+ |
|
| 116 |
+ ObserveActionMap actionMap = ObserveSwingApplicationContext.get().getActionMap();
|
|
| 117 |
+ InputMap inputMap = ObserveSwingApplicationContext.get().getMainUI().getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
|
|
| 118 |
+ // initialisation des éditeurs
|
|
| 119 |
+ |
|
| 120 |
+ Set<String> doNotBlockComponentIds = new HashSet<>();
|
|
| 121 |
+ |
|
| 122 |
+ ui.getActionMap().setParent(actionMap);
|
|
| 123 |
+ ui.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap);
|
|
| 124 |
+ |
|
| 125 |
+ for (String name : ui.get$objectMap().keySet()) {
|
|
| 126 |
+ Object o = ui.getObjectById(name);
|
|
| 127 |
+ |
|
| 128 |
+ if (o == null) {
|
|
| 129 |
+ continue;
|
|
| 130 |
+ }
|
|
| 131 |
+ |
|
| 132 |
+// if (o instanceof JComponent) {
|
|
| 133 |
+//
|
|
| 134 |
+// init((JComponent) o, doNotBlockComponentIds);
|
|
| 135 |
+// }
|
|
| 136 |
+ |
|
| 137 |
+ if (o instanceof AbstractButton) {
|
|
| 138 |
+ init(actionMap, (AbstractButton) o);
|
|
| 139 |
+ continue;
|
|
| 140 |
+ }
|
|
| 141 |
+ |
|
| 142 |
+// if (o instanceof BeanComboBox<?>) {
|
|
| 143 |
+// init((BeanComboBox<?>) o);
|
|
| 144 |
+// continue;
|
|
| 145 |
+// }
|
|
| 146 |
+// if (o instanceof BeanFilterableComboBox<?>) {
|
|
| 147 |
+// init((BeanFilterableComboBox<?>) o);
|
|
| 148 |
+// continue;
|
|
| 149 |
+// }
|
|
| 150 |
+ |
|
| 151 |
+// if (o instanceof BeanListHeader<?>) {
|
|
| 152 |
+// init((BeanListHeader) o);
|
|
| 153 |
+// continue;
|
|
| 154 |
+// }
|
|
| 155 |
+ |
|
| 156 |
+// if (o instanceof FilterableDoubleList<?>) {
|
|
| 157 |
+// init((FilterableDoubleList<?>) o);
|
|
| 158 |
+// continue;
|
|
| 159 |
+// }
|
|
| 160 |
+ |
|
| 161 |
+// if (o instanceof TimeEditor) {
|
|
| 162 |
+// init((TimeEditor) o);
|
|
| 163 |
+// continue;
|
|
| 164 |
+// }
|
|
| 165 |
+ |
|
| 166 |
+// if (o instanceof DateTimeEditor) {
|
|
| 167 |
+// init((DateTimeEditor) o);
|
|
| 168 |
+// continue;
|
|
| 169 |
+// }
|
|
| 170 |
+ |
|
| 171 |
+// if (o instanceof CoordinatesEditor) {
|
|
| 172 |
+// init((CoordinatesEditor) o);
|
|
| 173 |
+// continue;
|
|
| 174 |
+// }
|
|
| 175 |
+ |
|
| 176 |
+// if (o instanceof EnumEditor) {
|
|
| 177 |
+// init((EnumEditor<?>) o);
|
|
| 178 |
+// continue;
|
|
| 179 |
+// }
|
|
| 180 |
+ |
|
| 181 |
+// if (o instanceof BigTextEditor) {
|
|
| 182 |
+// init((BigTextEditor) o);
|
|
| 183 |
+// continue;
|
|
| 184 |
+// }
|
|
| 185 |
+// if (o instanceof JTabbedPane) {
|
|
| 186 |
+// init((JTabbedPane) o);
|
|
| 187 |
+// continue;
|
|
| 188 |
+// }
|
|
| 189 |
+// if (o instanceof JLabel) {
|
|
| 190 |
+// init((JLabel) o);
|
|
| 191 |
+// continue;
|
|
| 192 |
+// }
|
|
| 193 |
+ |
|
| 194 |
+ }
|
|
| 195 |
+ |
|
| 196 |
+ }
|
|
| 197 |
+ |
|
| 198 |
+ private void init(JLabel editor) {
|
|
| 199 |
+ String editorName = StringUtils.removeEnd(editor.getName(), "Label");
|
|
| 200 |
+ Object objectById = ui.getObjectById(editorName);
|
|
| 201 |
+ if (objectById instanceof JComponent) {
|
|
| 202 |
+ editor.setLabelFor((Component) objectById);
|
|
| 203 |
+ }
|
|
| 204 |
+ }
|
|
| 205 |
+ |
|
| 206 |
+ protected void init(ObserveActionMap actionMap, AbstractButton editor) {
|
|
| 207 |
+ String actionId = (String) editor.getClientProperty(OBSERVE_ACTION);
|
|
| 208 |
+ if (actionId == null) {
|
|
| 209 |
+ return;
|
|
| 210 |
+ }
|
|
| 211 |
+ |
|
| 212 |
+ // on a trouve une action commune
|
|
| 213 |
+ UIActionSupport action = actionMap.newAction(actionId, ui);
|
|
| 214 |
+ Objects.requireNonNull(action, "action [" + actionId + "] not found for ui " + ui.getClass().getName());
|
|
| 215 |
+ |
|
| 216 |
+ log.debug("init common action " + actionId);
|
|
| 217 |
+ action.initAction(ui, editor);
|
|
| 218 |
+ |
|
| 219 |
+// actionId = (String) editor.getClientProperty(GLOBAL_ACTION);
|
|
| 220 |
+// if (actionId != null) {
|
|
| 221 |
+// action = (UIActionSupport) actionMap.get(actionId);
|
|
| 222 |
+// Objects.requireNonNull(action, "action [" + actionId + "] not found for ui " + ui.getClass().getName());
|
|
| 223 |
+// KeyStroke acceleratorKey = action.getAcceleratorKey();
|
|
| 224 |
+// ObserveKeyStrokes.addKeyStroke(editor, acceleratorKey);
|
|
| 225 |
+// }
|
|
| 226 |
+ |
|
| 227 |
+ }
|
|
| 228 |
+ |
|
| 229 |
+ @SuppressWarnings("unchecked")
|
|
| 230 |
+ protected void init(BeanComboBox beanComboBox) {
|
|
| 231 |
+ if (log.isDebugEnabled()) {
|
|
| 232 |
+ log.debug("init combobox for " + beanComboBox.getBeanType());
|
|
| 233 |
+ }
|
|
| 234 |
+ Class referenceType = beanComboBox.getBeanType();
|
|
| 235 |
+ beanComboBox.setI18nLabelBuilder(ObserveI18nLabelsBuilder.createFromReferenceType(referenceType));
|
|
| 236 |
+ beanComboBox.setI18nPrefix("observe.common.");
|
|
| 237 |
+ beanComboBox.setMinimumSize(new Dimension(0, 24));
|
|
| 238 |
+ |
|
| 239 |
+ if (StringUtils.isEmpty(beanComboBox.getProperty())) {
|
|
| 240 |
+ beanComboBox.setProperty(beanComboBox.getName());
|
|
| 241 |
+ }
|
|
| 242 |
+ }
|
|
| 243 |
+ |
|
| 244 |
+ @SuppressWarnings("unchecked")
|
|
| 245 |
+ protected void init(BeanFilterableComboBox BeanFilterableComboBox) {
|
|
| 246 |
+ if (log.isDebugEnabled()) {
|
|
| 247 |
+ log.debug("init combobox for " + BeanFilterableComboBox.getBeanType());
|
|
| 248 |
+ }
|
|
| 249 |
+ BeanFilterableComboBox.getCombobox().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), "none");
|
|
| 250 |
+ Class referenceType = BeanFilterableComboBox.getBeanType();
|
|
| 251 |
+ BeanFilterableComboBox.setI18nLabelBuilder(ObserveI18nLabelsBuilder.createFromReferenceType(referenceType));
|
|
| 252 |
+ BeanFilterableComboBox.setI18nPrefix("observe.common.");
|
|
| 253 |
+ BeanFilterableComboBox.setMinimumSize(new Dimension(0, 24));
|
|
| 254 |
+ |
|
| 255 |
+ if (StringUtils.isEmpty(BeanFilterableComboBox.getProperty())) {
|
|
| 256 |
+ BeanFilterableComboBox.setProperty(BeanFilterableComboBox.getName());
|
|
| 257 |
+ }
|
|
| 258 |
+ }
|
|
| 259 |
+ |
|
| 260 |
+ @SuppressWarnings("unchecked")
|
|
| 261 |
+ protected void init(BeanListHeader beanList) {
|
|
| 262 |
+ |
|
| 263 |
+ beanList.setI18nPrefix("observe.common.");
|
|
| 264 |
+ |
|
| 265 |
+ log.debug("init list for " + beanList.getBeanType());
|
|
| 266 |
+ |
|
| 267 |
+ Class referenceType = beanList.getBeanType();
|
|
| 268 |
+ beanList.setI18nLabelBuilder(ObserveI18nLabelsBuilder.createFromReferenceType(referenceType));
|
|
| 269 |
+ }
|
|
| 270 |
+ |
|
| 271 |
+ @SuppressWarnings("unchecked")
|
|
| 272 |
+ protected void init(FilterableDoubleList beanList) {
|
|
| 273 |
+ |
|
| 274 |
+ beanList.setI18nPrefix("observe.common.");
|
|
| 275 |
+ Class referenceType = beanList.getBeanType();
|
|
| 276 |
+ beanList.setI18nLabelBuilder(ObserveI18nLabelsBuilder.createFromReferenceType(referenceType));
|
|
| 277 |
+ beanList.getAddButton().setFocusable(false);
|
|
| 278 |
+ beanList.getRemoveButton().setFocusable(false);
|
|
| 279 |
+ |
|
| 280 |
+ log.debug("init list for " + beanList.getBeanType());
|
|
| 281 |
+ }
|
|
| 282 |
+ |
|
| 283 |
+ protected void init(BigTextEditor editor) {
|
|
| 284 |
+ log.debug("init big text editor " + editor.getName());
|
|
| 285 |
+ if (editor.getProperty() == null) {
|
|
| 286 |
+ editor.setProperty(editor.getName());
|
|
| 287 |
+ }
|
|
| 288 |
+ }
|
|
| 289 |
+ |
|
| 290 |
+ protected void init(TimeEditor editor) {
|
|
| 291 |
+ log.debug("init time editor " + editor.getName());
|
|
| 292 |
+ editor.init();
|
|
| 293 |
+ if (isAutoSelectOnFocus(editor)) {
|
|
| 294 |
+ |
|
| 295 |
+ addAutoSelectOnFocus((JSpinner.DateEditor) editor.getHourEditor().getEditor());
|
|
| 296 |
+ addAutoSelectOnFocus((JSpinner.DateEditor) editor.getMinuteEditor().getEditor());
|
|
| 297 |
+ |
|
| 298 |
+ }
|
|
| 299 |
+ }
|
|
| 300 |
+ |
|
| 301 |
+ protected void init(DateTimeEditor editor) {
|
|
| 302 |
+ log.debug("init date time editor " + editor.getName());
|
|
| 303 |
+ editor.init();
|
|
| 304 |
+ editor.getSliderHidor().setFocusable(false);
|
|
| 305 |
+ if (isAutoSelectOnFocus(editor)) {
|
|
| 306 |
+ |
|
| 307 |
+ addAutoSelectOnFocus((JSpinner.DateEditor) editor.getHourEditor().getEditor());
|
|
| 308 |
+ addAutoSelectOnFocus((JSpinner.DateEditor) editor.getMinuteEditor().getEditor());
|
|
| 309 |
+ addAutoSelectOnFocus(editor.getDayDateEditor().getEditor());
|
|
| 310 |
+ editor.getDayDateEditor().getEditor().addFocusListener(new FocusAdapter() {
|
|
| 311 |
+ |
|
| 312 |
+ private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
|
| 313 |
+ |
|
| 314 |
+ @Override
|
|
| 315 |
+ public void focusLost(FocusEvent e) {
|
|
| 316 |
+ |
|
| 317 |
+ JFormattedTextField source = (JFormattedTextField) e.getSource();
|
|
| 318 |
+ if (source.isEditValid()) {
|
|
| 319 |
+ try {
|
|
| 320 |
+ Date newDate = simpleDateFormat.parse(editor.getDayDateEditor().getEditor().getText());
|
|
| 321 |
+ Object oldValue = editor.getModel().getPropertyDayDate() == null ? null : UIHelper.getProperty(editor.getModel().getBean(), editor.getModel().getPropertyDayDate());
|
|
| 322 |
+ if (!Objects.equals(oldValue, newDate)) {
|
|
| 323 |
+ editor.getDayDateEditor().commitEdit();
|
|
| 324 |
+ log.debug("quit date editor, commit value: " + source.getValue());
|
|
| 325 |
+ }
|
|
| 326 |
+ } catch (ParseException e1) {
|
|
| 327 |
+ // l'édition est valide donc pas de problème ici
|
|
| 328 |
+ }
|
|
| 329 |
+ }
|
|
| 330 |
+ super.focusLost(e);
|
|
| 331 |
+ }
|
|
| 332 |
+ });
|
|
| 333 |
+ |
|
| 334 |
+ }
|
|
| 335 |
+ }
|
|
| 336 |
+ |
|
| 337 |
+ private void addAutoSelectOnFocus(JSpinner.DateEditor hourEditor) {
|
|
| 338 |
+ addAutoSelectOnFocus(hourEditor.getTextField());
|
|
| 339 |
+ }
|
|
| 340 |
+ |
|
| 341 |
+ protected void init(CoordinatesEditor editor) {
|
|
| 342 |
+ log.debug("init coordinates editor " + editor.getName());
|
|
| 343 |
+ editor.setFormat(ObserveSwingApplicationContext.get().getConfig().getCoordinateFormat());
|
|
| 344 |
+ editor.init();
|
|
| 345 |
+ editor.getDmdFormat().setFocusable(false);
|
|
| 346 |
+ editor.getDmsFormat().setFocusable(false);
|
|
| 347 |
+ editor.getDdFormat().setFocusable(false);
|
|
| 348 |
+ |
|
| 349 |
+ }
|
|
| 350 |
+ |
|
| 351 |
+ protected void init(JTabbedPane tabbedPane) {
|
|
| 352 |
+ boolean mainTabbedPane = GoToTabUIActionSupport.MAIN_TABBED_PANE.equals(tabbedPane.getName());
|
|
| 353 |
+ boolean subTabbedPane = GoToTabUIActionSupport.SUB_TABBED_PANE.equals(tabbedPane.getName());
|
|
| 354 |
+ if (!mainTabbedPane && !subTabbedPane) {
|
|
| 355 |
+ return;
|
|
| 356 |
+ }
|
|
| 357 |
+ int tabCount = tabbedPane.getTabCount();
|
|
| 358 |
+ InputMap inputMap = ui.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
|
|
| 359 |
+ if (mainTabbedPane) {
|
|
| 360 |
+ ObserveKeyStrokes.addKeyStrokeToMainTabbedPane(tabbedPane);
|
|
| 361 |
+ if (tabCount > 0) {
|
|
| 362 |
+ inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_1, GoToTab1UIAction.ACTION_NAME);
|
|
| 363 |
+ }
|
|
| 364 |
+ if (tabCount > 1) {
|
|
| 365 |
+ inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_2, GoToTab2UIAction.ACTION_NAME);
|
|
| 366 |
+ }
|
|
| 367 |
+ if (tabCount > 2) {
|
|
| 368 |
+ inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_3, GoToTab3UIAction.ACTION_NAME);
|
|
| 369 |
+ }
|
|
| 370 |
+ if (tabCount > 3) {
|
|
| 371 |
+ inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_4, GoToTab4UIAction.ACTION_NAME);
|
|
| 372 |
+ }
|
|
| 373 |
+ if (tabCount > 4) {
|
|
| 374 |
+ inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_5, GoToTab5UIAction.ACTION_NAME);
|
|
| 375 |
+ }
|
|
| 376 |
+ if (tabCount > 5) {
|
|
| 377 |
+ inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_6, GoToTab6UIAction.ACTION_NAME);
|
|
| 378 |
+ }
|
|
| 379 |
+ }
|
|
| 380 |
+ if (subTabbedPane) {
|
|
| 381 |
+ ObserveKeyStrokes.addKeyStrokeToSubTabbedPane(tabbedPane);
|
|
| 382 |
+ if (tabCount > 0) {
|
|
| 383 |
+ inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_SUB_TAB_1, GoToSubTab1UIAction.ACTION_NAME);
|
|
| 384 |
+ }
|
|
| 385 |
+ if (tabCount > 1) {
|
|
| 386 |
+ inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_SUB_TAB_2, GoToSubTab2UIAction.ACTION_NAME);
|
|
| 387 |
+ }
|
|
| 388 |
+ if (tabCount > 2) {
|
|
| 389 |
+ inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_SUB_TAB_3, GoToSubTab3UIAction.ACTION_NAME);
|
|
| 390 |
+ }
|
|
| 391 |
+ }
|
|
| 392 |
+ |
|
| 393 |
+ }
|
|
| 394 |
+ |
|
| 395 |
+ protected void init(JComponent editor, Set<String> notBlockingComponents) {
|
|
| 396 |
+ final Boolean propertyName = (Boolean) editor.getClientProperty(CLIENT_PROPERTY_NOT_BLOCKING);
|
|
| 397 |
+ if (propertyName != null) {
|
|
| 398 |
+ |
|
| 399 |
+ if (editor instanceof FilterableDoubleList) {
|
|
| 400 |
+ |
|
| 401 |
+ notBlockingComponents.add("universeListPane");
|
|
| 402 |
+ notBlockingComponents.add("selectedListPane");
|
|
| 403 |
+ |
|
| 404 |
+ } else {
|
|
| 405 |
+ |
|
| 406 |
+ notBlockingComponents.add(editor.getName());
|
|
| 407 |
+ |
|
| 408 |
+ }
|
|
| 409 |
+ }
|
|
| 410 |
+ }
|
|
| 411 |
+ |
|
| 412 |
+ protected <B extends Enum<B>> void init(EnumEditor<B> editor) {
|
|
| 413 |
+ log.debug("init enumEditor editor " + editor.getName());
|
|
| 414 |
+ ImmutableMap.Builder<B, String> labelsBuilder = ImmutableMap.builder();
|
|
| 415 |
+ for (B e : EnumSet.allOf(editor.getType())) {
|
|
| 416 |
+ String label = I18nEnumHelper.getLabel(e);
|
|
| 417 |
+ labelsBuilder.put(e, label);
|
|
| 418 |
+ }
|
|
| 419 |
+ editor.setRenderer(new EnumEditorRenderer<>(labelsBuilder.build()));
|
|
| 420 |
+ editor.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), "none");
|
|
| 421 |
+ }
|
|
| 422 |
+ |
|
| 423 |
+ private boolean isAutoSelectOnFocus(JComponent comp) {
|
|
| 424 |
+ Boolean selectOnFocus = (Boolean) comp.getClientProperty("selectOnFocus");
|
|
| 425 |
+ return BooleanUtils.isTrue(selectOnFocus);
|
|
| 426 |
+ }
|
|
| 427 |
+ |
|
| 428 |
+ private void addAutoSelectOnFocus(JTextField jTextField) {
|
|
| 429 |
+ jTextField.addFocusListener(new FocusAdapter() {
|
|
| 430 |
+ |
|
| 431 |
+ @Override
|
|
| 432 |
+ public void focusGained(final FocusEvent e) {
|
|
| 433 |
+ SwingUtilities.invokeLater(() -> {
|
|
| 434 |
+ JTextField source = (JTextField) e.getSource();
|
|
| 435 |
+ source.selectAll();
|
|
| 436 |
+ });
|
|
| 437 |
+ |
|
| 438 |
+ }
|
|
| 439 |
+ });
|
|
| 440 |
+ }
|
|
| 441 |
+ |
|
| 442 |
+}
|
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.admin.config; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| ... | ... | @@ -38,8 +38,8 @@ import fr.ird.observe.services.service.BabModelVersionException; |
| 38 | 38 |
import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException;
|
| 39 | 39 |
import fr.ird.observe.services.service.DatabaseNotFoundException;
|
| 40 | 40 |
import org.apache.commons.lang3.StringUtils;
|
| 41 |
-import org.apache.logging.log4j.Logger;
|
|
| 42 | 41 |
import org.apache.logging.log4j.LogManager;
|
| 42 |
+import org.apache.logging.log4j.Logger;
|
|
| 43 | 43 |
|
| 44 | 44 |
import java.beans.PropertyChangeListener;
|
| 45 | 45 |
import java.io.File;
|
| ... | ... | @@ -59,11 +59,15 @@ import static org.nuiton.i18n.I18n.t; |
| 59 | 59 |
*/
|
| 60 | 60 |
public class ConfigModel extends AdminActionModel {
|
| 61 | 61 |
|
| 62 |
- /** Logger */
|
|
| 63 |
- private static final Logger log = LogManager.getLogger(ConfigModel.class);
|
|
| 64 | 62 |
public static final String PROPERTY_LOCAL_SOURCE_LABEL = "localSourceLabel";
|
| 65 | 63 |
public static final String PROPERTY_CENTRAL_SOURCE_LABEL = "centralSourceLabel";
|
| 66 |
- |
|
| 64 |
+ public static final PropertyChangeListener LOG_PROPERTY_CHANGE_LISTENER = new AdminUIModel.LogPropertyChanged();
|
|
| 65 |
+ /** Logger */
|
|
| 66 |
+ private static final Logger log = LogManager.getLogger(ConfigModel.class);
|
|
| 67 |
+ /** la configuration de la base source */
|
|
| 68 |
+ protected final StorageUIModel localSourceModel;
|
|
| 69 |
+ /** la configuration de la base central */
|
|
| 70 |
+ protected final StorageUIModel centralSourceModel;
|
|
| 67 | 71 |
/** la source de données en cours d'utilisation par l'application */
|
| 68 | 72 |
protected ObserveSwingDataSource previousSource;
|
| 69 | 73 |
/** la source de données sur laquel on veut travailler */
|
| ... | ... | @@ -72,10 +76,6 @@ public class ConfigModel extends AdminActionModel { |
| 72 | 76 |
protected ObserveDataSourceInformation localSourceInformation;
|
| 73 | 77 |
/** la source de données dite central (contenant le référentiel valide) */
|
| 74 | 78 |
protected ObserveSwingDataSource centralSource;
|
| 75 |
- /** la configuration de la base source */
|
|
| 76 |
- protected final StorageUIModel localSourceModel;
|
|
| 77 |
- /** la configuration de la base central */
|
|
| 78 |
- protected final StorageUIModel centralSourceModel;
|
|
| 79 | 79 |
private String localSourceLabel = t("observe.storage.config.source.storage");
|
| 80 | 80 |
private String centralSourceLabel = t("observe.storage.config.referentiel.storage");
|
| 81 | 81 |
|
| ... | ... | @@ -158,7 +158,6 @@ public class ConfigModel extends AdminActionModel { |
| 158 | 158 |
|
| 159 | 159 |
}
|
| 160 | 160 |
|
| 161 |
- |
|
| 162 | 161 |
public String getLocalSourceLabel() {
|
| 163 | 162 |
return localSourceLabel;
|
| 164 | 163 |
}
|
| ... | ... | @@ -179,7 +178,6 @@ public class ConfigModel extends AdminActionModel { |
| 179 | 178 |
firePropertyChange(PROPERTY_CENTRAL_SOURCE_LABEL, oldValue, centralSourceLabel);
|
| 180 | 179 |
}
|
| 181 | 180 |
|
| 182 |
- |
|
| 183 | 181 |
public boolean validate(AdminUIModel uiModel) {
|
| 184 | 182 |
|
| 185 | 183 |
boolean validate = true;
|
| ... | ... | @@ -430,8 +428,6 @@ public class ConfigModel extends AdminActionModel { |
| 430 | 428 |
return validate;
|
| 431 | 429 |
}
|
| 432 | 430 |
|
| 433 |
- public static final PropertyChangeListener LOG_PROPERTY_CHANGE_LISTENER = new AdminUIModel.LogPropertyChanged();
|
|
| 434 |
- |
|
| 435 | 431 |
protected void startCentralSourceModel(AdminUI ui) {
|
| 436 | 432 |
|
| 437 | 433 |
AdminUIModel uiModel = ui.getModel();
|
| ... | ... | @@ -562,6 +558,9 @@ public class ConfigModel extends AdminActionModel { |
| 562 | 558 |
|
| 563 | 559 |
DbMode dbMode = localSourceModel.getDbMode();
|
| 564 | 560 |
localSourceModel.start(dbMode);
|
| 561 |
+// if (previousSource != null && !previousSource.isLocal()) {
|
|
| 562 |
+// localSourceModel.testRemote();
|
|
| 563 |
+// }
|
|
| 565 | 564 |
|
| 566 | 565 |
if (log.isDebugEnabled()) {
|
| 567 | 566 |
localSourceModel.removePropertyChangeListener(LOG_PROPERTY_CHANGE_LISTENER);
|
| ... | ... | @@ -28,6 +28,8 @@ |
| 28 | 28 |
_failedIcon='SwingUtil.getUIManagerActionIcon("connect_no")'>
|
| 29 | 29 |
|
| 30 | 30 |
<import>
|
| 31 |
+ fr.ird.observe.client.ui.actions.admin.ObtainLeftSourceUIAction
|
|
| 32 |
+ fr.ird.observe.client.ui.actions.admin.ObtainRightSourceUIAction
|
|
| 31 | 33 |
fr.ird.observe.client.ui.admin.AdminActionModel
|
| 32 | 34 |
fr.ird.observe.client.ui.admin.AdminUI
|
| 33 | 35 |
fr.ird.observe.client.ui.admin.AdminStep
|
| ... | ... | @@ -121,7 +123,7 @@ public void addMessage(AdminStep step, String text) { |
| 121 | 123 |
<JLabel id='localSourceLabel'/>
|
| 122 | 124 |
</cell>
|
| 123 | 125 |
<cell>
|
| 124 |
- <JButton id='configureLocalSource' onActionPerformed='handler.obtainIncomingConnexion()'/>
|
|
| 126 |
+ <JButton id='configureLocalSource'/>
|
|
| 125 | 127 |
</cell>
|
| 126 | 128 |
<cell anchor='east'>
|
| 127 | 129 |
<JLabel id='localSourceStatus'/>
|
| ... | ... | @@ -145,7 +147,7 @@ public void addMessage(AdminStep step, String text) { |
| 145 | 147 |
<JLabel id='centralSourceLabel'/>
|
| 146 | 148 |
</cell>
|
| 147 | 149 |
<cell>
|
| 148 |
- <JButton id='configureCentralSource' onActionPerformed='handler.obtainRemoteConnexion()'/>
|
|
| 150 |
+ <JButton id='configureCentralSource'/>
|
|
| 149 | 151 |
</cell>
|
| 150 | 152 |
<cell anchor='east'>
|
| 151 | 153 |
<JLabel id='centralSourceStatus'/>
|
| ... | ... | @@ -95,8 +95,7 @@ |
| 95 | 95 |
}
|
| 96 | 96 |
|
| 97 | 97 |
#configureLocalSource {
|
| 98 |
- text:"observe.action.configure";
|
|
| 99 |
- actionIcon:"config";
|
|
| 98 |
+ _observeAction:{ObtainLeftSourceUIAction.ACTION_NAME};
|
|
| 100 | 99 |
}
|
| 101 | 100 |
|
| 102 | 101 |
#localSourceStatus {
|
| ... | ... | @@ -118,8 +117,7 @@ |
| 118 | 117 |
}
|
| 119 | 118 |
|
| 120 | 119 |
#configureCentralSource {
|
| 121 |
- text:"observe.action.configure";
|
|
| 122 |
- actionIcon:"config";
|
|
| 120 |
+ _observeAction:{ObtainRightSourceUIAction.ACTION_NAME};
|
|
| 123 | 121 |
}
|
| 124 | 122 |
|
| 125 | 123 |
#centralSourceStatus {
|
| ... | ... | @@ -6,15 +6,15 @@ |
| 6 | 6 |
* %%
|
| 7 | 7 |
* This program is free software: you can redistribute it and/or modify
|
| 8 | 8 |
* it under the terms of the GNU General Public License as
|
| 9 |
- * published by the Free Software Foundation, either version 3 of the
|
|
| 9 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 10 | 10 |
* License, or (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 17 |
- * You should have received a copy of the GNU General Public
|
|
| 16 |
+ *
|
|
| 17 |
+ * You should have received a copy of the GNU General Public
|
|
| 18 | 18 |
* License along with this program. If not, see
|
| 19 | 19 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| 20 | 20 |
* #L%
|
| ... | ... | @@ -23,25 +23,18 @@ package fr.ird.observe.client.ui.admin.config; |
| 23 | 23 |
|
| 24 | 24 |
import fr.ird.observe.client.ObserveSwingApplicationContext;
|
| 25 | 25 |
import fr.ird.observe.client.ObserveTextGenerator;
|
| 26 |
-import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
|
| 27 | 26 |
import fr.ird.observe.client.ui.admin.AdminStep;
|
| 28 | 27 |
import fr.ird.observe.client.ui.admin.AdminTabUIHandler;
|
| 29 |
-import fr.ird.observe.client.ui.admin.AdminUIModel;
|
|
| 30 |
-import fr.ird.observe.client.ui.storage.StorageStep;
|
|
| 31 |
-import fr.ird.observe.client.ui.storage.StorageUILauncher;
|
|
| 28 |
+import fr.ird.observe.client.ui.admin.AdminTabUIInitializer;
|
|
| 32 | 29 |
import fr.ird.observe.client.ui.storage.StorageUIModel;
|
| 33 | 30 |
import fr.ird.observe.client.ui.util.UIHelper;
|
| 34 | 31 |
import fr.ird.observe.services.configuration.ObserveDataSourceInformation;
|
| 35 |
-import org.apache.logging.log4j.Logger;
|
|
| 36 | 32 |
import org.apache.logging.log4j.LogManager;
|
| 33 |
+import org.apache.logging.log4j.Logger;
|
|
| 37 | 34 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 38 | 35 |
|
| 39 |
-import javax.swing.AbstractAction;
|
|
| 40 | 36 |
import javax.swing.JCheckBox;
|
| 41 |
-import javax.swing.JComponent;
|
|
| 42 | 37 |
import javax.swing.JLabel;
|
| 43 |
-import java.awt.Window;
|
|
| 44 |
-import java.awt.event.ActionEvent;
|
|
| 45 | 38 |
import java.util.Set;
|
| 46 | 39 |
|
| 47 | 40 |
import static org.nuiton.i18n.I18n.t;
|
| ... | ... | @@ -59,24 +52,7 @@ public class ConfigUIHandler extends AdminTabUIHandler<ConfigUI> implements UIHa |
| 59 | 52 |
|
| 60 | 53 |
@Override
|
| 61 | 54 |
public void afterInit(ConfigUI ui) {
|
| 62 |
- |
|
| 63 |
- ui.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ObserveKeyStrokes.KEY_STROKE_CONFIGURE_LOCAL_SOURCE, "obtainLocalSource");
|
|
| 64 |
- ui.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ObserveKeyStrokes.KEY_STROKE_CONFIGURE_REMOTE_SOURCE, "obtainRemoteSource");
|
|
| 65 |
- ui.getActionMap().put("obtainLocalSource", new AbstractAction() {
|
|
| 66 |
- @Override
|
|
| 67 |
- public void actionPerformed(ActionEvent e) {
|
|
| 68 |
- ui.doActionPerformed__on__configureLocalSource(e);
|
|
| 69 |
- }
|
|
| 70 |
- });
|
|
| 71 |
- ui.getActionMap().put("obtainRemoteSource", new AbstractAction() {
|
|
| 72 |
- @Override
|
|
| 73 |
- public void actionPerformed(ActionEvent e) {
|
|
| 74 |
- ui.doActionPerformed__on__configureCentralSource(e);
|
|
| 75 |
- }
|
|
| 76 |
- });
|
|
| 77 |
- |
|
| 78 |
- ObserveKeyStrokes.addKeyStroke(ui.getConfigureLocalSource(), ObserveKeyStrokes.KEY_STROKE_CONFIGURE_LOCAL_SOURCE);
|
|
| 79 |
- ObserveKeyStrokes.addKeyStroke(ui.getConfigureCentralSource(), ObserveKeyStrokes.KEY_STROKE_CONFIGURE_REMOTE_SOURCE);
|
|
| 55 |
+ new AdminTabUIInitializer<>(ui).initUI();
|
|
| 80 | 56 |
super.afterInit(ui);
|
| 81 | 57 |
UIHelper.setLayerUI(ui.getOperations(), parentUI.getOperationBlockLayerUI());
|
| 82 | 58 |
UIHelper.setLayerUI(ui.getConfig(), parentUI.getConfigBlockLayerUI());
|
| ... | ... | @@ -121,29 +97,29 @@ public class ConfigUIHandler extends AdminTabUIHandler<ConfigUI> implements UIHa |
| 121 | 97 |
return operations.contains(scope);
|
| 122 | 98 |
}
|
| 123 | 99 |
|
| 124 |
- public void obtainIncomingConnexion() {
|
|
| 125 |
- StorageUIModel sourceModel = ui.getLocalSourceModel();
|
|
| 126 |
- StorageUILauncher.obtainConnexion(ui, ui.getParentContainer(Window.class), sourceModel);
|
|
| 127 |
- if (log.isDebugEnabled()) {
|
|
| 128 |
- log.debug("After modifiy source model isValid : " + sourceModel.isValid() + " / " + sourceModel.isValidStep());
|
|
| 129 |
- }
|
|
| 130 |
- AdminUIModel model = ui.getModel();
|
|
| 131 |
- model.getConfigModel().removeLocalSource();
|
|
| 132 |
- model.getConfigModel().getLocalSourceModel().validate();
|
|
| 133 |
- model.validate();
|
|
| 134 |
- }
|
|
| 135 |
- |
|
| 136 |
- public void obtainRemoteConnexion() {
|
|
| 137 |
- if (log.isInfoEnabled()) {
|
|
| 138 |
- log.info("start obtain remote connexion");
|
|
| 139 |
- }
|
|
| 140 |
- StorageUIModel sourceModel = ui.getCentralSourceModel();
|
|
| 141 |
- StorageUILauncher.obtainConnexion(ui, ui.getParentContainer(Window.class), sourceModel);
|
|
| 142 |
- AdminUIModel model = ui.getModel();
|
|
| 143 |
- model.getConfigModel().removeCentralSource();
|
|
| 144 |
- model.getConfigModel().getCentralSourceModel().validate(StorageStep.CONFIG);
|
|
| 145 |
- model.validate();
|
|
| 146 |
- }
|
|
| 100 |
+// public void obtainIncomingConnexion() {
|
|
| 101 |
+// StorageUIModel sourceModel = ui.getLocalSourceModel();
|
|
| 102 |
+// StorageUILauncher.obtainConnexion(ui, ui.getParentContainer(Window.class), sourceModel);
|
|
| 103 |
+// if (log.isDebugEnabled()) {
|
|
| 104 |
+// log.debug("After modifiy source model isValid : " + sourceModel.isValid() + " / " + sourceModel.isValidStep());
|
|
| 105 |
+// }
|
|
| 106 |
+// AdminUIModel model = ui.getModel();
|
|
| 107 |
+// model.getConfigModel().removeLocalSource();
|
|
| 108 |
+// model.getConfigModel().getLocalSourceModel().validate();
|
|
| 109 |
+// model.validate();
|
|
| 110 |
+// }
|
|
| 111 |
+//
|
|
| 112 |
+// public void obtainRemoteConnexion() {
|
|
| 113 |
+// if (log.isInfoEnabled()) {
|
|
| 114 |
+// log.info("start obtain remote connexion");
|
|
| 115 |
+// }
|
|
| 116 |
+// StorageUIModel sourceModel = ui.getCentralSourceModel();
|
|
| 117 |
+// StorageUILauncher.obtainConnexion(ui, ui.getParentContainer(Window.class), sourceModel);
|
|
| 118 |
+// AdminUIModel model = ui.getModel();
|
|
| 119 |
+// model.getConfigModel().removeCentralSource();
|
|
| 120 |
+// model.getConfigModel().getCentralSourceModel().validate(StorageStep.CONFIG);
|
|
| 121 |
+// model.validate();
|
|
| 122 |
+// }
|
|
| 147 | 123 |
|
| 148 | 124 |
protected String updateDataSourcePolicy(StorageUIModel sourceModel, boolean valid) {
|
| 149 | 125 |
String text = null;
|
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.content; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| ... | ... | @@ -30,8 +30,8 @@ import fr.ird.observe.client.ui.ObserveMainUI; |
| 30 | 30 |
import fr.ird.observe.client.ui.actions.UIActionSupport;
|
| 31 | 31 |
import fr.ird.observe.client.ui.actions.main.global.GlobalUIActionSupport;
|
| 32 | 32 |
import org.apache.commons.beanutils.ConstructorUtils;
|
| 33 |
-import org.apache.logging.log4j.Logger;
|
|
| 34 | 33 |
import org.apache.logging.log4j.LogManager;
|
| 34 |
+import org.apache.logging.log4j.Logger;
|
|
| 35 | 35 |
import org.reflections.Reflections;
|
| 36 | 36 |
|
| 37 | 37 |
import javax.swing.AbstractButton;
|
| ... | ... | @@ -163,4 +163,16 @@ public class ObserveActionMap extends ActionMap { |
| 163 | 163 |
|
| 164 | 164 |
}
|
| 165 | 165 |
|
| 166 |
+ public <A extends UIActionSupport> A newAction(String key, Object args) {
|
|
| 167 |
+ |
|
| 168 |
+ try {
|
|
| 169 |
+ @SuppressWarnings("unchecked") Class<A> actionType = (Class<A>) Class.forName(key);
|
|
| 170 |
+ log.debug("Create action: " + key + ", type: " + actionType.getName());
|
|
| 171 |
+ return ConstructorUtils.invokeConstructor(actionType, new Object[]{ui, args}, new Class[]{ObserveMainUI.class, args.getClass()});
|
|
| 172 |
+ } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
|
|
| 173 |
+ throw new ObserveSwingTechnicalException("Hum, can't creation action for type: " + key, e);
|
|
| 174 |
+ }
|
|
| 175 |
+ |
|
| 176 |
+ }
|
|
| 177 |
+ |
|
| 166 | 178 |
}
|
| ... | ... | @@ -590,15 +590,17 @@ public class StorageUIModel extends WizardModel<StorageStep> { |
| 590 | 590 |
|
| 591 | 591 |
public void start(DbMode dbMode) {
|
| 592 | 592 |
|
| 593 |
- if (log.isDebugEnabled()) {
|
|
| 594 |
- log.debug("Will use dbMode : " + dbMode + " vs previous mode " + getDbMode());
|
|
| 595 |
- }
|
|
| 593 |
+ boolean testRemote = dataSourceInformation != null;
|
|
| 594 |
+ |
|
| 595 |
+ log.debug("Will use dbMode : " + dbMode + " vs previous mode " + getDbMode());
|
|
| 596 | 596 |
setDbMode(dbMode);
|
| 597 | 597 |
|
| 598 | 598 |
startCentralSourceModel();
|
| 599 | 599 |
startCentralDataSourceModel();
|
| 600 | 600 |
|
| 601 | 601 |
start();
|
| 602 |
+ |
|
| 603 |
+ |
|
| 602 | 604 |
firePropertyChange(DB_MODE_PROPERTY_NAME, getDbMode());
|
| 603 | 605 |
firePropertyChange(CREATION_MODE_PROPERTY_NAME, getCreationMode());
|
| 604 | 606 |
firePropertyChange(DUMP_FILE_PROPERTY_NAME, getDumpFile());
|
| ... | ... | @@ -623,6 +625,11 @@ public class StorageUIModel extends WizardModel<StorageStep> { |
| 623 | 625 |
firePropertyChange(CAN_MIGRATE_PROPERTY_NAME, isCanMigrate());
|
| 624 | 626 |
firePropertyChange(SHOW_MIGRATION_SQL_PROPERTY_NAME, isShowMigrationSql());
|
| 625 | 627 |
firePropertyChange(SHOW_MIGRATION_PROGRESSION_PROPERTY_NAME, isShowMigrationProgression());
|
| 628 |
+ |
|
| 629 |
+ if (testRemote && !isLocal()) {
|
|
| 630 |
+ log.info("Test previous data source configuration...");
|
|
| 631 |
+ testRemote();
|
|
| 632 |
+ }
|
|
| 626 | 633 |
}
|
| 627 | 634 |
|
| 628 | 635 |
public boolean isCanUseLocalService() {
|
| ... | ... | @@ -1130,7 +1137,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { |
| 1130 | 1137 |
boolean oldValue = this.localStorageExist;
|
| 1131 | 1138 |
this.localStorageExist = localStorageExist;
|
| 1132 | 1139 |
firePropertyChange(LOCAL_STORAGE_EXIST_PROPERTY_NAME, oldValue,
|
| 1133 |
- localStorageExist);
|
|
| 1140 |
+ localStorageExist);
|
|
| 1134 | 1141 |
validate();
|
| 1135 | 1142 |
}
|
| 1136 | 1143 |
|
| ... | ... | @@ -1585,10 +1592,13 @@ public class StorageUIModel extends WizardModel<StorageStep> { |
| 1585 | 1592 |
config = pgConfig;
|
| 1586 | 1593 |
} else if (isEditServerConfig()) {
|
| 1587 | 1594 |
try {
|
| 1588 |
- URL url = new URL(serverUrl);
|
|
| 1595 |
+ if (restConfig.getServerUrl() != null && serverUrl == null) {
|
|
| 1589 | 1596 |
|
| 1590 |
- restConfig.setServerUrl(url);
|
|
| 1597 |
+ } else {
|
|
| 1598 |
+ URL url = new URL(serverUrl);
|
|
| 1591 | 1599 |
|
| 1600 |
+ restConfig.setServerUrl(url);
|
|
| 1601 |
+ }
|
|
| 1592 | 1602 |
config = restConfig;
|
| 1593 | 1603 |
|
| 1594 | 1604 |
} catch (MalformedURLException e) {
|