Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe
Commits:
-
106dfb41
by Tony CHEMIT at 2018-06-18T18:50:30Z
3 changed files:
- client/src/main/java/fr/ird/observe/client/ui/actions/content/CopyFloatingObjectPartToLeftAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/content/CopyFloatingObjectPartToRightAction.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTableModel.java
Changes:
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.actions.content; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| ... | ... | @@ -27,12 +27,14 @@ import fr.ird.observe.client.ui.ObserveMainUI; |
| 27 | 27 |
import fr.ird.observe.client.ui.content.ContentUI;
|
| 28 | 28 |
import fr.ird.observe.client.ui.content.data.seine.FloatingObjectUI;
|
| 29 | 29 |
import fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTreeNode;
|
| 30 |
+import fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTreeTableModel;
|
|
| 30 | 31 |
import org.apache.commons.logging.Log;
|
| 31 | 32 |
import org.apache.commons.logging.LogFactory;
|
| 32 | 33 |
import org.jdesktop.swingx.JXTreeTable;
|
| 33 | 34 |
import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
|
| 34 | 35 |
import org.jdesktop.swingx.treetable.MutableTreeTableNode;
|
| 35 | 36 |
|
| 37 |
+import javax.swing.SwingUtilities;
|
|
| 36 | 38 |
import java.util.Enumeration;
|
| 37 | 39 |
|
| 38 | 40 |
import static org.nuiton.i18n.I18n.t;
|
| ... | ... | @@ -51,7 +53,7 @@ public class CopyFloatingObjectPartToLeftAction extends AbstractContentUIAction |
| 51 | 53 |
|
| 52 | 54 |
public CopyFloatingObjectPartToLeftAction(ObserveMainUI mainUI) {
|
| 53 | 55 |
super(mainUI, ACTION_NAME, t("observe.action.copyFloatingObjectPartToLeft"),
|
| 54 |
- t("observe.action.copyFloatingObjectPartToLeft.tip"), "copyToLeft", ObserveKeyStrokes.KEY_STROKE_COPY_FLOATING_OBJECT_PART_TO_LEFT);
|
|
| 56 |
+ t("observe.action.copyFloatingObjectPartToLeft.tip"), "copyToLeft", ObserveKeyStrokes.KEY_STROKE_COPY_FLOATING_OBJECT_PART_TO_LEFT);
|
|
| 55 | 57 |
}
|
| 56 | 58 |
|
| 57 | 59 |
@Override
|
| ... | ... | @@ -60,12 +62,23 @@ public class CopyFloatingObjectPartToLeftAction extends AbstractContentUIAction |
| 60 | 62 |
FloatingObjectUI ui = (FloatingObjectUI) contentUI;
|
| 61 | 63 |
JXTreeTable table = ui.getTable();
|
| 62 | 64 |
log.info("Start action from " + table);
|
| 63 |
- DefaultTreeTableModel treeTableModel = (DefaultTreeTableModel) table.getTreeTableModel();
|
|
| 64 |
- FloatingObjectPartsTreeNode root = (FloatingObjectPartsTreeNode) treeTableModel.getRoot();
|
|
| 65 |
- Enumeration<? extends MutableTreeTableNode> children = root.children();
|
|
| 66 |
- while (children.hasMoreElements()) {
|
|
| 67 |
- FloatingObjectPartsTreeNode mutableTreeTableNode = (FloatingObjectPartsTreeNode) children.nextElement();
|
|
| 68 |
- move(treeTableModel, mutableTreeTableNode);
|
|
| 65 |
+ getMainUI().getModel().setBusy(true);
|
|
| 66 |
+ try {
|
|
| 67 |
+ FloatingObjectPartsTreeTableModel treeTableModel = (FloatingObjectPartsTreeTableModel) table.getTreeTableModel();
|
|
| 68 |
+ FloatingObjectPartsTreeNode root = treeTableModel.getRoot();
|
|
| 69 |
+ Enumeration<? extends MutableTreeTableNode> children = root.children();
|
|
| 70 |
+ treeTableModel.setAdjusting(true);
|
|
| 71 |
+ try {
|
|
| 72 |
+ while (children.hasMoreElements()) {
|
|
| 73 |
+ FloatingObjectPartsTreeNode mutableTreeTableNode = (FloatingObjectPartsTreeNode) children.nextElement();
|
|
| 74 |
+ move(treeTableModel, mutableTreeTableNode);
|
|
| 75 |
+ }
|
|
| 76 |
+ } finally {
|
|
| 77 |
+ treeTableModel.setAdjusting(false);
|
|
| 78 |
+ }
|
|
| 79 |
+ SwingUtilities.invokeLater(table::revalidate);
|
|
| 80 |
+ } finally {
|
|
| 81 |
+ getMainUI().getModel().setBusy(false);
|
|
| 69 | 82 |
}
|
| 70 | 83 |
}
|
| 71 | 84 |
|
| ... | ... | @@ -10,29 +10,32 @@ package fr.ird.observe.client.ui.actions.content; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.client.ObserveSwingApplicationContext;
|
|
| 25 | 26 |
import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
| 26 | 27 |
import fr.ird.observe.client.ui.ObserveMainUI;
|
| 27 | 28 |
import fr.ird.observe.client.ui.content.ContentUI;
|
| 28 | 29 |
import fr.ird.observe.client.ui.content.data.seine.FloatingObjectUI;
|
| 29 | 30 |
import fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTreeNode;
|
| 31 |
+import fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTreeTableModel;
|
|
| 30 | 32 |
import org.apache.commons.logging.Log;
|
| 31 | 33 |
import org.apache.commons.logging.LogFactory;
|
| 32 | 34 |
import org.jdesktop.swingx.JXTreeTable;
|
| 33 | 35 |
import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
|
| 34 | 36 |
import org.jdesktop.swingx.treetable.MutableTreeTableNode;
|
| 35 | 37 |
|
| 38 |
+import javax.swing.SwingUtilities;
|
|
| 36 | 39 |
import java.util.Enumeration;
|
| 37 | 40 |
|
| 38 | 41 |
import static org.nuiton.i18n.I18n.t;
|
| ... | ... | @@ -51,7 +54,7 @@ public class CopyFloatingObjectPartToRightAction extends AbstractContentUIAction |
| 51 | 54 |
|
| 52 | 55 |
public CopyFloatingObjectPartToRightAction(ObserveMainUI mainUI) {
|
| 53 | 56 |
super(mainUI, ACTION_NAME, t("observe.action.copyFloatingObjectPartToRight"),
|
| 54 |
- t("observe.action.copyFloatingObjectPartToRight.tip"), "copyToRight", ObserveKeyStrokes.KEY_STROKE_COPY_FLOATING_OBJECT_PART_TO_RIGHT);
|
|
| 57 |
+ t("observe.action.copyFloatingObjectPartToRight.tip"), "copyToRight", ObserveKeyStrokes.KEY_STROKE_COPY_FLOATING_OBJECT_PART_TO_RIGHT);
|
|
| 55 | 58 |
}
|
| 56 | 59 |
|
| 57 | 60 |
@Override
|
| ... | ... | @@ -60,15 +63,24 @@ public class CopyFloatingObjectPartToRightAction extends AbstractContentUIAction |
| 60 | 63 |
FloatingObjectUI ui = (FloatingObjectUI) contentUI;
|
| 61 | 64 |
JXTreeTable table = ui.getTable();
|
| 62 | 65 |
log.info("Start action from " + table);
|
| 63 |
- |
|
| 64 |
- DefaultTreeTableModel treeTableModel = (DefaultTreeTableModel) table.getTreeTableModel();
|
|
| 65 |
- FloatingObjectPartsTreeNode root = (FloatingObjectPartsTreeNode) treeTableModel.getRoot();
|
|
| 66 |
- Enumeration<? extends MutableTreeTableNode> children = root.children();
|
|
| 67 |
- while (children.hasMoreElements()) {
|
|
| 68 |
- FloatingObjectPartsTreeNode mutableTreeTableNode = (FloatingObjectPartsTreeNode) children.nextElement();
|
|
| 69 |
- move(treeTableModel, mutableTreeTableNode);
|
|
| 66 |
+ getMainUI().getModel().setBusy(true);
|
|
| 67 |
+ try {
|
|
| 68 |
+ FloatingObjectPartsTreeTableModel treeTableModel = (FloatingObjectPartsTreeTableModel) table.getTreeTableModel();
|
|
| 69 |
+ FloatingObjectPartsTreeNode root = treeTableModel.getRoot();
|
|
| 70 |
+ Enumeration<? extends MutableTreeTableNode> children = root.children();
|
|
| 71 |
+ treeTableModel.setAdjusting(true);
|
|
| 72 |
+ try {
|
|
| 73 |
+ while (children.hasMoreElements()) {
|
|
| 74 |
+ FloatingObjectPartsTreeNode mutableTreeTableNode = (FloatingObjectPartsTreeNode) children.nextElement();
|
|
| 75 |
+ move(treeTableModel, mutableTreeTableNode);
|
|
| 76 |
+ }
|
|
| 77 |
+ } finally {
|
|
| 78 |
+ treeTableModel.setAdjusting(false);
|
|
| 79 |
+ }
|
|
| 80 |
+ SwingUtilities.invokeLater(table::revalidate);
|
|
| 81 |
+ } finally {
|
|
| 82 |
+ getMainUI().getModel().setBusy(false);
|
|
| 70 | 83 |
}
|
| 71 |
- table.revalidate();
|
|
| 72 | 84 |
}
|
| 73 | 85 |
|
| 74 | 86 |
private void move(DefaultTreeTableModel treeTableModel, FloatingObjectPartsTreeNode node) {
|
| ... | ... | @@ -52,6 +52,7 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { |
| 52 | 52 |
private ImmutableSet<FloatingObjectPartsTreeNode> needOneSelectionNodes;
|
| 53 | 53 |
private ImmutableSet<FloatingObjectPartsTreeNode> mandatoryNodes;
|
| 54 | 54 |
private ImmutableSet<FloatingObjectPartsTreeNode> withValidationNodes;
|
| 55 |
+ private boolean adjusting;
|
|
| 55 | 56 |
|
| 56 | 57 |
public FloatingObjectPartsTreeTableModel(FloatingObjectUIModel uiModel) {
|
| 57 | 58 |
super(FloatingObjectPartsTreeNode.createRoot(uiModel, null), Arrays.asList(
|
| ... | ... | @@ -113,6 +114,9 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { |
| 113 | 114 |
previousNode.ifPresent(p -> log.info("Previous selected node: " + p));
|
| 114 | 115 |
super.setValueAt(value, node, column);
|
| 115 | 116 |
previousNode.ifPresent(t -> super.setValueAt(null, t, column));
|
| 117 |
+ if (adjusting) {
|
|
| 118 |
+ return;
|
|
| 119 |
+ }
|
|
| 116 | 120 |
reset();
|
| 117 | 121 |
uiModel.setModified(true);
|
| 118 | 122 |
}
|
| ... | ... | @@ -131,4 +135,15 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { |
| 131 | 135 |
uiModel.getBean().setMaterialsValid(!notValid);
|
| 132 | 136 |
}
|
| 133 | 137 |
|
| 138 |
+ public boolean isAdjusting() {
|
|
| 139 |
+ return adjusting;
|
|
| 140 |
+ }
|
|
| 141 |
+ |
|
| 142 |
+ public void setAdjusting(boolean adjusting) {
|
|
| 143 |
+ this.adjusting = adjusting;
|
|
| 144 |
+ if (!adjusting) {
|
|
| 145 |
+ reset();
|
|
| 146 |
+ uiModel.setModified(true);
|
|
| 147 |
+ }
|
|
| 148 |
+ }
|
|
| 134 | 149 |
}
|