Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
08505b7c
by Tony CHEMIT at 2017-08-17T16:17:45+02:00
26 changed files:
- client/src/main/java/fr/ird/observe/client/ui/actions/UIActionSupport.java
- client/src/main/java/fr/ird/observe/client/ui/actions/main/global/DeleteDataGlobalUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/main/global/NewNextDataGlobalUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/main/global/ResetDataGlobalUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/main/global/SaveDataGlobalUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/storage/SaveCurrentRemoteConfigurationUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/storage/SaveCurrentServerConfigurationUIAction.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/storage/presets/CreatePresetUIAction.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/storage/presets/DeleteRemoteUIAction.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/storage/presets/DeleteServerUIAction.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/storage/presets/PresetsUIActionSupport.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/storage/presets/QuitPresetsUIAction.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/storage/presets/ResetRemoteUIAction.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/storage/presets/ResetServerUIAction.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/storage/presets/SaveRemoteUIAction.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/storage/presets/SaveServerUIAction.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/storage/presets/TestRemoteUIAction.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/storage/presets/TestServerUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/storage/StorageUIModel.java
- client/src/main/java/fr/ird/observe/client/ui/storage/presets/RemotePresetsUI.jaxx
- client/src/main/java/fr/ird/observe/client/ui/storage/presets/RemotePresetsUI.jcss
- client/src/main/java/fr/ird/observe/client/ui/storage/presets/RemotePresetsUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/storage/presets/RemotePresetsUIModel.java
- client/src/main/resources/i18n/client_en_GB.properties
- client/src/main/resources/i18n/client_es_ES.properties
- client/src/main/resources/i18n/client_fr_FR.properties
Changes:
| ... | ... | @@ -53,7 +53,7 @@ public abstract class UIActionSupport extends AbstractAction { |
| 53 | 53 |
private static final long serialVersionUID = 1L;
|
| 54 | 54 |
|
| 55 | 55 |
public static final String EDITOR = "editor";
|
| 56 |
- protected static final String CLIENT_PROPERTY_UI = "ui";
|
|
| 56 |
+ public static final String CLIENT_PROPERTY_UI = "ui";
|
|
| 57 | 57 |
|
| 58 | 58 |
private final ObserveMainUI mainUI;
|
| 59 | 59 |
|
| ... | ... | @@ -24,10 +24,12 @@ package fr.ird.observe.client.ui.actions.main.global; |
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
| 26 | 26 |
import fr.ird.observe.client.ui.ObserveMainUI;
|
| 27 |
+import fr.ird.observe.client.ui.ObserveUIMode;
|
|
| 27 | 28 |
import fr.ird.observe.client.ui.actions.UIActionSupport;
|
| 28 | 29 |
import fr.ird.observe.client.ui.content.ContentUI;
|
| 29 | 30 |
import fr.ird.observe.client.ui.content.ref.ContentReferenceUI;
|
| 30 | 31 |
import fr.ird.observe.client.ui.content.table.ContentTableUI;
|
| 32 |
+import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
|
| 31 | 33 |
import java.util.Objects;
|
| 32 | 34 |
import javax.swing.JButton;
|
| 33 | 35 |
|
| ... | ... | @@ -47,19 +49,35 @@ public class DeleteDataGlobalUIAction extends GlobalUIActionSupport { |
| 47 | 49 |
|
| 48 | 50 |
@Override
|
| 49 | 51 |
protected UIActionSupport getDelegateAction(ContentUI<?, ?> contentUI) {
|
| 50 |
- JButton button;
|
|
| 51 |
- if (contentUI instanceof ContentTableUI) {
|
|
| 52 |
- ContentTableUI ui = (ContentTableUI) contentUI;
|
|
| 53 |
- button = ui.getDeleteEntry();
|
|
| 54 |
- } else if (contentUI instanceof ContentReferenceUI) {
|
|
| 55 |
- ContentReferenceUI ui = (ContentReferenceUI) contentUI;
|
|
| 56 |
- if (ui.getModel().isEditing()) {
|
|
| 57 |
- button = ui.getDeleteFromDetail();
|
|
| 58 |
- } else {
|
|
| 59 |
- button = ui.getDeleteFromList();
|
|
| 52 |
+ JButton button = null;
|
|
| 53 |
+ if (contentUI == null) {
|
|
| 54 |
+ |
|
| 55 |
+ if (ObserveUIMode.PRESETS == getMainUI().getModel().getMode()) {
|
|
| 56 |
+ RemotePresetsUI presetsUI = (RemotePresetsUI) getMainUI().getDataSourcePresets().getContentContainer();
|
|
| 57 |
+ switch (presetsUI.getTabs().getSelectedIndex()) {
|
|
| 58 |
+ case 0:
|
|
| 59 |
+ button = presetsUI.getDeleteRemoteAction();
|
|
| 60 |
+ break;
|
|
| 61 |
+ case 1:
|
|
| 62 |
+ button = presetsUI.getDeleteServerAction();
|
|
| 63 |
+ break;
|
|
| 64 |
+ |
|
| 65 |
+ }
|
|
| 60 | 66 |
}
|
| 61 | 67 |
} else {
|
| 62 |
- button = (JButton) contentUI.getObjectById("delete");
|
|
| 68 |
+ if (contentUI instanceof ContentTableUI) {
|
|
| 69 |
+ ContentTableUI ui = (ContentTableUI) contentUI;
|
|
| 70 |
+ button = ui.getDeleteEntry();
|
|
| 71 |
+ } else if (contentUI instanceof ContentReferenceUI) {
|
|
| 72 |
+ ContentReferenceUI ui = (ContentReferenceUI) contentUI;
|
|
| 73 |
+ if (ui.getModel().isEditing()) {
|
|
| 74 |
+ button = ui.getDeleteFromDetail();
|
|
| 75 |
+ } else {
|
|
| 76 |
+ button = ui.getDeleteFromList();
|
|
| 77 |
+ }
|
|
| 78 |
+ } else {
|
|
| 79 |
+ button = (JButton) contentUI.getObjectById("delete");
|
|
| 80 |
+ }
|
|
| 63 | 81 |
}
|
| 64 | 82 |
Objects.requireNonNull(button);
|
| 65 | 83 |
UIActionSupport action = (UIActionSupport) button.getAction();
|
| ... | ... | @@ -24,12 +24,14 @@ package fr.ird.observe.client.ui.actions.main.global; |
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
| 26 | 26 |
import fr.ird.observe.client.ui.ObserveMainUI;
|
| 27 |
+import fr.ird.observe.client.ui.ObserveUIMode;
|
|
| 27 | 28 |
import fr.ird.observe.client.ui.actions.UIActionSupport;
|
| 28 | 29 |
import fr.ird.observe.client.ui.content.ContentUI;
|
| 29 | 30 |
import fr.ird.observe.client.ui.content.list.ContentListUI;
|
| 30 | 31 |
import fr.ird.observe.client.ui.content.open.ContentOpenableUI;
|
| 31 | 32 |
import fr.ird.observe.client.ui.content.ref.ContentReferenceUI;
|
| 32 | 33 |
import fr.ird.observe.client.ui.content.table.ContentTableUI;
|
| 34 |
+import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
|
| 33 | 35 |
import javax.swing.JButton;
|
| 34 | 36 |
|
| 35 | 37 |
/**
|
| ... | ... | @@ -49,18 +51,27 @@ public class NewNextDataGlobalUIAction extends GlobalUIActionSupport { |
| 49 | 51 |
@Override
|
| 50 | 52 |
protected UIActionSupport getDelegateAction(ContentUI<?, ?> contentUI) {
|
| 51 | 53 |
JButton button = null;
|
| 52 |
- if (contentUI instanceof ContentListUI) {
|
|
| 53 |
- ContentListUI ui = (ContentListUI) contentUI;
|
|
| 54 |
- button = ui.getCreate();
|
|
| 55 |
- } else if (contentUI instanceof ContentOpenableUI) {
|
|
| 56 |
- ContentOpenableUI ui = (ContentOpenableUI) contentUI;
|
|
| 57 |
- button = ui.getCloseAndCreate();
|
|
| 58 |
- } else if (contentUI instanceof ContentTableUI) {
|
|
| 59 |
- ContentTableUI ui = (ContentTableUI) contentUI;
|
|
| 60 |
- button = ui.getNewEntry();
|
|
| 61 |
- } else if (contentUI instanceof ContentReferenceUI) {
|
|
| 62 |
- ContentReferenceUI ui = (ContentReferenceUI) contentUI;
|
|
| 63 |
- button = ui.getCreate();
|
|
| 54 |
+ if (contentUI == null) {
|
|
| 55 |
+ |
|
| 56 |
+ if (ObserveUIMode.PRESETS == getMainUI().getModel().getMode()) {
|
|
| 57 |
+ RemotePresetsUI presetsUI = (RemotePresetsUI) getMainUI().getDataSourcePresets().getContentContainer();
|
|
| 58 |
+ button = presetsUI.getCreateAction();
|
|
| 59 |
+ }
|
|
| 60 |
+ } else {
|
|
| 61 |
+ |
|
| 62 |
+ if (contentUI instanceof ContentListUI) {
|
|
| 63 |
+ ContentListUI ui = (ContentListUI) contentUI;
|
|
| 64 |
+ button = ui.getCreate();
|
|
| 65 |
+ } else if (contentUI instanceof ContentOpenableUI) {
|
|
| 66 |
+ ContentOpenableUI ui = (ContentOpenableUI) contentUI;
|
|
| 67 |
+ button = ui.getCloseAndCreate();
|
|
| 68 |
+ } else if (contentUI instanceof ContentTableUI) {
|
|
| 69 |
+ ContentTableUI ui = (ContentTableUI) contentUI;
|
|
| 70 |
+ button = ui.getNewEntry();
|
|
| 71 |
+ } else if (contentUI instanceof ContentReferenceUI) {
|
|
| 72 |
+ ContentReferenceUI ui = (ContentReferenceUI) contentUI;
|
|
| 73 |
+ button = ui.getCreate();
|
|
| 74 |
+ }
|
|
| 64 | 75 |
}
|
| 65 | 76 |
return button == null ? null : (UIActionSupport) button.getAction();
|
| 66 | 77 |
}
|
| ... | ... | @@ -24,8 +24,10 @@ package fr.ird.observe.client.ui.actions.main.global; |
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
| 26 | 26 |
import fr.ird.observe.client.ui.ObserveMainUI;
|
| 27 |
+import fr.ird.observe.client.ui.ObserveUIMode;
|
|
| 27 | 28 |
import fr.ird.observe.client.ui.actions.UIActionSupport;
|
| 28 | 29 |
import fr.ird.observe.client.ui.content.ContentUI;
|
| 30 |
+import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
|
| 29 | 31 |
import javax.swing.JButton;
|
| 30 | 32 |
|
| 31 | 33 |
/**
|
| ... | ... | @@ -45,7 +47,24 @@ public class ResetDataGlobalUIAction extends GlobalUIActionSupport { |
| 45 | 47 |
@Override
|
| 46 | 48 |
protected UIActionSupport getDelegateAction(ContentUI<?, ?> contentUI) {
|
| 47 | 49 |
UIActionSupport action = null;
|
| 48 |
- JButton button = (JButton) contentUI.getObjectById("reset");
|
|
| 50 |
+ JButton button = null;
|
|
| 51 |
+ if (contentUI == null) {
|
|
| 52 |
+ |
|
| 53 |
+ if (ObserveUIMode.PRESETS == getMainUI().getModel().getMode()) {
|
|
| 54 |
+ RemotePresetsUI presetsUI = (RemotePresetsUI) getMainUI().getDataSourcePresets().getContentContainer();
|
|
| 55 |
+ switch (presetsUI.getTabs().getSelectedIndex()) {
|
|
| 56 |
+ case 0:
|
|
| 57 |
+ button = presetsUI.getResetRemoteAction();
|
|
| 58 |
+ break;
|
|
| 59 |
+ case 1:
|
|
| 60 |
+ button = presetsUI.getResetServerAction();
|
|
| 61 |
+ break;
|
|
| 62 |
+ |
|
| 63 |
+ }
|
|
| 64 |
+ }
|
|
| 65 |
+ } else {
|
|
| 66 |
+ button = (JButton) contentUI.getObjectById("reset");
|
|
| 67 |
+ }
|
|
| 49 | 68 |
if (button != null) {
|
| 50 | 69 |
action = (UIActionSupport) button.getAction();
|
| 51 | 70 |
}
|
| ... | ... | @@ -24,8 +24,10 @@ package fr.ird.observe.client.ui.actions.main.global; |
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
| 26 | 26 |
import fr.ird.observe.client.ui.ObserveMainUI;
|
| 27 |
+import fr.ird.observe.client.ui.ObserveUIMode;
|
|
| 27 | 28 |
import fr.ird.observe.client.ui.actions.UIActionSupport;
|
| 28 | 29 |
import fr.ird.observe.client.ui.content.ContentUI;
|
| 30 |
+import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
|
| 29 | 31 |
import javax.swing.JButton;
|
| 30 | 32 |
|
| 31 | 33 |
/**
|
| ... | ... | @@ -45,7 +47,25 @@ public class SaveDataGlobalUIAction extends GlobalUIActionSupport { |
| 45 | 47 |
@Override
|
| 46 | 48 |
protected UIActionSupport getDelegateAction(ContentUI<?, ?> contentUI) {
|
| 47 | 49 |
UIActionSupport action = null;
|
| 48 |
- JButton button = (JButton) contentUI.getObjectById("save");
|
|
| 50 |
+ |
|
| 51 |
+ JButton button = null;
|
|
| 52 |
+ if (contentUI == null) {
|
|
| 53 |
+ |
|
| 54 |
+ if (ObserveUIMode.PRESETS == getMainUI().getModel().getMode()) {
|
|
| 55 |
+ RemotePresetsUI presetsUI = (RemotePresetsUI) getMainUI().getDataSourcePresets().getContentContainer();
|
|
| 56 |
+ switch (presetsUI.getTabs().getSelectedIndex()) {
|
|
| 57 |
+ case 0:
|
|
| 58 |
+ button = presetsUI.getSaveRemoteAction();
|
|
| 59 |
+ break;
|
|
| 60 |
+ case 1:
|
|
| 61 |
+ button = presetsUI.getSaveServerAction();
|
|
| 62 |
+ break;
|
|
| 63 |
+ |
|
| 64 |
+ }
|
|
| 65 |
+ }
|
|
| 66 |
+ } else {
|
|
| 67 |
+ button = (JButton) contentUI.getObjectById("save");
|
|
| 68 |
+ }
|
|
| 49 | 69 |
if (button != null) {
|
| 50 | 70 |
action = (UIActionSupport) button.getAction();
|
| 51 | 71 |
}
|
| ... | ... | @@ -24,10 +24,10 @@ package fr.ird.observe.client.ui.actions.storage; |
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.ObserveSwingApplicationContext;
|
| 26 | 26 |
import fr.ird.observe.client.ui.ObserveMainUI;
|
| 27 |
-import fr.ird.observe.client.ui.util.UIHelper;
|
|
| 28 | 27 |
import fr.ird.observe.client.ui.actions.main.menu.MenuActionSupport;
|
| 29 | 28 |
import fr.ird.observe.client.ui.storage.StorageUIModel;
|
| 30 | 29 |
import fr.ird.observe.client.ui.storage.tabs.ConfigUI;
|
| 30 |
+import fr.ird.observe.client.ui.util.UIHelper;
|
|
| 31 | 31 |
import fr.ird.observe.services.dto.presets.RemoteDataSourceConfiguration;
|
| 32 | 32 |
import java.awt.Dimension;
|
| 33 | 33 |
import java.awt.GridLayout;
|
| ... | ... | @@ -118,6 +118,6 @@ public class SaveCurrentRemoteConfigurationUIAction extends MenuActionSupport { |
| 118 | 118 |
configuration.setPassword(new String(model.getRemotePassword()));
|
| 119 | 119 |
configuration.setUseSsl(model.isUseSsl());
|
| 120 | 120 |
ObserveSwingApplicationContext.get().getConfig().addRemoteDataSourceConfiguration(configuration);
|
| 121 |
- configUI.getHandler().addRemoteConfiguration(configuration);
|
|
| 121 |
+ configUI.getHandler().addRemoteConfiguration(getMainUI(), configuration, configUI.getRemoteMenu().getComponentCount() - 2);
|
|
| 122 | 122 |
}
|
| 123 | 123 |
}
|
| ... | ... | @@ -23,10 +23,10 @@ package fr.ird.observe.client.ui.actions.storage; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.ui.ObserveMainUI;
|
| 26 |
-import fr.ird.observe.client.ui.util.UIHelper;
|
|
| 27 | 26 |
import fr.ird.observe.client.ui.actions.main.menu.MenuActionSupport;
|
| 28 | 27 |
import fr.ird.observe.client.ui.storage.StorageUIModel;
|
| 29 | 28 |
import fr.ird.observe.client.ui.storage.tabs.ConfigUI;
|
| 29 |
+import fr.ird.observe.client.ui.util.UIHelper;
|
|
| 30 | 30 |
import fr.ird.observe.services.dto.presets.ServerDataSourceConfiguration;
|
| 31 | 31 |
import java.awt.Dimension;
|
| 32 | 32 |
import java.awt.GridLayout;
|
| ... | ... | @@ -59,10 +59,6 @@ public class SaveCurrentServerConfigurationUIAction extends MenuActionSupport { |
| 59 | 59 |
super(mainUI, ACTION_NAME, t("observe.storage.serverConfiguration.presets.save"), t("observe.storage.serverConfiguration.presets.save"), "save", 'S');
|
| 60 | 60 |
}
|
| 61 | 61 |
|
| 62 |
- public SaveCurrentServerConfigurationUIAction(ConfigUI mainUI) {
|
|
| 63 |
- super(null, ACTION_NAME, t("observe.storage.serverConfiguration.presets.save"), t("observe.storage.serverConfiguration.presets.save"), "save", 'S');
|
|
| 64 |
- }
|
|
| 65 |
- |
|
| 66 | 62 |
@Override
|
| 67 | 63 |
protected void doActionPerformed(ActionEvent e) {
|
| 68 | 64 |
|
| ... | ... | @@ -122,7 +118,7 @@ public class SaveCurrentServerConfigurationUIAction extends MenuActionSupport { |
| 122 | 118 |
configuration.setDatabaseName(model.getServerDatabase());
|
| 123 | 119 |
getMainUI().getConfig().addServerDataSourceConfiguration(configuration);
|
| 124 | 120 |
|
| 125 |
- configUI.getHandler().addServerConfiguration(configuration);
|
|
| 121 |
+ configUI.getHandler().addServerConfiguration(getMainUI(), configuration, configUI.getServerMenu().getComponentCount() - 2);
|
|
| 126 | 122 |
}
|
| 127 | 123 |
}
|
| 128 | 124 |
|
| 1 |
+package fr.ird.observe.client.ui.actions.storage.presets;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2017 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.storage.presets.RemotePresetsUI;
|
|
| 28 |
+import fr.ird.observe.services.dto.presets.RemoteDataSourceConfiguration;
|
|
| 29 |
+import fr.ird.observe.services.dto.presets.ServerDataSourceConfiguration;
|
|
| 30 |
+import java.util.ArrayList;
|
|
| 31 |
+import java.util.List;
|
|
| 32 |
+ |
|
| 33 |
+ |
|
| 34 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 35 |
+ |
|
| 36 |
+/**
|
|
| 37 |
+ * Created by tchemit on 17/08/17.
|
|
| 38 |
+ *
|
|
| 39 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 40 |
+ */
|
|
| 41 |
+public class CreatePresetUIAction extends PresetsUIActionSupport {
|
|
| 42 |
+ |
|
| 43 |
+ public static final String ACTION_NAME = CreatePresetUIAction.class.getName();
|
|
| 44 |
+ |
|
| 45 |
+ public CreatePresetUIAction(ObserveMainUI mainUI) {
|
|
| 46 |
+ super(mainUI, ACTION_NAME, n("observe.action.presets.create"), n("observe.action.presets.create.tip"), "add", ObserveKeyStrokes.KEY_STROKE_NEW_NEXT_DATA);
|
|
| 47 |
+ }
|
|
| 48 |
+ |
|
| 49 |
+ @Override
|
|
| 50 |
+ protected void doActionPerformed(RemotePresetsUI ui) {
|
|
| 51 |
+ |
|
| 52 |
+ switch (ui.getTabs().getSelectedIndex()) {
|
|
| 53 |
+ case 0: {
|
|
| 54 |
+ RemoteDataSourceConfiguration configuration = new RemoteDataSourceConfiguration();
|
|
| 55 |
+ configuration.setName("Change me");
|
|
| 56 |
+ List<RemoteDataSourceConfiguration> configurations = new ArrayList<>(ui.getModel().getRemoteDataSourceConfigurations());
|
|
| 57 |
+ configurations.add(configuration);
|
|
| 58 |
+ ui.getModel().setRemoteDataSourceConfigurations(configurations);
|
|
| 59 |
+ |
|
| 60 |
+ ui.getRemoteConfigurations().setSelectedValue(configuration, true);
|
|
| 61 |
+ }
|
|
| 62 |
+ break;
|
|
| 63 |
+ case 1: {
|
|
| 64 |
+ ServerDataSourceConfiguration configuration = new ServerDataSourceConfiguration();
|
|
| 65 |
+ configuration.setName("Change me");
|
|
| 66 |
+ |
|
| 67 |
+ List<ServerDataSourceConfiguration> configurations = new ArrayList<>(ui.getModel().getServerDataSourceConfigurations());
|
|
| 68 |
+ configurations.add(configuration);
|
|
| 69 |
+ ui.getModel().setServerDataSourceConfigurations(configurations);
|
|
| 70 |
+ ui.getServerConfigurations().setSelectedValue(configuration, true);
|
|
| 71 |
+ }
|
|
| 72 |
+ break;
|
|
| 73 |
+ }
|
|
| 74 |
+ |
|
| 75 |
+ }
|
|
| 76 |
+}
|
| 1 |
+package fr.ird.observe.client.ui.actions.storage.presets;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2017 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.ObserveSwingApplicationContext;
|
|
| 26 |
+import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
|
| 27 |
+import fr.ird.observe.client.ui.ObserveMainUI;
|
|
| 28 |
+import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
|
| 29 |
+import fr.ird.observe.client.ui.util.UIHelper;
|
|
| 30 |
+import fr.ird.observe.services.dto.presets.RemoteDataSourceConfiguration;
|
|
| 31 |
+import fr.ird.observe.services.dto.presets.ServerDataSourceConfiguration;
|
|
| 32 |
+import java.util.ArrayList;
|
|
| 33 |
+import java.util.List;
|
|
| 34 |
+import javax.swing.JOptionPane;
|
|
| 35 |
+import org.nuiton.decorator.Decorator;
|
|
| 36 |
+ |
|
| 37 |
+ |
|
| 38 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 39 |
+import static org.nuiton.i18n.I18n.t;
|
|
| 40 |
+ |
|
| 41 |
+/**
|
|
| 42 |
+ * Created by tchemit on 17/08/17.
|
|
| 43 |
+ *
|
|
| 44 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 45 |
+ */
|
|
| 46 |
+public class DeleteRemoteUIAction extends PresetsUIActionSupport {
|
|
| 47 |
+ |
|
| 48 |
+ public static final String ACTION_NAME = DeleteRemoteUIAction.class.getName();
|
|
| 49 |
+ |
|
| 50 |
+ public DeleteRemoteUIAction(ObserveMainUI mainUI) {
|
|
| 51 |
+ super(mainUI, ACTION_NAME, n("observe.action.delete"), n("observe.action.delete.remote.tip"), "delete", ObserveKeyStrokes.KEY_STROKE_DELETE_DATA_GLOBAL);
|
|
| 52 |
+ }
|
|
| 53 |
+ |
|
| 54 |
+ @Override
|
|
| 55 |
+ protected void doActionPerformed(RemotePresetsUI ui) {
|
|
| 56 |
+ |
|
| 57 |
+ Decorator<RemoteDataSourceConfiguration> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(RemoteDataSourceConfiguration.class);
|
|
| 58 |
+ RemoteDataSourceConfiguration configuration = ui.getModel().getRemoteDataSourceConfiguration();
|
|
| 59 |
+ int response = UIHelper.askUser(t("observe.storage.presets.delete.title"),
|
|
| 60 |
+ t("observe.storage.presets.delete.message", decorator.toString(configuration)),
|
|
| 61 |
+ JOptionPane.QUESTION_MESSAGE,
|
|
| 62 |
+ new Object[]{t("observe.action.delete"), t("observe.action.cancel")},
|
|
| 63 |
+ 0);
|
|
| 64 |
+ boolean delete = response == 0;
|
|
| 65 |
+ |
|
| 66 |
+ if (delete) {
|
|
| 67 |
+
|
|
| 68 |
+ List<RemoteDataSourceConfiguration> configurations = new ArrayList<>(ui.getModel().getRemoteDataSourceConfigurations());
|
|
| 69 |
+ configurations.remove(configuration);
|
|
| 70 |
+ ui.getModel().setRemoteDataSourceConfigurations(configurations);
|
|
| 71 |
+ ObserveSwingApplicationContext.get().getConfig().removeRemoteDataSourceConfiguration(configuration);
|
|
| 72 |
+ ui.getModel().setRemoteDataSourceConfiguration(null);
|
|
| 73 |
+ }
|
|
| 74 |
+ }
|
|
| 75 |
+}
|
| 1 |
+package fr.ird.observe.client.ui.actions.storage.presets;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2017 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.ObserveSwingApplicationContext;
|
|
| 26 |
+import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
|
| 27 |
+import fr.ird.observe.client.ui.ObserveMainUI;
|
|
| 28 |
+import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
|
| 29 |
+import fr.ird.observe.client.ui.util.UIHelper;
|
|
| 30 |
+import fr.ird.observe.services.dto.presets.ServerDataSourceConfiguration;
|
|
| 31 |
+import java.util.ArrayList;
|
|
| 32 |
+import java.util.List;
|
|
| 33 |
+import javax.swing.JOptionPane;
|
|
| 34 |
+import org.nuiton.decorator.Decorator;
|
|
| 35 |
+ |
|
| 36 |
+ |
|
| 37 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 38 |
+import static org.nuiton.i18n.I18n.t;
|
|
| 39 |
+ |
|
| 40 |
+/**
|
|
| 41 |
+ * Created by tchemit on 17/08/17.
|
|
| 42 |
+ *
|
|
| 43 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 44 |
+ */
|
|
| 45 |
+public class DeleteServerUIAction extends PresetsUIActionSupport {
|
|
| 46 |
+ |
|
| 47 |
+ public static final String ACTION_NAME = DeleteServerUIAction.class.getName();
|
|
| 48 |
+ |
|
| 49 |
+ public DeleteServerUIAction(ObserveMainUI mainUI) {
|
|
| 50 |
+ super(mainUI, ACTION_NAME, n("observe.action.delete"), n("observe.action.delete.server.tip"), "delete", ObserveKeyStrokes.KEY_STROKE_DELETE_DATA_GLOBAL);
|
|
| 51 |
+ }
|
|
| 52 |
+ |
|
| 53 |
+ @Override
|
|
| 54 |
+ protected void doActionPerformed(RemotePresetsUI ui) {
|
|
| 55 |
+ |
|
| 56 |
+ Decorator<ServerDataSourceConfiguration> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(ServerDataSourceConfiguration.class);
|
|
| 57 |
+ ServerDataSourceConfiguration configuration = ui.getModel().getServerDataSourceConfiguration();
|
|
| 58 |
+ |
|
| 59 |
+ int response = UIHelper.askUser(t("observe.storage.presets.delete.title"),
|
|
| 60 |
+ t("observe.storage.presets.delete.message", decorator.toString(configuration)),
|
|
| 61 |
+ JOptionPane.QUESTION_MESSAGE,
|
|
| 62 |
+ new Object[]{t("observe.action.delete"), t("observe.action.cancel")},
|
|
| 63 |
+ 0
|
|
| 64 |
+ );
|
|
| 65 |
+ boolean delete = response == 0;
|
|
| 66 |
+ |
|
| 67 |
+ if (delete) {
|
|
| 68 |
+ |
|
| 69 |
+ List<ServerDataSourceConfiguration> configurations = new ArrayList<>(ui.getModel().getServerDataSourceConfigurations());
|
|
| 70 |
+ configurations.remove(configuration);
|
|
| 71 |
+ ui.getModel().setServerDataSourceConfigurations(configurations);
|
|
| 72 |
+ ObserveSwingApplicationContext.get().getConfig().removeServerDataSourceConfiguration(configuration);
|
|
| 73 |
+ ui.getModel().setServerDataSourceConfiguration(null);
|
|
| 74 |
+ }
|
|
| 75 |
+ |
|
| 76 |
+ }
|
|
| 77 |
+}
|
| 1 |
+package fr.ird.observe.client.ui.actions.storage.presets;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2017 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.ObserveMainUI;
|
|
| 26 |
+import fr.ird.observe.client.ui.actions.UIActionSupport;
|
|
| 27 |
+import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
|
| 28 |
+import java.awt.event.ActionEvent;
|
|
| 29 |
+import javax.swing.KeyStroke;
|
|
| 30 |
+ |
|
| 31 |
+/**
|
|
| 32 |
+ * Created by tchemit on 17/08/17.
|
|
| 33 |
+ *
|
|
| 34 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 35 |
+ */
|
|
| 36 |
+public abstract class PresetsUIActionSupport extends UIActionSupport {
|
|
| 37 |
+ |
|
| 38 |
+ PresetsUIActionSupport(ObserveMainUI mainUI, String actionName, String label, String tip, String actionIcon, KeyStroke keyStroke) {
|
|
| 39 |
+ super(mainUI, actionName, label, tip, actionIcon, keyStroke);
|
|
| 40 |
+ }
|
|
| 41 |
+ PresetsUIActionSupport(ObserveMainUI mainUI, String actionName, String label, String tip, String actionIcon, char keyStroke) {
|
|
| 42 |
+ super(mainUI, actionName, label, tip, actionIcon, keyStroke);
|
|
| 43 |
+ }
|
|
| 44 |
+ |
|
| 45 |
+ protected abstract void doActionPerformed(RemotePresetsUI ui);
|
|
| 46 |
+ |
|
| 47 |
+ @Override
|
|
| 48 |
+ public void actionPerformed(ActionEvent event) {
|
|
| 49 |
+ if (!getEditor().isShowing()) {
|
|
| 50 |
+ return;
|
|
| 51 |
+ }
|
|
| 52 |
+ |
|
| 53 |
+ RemotePresetsUI ui = (RemotePresetsUI) getEditor().getClientProperty(CLIENT_PROPERTY_UI);
|
|
| 54 |
+ |
|
| 55 |
+ doActionPerformed(ui);
|
|
| 56 |
+ |
|
| 57 |
+ }
|
|
| 58 |
+}
|
| 1 |
+package fr.ird.observe.client.ui.actions.storage.presets;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2017 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.ObserveSwingApplicationContext;
|
|
| 26 |
+import fr.ird.observe.client.ui.ObserveMainUI;
|
|
| 27 |
+import fr.ird.observe.client.ui.ObserveUIMode;
|
|
| 28 |
+import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
|
| 29 |
+import javax.swing.JPanel;
|
|
| 30 |
+ |
|
| 31 |
+ |
|
| 32 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 33 |
+ |
|
| 34 |
+/**
|
|
| 35 |
+ * Created by tchemit on 17/08/17.
|
|
| 36 |
+ *
|
|
| 37 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 38 |
+ */
|
|
| 39 |
+public class QuitPresetsUIAction extends PresetsUIActionSupport {
|
|
| 40 |
+ |
|
| 41 |
+ public static final String ACTION_NAME = QuitPresetsUIAction.class.getName();
|
|
| 42 |
+ |
|
| 43 |
+ public QuitPresetsUIAction(ObserveMainUI mainUI) {
|
|
| 44 |
+ super(mainUI, ACTION_NAME, n("observe.action.quit"), n("observe.action.quit.tip"), "exit", 'Q');
|
|
| 45 |
+ }
|
|
| 46 |
+ |
|
| 47 |
+ @Override
|
|
| 48 |
+ protected void doActionPerformed(RemotePresetsUI ui) {
|
|
| 49 |
+ |
|
| 50 |
+ ObserveMainUI mainUI = ObserveSwingApplicationContext.get().getMainUI();
|
|
| 51 |
+ mainUI.getDataSourcePresets().setContentContainer(new JPanel());
|
|
| 52 |
+ if (ObserveSwingApplicationContext.get().getDataSourcesManager().getMainDataSource() == null) {
|
|
| 53 |
+ mainUI.getModel().setMode(ObserveUIMode.NO_DB);
|
|
| 54 |
+ } else {
|
|
| 55 |
+ mainUI.getModel().setMode(ObserveUIMode.DB);
|
|
| 56 |
+ }
|
|
| 57 |
+ }
|
|
| 58 |
+}
|
| 1 |
+package fr.ird.observe.client.ui.actions.storage.presets;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2017 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.storage.presets.RemotePresetsUI;
|
|
| 28 |
+import fr.ird.observe.services.dto.presets.RemoteDataSourceConfiguration;
|
|
| 29 |
+ |
|
| 30 |
+ |
|
| 31 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 32 |
+ |
|
| 33 |
+/**
|
|
| 34 |
+ * Created by tchemit on 17/08/17.
|
|
| 35 |
+ *
|
|
| 36 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 37 |
+ */
|
|
| 38 |
+public class ResetRemoteUIAction extends PresetsUIActionSupport {
|
|
| 39 |
+ |
|
| 40 |
+ public static final String ACTION_NAME = ResetRemoteUIAction.class.getName();
|
|
| 41 |
+ |
|
| 42 |
+ public ResetRemoteUIAction(ObserveMainUI mainUI) {
|
|
| 43 |
+ super(mainUI, ACTION_NAME, n("observe.action.reset"), n("observe.action.reset.remote.tip"), "revert", ObserveKeyStrokes.KEY_STROKE_RESET_DATA);
|
|
| 44 |
+ }
|
|
| 45 |
+ |
|
| 46 |
+ @Override
|
|
| 47 |
+ protected void doActionPerformed(RemotePresetsUI ui) {
|
|
| 48 |
+ |
|
| 49 |
+ RemoteDataSourceConfiguration selectedValue = ui.getRemoteConfigurations().getSelectedValue();
|
|
| 50 |
+ |
|
| 51 |
+ ui.getModel().setRemoteDataSourceConfiguration(null);
|
|
| 52 |
+ ui.getModel().setRemoteDataSourceConfiguration(selectedValue);
|
|
| 53 |
+ |
|
| 54 |
+ }
|
|
| 55 |
+}
|
| 1 |
+package fr.ird.observe.client.ui.actions.storage.presets;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2017 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.storage.presets.RemotePresetsUI;
|
|
| 28 |
+import fr.ird.observe.services.dto.presets.ServerDataSourceConfiguration;
|
|
| 29 |
+ |
|
| 30 |
+ |
|
| 31 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 32 |
+ |
|
| 33 |
+/**
|
|
| 34 |
+ * Created by tchemit on 17/08/17.
|
|
| 35 |
+ *
|
|
| 36 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 37 |
+ */
|
|
| 38 |
+public class ResetServerUIAction extends PresetsUIActionSupport {
|
|
| 39 |
+ |
|
| 40 |
+ public static final String ACTION_NAME = ResetServerUIAction.class.getName();
|
|
| 41 |
+ |
|
| 42 |
+ public ResetServerUIAction(ObserveMainUI mainUI) {
|
|
| 43 |
+ super(mainUI, ACTION_NAME, n("observe.action.reset"), n("observe.action.reset.server.tip"), "revert", ObserveKeyStrokes.KEY_STROKE_RESET_DATA);
|
|
| 44 |
+ }
|
|
| 45 |
+ |
|
| 46 |
+ @Override
|
|
| 47 |
+ protected void doActionPerformed(RemotePresetsUI ui) {
|
|
| 48 |
+ |
|
| 49 |
+ ServerDataSourceConfiguration selectedValue = ui.getServerConfigurations().getSelectedValue();
|
|
| 50 |
+ ui.getModel().setServerDataSourceConfiguration(null);
|
|
| 51 |
+ ui.getModel().setServerDataSourceConfiguration(selectedValue);
|
|
| 52 |
+ |
|
| 53 |
+ }
|
|
| 54 |
+}
|
| 1 |
+package fr.ird.observe.client.ui.actions.storage.presets;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2017 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.ObserveSwingApplicationContext;
|
|
| 26 |
+import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
|
| 27 |
+import fr.ird.observe.client.ui.ObserveMainUI;
|
|
| 28 |
+import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
|
| 29 |
+import fr.ird.observe.services.dto.presets.RemoteDataSourceConfiguration;
|
|
| 30 |
+ |
|
| 31 |
+ |
|
| 32 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 33 |
+ |
|
| 34 |
+/**
|
|
| 35 |
+ * Created by tchemit on 17/08/17.
|
|
| 36 |
+ *
|
|
| 37 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 38 |
+ */
|
|
| 39 |
+public class SaveRemoteUIAction extends PresetsUIActionSupport {
|
|
| 40 |
+ |
|
| 41 |
+ public static final String ACTION_NAME = SaveRemoteUIAction.class.getName();
|
|
| 42 |
+ |
|
| 43 |
+ public SaveRemoteUIAction(ObserveMainUI mainUI) {
|
|
| 44 |
+ super(mainUI, ACTION_NAME, n("observe.action.save"), n("observe.action.save.remote.tip"), "save", ObserveKeyStrokes.KEY_STROKE_SAVE_DATA);
|
|
| 45 |
+ }
|
|
| 46 |
+ |
|
| 47 |
+ @Override
|
|
| 48 |
+ protected void doActionPerformed(RemotePresetsUI ui) {
|
|
| 49 |
+ |
|
| 50 |
+ RemoteDataSourceConfiguration remoteDataSourceConfiguration = ui.getModel().getRemoteDataSourceConfiguration();
|
|
| 51 |
+ |
|
| 52 |
+ remoteDataSourceConfiguration.setName(ui.getRemoteName().getText().trim());
|
|
| 53 |
+ remoteDataSourceConfiguration.setUrl(ui.getRemoteUrl().getText().trim());
|
|
| 54 |
+ remoteDataSourceConfiguration.setLogin(ui.getRemoteLogin().getText().trim());
|
|
| 55 |
+ remoteDataSourceConfiguration.setPassword(ui.getRemotePassword().getText().trim());
|
|
| 56 |
+ remoteDataSourceConfiguration.setUseSsl(ui.getRemoteUseSsl().isSelected());
|
|
| 57 |
+ |
|
| 58 |
+ ObserveSwingApplicationContext.get().getConfig().updateRemoteDataSourceConfiguration(remoteDataSourceConfiguration);
|
|
| 59 |
+ |
|
| 60 |
+ ui.getModel().setRemoteDataSourceConfiguration(null);
|
|
| 61 |
+ ui.getModel().setRemoteDataSourceConfiguration(remoteDataSourceConfiguration);
|
|
| 62 |
+ ui.getModel().setRemoteModified(false);
|
|
| 63 |
+ |
|
| 64 |
+ }
|
|
| 65 |
+}
|
| 1 |
+package fr.ird.observe.client.ui.actions.storage.presets;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2017 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.ObserveSwingApplicationContext;
|
|
| 26 |
+import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
|
| 27 |
+import fr.ird.observe.client.ui.ObserveMainUI;
|
|
| 28 |
+import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
|
| 29 |
+import fr.ird.observe.services.dto.presets.ServerDataSourceConfiguration;
|
|
| 30 |
+ |
|
| 31 |
+ |
|
| 32 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 33 |
+ |
|
| 34 |
+/**
|
|
| 35 |
+ * Created by tchemit on 17/08/17.
|
|
| 36 |
+ *
|
|
| 37 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 38 |
+ */
|
|
| 39 |
+public class SaveServerUIAction extends PresetsUIActionSupport {
|
|
| 40 |
+ |
|
| 41 |
+ public static final String ACTION_NAME = SaveServerUIAction.class.getName();
|
|
| 42 |
+ |
|
| 43 |
+ public SaveServerUIAction(ObserveMainUI mainUI) {
|
|
| 44 |
+ super(mainUI, ACTION_NAME, n("observe.action.save"), n("observe.action.save.server.tip"), "save", ObserveKeyStrokes.KEY_STROKE_SAVE_DATA);
|
|
| 45 |
+ }
|
|
| 46 |
+ |
|
| 47 |
+ @Override
|
|
| 48 |
+ protected void doActionPerformed(RemotePresetsUI ui) {
|
|
| 49 |
+ |
|
| 50 |
+ ServerDataSourceConfiguration serverDataSourceConfiguration = ui.getModel().getServerDataSourceConfiguration();
|
|
| 51 |
+ |
|
| 52 |
+ serverDataSourceConfiguration.setName(ui.getServerName().getText().trim());
|
|
| 53 |
+ serverDataSourceConfiguration.setUrl(ui.getServerUrl().getText().trim());
|
|
| 54 |
+ serverDataSourceConfiguration.setLogin(ui.getServerLogin().getText().trim());
|
|
| 55 |
+ serverDataSourceConfiguration.setPassword(ui.getServerPassword().getText().trim());
|
|
| 56 |
+ String databaseName = ui.getServerDataBase().getText().trim();
|
|
| 57 |
+ serverDataSourceConfiguration.setDatabaseName(databaseName.isEmpty() ? null : databaseName);
|
|
| 58 |
+ |
|
| 59 |
+ ObserveSwingApplicationContext.get().getConfig().updateServerDataSourceConfiguration(serverDataSourceConfiguration);
|
|
| 60 |
+ |
|
| 61 |
+ ui.getModel().setServerDataSourceConfiguration(null);
|
|
| 62 |
+ ui.getModel().setServerDataSourceConfiguration(serverDataSourceConfiguration);
|
|
| 63 |
+ ui.getModel().setServerModified(false);
|
|
| 64 |
+ |
|
| 65 |
+ }
|
|
| 66 |
+}
|
| 1 |
+package fr.ird.observe.client.ui.actions.storage.presets;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2017 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.ObserveSwingApplicationContext;
|
|
| 26 |
+import fr.ird.observe.client.db.ObserveSwingDataSource;
|
|
| 27 |
+import fr.ird.observe.client.ui.ObserveMainUI;
|
|
| 28 |
+import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
|
| 29 |
+import fr.ird.observe.client.ui.util.UIHelper;
|
|
| 30 |
+import fr.ird.observe.services.configuration.ObserveDataSourceInformation;
|
|
| 31 |
+import fr.ird.observe.services.configuration.topia.ObserveDataSourceConfigurationTopiaPG;
|
|
| 32 |
+import fr.ird.observe.services.security.BadObserveWebUserPasswordException;
|
|
| 33 |
+import fr.ird.observe.services.security.UnknownObserveWebUserException;
|
|
| 34 |
+import fr.ird.observe.services.security.UnknownObserveWebUserForDatabaseException;
|
|
| 35 |
+import fr.ird.observe.services.security.UserLoginNotFoundException;
|
|
| 36 |
+import fr.ird.observe.services.security.UserPasswordNotFoundException;
|
|
| 37 |
+import org.nuiton.version.Version;
|
|
| 38 |
+ |
|
| 39 |
+ |
|
| 40 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 41 |
+import static org.nuiton.i18n.I18n.t;
|
|
| 42 |
+ |
|
| 43 |
+/**
|
|
| 44 |
+ * Created by tchemit on 17/08/17.
|
|
| 45 |
+ *
|
|
| 46 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 47 |
+ */
|
|
| 48 |
+public class TestRemoteUIAction extends PresetsUIActionSupport {
|
|
| 49 |
+ |
|
| 50 |
+ public static final String ACTION_NAME = TestRemoteUIAction.class.getName();
|
|
| 51 |
+ |
|
| 52 |
+ public TestRemoteUIAction(ObserveMainUI mainUI) {
|
|
| 53 |
+ super(mainUI, ACTION_NAME, n("observe.action.test.remote"), n("observe.action.test.remote.tip"), "connect_creating", 'V');
|
|
| 54 |
+ }
|
|
| 55 |
+ |
|
| 56 |
+ @Override
|
|
| 57 |
+ protected void doActionPerformed(RemotePresetsUI ui) {
|
|
| 58 |
+ |
|
| 59 |
+ ObserveDataSourceConfigurationTopiaPG config = new ObserveDataSourceConfigurationTopiaPG();
|
|
| 60 |
+ config.setJdbcUrl(ui.getRemoteUrl().getText().trim());
|
|
| 61 |
+ config.setUsername(ui.getRemoteLogin().getText().trim());
|
|
| 62 |
+ config.setPassword(ui.getRemotePassword().getText().trim().toCharArray());
|
|
| 63 |
+ config.setUseSsl(ui.getRemoteUseSsl().isSelected());
|
|
| 64 |
+ |
|
| 65 |
+ String connexionStatusError = null;
|
|
| 66 |
+ |
|
| 67 |
+ Version modelVersion = ObserveSwingApplicationContext.get().getConfig().getModelVersion();
|
|
| 68 |
+ ObserveSwingDataSource dataSource = ObserveSwingApplicationContext.get().getDataSourcesManager().newDataSource(config);
|
|
| 69 |
+ try {
|
|
| 70 |
+ |
|
| 71 |
+ ObserveDataSourceInformation dataSourceInformation = dataSource.checkCanConnect();
|
|
| 72 |
+ |
|
| 73 |
+ Version versionDataSource = dataSourceInformation.getVersion();
|
|
| 74 |
+ |
|
| 75 |
+ // en mise a jour de la base on ne test pas la version
|
|
| 76 |
+ if (!modelVersion.equals(versionDataSource)) {
|
|
| 77 |
+ |
|
| 78 |
+ connexionStatusError = t("observe.storage.error.dbVersionMismatch", versionDataSource, modelVersion);
|
|
| 79 |
+ }
|
|
| 80 |
+ |
|
| 81 |
+ } catch (UnknownObserveWebUserException e) {
|
|
| 82 |
+ connexionStatusError = t("observe.storage.error.rest.user.unknown", e.getUserLogin());
|
|
| 83 |
+ } catch (BadObserveWebUserPasswordException e) {
|
|
| 84 |
+ connexionStatusError = t("observe.storage.error.rest.password.bad", e.getUserLogin());
|
|
| 85 |
+ } catch (UnknownObserveWebUserForDatabaseException e) {
|
|
| 86 |
+ connexionStatusError = t("observe.storage.error.rest.database.unknownForUser", e.getDatabaseName(), e.getRole());
|
|
| 87 |
+ } catch (UserLoginNotFoundException e) {
|
|
| 88 |
+ connexionStatusError = t("observe.storage.error.rest.user.required");
|
|
| 89 |
+ } catch (UserPasswordNotFoundException e) {
|
|
| 90 |
+ connexionStatusError = t("observe.storage.error.rest.password.required");
|
|
| 91 |
+ } catch (Exception e) {
|
|
| 92 |
+ connexionStatusError = e.getMessage();
|
|
| 93 |
+ if (connexionStatusError == null || connexionStatusError.isEmpty()) {
|
|
| 94 |
+ connexionStatusError = e.getClass().getName();
|
|
| 95 |
+ }
|
|
| 96 |
+ } finally {
|
|
| 97 |
+ if (dataSource.isOpen()) {
|
|
| 98 |
+ dataSource.close();
|
|
| 99 |
+ }
|
|
| 100 |
+ }
|
|
| 101 |
+ |
|
| 102 |
+ if (connexionStatusError == null) {
|
|
| 103 |
+ UIHelper.displayInfo("Test de connexion", "Le connexion a été établie avec succès.");
|
|
| 104 |
+ } else {
|
|
| 105 |
+ UIHelper.displayWarning("Test de connexion", "Le test de connexion a échoué :\n" + connexionStatusError);
|
|
| 106 |
+ }
|
|
| 107 |
+ |
|
| 108 |
+ }
|
|
| 109 |
+}
|
| 1 |
+package fr.ird.observe.client.ui.actions.storage.presets;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2017 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.ObserveSwingApplicationContext;
|
|
| 26 |
+import fr.ird.observe.client.db.ObserveSwingDataSource;
|
|
| 27 |
+import fr.ird.observe.client.ui.ObserveMainUI;
|
|
| 28 |
+import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
|
| 29 |
+import fr.ird.observe.client.ui.util.UIHelper;
|
|
| 30 |
+import fr.ird.observe.services.configuration.ObserveDataSourceInformation;
|
|
| 31 |
+import fr.ird.observe.services.configuration.rest.ObserveDataSourceConfigurationRest;
|
|
| 32 |
+import fr.ird.observe.services.security.BadObserveWebUserPasswordException;
|
|
| 33 |
+import fr.ird.observe.services.security.UnknownObserveWebUserException;
|
|
| 34 |
+import fr.ird.observe.services.security.UnknownObserveWebUserForDatabaseException;
|
|
| 35 |
+import fr.ird.observe.services.security.UserLoginNotFoundException;
|
|
| 36 |
+import fr.ird.observe.services.security.UserPasswordNotFoundException;
|
|
| 37 |
+import fr.ird.observe.services.service.PingService;
|
|
| 38 |
+import java.net.MalformedURLException;
|
|
| 39 |
+import java.net.URL;
|
|
| 40 |
+import org.nuiton.version.Version;
|
|
| 41 |
+ |
|
| 42 |
+ |
|
| 43 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 44 |
+import static org.nuiton.i18n.I18n.t;
|
|
| 45 |
+ |
|
| 46 |
+/**
|
|
| 47 |
+ * Created by tchemit on 17/08/17.
|
|
| 48 |
+ *
|
|
| 49 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 50 |
+ */
|
|
| 51 |
+public class TestServerUIAction extends PresetsUIActionSupport {
|
|
| 52 |
+ |
|
| 53 |
+ public static final String ACTION_NAME = TestServerUIAction.class.getName();
|
|
| 54 |
+ |
|
| 55 |
+ public TestServerUIAction(ObserveMainUI mainUI) {
|
|
| 56 |
+ super(mainUI, ACTION_NAME, n("observe.action.test.server"), n("observe.action.test.server.tip"), "connect_creating", 'V');
|
|
| 57 |
+ }
|
|
| 58 |
+ |
|
| 59 |
+ @Override
|
|
| 60 |
+ protected void doActionPerformed(RemotePresetsUI ui) {
|
|
| 61 |
+ |
|
| 62 |
+ String connexionStatusError = null;
|
|
| 63 |
+ ObserveDataSourceConfigurationRest config = new ObserveDataSourceConfigurationRest();
|
|
| 64 |
+ String url = ui.getServerUrl().getText().trim();
|
|
| 65 |
+ try {
|
|
| 66 |
+ config.setServerUrl(new URL(url));
|
|
| 67 |
+ } catch (MalformedURLException e) {
|
|
| 68 |
+ connexionStatusError = t("observe.storage.error.badUrl", url);
|
|
| 69 |
+ }
|
|
| 70 |
+ config.setLogin(ui.getServerLogin().getText().trim());
|
|
| 71 |
+ config.setPassword(ui.getServerPassword().getText().trim().toCharArray());
|
|
| 72 |
+ String databaseName = ui.getServerDataBase().getText().trim();
|
|
| 73 |
+ config.setOptionalDatabaseName(databaseName.isEmpty() ? null : databaseName);
|
|
| 74 |
+ |
|
| 75 |
+ Version applicationVersion = ObserveSwingApplicationContext.get().getConfig().getVersion();
|
|
| 76 |
+ Version modelVersion = ObserveSwingApplicationContext.get().getConfig().getModelVersion();
|
|
| 77 |
+ ObserveSwingDataSource dataSource = ObserveSwingApplicationContext.get().getDataSourcesManager().newDataSource(config);
|
|
| 78 |
+ try {
|
|
| 79 |
+ |
|
| 80 |
+ PingService pingService = dataSource.getPingService();
|
|
| 81 |
+ |
|
| 82 |
+ if (getMainUI().getConfig().isCheckServerVersion()) {
|
|
| 83 |
+ |
|
| 84 |
+ Version serverVersion = pingService.getServerVersion();
|
|
| 85 |
+ |
|
| 86 |
+ if (!applicationVersion.equals(serverVersion)) {
|
|
| 87 |
+ |
|
| 88 |
+ connexionStatusError = t("observe.storage.error.serverVersionMismatch", serverVersion, applicationVersion);
|
|
| 89 |
+ |
|
| 90 |
+ }
|
|
| 91 |
+ }
|
|
| 92 |
+ |
|
| 93 |
+ if (connexionStatusError == null) {
|
|
| 94 |
+ Version modelServerVersion = pingService.getModelVersion();
|
|
| 95 |
+ |
|
| 96 |
+ if (!modelVersion.equals(modelServerVersion)) {
|
|
| 97 |
+ |
|
| 98 |
+ connexionStatusError = t("observe.storage.error.serverVersionModelMismatch", modelServerVersion, modelVersion);
|
|
| 99 |
+ |
|
| 100 |
+ }
|
|
| 101 |
+ |
|
| 102 |
+ }
|
|
| 103 |
+ if (connexionStatusError == null) {
|
|
| 104 |
+ |
|
| 105 |
+ ObserveDataSourceInformation dataSourceInformation = dataSource.checkCanConnect();
|
|
| 106 |
+ |
|
| 107 |
+ Version versionDataSource = dataSourceInformation.getVersion();
|
|
| 108 |
+ |
|
| 109 |
+ // en mise a jour de la base on ne test pas la version
|
|
| 110 |
+ if (!modelVersion.equals(versionDataSource)) {
|
|
| 111 |
+ |
|
| 112 |
+ connexionStatusError = t("observe.storage.error.dbVersionMismatch", versionDataSource, modelVersion);
|
|
| 113 |
+ }
|
|
| 114 |
+ }
|
|
| 115 |
+ |
|
| 116 |
+ } catch (UnknownObserveWebUserException e) {
|
|
| 117 |
+ connexionStatusError = t("observe.storage.error.rest.user.unknown", e.getUserLogin());
|
|
| 118 |
+ } catch (BadObserveWebUserPasswordException e) {
|
|
| 119 |
+ connexionStatusError = t("observe.storage.error.rest.password.bad", e.getUserLogin());
|
|
| 120 |
+ } catch (UnknownObserveWebUserForDatabaseException e) {
|
|
| 121 |
+ connexionStatusError = t("observe.storage.error.rest.database.unknownForUser", e.getDatabaseName(), e.getRole());
|
|
| 122 |
+ } catch (UserLoginNotFoundException e) {
|
|
| 123 |
+ connexionStatusError = t("observe.storage.error.rest.user.required");
|
|
| 124 |
+ } catch (UserPasswordNotFoundException e) {
|
|
| 125 |
+ connexionStatusError = t("observe.storage.error.rest.password.required");
|
|
| 126 |
+ } catch (Exception e) {
|
|
| 127 |
+ connexionStatusError = e.getMessage();
|
|
| 128 |
+ if (connexionStatusError == null || connexionStatusError.isEmpty()) {
|
|
| 129 |
+ connexionStatusError = e.getClass().getName();
|
|
| 130 |
+ }
|
|
| 131 |
+ } finally {
|
|
| 132 |
+ if (dataSource.isOpen()) {
|
|
| 133 |
+ dataSource.close();
|
|
| 134 |
+ }
|
|
| 135 |
+ }
|
|
| 136 |
+ |
|
| 137 |
+ if (connexionStatusError == null) {
|
|
| 138 |
+ UIHelper.displayInfo("Test de connexion", "Le connexion a été établie avec succès.");
|
|
| 139 |
+ } else {
|
|
| 140 |
+ UIHelper.displayWarning("Test de connexion", "Le test de connexion a échoué :\n" + connexionStatusError);
|
|
| 141 |
+ }
|
|
| 142 |
+ }
|
|
| 143 |
+}
|
| ... | ... | @@ -1764,7 +1764,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { |
| 1764 | 1764 |
|
| 1765 | 1765 |
} catch (UserPasswordNotFoundException e) {
|
| 1766 | 1766 |
|
| 1767 |
- connexionStatusError = t("observe.storage.error.rest.pasword.required");
|
|
| 1767 |
+ connexionStatusError = t("observe.storage.error.rest.password.required");
|
|
| 1768 | 1768 |
setConnexionStatus(ConnexionStatus.FAILED);
|
| 1769 | 1769 |
|
| 1770 | 1770 |
} catch (ObserveWebSecurityExceptionSupport e) {
|
| ... | ... | @@ -25,6 +25,17 @@ |
| 25 | 25 |
fr.ird.observe.services.dto.presets.RemoteDataSourceConfiguration
|
| 26 | 26 |
fr.ird.observe.services.dto.presets.ServerDataSourceConfiguration
|
| 27 | 27 |
|
| 28 |
+ fr.ird.observe.client.ui.actions.storage.presets.CreatePresetUIAction
|
|
| 29 |
+ fr.ird.observe.client.ui.actions.storage.presets.DeleteRemoteUIAction
|
|
| 30 |
+ fr.ird.observe.client.ui.actions.storage.presets.DeleteServerUIAction
|
|
| 31 |
+ fr.ird.observe.client.ui.actions.storage.presets.QuitPresetsUIAction
|
|
| 32 |
+ fr.ird.observe.client.ui.actions.storage.presets.ResetRemoteUIAction
|
|
| 33 |
+ fr.ird.observe.client.ui.actions.storage.presets.ResetServerUIAction
|
|
| 34 |
+ fr.ird.observe.client.ui.actions.storage.presets.SaveRemoteUIAction
|
|
| 35 |
+ fr.ird.observe.client.ui.actions.storage.presets.SaveServerUIAction
|
|
| 36 |
+ fr.ird.observe.client.ui.actions.storage.presets.TestRemoteUIAction
|
|
| 37 |
+ fr.ird.observe.client.ui.actions.storage.presets.TestServerUIAction
|
|
| 38 |
+ |
|
| 28 | 39 |
org.nuiton.jaxx.widgets.select.BeanComboBox
|
| 29 | 40 |
|
| 30 | 41 |
</import>
|
| ... | ... | @@ -33,128 +44,130 @@ |
| 33 | 44 |
|
| 34 | 45 |
<JTabbedPane id='tabs' constraints='BorderLayout.CENTER'>
|
| 35 | 46 |
<tab id='remoteTab' title="observe.storage.remote.presets.title">
|
| 36 |
- <JPanel id="remotePanel" layout="{new BorderLayout()}">
|
|
| 37 |
- <BeanComboBox id='remoteConfigurations' constructorParams='this' genericType='RemoteDataSourceConfiguration'
|
|
| 38 |
- constraints='BorderLayout.NORTH'/>
|
|
| 39 |
- <JLabel id="noRemoteSelected" constraints='BorderLayout.CENTER'/>
|
|
| 40 |
- <Table id="remoteForm" constraints='BorderLayout.SOUTH' fill="both">
|
|
| 41 |
- <row>
|
|
| 42 |
- <cell anchor='west'>
|
|
| 43 |
- <JLabel text='observe.storage.remote.name'/>
|
|
| 44 |
- </cell>
|
|
| 45 |
- <cell weightx='1' fill="both" anchor='east'>
|
|
| 46 |
- <JTextField id="remoteName" onKeyReleased="model.setRemoteModified(true);"/>
|
|
| 47 |
- </cell>
|
|
| 48 |
- </row>
|
|
| 49 |
- <row>
|
|
| 50 |
- <cell anchor='west'>
|
|
| 51 |
- <JLabel text='observe.storage.remote.url'/>
|
|
| 52 |
- </cell>
|
|
| 53 |
- <cell weightx='1' fill="both" anchor='east'>
|
|
| 54 |
- <JTextField id="remoteUrl" onKeyReleased="model.setRemoteModified(true);"/>
|
|
| 55 |
- </cell>
|
|
| 56 |
- </row>
|
|
| 57 |
- <row>
|
|
| 58 |
- <cell anchor='west'>
|
|
| 59 |
- <JLabel text='observe.storage.remote.login'/>
|
|
| 60 |
- </cell>
|
|
| 61 |
- <cell weightx='1' fill="both" anchor='east'>
|
|
| 62 |
- <JTextField id="remoteLogin" onKeyReleased="model.setRemoteModified(true);"/>
|
|
| 63 |
- </cell>
|
|
| 64 |
- </row>
|
|
| 65 |
- <row>
|
|
| 66 |
- <cell anchor='west'>
|
|
| 67 |
- <JLabel text='observe.storage.remote.password'/>
|
|
| 68 |
- </cell>
|
|
| 69 |
- <cell weightx='1' fill="both" anchor='east'>
|
|
| 70 |
- <JTextField id="remotePassword" onKeyReleased="model.setRemoteModified(true);"/>
|
|
| 71 |
- </cell>
|
|
| 72 |
- </row>
|
|
| 73 |
- <row>
|
|
| 74 |
- <cell columns='2'>
|
|
| 75 |
- <JCheckBox id="remoteUseSsl" onActionPerformed="model.setRemoteModified(true);"/>
|
|
| 76 |
- </cell>
|
|
| 77 |
- </row>
|
|
| 47 |
+ <JSplitPane id="remotePanel">
|
|
| 48 |
+ <JList id='remoteConfigurations' genericType="RemoteDataSourceConfiguration"/>
|
|
| 49 |
+ <JPanel id="remoteContentPanel" layout="{new BorderLayout()}">
|
|
| 50 |
+ <JLabel id="noRemoteSelected" constraints='BorderLayout.CENTER'/>
|
|
| 51 |
+ <Table id="remoteForm" constraints='BorderLayout.SOUTH' fill="both">
|
|
| 52 |
+ <row>
|
|
| 53 |
+ <cell anchor='west'>
|
|
| 54 |
+ <JLabel text='observe.storage.remote.name'/>
|
|
| 55 |
+ </cell>
|
|
| 56 |
+ <cell weightx='1' fill="both" anchor='east'>
|
|
| 57 |
+ <JTextField id="remoteName" onKeyReleased="model.setRemoteModified(true);"/>
|
|
| 58 |
+ </cell>
|
|
| 59 |
+ </row>
|
|
| 60 |
+ <row>
|
|
| 61 |
+ <cell anchor='west'>
|
|
| 62 |
+ <JLabel text='observe.storage.remote.url'/>
|
|
| 63 |
+ </cell>
|
|
| 64 |
+ <cell weightx='1' fill="both" anchor='east'>
|
|
| 65 |
+ <JTextField id="remoteUrl" onKeyReleased="model.setRemoteModified(true);"/>
|
|
| 66 |
+ </cell>
|
|
| 67 |
+ </row>
|
|
| 68 |
+ <row>
|
|
| 69 |
+ <cell anchor='west'>
|
|
| 70 |
+ <JLabel text='observe.storage.remote.login'/>
|
|
| 71 |
+ </cell>
|
|
| 72 |
+ <cell weightx='1' fill="both" anchor='east'>
|
|
| 73 |
+ <JTextField id="remoteLogin" onKeyReleased="model.setRemoteModified(true);"/>
|
|
| 74 |
+ </cell>
|
|
| 75 |
+ </row>
|
|
| 76 |
+ <row>
|
|
| 77 |
+ <cell anchor='west'>
|
|
| 78 |
+ <JLabel text='observe.storage.remote.password'/>
|
|
| 79 |
+ </cell>
|
|
| 80 |
+ <cell weightx='1' fill="both" anchor='east'>
|
|
| 81 |
+ <JTextField id="remotePassword" onKeyReleased="model.setRemoteModified(true);"/>
|
|
| 82 |
+ </cell>
|
|
| 83 |
+ </row>
|
|
| 84 |
+ <row>
|
|
| 85 |
+ <cell columns='2'>
|
|
| 86 |
+ <JCheckBox id="remoteUseSsl" onActionPerformed="model.setRemoteModified(true);"/>
|
|
| 87 |
+ </cell>
|
|
| 88 |
+ </row>
|
|
| 78 | 89 |
|
| 79 |
- <!-- tester la connexion -->
|
|
| 80 |
- <row>
|
|
| 81 |
- <cell columns='2'>
|
|
| 82 |
- <JPanel layout="{new GridLayout(1, 0)}">
|
|
| 83 |
- <JButton id="saveRemoteAction" onActionPerformed='handler.saveRemote()'/>
|
|
| 84 |
- <JButton id="deleteRemoteAction" onActionPerformed='handler.deleteRemote()'/>
|
|
| 85 |
- <JButton id="testRemoteAction" onActionPerformed='handler.testRemote()'/>
|
|
| 86 |
- </JPanel>
|
|
| 87 |
- </cell>
|
|
| 88 |
- </row>
|
|
| 89 |
- </Table>
|
|
| 90 |
- </JPanel>
|
|
| 90 |
+ <row>
|
|
| 91 |
+ <cell columns='2'>
|
|
| 92 |
+ <JPanel layout="{new GridLayout(1, 0)}">
|
|
| 93 |
+ <JButton id="resetRemoteAction"/>
|
|
| 94 |
+ <JButton id="saveRemoteAction"/>
|
|
| 95 |
+ <JButton id="deleteRemoteAction"/>
|
|
| 96 |
+ <JButton id="testRemoteAction"/>
|
|
| 97 |
+ </JPanel>
|
|
| 98 |
+ </cell>
|
|
| 99 |
+ </row>
|
|
| 100 |
+ </Table>
|
|
| 101 |
+ </JPanel>
|
|
| 102 |
+ </JSplitPane>
|
|
| 91 | 103 |
</tab>
|
| 92 | 104 |
<tab id='serverTab' title="observe.storage.server.presets.title">
|
| 93 | 105 |
|
| 94 |
- <JPanel id="serverPanel" layout="{new BorderLayout()}">
|
|
| 95 |
- <BeanComboBox id='serverConfigurations' constructorParams='this' genericType='ServerDataSourceConfiguration'
|
|
| 96 |
- constraints='BorderLayout.NORTH'/>
|
|
| 97 |
- <JLabel id="noServerSelected" constraints='BorderLayout.CENTER'/>
|
|
| 98 |
- |
|
| 99 |
- <Table id="serverForm" constraints='BorderLayout.SOUTH' fill="both">
|
|
| 100 |
- <row>
|
|
| 101 |
- <cell anchor='west'>
|
|
| 102 |
- <JLabel text='observe.storage.remote.name'/>
|
|
| 103 |
- </cell>
|
|
| 104 |
- <cell weightx='1' fill="both" anchor='east'>
|
|
| 105 |
- <JTextField id="serverName" onKeyReleased="model.setServerModified(true);"/>
|
|
| 106 |
- </cell>
|
|
| 107 |
- </row>
|
|
| 108 |
- <row>
|
|
| 109 |
- <cell anchor='west'>
|
|
| 110 |
- <JLabel text='observe.storage.remote.url'/>
|
|
| 111 |
- </cell>
|
|
| 112 |
- <cell weightx='1' fill="both" anchor='east'>
|
|
| 113 |
- <JTextField id="serverUrl" onKeyReleased="model.setServerModified(true);"/>
|
|
| 114 |
- </cell>
|
|
| 115 |
- </row>
|
|
| 116 |
- <row>
|
|
| 117 |
- <cell anchor='west'>
|
|
| 118 |
- <JLabel text='observe.storage.remote.login'/>
|
|
| 119 |
- </cell>
|
|
| 120 |
- <cell weightx='1' fill="both" anchor='east'>
|
|
| 121 |
- <JTextField id="serverLogin" onKeyReleased="model.setServerModified(true);"/>
|
|
| 122 |
- </cell>
|
|
| 123 |
- </row>
|
|
| 124 |
- <row>
|
|
| 125 |
- <cell anchor='west'>
|
|
| 126 |
- <JLabel text='observe.storage.remote.password'/>
|
|
| 127 |
- </cell>
|
|
| 128 |
- <cell weightx='1' fill="both" anchor='east'>
|
|
| 129 |
- <JTextField id="serverPassword" onKeyReleased="model.setServerModified(true);"/>
|
|
| 130 |
- </cell>
|
|
| 131 |
- </row>
|
|
| 132 |
- <row>
|
|
| 133 |
- <cell anchor='west'>
|
|
| 134 |
- <JLabel id="serverDataBaseLabel" text='observe.storage.server.dataBase'/>
|
|
| 135 |
- </cell>
|
|
| 136 |
- <cell weightx='1' fill="both" anchor='east'>
|
|
| 137 |
- <JTextField id="serverDataBase" onKeyReleased="model.setServerModified(true);"/>
|
|
| 138 |
- </cell>
|
|
| 139 |
- </row>
|
|
| 106 |
+ <JSplitPane id="serverPanel">
|
|
| 107 |
+ <JList id='serverConfigurations' genericType="ServerDataSourceConfiguration"/>
|
|
| 108 |
+ <JPanel id="serverContentPanel" layout="{new BorderLayout()}">
|
|
| 109 |
+ <JLabel id="noServerSelected" constraints='BorderLayout.CENTER'/>
|
|
| 110 |
+ <Table id="serverForm" constraints='BorderLayout.SOUTH' fill="both">
|
|
| 111 |
+ <row>
|
|
| 112 |
+ <cell anchor='west'>
|
|
| 113 |
+ <JLabel text='observe.storage.remote.name'/>
|
|
| 114 |
+ </cell>
|
|
| 115 |
+ <cell weightx='1' fill="both" anchor='east'>
|
|
| 116 |
+ <JTextField id="serverName" onKeyReleased="model.setServerModified(true);"/>
|
|
| 117 |
+ </cell>
|
|
| 118 |
+ </row>
|
|
| 119 |
+ <row>
|
|
| 120 |
+ <cell anchor='west'>
|
|
| 121 |
+ <JLabel text='observe.storage.remote.url'/>
|
|
| 122 |
+ </cell>
|
|
| 123 |
+ <cell weightx='1' fill="both" anchor='east'>
|
|
| 124 |
+ <JTextField id="serverUrl" onKeyReleased="model.setServerModified(true);"/>
|
|
| 125 |
+ </cell>
|
|
| 126 |
+ </row>
|
|
| 127 |
+ <row>
|
|
| 128 |
+ <cell anchor='west'>
|
|
| 129 |
+ <JLabel text='observe.storage.remote.login'/>
|
|
| 130 |
+ </cell>
|
|
| 131 |
+ <cell weightx='1' fill="both" anchor='east'>
|
|
| 132 |
+ <JTextField id="serverLogin" onKeyReleased="model.setServerModified(true);"/>
|
|
| 133 |
+ </cell>
|
|
| 134 |
+ </row>
|
|
| 135 |
+ <row>
|
|
| 136 |
+ <cell anchor='west'>
|
|
| 137 |
+ <JLabel text='observe.storage.remote.password'/>
|
|
| 138 |
+ </cell>
|
|
| 139 |
+ <cell weightx='1' fill="both" anchor='east'>
|
|
| 140 |
+ <JTextField id="serverPassword" onKeyReleased="model.setServerModified(true);"/>
|
|
| 141 |
+ </cell>
|
|
| 142 |
+ </row>
|
|
| 143 |
+ <row>
|
|
| 144 |
+ <cell anchor='west'>
|
|
| 145 |
+ <JLabel id="serverDataBaseLabel" text='observe.storage.server.dataBase'/>
|
|
| 146 |
+ </cell>
|
|
| 147 |
+ <cell weightx='1' fill="both" anchor='east'>
|
|
| 148 |
+ <JTextField id="serverDataBase" onKeyReleased="model.setServerModified(true);"/>
|
|
| 149 |
+ </cell>
|
|
| 150 |
+ </row>
|
|
| 140 | 151 |
|
| 141 |
- <!-- tester la connexion -->
|
|
| 142 |
- <row>
|
|
| 143 |
- <cell columns='2'>
|
|
| 144 |
- <JPanel layout="{new GridLayout(1, 0)}">
|
|
| 145 |
- <JButton id="saveServerAction" onActionPerformed='handler.saveServer()'/>
|
|
| 146 |
- <JButton id="deleteServerAction" onActionPerformed='handler.deleteServer()'/>
|
|
| 147 |
- <JButton id="testServerAction" onActionPerformed='handler.testServer()'/>
|
|
| 148 |
- </JPanel>
|
|
| 149 |
- </cell>
|
|
| 150 |
- </row>
|
|
| 151 |
- </Table>
|
|
| 152 |
- </JPanel>
|
|
| 152 |
+ <row>
|
|
| 153 |
+ <cell columns='2'>
|
|
| 154 |
+ <JPanel layout="{new GridLayout(1, 0)}">
|
|
| 155 |
+ <JButton id="resetServerAction"/>
|
|
| 156 |
+ <JButton id="saveServerAction"/>
|
|
| 157 |
+ <JButton id="deleteServerAction"/>
|
|
| 158 |
+ <JButton id="testServerAction"/>
|
|
| 159 |
+ </JPanel>
|
|
| 160 |
+ </cell>
|
|
| 161 |
+ </row>
|
|
| 162 |
+ </Table>
|
|
| 163 |
+ </JPanel>
|
|
| 164 |
+ </JSplitPane>
|
|
| 153 | 165 |
</tab>
|
| 154 | 166 |
</JTabbedPane>
|
| 155 | 167 |
|
| 156 | 168 |
<JPanel constraints='BorderLayout.SOUTH' layout="{new GridLayout(1, 0)}">
|
| 157 |
- <JButton id="quitAction" onActionPerformed='handler.quit()'/>
|
|
| 169 |
+ <JButton id="createAction"/>
|
|
| 170 |
+ <JButton id="quitAction"/>
|
|
| 158 | 171 |
</JPanel>
|
| 159 | 172 |
|
| 160 | 173 |
</JPanel>
|
| ... | ... | @@ -19,9 +19,6 @@ |
| 19 | 19 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| 20 | 20 |
* #L%
|
| 21 | 21 |
*/
|
| 22 |
-#remoteConfigurations {
|
|
| 23 |
- selectedItem: {model.getRemoteDataSourceConfiguration()};
|
|
| 24 |
-}
|
|
| 25 | 22 |
|
| 26 | 23 |
#noRemoteSelected {
|
| 27 | 24 |
visible: true;
|
| ... | ... | @@ -54,10 +51,6 @@ |
| 54 | 51 |
selected:{model.getRemoteDataSourceConfiguration().isUseSsl()};
|
| 55 | 52 |
}
|
| 56 | 53 |
|
| 57 |
-#serverConfigurations {
|
|
| 58 |
- selectedItem: {model.getServerDataSourceConfiguration()};
|
|
| 59 |
-}
|
|
| 60 |
- |
|
| 61 | 54 |
#noServerSelected {
|
| 62 | 55 |
visible: true;
|
| 63 | 56 |
text:"observe.storage.presets.no.selected";
|
| ... | ... | @@ -88,49 +81,45 @@ |
| 88 | 81 |
text:{SwingUtil.getStringValue(model.getServerDataSourceConfiguration().getDatabaseName())};
|
| 89 | 82 |
}
|
| 90 | 83 |
|
| 84 |
+#resetRemoteAction {
|
|
| 85 |
+ enabled:{model.isRemoteModified()};
|
|
| 86 |
+ _observeAction:{ResetRemoteUIAction.ACTION_NAME};
|
|
| 87 |
+}
|
|
| 88 |
+ |
|
| 91 | 89 |
#saveRemoteAction {
|
| 92 |
- text:"observe.action.save";
|
|
| 93 |
- actionIcon:"save";
|
|
| 94 |
- mnemonic:E;
|
|
| 95 | 90 |
enabled:{model.isRemoteModified()};
|
| 91 |
+ _observeAction:{SaveRemoteUIAction.ACTION_NAME};
|
|
| 96 | 92 |
}
|
| 97 | 93 |
|
| 98 | 94 |
#deleteRemoteAction {
|
| 99 |
- text:"observe.action.delete";
|
|
| 100 |
- actionIcon:"delete";
|
|
| 101 |
- mnemonic:S;
|
|
| 95 |
+ _observeAction:{DeleteRemoteUIAction.ACTION_NAME};
|
|
| 102 | 96 |
}
|
| 103 | 97 |
|
| 104 | 98 |
#testRemoteAction {
|
| 105 |
- text:"observe.action.test.remote";
|
|
| 106 |
- toolTipText:"observe.action.test.remote.tip";
|
|
| 107 |
- actionIcon:"connect_creating";
|
|
| 108 |
- mnemonic:V;
|
|
| 99 |
+ _observeAction:{TestRemoteUIAction.ACTION_NAME};
|
|
| 100 |
+}
|
|
| 101 |
+ |
|
| 102 |
+#resetServerAction {
|
|
| 103 |
+ enabled:{model.isServerModified()};
|
|
| 104 |
+ _observeAction:{ResetServerUIAction.ACTION_NAME};
|
|
| 109 | 105 |
}
|
| 110 | 106 |
|
| 111 | 107 |
#saveServerAction {
|
| 112 |
- text:"observe.action.save";
|
|
| 113 |
- actionIcon:"save";
|
|
| 114 |
- mnemonic:E;
|
|
| 115 | 108 |
enabled:{model.isServerModified()};
|
| 109 |
+ _observeAction:{SaveServerUIAction.ACTION_NAME};
|
|
| 116 | 110 |
}
|
| 117 | 111 |
|
| 118 | 112 |
#deleteServerAction {
|
| 119 |
- text:"observe.action.delete";
|
|
| 120 |
- actionIcon:"delete";
|
|
| 121 |
- mnemonic:S;
|
|
| 113 |
+ _observeAction:{DeleteServerUIAction.ACTION_NAME};
|
|
| 122 | 114 |
}
|
| 123 | 115 |
|
| 124 | 116 |
#testServerAction {
|
| 125 |
- text:"observe.action.test.remote";
|
|
| 126 |
- toolTipText:"observe.action.test.remote.tip";
|
|
| 127 |
- actionIcon:"connect_creating";
|
|
| 128 |
- mnemonic:V;
|
|
| 117 |
+ _observeAction:{TestServerUIAction.ACTION_NAME};
|
|
| 129 | 118 |
}
|
| 130 | 119 |
|
| 120 |
+#createAction {
|
|
| 121 |
+ _observeAction:{CreatePresetUIAction.ACTION_NAME};
|
|
| 122 |
+}
|
|
| 131 | 123 |
#quitAction {
|
| 132 |
- text:"observe.action.quit";
|
|
| 133 |
- toolTipText:"observe.action.quit.tip";
|
|
| 134 |
- actionIcon:"exit";
|
|
| 135 |
- mnemonic:Q;
|
|
| 124 |
+ _observeAction:{QuitPresetsUIAction.ACTION_NAME};
|
|
| 136 | 125 |
}
|
| ... | ... | @@ -24,38 +24,27 @@ package fr.ird.observe.client.ui.storage.presets; |
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.ObserveSwingApplicationContext;
|
| 26 | 26 |
import fr.ird.observe.client.configuration.ClientConfig;
|
| 27 |
-import fr.ird.observe.client.db.ObserveSwingDataSource;
|
|
| 28 |
-import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
|
| 29 |
-import fr.ird.observe.client.ui.ObserveMainUI;
|
|
| 30 |
-import fr.ird.observe.client.ui.ObserveUIMode;
|
|
| 27 |
+import fr.ird.observe.client.ui.actions.UIActionSupport;
|
|
| 31 | 28 |
import fr.ird.observe.client.ui.util.UIHelper;
|
| 32 |
-import fr.ird.observe.services.configuration.ObserveDataSourceInformation;
|
|
| 33 |
-import fr.ird.observe.services.configuration.rest.ObserveDataSourceConfigurationRest;
|
|
| 34 |
-import fr.ird.observe.services.configuration.topia.ObserveDataSourceConfigurationTopiaPG;
|
|
| 35 | 29 |
import fr.ird.observe.services.dto.presets.RemoteDataSourceConfiguration;
|
| 36 | 30 |
import fr.ird.observe.services.dto.presets.ServerDataSourceConfiguration;
|
| 37 |
-import fr.ird.observe.services.security.BadObserveWebUserPasswordException;
|
|
| 38 |
-import fr.ird.observe.services.security.UnknownObserveWebUserException;
|
|
| 39 |
-import fr.ird.observe.services.security.UnknownObserveWebUserForDatabaseException;
|
|
| 40 |
-import fr.ird.observe.services.security.UserLoginNotFoundException;
|
|
| 41 |
-import fr.ird.observe.services.security.UserPasswordNotFoundException;
|
|
| 42 |
-import fr.ird.observe.services.service.PingService;
|
|
| 43 | 31 |
import java.awt.BorderLayout;
|
| 44 |
-import java.net.MalformedURLException;
|
|
| 45 |
-import java.net.URL;
|
|
| 46 |
-import java.util.ArrayList;
|
|
| 47 | 32 |
import java.util.List;
|
| 48 |
-import javax.swing.JOptionPane;
|
|
| 49 |
-import javax.swing.JPanel;
|
|
| 33 |
+import java.util.Objects;
|
|
| 34 |
+import javax.swing.AbstractButton;
|
|
| 35 |
+import javax.swing.ActionMap;
|
|
| 36 |
+import javax.swing.DefaultListModel;
|
|
| 37 |
+import javax.swing.InputMap;
|
|
| 38 |
+import javax.swing.JComponent;
|
|
| 50 | 39 |
import javax.swing.SwingUtilities;
|
| 40 |
+import org.apache.commons.logging.Log;
|
|
| 41 |
+import org.apache.commons.logging.LogFactory;
|
|
| 51 | 42 |
import org.nuiton.decorator.Decorator;
|
| 52 |
-import org.nuiton.decorator.JXPathDecorator;
|
|
| 53 | 43 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 54 |
-import org.nuiton.jaxx.widgets.select.BeanComboBox;
|
|
| 55 |
-import org.nuiton.version.Version;
|
|
| 44 |
+import org.nuiton.jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
|
|
| 56 | 45 |
|
| 57 | 46 |
|
| 58 |
-import static org.nuiton.i18n.I18n.t;
|
|
| 47 |
+import static fr.ird.observe.client.ui.content.ContentUIInitializer.OBSERVE_ACTION;
|
|
| 59 | 48 |
|
| 60 | 49 |
/**
|
| 61 | 50 |
* Created on 20/12/16.
|
| ... | ... | @@ -65,6 +54,9 @@ import static org.nuiton.i18n.I18n.t; |
| 65 | 54 |
*/
|
| 66 | 55 |
public class RemotePresetsUIHandler implements UIHandler<RemotePresetsUI> {
|
| 67 | 56 |
|
| 57 |
+ /** Logger. */
|
|
| 58 |
+ private static final Log log = LogFactory.getLog(RemotePresetsUIHandler.class);
|
|
| 59 |
+ |
|
| 68 | 60 |
private RemotePresetsUI ui;
|
| 69 | 61 |
|
| 70 | 62 |
@Override
|
| ... | ... | @@ -80,262 +72,139 @@ public class RemotePresetsUIHandler implements UIHandler<RemotePresetsUI> { |
| 80 | 72 |
@Override
|
| 81 | 73 |
public void afterInit(RemotePresetsUI ui) {
|
| 82 | 74 |
|
| 75 |
+ ActionMap actionMap = ObserveSwingApplicationContext.get().getActionMap();
|
|
| 76 |
+ InputMap inputMap = ui.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
|
| 77 |
+ for (Object o : ui.get$objectMap().values()) {
|
|
| 78 |
+ |
|
| 79 |
+ if (o instanceof AbstractButton) {
|
|
| 80 |
+ init(inputMap, actionMap, (AbstractButton) o);
|
|
| 81 |
+ }
|
|
| 82 |
+ |
|
| 83 |
+ }
|
|
| 84 |
+ |
|
| 83 | 85 |
Decorator<RemoteDataSourceConfiguration> remoteDecorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(RemoteDataSourceConfiguration.class);
|
| 84 |
- ui.getRemoteConfigurations().init((JXPathDecorator<RemoteDataSourceConfiguration>) remoteDecorator, ui.getModel().getRemoteDataSourceConfigurations());
|
|
| 85 | 86 |
|
| 86 |
- Decorator<ServerDataSourceConfiguration> serverDecorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(ServerDataSourceConfiguration.class);
|
|
| 87 |
- ui.getServerConfigurations().init((JXPathDecorator<ServerDataSourceConfiguration>) serverDecorator, ui.getModel().getServerDataSourceConfigurations());
|
|
| 87 |
+ ui.getRemoteConfigurations().setCellRenderer(new DecoratorListCellRenderer<>(remoteDecorator));
|
|
| 88 |
+ DefaultListModel<RemoteDataSourceConfiguration> remoteModel = new DefaultListModel<>();
|
|
| 89 |
+ ui.getModel().getRemoteDataSourceConfigurations().forEach(remoteModel::addElement);
|
|
| 88 | 90 |
|
| 89 |
- ui.getModel().addPropertyChangeListener("remoteDataSourceConfigurations", evt -> ui.getRemoteConfigurations().setData((List<RemoteDataSourceConfiguration>) evt.getNewValue()));
|
|
| 90 |
- ui.getModel().addPropertyChangeListener("serverDataSourceConfigurations", evt -> ui.getServerConfigurations().setData((List<ServerDataSourceConfiguration>) evt.getNewValue()));
|
|
| 91 |
+ ui.getRemoteConfigurations().setModel(remoteModel);
|
|
| 91 | 92 |
|
| 92 |
- ui.getServerConfigurations().addPropertyChangeListener(BeanComboBox.PROPERTY_SELECTED_ITEM, evt -> {
|
|
| 93 |
+ ui.getRemoteConfigurations().addListSelectionListener(evt -> {
|
|
| 93 | 94 |
|
| 94 |
- ServerDataSourceConfiguration oldValue = (ServerDataSourceConfiguration) evt.getOldValue();
|
|
| 95 |
- ui.getModel().setServerDataSourceConfiguration((ServerDataSourceConfiguration) evt.getNewValue());
|
|
| 95 |
+ if (ui.getRemoteConfigurations().isSelectionEmpty()) {
|
|
| 96 | 96 |
|
| 97 |
- if (ui.getModel().getServerDataSourceConfiguration() == null) {
|
|
| 98 |
- ui.getServerPanel().remove(ui.getServerForm());
|
|
| 99 |
- ui.getServerPanel().add(ui.getNoServerSelected(), BorderLayout.CENTER);
|
|
| 97 |
+ ui.getModel().setRemoteDataSourceConfiguration(null);
|
|
| 98 |
+ ui.getModel().setRemoteModified(false);
|
|
| 100 | 99 |
} else {
|
| 101 |
- if (oldValue == null) {
|
|
| 102 |
- ui.getServerForm().setVisible(true);
|
|
| 103 |
- ui.getServerPanel().remove(ui.getNoServerSelected());
|
|
| 104 |
- ui.getServerPanel().add(ui.getServerForm(), BorderLayout.CENTER);
|
|
| 105 |
- }
|
|
| 106 |
- ui.getModel().setServerModified(false);
|
|
| 100 |
+ ui.getModel().setRemoteDataSourceConfiguration(ui.getRemoteConfigurations().getSelectedValue());
|
|
| 107 | 101 |
}
|
| 108 |
- SwingUtilities.invokeLater(ui::repaint);
|
|
| 109 | 102 |
});
|
| 110 |
- ui.getRemoteConfigurations().addPropertyChangeListener(BeanComboBox.PROPERTY_SELECTED_ITEM, evt -> {
|
|
| 103 |
+ |
|
| 104 |
+ ui.getModel().addPropertyChangeListener("remoteDataSourceConfigurations", evt -> {
|
|
| 105 |
+ |
|
| 106 |
+ List newValue = (List) evt.getNewValue();
|
|
| 107 |
+ |
|
| 108 |
+ DefaultListModel<RemoteDataSourceConfiguration> model = (DefaultListModel<RemoteDataSourceConfiguration>) ui.getRemoteConfigurations().getModel();
|
|
| 109 |
+ model.clear();
|
|
| 110 |
+ for (Object remoteDataSourceConfiguration : newValue) {
|
|
| 111 |
+ model.addElement((RemoteDataSourceConfiguration) remoteDataSourceConfiguration);
|
|
| 112 |
+ }
|
|
| 113 |
+ |
|
| 114 |
+ });
|
|
| 115 |
+ |
|
| 116 |
+ |
|
| 117 |
+ ui.getModel().addPropertyChangeListener("remoteDataSourceConfiguration", evt -> {
|
|
| 111 | 118 |
|
| 112 | 119 |
RemoteDataSourceConfiguration oldValue = (RemoteDataSourceConfiguration) evt.getOldValue();
|
| 113 |
- ui.getModel().setRemoteDataSourceConfiguration((RemoteDataSourceConfiguration) evt.getNewValue());
|
|
| 114 | 120 |
|
| 115 | 121 |
if (ui.getModel().getRemoteDataSourceConfiguration() == null) {
|
| 116 |
- ui.getRemotePanel().remove(ui.getRemoteForm());
|
|
| 117 |
- ui.getRemotePanel().add(ui.getNoRemoteSelected(), BorderLayout.CENTER);
|
|
| 122 |
+ ui.getRemoteContentPanel().remove(ui.getRemoteForm());
|
|
| 123 |
+ ui.getRemoteContentPanel().add(ui.getNoRemoteSelected(), BorderLayout.CENTER);
|
|
| 124 |
+ UIHelper.askFocus(ui.getCreateAction());
|
|
| 118 | 125 |
} else {
|
| 119 | 126 |
if (oldValue == null) {
|
| 120 | 127 |
ui.getRemoteForm().setVisible(true);
|
| 121 |
- ui.getRemotePanel().remove(ui.getNoRemoteSelected());
|
|
| 122 |
- ui.getRemotePanel().add(ui.getRemoteForm(), BorderLayout.CENTER);
|
|
| 128 |
+ ui.getRemoteContentPanel().remove(ui.getNoRemoteSelected());
|
|
| 129 |
+ ui.getRemoteContentPanel().add(ui.getRemoteForm(), BorderLayout.CENTER);
|
|
| 130 |
+ UIHelper.askFocus(ui.getRemoteName());
|
|
| 123 | 131 |
}
|
| 124 | 132 |
ui.getModel().setRemoteModified(false);
|
| 125 | 133 |
}
|
| 126 | 134 |
SwingUtilities.invokeLater(ui::repaint);
|
| 127 | 135 |
});
|
| 128 | 136 |
|
| 129 |
- ObserveKeyStrokes.addKeyStrokeFromMnemonic(ui);
|
|
| 130 |
- }
|
|
| 131 |
- |
|
| 132 |
- public void testRemote() {
|
|
| 133 |
- |
|
| 134 |
- ObserveDataSourceConfigurationTopiaPG config = new ObserveDataSourceConfigurationTopiaPG();
|
|
| 135 |
- config.setJdbcUrl(ui.getRemoteUrl().getText().trim());
|
|
| 136 |
- config.setUsername(ui.getRemoteLogin().getText().trim());
|
|
| 137 |
- config.setPassword(ui.getRemotePassword().getText().trim().toCharArray());
|
|
| 138 |
- config.setUseSsl(ui.getRemoteUseSsl().isSelected());
|
|
| 139 |
- |
|
| 140 |
- String connexionStatusError = null;
|
|
| 141 |
- |
|
| 142 |
- Version modelVersion = ObserveSwingApplicationContext.get().getConfig().getModelVersion();
|
|
| 143 |
- ObserveSwingDataSource dataSource = ObserveSwingApplicationContext.get().getDataSourcesManager().newDataSource(config);
|
|
| 144 |
- try {
|
|
| 145 |
- |
|
| 146 |
- ObserveDataSourceInformation dataSourceInformation = dataSource.checkCanConnect();
|
|
| 137 |
+ Decorator<ServerDataSourceConfiguration> serverDecorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(ServerDataSourceConfiguration.class);
|
|
| 138 |
+ ui.getServerConfigurations().setCellRenderer(new DecoratorListCellRenderer<>(serverDecorator));
|
|
| 139 |
+ DefaultListModel<ServerDataSourceConfiguration> ServerModel = new DefaultListModel<>();
|
|
| 140 |
+ ui.getModel().getServerDataSourceConfigurations().forEach(ServerModel::addElement);
|
|
| 147 | 141 |
|
| 148 |
- Version versionDataSource = dataSourceInformation.getVersion();
|
|
| 142 |
+ ui.getServerConfigurations().setModel(ServerModel);
|
|
| 149 | 143 |
|
| 150 |
- // en mise a jour de la base on ne test pas la version
|
|
| 151 |
- if (!modelVersion.equals(versionDataSource)) {
|
|
| 144 |
+ ui.getServerConfigurations().addListSelectionListener(evt -> {
|
|
| 152 | 145 |
|
| 153 |
- connexionStatusError = t("observe.storage.error.dbVersionMismatch", versionDataSource, modelVersion);
|
|
| 154 |
- }
|
|
| 146 |
+ if (ui.getServerConfigurations().isSelectionEmpty()) {
|
|
| 155 | 147 |
|
| 156 |
- } catch (UnknownObserveWebUserException e) {
|
|
| 157 |
- connexionStatusError = t("observe.storage.error.rest.user.unknown", e.getUserLogin());
|
|
| 158 |
- } catch (BadObserveWebUserPasswordException e) {
|
|
| 159 |
- connexionStatusError = t("observe.storage.error.rest.password.bad", e.getUserLogin());
|
|
| 160 |
- } catch (UnknownObserveWebUserForDatabaseException e) {
|
|
| 161 |
- connexionStatusError = t("observe.storage.error.rest.database.unknownForUser", e.getDatabaseName(), e.getRole());
|
|
| 162 |
- } catch (UserLoginNotFoundException e) {
|
|
| 163 |
- connexionStatusError = t("observe.storage.error.rest.user.required");
|
|
| 164 |
- } catch (UserPasswordNotFoundException e) {
|
|
| 165 |
- connexionStatusError = t("observe.storage.error.rest.pasword.required");
|
|
| 166 |
- } catch (Exception e) {
|
|
| 167 |
- connexionStatusError = e.getMessage();
|
|
| 168 |
- if (connexionStatusError == null || connexionStatusError.isEmpty()) {
|
|
| 169 |
- connexionStatusError = e.getClass().getName();
|
|
| 170 |
- }
|
|
| 171 |
- } finally {
|
|
| 172 |
- if (dataSource.isOpen()) {
|
|
| 173 |
- dataSource.close();
|
|
| 148 |
+ ui.getModel().setServerDataSourceConfiguration(null);
|
|
| 149 |
+ ui.getModel().setServerModified(false);
|
|
| 150 |
+ } else {
|
|
| 151 |
+ ui.getModel().setServerDataSourceConfiguration(ui.getServerConfigurations().getSelectedValue());
|
|
| 174 | 152 |
}
|
| 175 |
- }
|
|
| 176 |
- |
|
| 177 |
- if (connexionStatusError == null) {
|
|
| 178 |
- UIHelper.displayInfo("Test de connexion", "Le connexion a été établie avec succès.");
|
|
| 179 |
- } else {
|
|
| 180 |
- UIHelper.displayWarning("Test de connexion", "Le test de connexion a échoué :\n" + connexionStatusError);
|
|
| 181 |
- }
|
|
| 182 |
- }
|
|
| 183 |
- |
|
| 184 |
- public void testServer() {
|
|
| 185 |
- |
|
| 186 |
- String connexionStatusError = null;
|
|
| 187 |
- ObserveDataSourceConfigurationRest config = new ObserveDataSourceConfigurationRest();
|
|
| 188 |
- String url = ui.getServerUrl().getText().trim();
|
|
| 189 |
- try {
|
|
| 190 |
- config.setServerUrl(new URL(url));
|
|
| 191 |
- } catch (MalformedURLException e) {
|
|
| 192 |
- connexionStatusError = t("observe.storage.error.badUrl", url);
|
|
| 193 |
- }
|
|
| 194 |
- config.setLogin(ui.getServerLogin().getText().trim());
|
|
| 195 |
- config.setPassword(ui.getServerPassword().getText().trim().toCharArray());
|
|
| 196 |
- String databaseName = ui.getServerDataBase().getText().trim();
|
|
| 197 |
- config.setOptionalDatabaseName(databaseName.isEmpty() ? null : databaseName);
|
|
| 198 |
- |
|
| 199 |
- Version modelVersion = ObserveSwingApplicationContext.get().getConfig().getModelVersion();
|
|
| 200 |
- ObserveSwingDataSource dataSource = ObserveSwingApplicationContext.get().getDataSourcesManager().newDataSource(config);
|
|
| 201 |
- try {
|
|
| 202 |
- |
|
| 203 |
- PingService pingService = dataSource.getPingService();
|
|
| 204 |
- |
|
| 205 |
- Version modelServerVersion = pingService.getModelVersion();
|
|
| 153 |
+ });
|
|
| 206 | 154 |
|
| 207 |
- if (!modelVersion.equals(modelServerVersion)) {
|
|
| 155 |
+ ui.getModel().addPropertyChangeListener("serverDataSourceConfigurations", evt -> {
|
|
| 208 | 156 |
|
| 209 |
- connexionStatusError = t("observe.storage.error.serverVersionMismatch", modelServerVersion, modelVersion);
|
|
| 157 |
+ List newValue = (List) evt.getNewValue();
|
|
| 210 | 158 |
|
| 159 |
+ DefaultListModel<ServerDataSourceConfiguration> model = (DefaultListModel<ServerDataSourceConfiguration>) ui.getServerConfigurations().getModel();
|
|
| 160 |
+ model.clear();
|
|
| 161 |
+ for (Object ServerDataSourceConfiguration : newValue) {
|
|
| 162 |
+ model.addElement((ServerDataSourceConfiguration) ServerDataSourceConfiguration);
|
|
| 211 | 163 |
}
|
| 212 | 164 |
|
| 213 |
- if (connexionStatusError == null) {
|
|
| 165 |
+ });
|
|
| 214 | 166 |
|
| 215 |
- ObserveDataSourceInformation dataSourceInformation = dataSource.checkCanConnect();
|
|
| 216 | 167 |
|
| 217 |
- Version versionDataSource = dataSourceInformation.getVersion();
|
|
| 168 |
+ ui.getModel().addPropertyChangeListener("serverDataSourceConfiguration", evt -> {
|
|
| 218 | 169 |
|
| 219 |
- // en mise a jour de la base on ne test pas la version
|
|
| 220 |
- if (!modelVersion.equals(versionDataSource)) {
|
|
| 170 |
+ ServerDataSourceConfiguration oldValue = (ServerDataSourceConfiguration) evt.getOldValue();
|
|
| 221 | 171 |
|
| 222 |
- connexionStatusError = t("observe.storage.error.dbVersionMismatch", versionDataSource, modelVersion);
|
|
| 172 |
+ if (ui.getModel().getServerDataSourceConfiguration() == null) {
|
|
| 173 |
+ ui.getServerContentPanel().remove(ui.getServerForm());
|
|
| 174 |
+ ui.getServerContentPanel().add(ui.getNoServerSelected(), BorderLayout.CENTER);
|
|
| 175 |
+ UIHelper.askFocus(ui.getCreateAction());
|
|
| 176 |
+ } else {
|
|
| 177 |
+ if (oldValue == null) {
|
|
| 178 |
+ ui.getServerForm().setVisible(true);
|
|
| 179 |
+ ui.getServerContentPanel().remove(ui.getNoServerSelected());
|
|
| 180 |
+ ui.getServerContentPanel().add(ui.getServerForm(), BorderLayout.CENTER);
|
|
| 181 |
+ UIHelper.askFocus(ui.getServerName());
|
|
| 223 | 182 |
}
|
| 183 |
+ ui.getModel().setServerModified(false);
|
|
| 224 | 184 |
}
|
| 185 |
+ SwingUtilities.invokeLater(ui::repaint);
|
|
| 186 |
+ });
|
|
| 225 | 187 |
|
| 226 |
- } catch (UnknownObserveWebUserException e) {
|
|
| 227 |
- connexionStatusError = t("observe.storage.error.rest.user.unknown", e.getUserLogin());
|
|
| 228 |
- } catch (BadObserveWebUserPasswordException e) {
|
|
| 229 |
- connexionStatusError = t("observe.storage.error.rest.password.bad", e.getUserLogin());
|
|
| 230 |
- } catch (UnknownObserveWebUserForDatabaseException e) {
|
|
| 231 |
- connexionStatusError = t("observe.storage.error.rest.database.unknownForUser", e.getDatabaseName(), e.getRole());
|
|
| 232 |
- } catch (UserLoginNotFoundException e) {
|
|
| 233 |
- connexionStatusError = t("observe.storage.error.rest.user.required");
|
|
| 234 |
- } catch (UserPasswordNotFoundException e) {
|
|
| 235 |
- connexionStatusError = t("observe.storage.error.rest.pasword.required");
|
|
| 236 |
- } catch (Exception e) {
|
|
| 237 |
- connexionStatusError = e.getMessage();
|
|
| 238 |
- if (connexionStatusError == null || connexionStatusError.isEmpty()) {
|
|
| 239 |
- connexionStatusError = e.getClass().getName();
|
|
| 240 |
- }
|
|
| 241 |
- } finally {
|
|
| 242 |
- if (dataSource.isOpen()) {
|
|
| 243 |
- dataSource.close();
|
|
| 244 |
- }
|
|
| 245 |
- }
|
|
| 188 |
+ UIHelper.askFocus(ui.getCreateAction());
|
|
| 246 | 189 |
|
| 247 |
- if (connexionStatusError == null) {
|
|
| 248 |
- UIHelper.displayInfo("Test de connexion", "Le connexion a été établie avec succès.");
|
|
| 249 |
- } else {
|
|
| 250 |
- UIHelper.displayWarning("Test de connexion", "Le test de connexion a échoué :\n" + connexionStatusError);
|
|
| 251 |
- }
|
|
| 252 | 190 |
}
|
| 253 | 191 |
|
| 254 |
- public void saveRemote() {
|
|
| 255 |
- |
|
| 256 |
- RemoteDataSourceConfiguration remoteDataSourceConfiguration = ui.getModel().getRemoteDataSourceConfiguration();
|
|
| 257 |
- |
|
| 258 |
- remoteDataSourceConfiguration.setName(ui.getRemoteName().getText().trim());
|
|
| 259 |
- remoteDataSourceConfiguration.setUrl(ui.getRemoteUrl().getText().trim());
|
|
| 260 |
- remoteDataSourceConfiguration.setLogin(ui.getRemoteLogin().getText().trim());
|
|
| 261 |
- remoteDataSourceConfiguration.setPassword(ui.getRemotePassword().getText().trim());
|
|
| 262 |
- remoteDataSourceConfiguration.setUseSsl(ui.getRemoteUseSsl().isSelected());
|
|
| 263 |
- |
|
| 264 |
- ObserveSwingApplicationContext.get().getConfig().updateRemoteDataSourceConfiguration(remoteDataSourceConfiguration);
|
|
| 192 |
+ protected void init(InputMap inputMap, ActionMap actionMap, AbstractButton editor) {
|
|
| 193 |
+ String actionId = (String) editor.getClientProperty(OBSERVE_ACTION);
|
|
| 194 |
+ if (actionId == null) {
|
|
| 265 | 195 |
|
| 266 |
- ui.getModel().setRemoteDataSourceConfiguration(null);
|
|
| 267 |
- ui.getModel().setRemoteDataSourceConfiguration(remoteDataSourceConfiguration);
|
|
| 268 |
- ui.getModel().setRemoteModified(false);
|
|
| 269 |
- |
|
| 270 |
- }
|
|
| 271 |
- |
|
| 272 |
- public void deleteRemote() {
|
|
| 273 |
- |
|
| 274 |
- int response = UIHelper.askUser(t("observe.storage.presets.delete.title"),
|
|
| 275 |
- t("observe.storage.presets.delete.message"),
|
|
| 276 |
- JOptionPane.QUESTION_MESSAGE,
|
|
| 277 |
- new Object[]{t("observe.action.delete"), t("observe.action.cancel")},
|
|
| 278 |
- 0);
|
|
| 279 |
- boolean delete = response == 0;
|
|
| 280 |
- |
|
| 281 |
- if (delete) {
|
|
| 282 |
- RemoteDataSourceConfiguration remoteDataSourceConfiguration = ui.getModel().getRemoteDataSourceConfiguration();
|
|
| 283 |
- List<RemoteDataSourceConfiguration> remoteDataSourceConfigurations = new ArrayList<>(ui.getModel().getRemoteDataSourceConfigurations());
|
|
| 284 |
- remoteDataSourceConfigurations.remove(remoteDataSourceConfiguration);
|
|
| 285 |
- ui.getModel().setRemoteDataSourceConfigurations(remoteDataSourceConfigurations);
|
|
| 286 |
- ObserveSwingApplicationContext.get().getConfig().removeRemoteDataSourceConfiguration(remoteDataSourceConfiguration);
|
|
| 287 |
- ui.getModel().setRemoteDataSourceConfiguration(null);
|
|
| 196 |
+ return;
|
|
| 288 | 197 |
}
|
| 289 |
- }
|
|
| 290 | 198 |
|
| 291 |
- public void saveServer() {
|
|
| 199 |
+ UIActionSupport action = (UIActionSupport) actionMap.get(actionId);
|
|
| 200 |
+ Objects.requireNonNull(action, "action [" + actionId + "] not found for ui " + ui.getClass().getName());
|
|
| 292 | 201 |
|
| 293 |
- ServerDataSourceConfiguration serverDataSourceConfiguration = ui.getModel().getServerDataSourceConfiguration();
|
|
| 294 |
- |
|
| 295 |
- serverDataSourceConfiguration.setName(ui.getServerName().getText().trim());
|
|
| 296 |
- serverDataSourceConfiguration.setUrl(ui.getServerUrl().getText().trim());
|
|
| 297 |
- serverDataSourceConfiguration.setLogin(ui.getServerLogin().getText().trim());
|
|
| 298 |
- serverDataSourceConfiguration.setPassword(ui.getServerPassword().getText().trim());
|
|
| 299 |
- String databaseName = ui.getServerDataBase().getText().trim();
|
|
| 300 |
- serverDataSourceConfiguration.setDatabaseName(databaseName.isEmpty() ? null : databaseName);
|
|
| 301 |
- |
|
| 302 |
- ObserveSwingApplicationContext.get().getConfig().updateServerDataSourceConfiguration(serverDataSourceConfiguration);
|
|
| 303 |
- |
|
| 304 |
- ui.getModel().setServerDataSourceConfiguration(null);
|
|
| 305 |
- ui.getModel().setServerDataSourceConfiguration(serverDataSourceConfiguration);
|
|
| 306 |
- ui.getModel().setServerModified(false);
|
|
| 307 |
- |
|
| 308 |
- }
|
|
| 309 |
- |
|
| 310 |
- public void deleteServer() {
|
|
| 311 |
- |
|
| 312 |
- int response = UIHelper.askUser(t("observe.storage.presets.delete.title"),
|
|
| 313 |
- t("observe.storage.presets.delete.message"),
|
|
| 314 |
- JOptionPane.QUESTION_MESSAGE,
|
|
| 315 |
- new Object[]{t("observe.action.delete"), t("observe.action.cancel")},
|
|
| 316 |
- 0
|
|
| 317 |
- );
|
|
| 318 |
- boolean delete = response == 0;
|
|
| 319 |
- |
|
| 320 |
- if (delete) {
|
|
| 321 |
- ServerDataSourceConfiguration serverDataSourceConfiguration = ui.getModel().getServerDataSourceConfiguration();
|
|
| 322 |
- List<ServerDataSourceConfiguration> serverDataSourceConfigurations = new ArrayList<>(ui.getModel().getServerDataSourceConfigurations());
|
|
| 323 |
- serverDataSourceConfigurations.remove(serverDataSourceConfiguration);
|
|
| 324 |
- ui.getModel().setServerDataSourceConfigurations(serverDataSourceConfigurations);
|
|
| 325 |
- ObserveSwingApplicationContext.get().getConfig().removeServerDataSourceConfiguration(serverDataSourceConfiguration);
|
|
| 326 |
- ui.getModel().setServerDataSourceConfiguration(null);
|
|
| 202 |
+ if (log.isDebugEnabled()) {
|
|
| 203 |
+ log.debug("init common action " + actionId);
|
|
| 327 | 204 |
}
|
| 328 |
- }
|
|
| 329 | 205 |
|
| 330 |
- public void quit() {
|
|
| 331 |
- |
|
| 332 |
- ObserveMainUI mainUI = ObserveSwingApplicationContext.get().getMainUI();
|
|
| 333 |
- mainUI.getDataSourcePresets().setContentContainer(new JPanel());
|
|
| 334 |
- if (ObserveSwingApplicationContext.get().getDataSourcesManager().getMainDataSource() == null) {
|
|
| 335 |
- mainUI.getModel().setMode(ObserveUIMode.NO_DB);
|
|
| 336 |
- } else {
|
|
| 337 |
- mainUI.getModel().setMode(ObserveUIMode.DB);
|
|
| 338 |
- }
|
|
| 206 |
+ action.initForMainUi(editor, inputMap, actionMap);
|
|
| 207 |
+ editor.putClientProperty(UIActionSupport.CLIENT_PROPERTY_UI, ui);
|
|
| 339 | 208 |
|
| 340 | 209 |
}
|
| 341 | 210 |
}
|
| ... | ... | @@ -66,8 +66,9 @@ public class RemotePresetsUIModel extends AbstractBean { |
| 66 | 66 |
}
|
| 67 | 67 |
|
| 68 | 68 |
public void setRemoteDataSourceConfiguration(RemoteDataSourceConfiguration remoteDataSourceConfiguration) {
|
| 69 |
+ RemoteDataSourceConfiguration oldValue = getRemoteDataSourceConfiguration();
|
|
| 69 | 70 |
this.remoteDataSourceConfiguration = remoteDataSourceConfiguration;
|
| 70 |
- firePropertyChange("remoteDataSourceConfiguration", null, remoteDataSourceConfiguration);
|
|
| 71 |
+ firePropertyChange("remoteDataSourceConfiguration", oldValue, remoteDataSourceConfiguration);
|
|
| 71 | 72 |
}
|
| 72 | 73 |
|
| 73 | 74 |
public ServerDataSourceConfiguration getServerDataSourceConfiguration() {
|
| ... | ... | @@ -75,8 +76,9 @@ public class RemotePresetsUIModel extends AbstractBean { |
| 75 | 76 |
}
|
| 76 | 77 |
|
| 77 | 78 |
public void setServerDataSourceConfiguration(ServerDataSourceConfiguration serverDataSourceConfiguration) {
|
| 79 |
+ ServerDataSourceConfiguration oldValue = getServerDataSourceConfiguration();
|
|
| 78 | 80 |
this.serverDataSourceConfiguration = serverDataSourceConfiguration;
|
| 79 |
- firePropertyChange("serverDataSourceConfiguration", null, serverDataSourceConfiguration);
|
|
| 81 |
+ firePropertyChange("serverDataSourceConfiguration", oldValue, serverDataSourceConfiguration);
|
|
| 80 | 82 |
}
|
| 81 | 83 |
|
| 82 | 84 |
public boolean isRemoteModified() {
|
| ... | ... | @@ -71,7 +71,9 @@ observe.action.delete.activity.tip=Delete activity |
| 71 | 71 |
observe.action.delete.entry.tip=Delete entry in edition
|
| 72 | 72 |
observe.action.delete.floatingObject.tip=Delete floating object
|
| 73 | 73 |
observe.action.delete.maree.tip=Delete trip
|
| 74 |
+observe.action.delete.remote.tip=Delete remote configuration
|
|
| 74 | 75 |
observe.action.delete.route.tip=Delete route
|
| 76 |
+observe.action.delete.server.tip=Delete server configuration
|
|
| 75 | 77 |
observe.action.delete.set.tip=Delete set
|
| 76 | 78 |
observe.action.delete.tip=Delete
|
| 77 | 79 |
observe.action.detail=Details
|
| ... | ... | @@ -108,6 +110,8 @@ observe.action.modify=Modify |
| 108 | 110 |
observe.action.new.entry=Add
|
| 109 | 111 |
observe.action.new.entry.tip=Create a new entry
|
| 110 | 112 |
observe.action.open.screen=Opening screen <%1$s>
|
| 113 |
+observe.action.presets.create=New configuration
|
|
| 114 |
+observe.action.presets.create.tip=Create a new configuration
|
|
| 111 | 115 |
observe.action.quit=Quit
|
| 112 | 116 |
observe.action.quit.tip=Quit manager
|
| 113 | 117 |
observe.action.reload.application=reload application
|
| ... | ... | @@ -120,12 +124,17 @@ observe.action.reloadResources=Reload i18n |
| 120 | 124 |
observe.action.reloadResources.tip=Reload i18n translations
|
| 121 | 125 |
observe.action.remove.floatingObjectReference=Remove as reference
|
| 122 | 126 |
observe.action.remove.floatingObjectReference.tip=Remove as reference
|
| 127 |
+observe.action.reset=Reset
|
|
| 128 |
+observe.action.reset.remote.tip=Cancel modifications on remote configuration
|
|
| 129 |
+observe.action.reset.server.tip=Cancel modifications on server configuration
|
|
| 123 | 130 |
observe.action.resetComment.tip=Reset comment
|
| 124 | 131 |
observe.action.restart.application=Restart
|
| 125 | 132 |
observe.action.restart.application.tip=Restart application
|
| 126 | 133 |
observe.action.save=Save
|
| 127 | 134 |
observe.action.save.all.tip=Save all modifications
|
| 128 | 135 |
observe.action.save.entry.tip=Save modifications
|
| 136 |
+observe.action.save.remote.tip=Save remote configuration
|
|
| 137 |
+observe.action.save.server.tip=Save server configuration
|
|
| 129 | 138 |
observe.action.save.tip=Save modifications
|
| 130 | 139 |
observe.action.save.to.file=Backup storage
|
| 131 | 140 |
observe.action.save.to.file.tip=Make a backup of opened storage
|
| ... | ... | @@ -148,6 +157,8 @@ observe.action.stop.server.mode.tip=Stop server mode on local database |
| 148 | 157 |
observe.action.storage.applyAction=Apply
|
| 149 | 158 |
observe.action.test.remote=Test connexion
|
| 150 | 159 |
observe.action.test.remote.tip=Click here to validate remote connexion
|
| 160 |
+observe.action.test.server=Test connexion
|
|
| 161 |
+observe.action.test.server.tip=Click here to validate server connexion
|
|
| 151 | 162 |
observe.action.toFullScreen=Full screen mode
|
| 152 | 163 |
observe.action.toFullScreen.tip=Reload application in full screen mode
|
| 153 | 164 |
observe.action.toWindowScreen=Window screen mode
|
| ... | ... | @@ -1488,7 +1499,7 @@ observe.storage.error.badUrl=The url format is not valid (%s) |
| 1488 | 1499 |
observe.storage.error.dbVersionMismatch=Version of remote database (%s) is not compliant with the model version (%s)
|
| 1489 | 1500 |
observe.storage.error.rest.database.unknownForUser=Database "%s" is not defined for user "%s"
|
| 1490 | 1501 |
observe.storage.error.rest.password.bad=Password is not valid
|
| 1491 |
-observe.storage.error.rest.pasword.required=Password is mandatory
|
|
| 1502 |
+observe.storage.error.rest.password.required=Password is mandatory
|
|
| 1492 | 1503 |
observe.storage.error.rest.user.required=User login is mandatory
|
| 1493 | 1504 |
observe.storage.error.rest.user.unknown=User "%s" is not defined on server
|
| 1494 | 1505 |
observe.storage.error.serverVersionMismatch=Remote server version (%s) is not compliant with the client version (%s)
|
| ... | ... | @@ -71,7 +71,9 @@ observe.action.delete.activity.tip=Eliminar la actividad |
| 71 | 71 |
observe.action.delete.entry.tip=Cancelar la edición de la entrada actual
|
| 72 | 72 |
observe.action.delete.floatingObject.tip=Eliminar el objeto flotante actual
|
| 73 | 73 |
observe.action.delete.maree.tip=Eliminar la marea
|
| 74 |
+observe.action.delete.remote.tip=Delete remote configuration \#TODO
|
|
| 74 | 75 |
observe.action.delete.route.tip=Eliminar la ruta
|
| 76 |
+observe.action.delete.server.tip=Delete server configuration \#TODO
|
|
| 75 | 77 |
observe.action.delete.set.tip=Eliminar el lance
|
| 76 | 78 |
observe.action.delete.tip=Eliminar
|
| 77 | 79 |
observe.action.detail=Ver detalles
|
| ... | ... | @@ -108,6 +110,8 @@ observe.action.modify=Modificar |
| 108 | 110 |
observe.action.new.entry=Nuevo
|
| 109 | 111 |
observe.action.new.entry.tip=Crear una nueva entrada
|
| 110 | 112 |
observe.action.open.screen=Abrir pantalla <%1$s>
|
| 113 |
+observe.action.presets.create=Nouvelle configuration \#TODO
|
|
| 114 |
+observe.action.presets.create.tip=Créer une nouvelle configuration \#TODO
|
|
| 111 | 115 |
observe.action.quit=Quitter \#TODO
|
| 112 | 116 |
observe.action.quit.tip=Quitter le gestionnaire \#TODO
|
| 113 | 117 |
observe.action.reload.application=Reinicializar la aplicación
|
| ... | ... | @@ -120,12 +124,17 @@ observe.action.reloadResources=Recargar las traducciones |
| 120 | 124 |
observe.action.reloadResources.tip=Recargar las traducciones i18n
|
| 121 | 125 |
observe.action.remove.floatingObjectReference=Supprimer la référence \#TODO
|
| 122 | 126 |
observe.action.remove.floatingObjectReference.tip=Supprimer la référence \#TODO
|
| 127 |
+observe.action.reset=Reset \#TODO
|
|
| 128 |
+observe.action.reset.remote.tip=Reset remote configuration \#TODO
|
|
| 129 |
+observe.action.reset.server.tip=Cancel modifications on server configuration \#TODO
|
|
| 123 | 130 |
observe.action.resetComment.tip=Supprimer le commentaire \#TODO
|
| 124 | 131 |
observe.action.restart.application=Reiniciar
|
| 125 | 132 |
observe.action.restart.application.tip=Reiniciar la aplicación
|
| 126 | 133 |
observe.action.save=Grabar
|
| 127 | 134 |
observe.action.save.all.tip=Guardar todas las modificaciones
|
| 128 | 135 |
observe.action.save.entry.tip=Guardar la edición en curso
|
| 136 |
+observe.action.save.remote.tip=Save remote configuration \#TODO
|
|
| 137 |
+observe.action.save.server.tip=Save server configuration \#TODO
|
|
| 129 | 138 |
observe.action.save.tip=Guardar las modificaciones
|
| 130 | 139 |
observe.action.save.to.file=Guardar la base de datos
|
| 131 | 140 |
observe.action.save.to.file.tip=Hacer una copia de seguridad de la base de datos abierta
|
| ... | ... | @@ -148,6 +157,8 @@ observe.action.stop.server.mode.tip=Parar el modo servidor de la base local |
| 148 | 157 |
observe.action.storage.applyAction=Aplicar
|
| 149 | 158 |
observe.action.test.remote=Comprobar la conexión
|
| 150 | 159 |
observe.action.test.remote.tip=Pulsar para comprobar la conexión con el servidor remoto
|
| 160 |
+observe.action.test.server=Comprobar la conexión
|
|
| 161 |
+observe.action.test.server.tip=Pulsar para comprobar la conexión con el servidor \#TODO
|
|
| 151 | 162 |
observe.action.toFullScreen=Mode plein écran \#TODO
|
| 152 | 163 |
observe.action.toFullScreen.tip=Recharcher l'application en mode plein écran \#TODO
|
| 153 | 164 |
observe.action.toWindowScreen=Mode fenêtre \#TODO
|
| ... | ... | @@ -1488,7 +1499,7 @@ observe.storage.error.badUrl=Error en el formato de la dirección (URL) %s |
| 1488 | 1499 |
observe.storage.error.dbVersionMismatch=La versión de la base remota (%s) no es compatible con la versión del modelo (%s).
|
| 1489 | 1500 |
observe.storage.error.rest.database.unknownForUser=La base de datos "%s" no está configurada para el usuario "%s"
|
| 1490 | 1501 |
observe.storage.error.rest.password.bad=Le contraseña es invalida
|
| 1491 |
-observe.storage.error.rest.pasword.required=Le contraseña es obligatoria
|
|
| 1502 |
+observe.storage.error.rest.password.required=Le contraseña es obligatoria
|
|
| 1492 | 1503 |
observe.storage.error.rest.user.required=El usuario es obligatorio
|
| 1493 | 1504 |
observe.storage.error.rest.user.unknown=El usuario "%s" no es conocido del servidor
|
| 1494 | 1505 |
observe.storage.error.serverVersionMismatch=La versión del servidor remoto (%s) no es compatible con la versión del modelo (%s)
|
| ... | ... | @@ -71,7 +71,9 @@ observe.action.delete.activity.tip=Supprimer l'activité |
| 71 | 71 |
observe.action.delete.entry.tip=Supprimer l'entrée en cours d'édition
|
| 72 | 72 |
observe.action.delete.floatingObject.tip=Supprimer l'objet flottant courant
|
| 73 | 73 |
observe.action.delete.maree.tip=Supprimer la marée
|
| 74 |
+observe.action.delete.remote.tip=Supprimer la configuration
|
|
| 74 | 75 |
observe.action.delete.route.tip=Supprimer la route
|
| 76 |
+observe.action.delete.server.tip=Supprimer la configuration
|
|
| 75 | 77 |
observe.action.delete.set.tip=Supprimer la calée
|
| 76 | 78 |
observe.action.delete.tip=Supprimer
|
| 77 | 79 |
observe.action.detail=Voir les détails
|
| ... | ... | @@ -108,6 +110,8 @@ observe.action.modify=Modifier |
| 108 | 110 |
observe.action.new.entry=Nouveau
|
| 109 | 111 |
observe.action.new.entry.tip=Créer une nouvelle entrée
|
| 110 | 112 |
observe.action.open.screen=Ouverture de l'écran <%1$s>
|
| 113 |
+observe.action.presets.create=Nouvelle configuration
|
|
| 114 |
+observe.action.presets.create.tip=Créer une nouvelle configuration
|
|
| 111 | 115 |
observe.action.quit=Quitter
|
| 112 | 116 |
observe.action.quit.tip=Quitter le gestionnaire
|
| 113 | 117 |
observe.action.reload.application=Redémarrer l'application
|
| ... | ... | @@ -120,12 +124,17 @@ observe.action.reloadResources=Ressources par défaut |
| 120 | 124 |
observe.action.reloadResources.tip=Rétablir les ressources par défaut (toute modification sera perdue)
|
| 121 | 125 |
observe.action.remove.floatingObjectReference=Supprimer la référence
|
| 122 | 126 |
observe.action.remove.floatingObjectReference.tip=Supprimer la référence
|
| 127 |
+observe.action.reset=Réinitialiser
|
|
| 128 |
+observe.action.reset.remote.tip=Annuler les modifications
|
|
| 129 |
+observe.action.reset.server.tip=Annuler les modifications
|
|
| 123 | 130 |
observe.action.resetComment.tip=Supprimer le commentaire
|
| 124 | 131 |
observe.action.restart.application=Redémarrer
|
| 125 | 132 |
observe.action.restart.application.tip=Redémarrer l'application
|
| 126 | 133 |
observe.action.save=Enregistrer
|
| 127 | 134 |
observe.action.save.all.tip=Sauver toutes les modifications
|
| 128 | 135 |
observe.action.save.entry.tip=Sauver l'entrée en cours d'édition
|
| 136 |
+observe.action.save.remote.tip=Enregister la configuration
|
|
| 137 |
+observe.action.save.server.tip=Enregister la configuration
|
|
| 129 | 138 |
observe.action.save.tip=Sauver les modifications
|
| 130 | 139 |
observe.action.save.to.file=Sauver la base
|
| 131 | 140 |
observe.action.save.to.file.tip=Effectuer une sauvegarde de la base ouverte
|
| ... | ... | @@ -148,6 +157,8 @@ observe.action.stop.server.mode.tip=Arrêter le mode serveur de la base locale |
| 148 | 157 |
observe.action.storage.applyAction=Appliquer
|
| 149 | 158 |
observe.action.test.remote=Valider la connexion
|
| 150 | 159 |
observe.action.test.remote.tip=Cliquer pour valider la connexion au serveur distant
|
| 160 |
+observe.action.test.server=Valider la connexion
|
|
| 161 |
+observe.action.test.server.tip=Cliquer pour valider la connexion au serveur
|
|
| 151 | 162 |
observe.action.toFullScreen=Mode plein écran
|
| 152 | 163 |
observe.action.toFullScreen.tip=Recharcher l'application en mode plein écran
|
| 153 | 164 |
observe.action.toWindowScreen=Mode fenêtre
|
| ... | ... | @@ -1488,7 +1499,7 @@ observe.storage.error.badUrl=Erreur dans le format de l'URL %s |
| 1488 | 1499 |
observe.storage.error.dbVersionMismatch=La version de la base distante (%s) n'est pas compatible avec la version du modèle (%s)
|
| 1489 | 1500 |
observe.storage.error.rest.database.unknownForUser=La base de données "%s" n'est pas définie pour l'utilisateur "%s"
|
| 1490 | 1501 |
observe.storage.error.rest.password.bad=Le mot de passe est invalide
|
| 1491 |
-observe.storage.error.rest.pasword.required=Le mot de passe est obligatoire
|
|
| 1502 |
+observe.storage.error.rest.password.required=Le mot de passe est obligatoire
|
|
| 1492 | 1503 |
observe.storage.error.rest.user.required=L'utilisateur est obligatoire
|
| 1493 | 1504 |
observe.storage.error.rest.user.unknown=L'utilisateur "%s" est inconnu sur le serveur
|
| 1494 | 1505 |
observe.storage.error.serverVersionMismatch=La version du serveur distant (%s) n'est pas compatible avec la version du client (%s)
|