|
From: <de...@us...> - 2012-01-19 11:03:48
|
Revision: 6928
http://fudaa.svn.sourceforge.net/fudaa/?rev=6928&view=rev
Author: deniger
Date: 2012-01-19 11:03:35 +0000 (Thu, 19 Jan 2012)
Log Message:
-----------
CRUE-88
Modified Paths:
--------------
trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/action/AbstractPerspectiveAction.java
trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/helper/DialogHelper.java
trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/services/AbstractPerspectiveService.java
trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/services/PerspectiveService.java
trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/services/PerspectiveState.java
trunk/soft/fudaa-crue/ui-common/src/main/resources/org/fudaa/fudaa/crue/common/action/Bundle.properties
trunk/soft/fudaa-crue/ui-common/src/main/resources/org/fudaa/fudaa/crue/common/helper/Bundle.properties
trunk/soft/fudaa-crue/ui-common/src/main/resources/org/fudaa/fudaa/crue/common/layer.xml
trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/perspective/ActiveModelisation.java
trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/perspective/PerspectiveServiceModelling.java
trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/layer.xml
trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/action/AbstractOtfaAction.java
trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/perspective/ActiveOtfa.java
trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/perspective/PerspectiveServiceOtfa.java
trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/service/OtfaService.java
trunk/soft/fudaa-crue/ui-otfa/src/main/resources/org/fudaa/fudaa/crue/otfa/layer.xml
trunk/soft/fudaa-crue/ui-post/src/main/java/org/fudaa/fudaa/crue/post/perspective/ActivePost.java
trunk/soft/fudaa-crue/ui-post/src/main/java/org/fudaa/fudaa/crue/post/perspective/PerspectiveServicePost.java
trunk/soft/fudaa-crue/ui-post/src/main/resources/org/fudaa/fudaa/crue/post/layer.xml
trunk/soft/fudaa-crue/ui-study/src/main/java/org/fudaa/fudaa/crue/study/perspective/ActiveStudy.java
trunk/soft/fudaa-crue/ui-study/src/main/java/org/fudaa/fudaa/crue/study/perspective/PerspectiveServiceStudy.java
trunk/soft/fudaa-crue/ui-study/src/main/resources/org/fudaa/fudaa/crue/study/layer.xml
Added Paths:
-----------
trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/action/EditPerspectiveAction.java
trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/helper/UserSaveAnswer.java
Modified: trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/action/AbstractPerspectiveAction.java
===================================================================
--- trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/action/AbstractPerspectiveAction.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/action/AbstractPerspectiveAction.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -4,18 +4,9 @@
*/
package org.fudaa.fudaa.crue.common.action;
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
import java.awt.event.ActionEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
import org.fudaa.fudaa.crue.common.Perspective;
-import org.fudaa.fudaa.crue.common.services.PerspectiveState;
import org.fudaa.fudaa.crue.common.services.SelectedPerspectiveService;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;
@@ -29,23 +20,14 @@
private Lookup.Result result = null;
SelectedPerspectiveService service = Lookup.getDefault().lookup(SelectedPerspectiveService.class);
private final Perspective perspectiveId;
- private EditableLookupListener editableListener;
- private AbstractActionState editableAction;
- public AbstractPerspectiveAction(String textCode, String perspectiveId, Perspective perspective, boolean editableOption) {
+ public Perspective getPerspectiveId() {
+ return perspectiveId;
+ }
+
+ public AbstractPerspectiveAction(String textCode, String perspectiveId, Perspective perspective) {
putValue(NAME, NbBundle.getMessage(getClass(), textCode));
putValue(SHORT_DESCRIPTION, getValue(NAME));
- if (editableOption) {
- editableAction = new AbstractActionState(NbBundle.getMessage(AbstractPerspectiveAction.class, "PerspectiveEditAction.Name"), null, "PERSPECTIVE_EDIT_MODE") {
-
- @Override
- public void changeAction() {
- updateEditModelToModel();
- }
- };
- editableAction.setEnabled(false);
- }
-
this.perspectiveId = perspective;
setBooleanState(false);
result = service.getLookup().lookupResult(Perspective.class);
@@ -54,38 +36,10 @@
service.register(perspective, perspectiveId);
}
- private class EditableLookupListener implements PropertyChangeListener {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- updateStateModeFromModel();
- }
- }
-
- private void updateEditModelToModel() {
- service.getPerspectiveService(perspectiveId).setState(editableAction.isSelected() ? PerspectiveState.MODE_EDIT : PerspectiveState.MODE_READ);
- }
-
- private void updateStateModeFromModel() {
- final PerspectiveState state = service.getPerspectiveService(perspectiveId).getState();
- editableAction.setSelected(state.equals(PerspectiveState.MODE_EDIT));
- editableAction.setEnabled(!PerspectiveState.MODE_READ_ONLY.equals(state));
- }
-
@Override
public void setBooleanState(boolean value) {
super.setBooleanState(value);
setEnabled(!value);
- //on active le listener sur la caractère édition
- if (editableAction != null) {
- if (service.isActivated(perspectiveId) && editableListener == null) {
- editableListener = new EditableLookupListener();
- service.getPerspectiveService(perspectiveId).addStateListener(editableListener);
- }
- final PerspectiveState state = service.getPerspectiveService(perspectiveId).getState();
- editableAction.setEnabled(!PerspectiveState.MODE_READ_ONLY.equals(state) && value);
- }
-
}
@Override
@@ -104,19 +58,6 @@
return new HelpCtx(getClass());
}
- @Override
- public Component getToolbarPresenter() {
- JPanel pn = new JPanel();
- pn.setLayout(new GridLayout(2, 1, 0, 0));
- pn.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
- pn.add(super.getToolbarPresenter());
- if (editableAction != null) {
- pn.add(editableAction.buildCheckBox(), BorderLayout.SOUTH);
- } else {
- pn.add(new JLabel(" "), BorderLayout.SOUTH);
- }
- return pn;
- }
@Override
public void actionPerformed(ActionEvent ev) {
Copied: trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/action/EditPerspectiveAction.java (from rev 6926, trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/action/AbstractPerspectiveAction.java)
===================================================================
--- trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/action/EditPerspectiveAction.java (rev 0)
+++ trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/action/EditPerspectiveAction.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -0,0 +1,160 @@
+package org.fudaa.fudaa.crue.common.action;
+
+import java.awt.event.ActionEvent;
+
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collection;
+import javax.swing.JCheckBox;
+import javax.swing.KeyStroke;
+import org.fudaa.fudaa.crue.common.Perspective;
+import org.fudaa.fudaa.crue.common.services.PerspectiveService;
+import org.fudaa.fudaa.crue.common.services.PerspectiveState;
+import org.fudaa.fudaa.crue.common.services.SelectedPerspectiveService;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionRegistration;
+import org.openide.awt.Actions;
+import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
+import org.openide.util.LookupEvent;
+import org.openide.util.LookupListener;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.BooleanStateAction;
+import org.openide.util.lookup.Lookups;
+
+@ActionID(category = "File",
+id = "org.fudaa.fudaa.crue.common.action.EditPerspectiveAction")
+@ActionRegistration(displayName = "#CTL_EditPerspectiveAction")
+@ActionReference(path = "Menu/Window", position = 6)
+public class EditPerspectiveAction extends BooleanStateAction implements LookupListener {
+
+ private Lookup.Result result = null;
+ SelectedPerspectiveService service = Lookup.getDefault().lookup(SelectedPerspectiveService.class);
+ private EditablePropertyListener editableListener;
+ PerspectiveService currentPerspective;
+ private DirtyPropertyListener dirtyListener;
+
+ public EditPerspectiveAction() {
+ putValue(NAME, NbBundle.getMessage(getClass(), "CTL_EditPerspectiveAction"));
+ putValue(SHORT_DESCRIPTION, getValue(NAME));
+ putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK));
+
+ setEnabled(false);
+ setBooleanState(false);
+ result = service.getLookup().lookupResult(Perspective.class);
+ result.allItems();
+ result.addLookupListener(this);
+ resultChanged(null);
+ }
+
+ @Override
+ public java.awt.Component getToolbarPresenter() {
+ final JCheckBox jCheckBox = new JCheckBox(this);
+ final KeyStroke keyStroke = (KeyStroke) getValue(ACCELERATOR_KEY);
+ jCheckBox.setToolTipText(getName() + " " + Actions.findKey(this));
+ jCheckBox.getInputMap(JCheckBox.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, this);
+ jCheckBox.getActionMap().put(this, this);
+ addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (PROP_BOOLEAN_STATE.equals(evt.getPropertyName())) {
+ jCheckBox.setSelected(getBooleanState());
+
+ }
+ }
+ });
+ return jCheckBox;
+ }
+
+ private class EditablePropertyListener implements PropertyChangeListener {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ updateHereFromPerspective();
+ updatePerspectiveAction();
+ }
+ }
+
+ private class DirtyPropertyListener implements PropertyChangeListener {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ updatePerspectiveAction();
+ }
+ }
+
+ private void updatePerspectiveAction() {
+ if (currentPerspective != null) {
+ final String FOLDER = "Actions/File/";
+ boolean dirty = currentPerspective.isDirty();
+ Lookup pathLookup = Lookups.forPath(FOLDER);
+ Collection<? extends AbstractPerspectiveAction> lookupAll = pathLookup.lookupAll(AbstractPerspectiveAction.class);
+ for (AbstractPerspectiveAction abstractPerspectiveAction : lookupAll) {
+ if (abstractPerspectiveAction.getPerspectiveId() != currentPerspective.getPerspective()) {
+ abstractPerspectiveAction.setEnabled(!dirty);
+ }
+ }
+ }
+ }
+
+ private void updateHereFromPerspective() {
+ PerspectiveService currentPerspectiveService = service.getCurrentPerspectiveService();
+ setEnabled(currentPerspectiveService != null && currentPerspectiveService.supportEdition() && currentPerspectiveService.getState() != null && currentPerspectiveService.getState().isModifiable());
+ setBooleanState(currentPerspectiveService != null && PerspectiveState.MODE_EDIT.equals(currentPerspectiveService.getState()));
+ }
+
+ @Override
+ public void resultChanged(LookupEvent lookupEvent) {
+ if (currentPerspective != null) {
+ if (editableListener != null) {
+ currentPerspective.removeStateListener(editableListener);
+ }
+ if (dirtyListener != null) {
+ currentPerspective.removeDirtyListener(dirtyListener);
+ }
+ }
+ updateHereFromPerspective();
+ currentPerspective = service.getCurrentPerspectiveService();
+ if (currentPerspective != null) {
+ if (editableListener == null) {
+ editableListener = new EditablePropertyListener();
+ }
+ if (dirtyListener == null) {
+ dirtyListener = new DirtyPropertyListener();
+ }
+ currentPerspective.addStateListener(editableListener);
+ currentPerspective.addDirtyListener(dirtyListener);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return (String) getValue(NAME);
+ }
+
+ @Override
+ public HelpCtx getHelpCtx() {
+ return new HelpCtx(getClass());
+ }
+
+ @Override
+ public void setBooleanState(boolean value) {
+ if (value == getBooleanState()) {
+ return;
+ }
+ super.setBooleanState(value);
+ if (service.getCurrentPerspectiveService() != null) {
+ service.getCurrentPerspectiveService().setState(getBooleanState() ? PerspectiveState.MODE_EDIT : PerspectiveState.MODE_READ);
+ }
+ updateHereFromPerspective();
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent ev) {
+ setBooleanState(!getBooleanState());
+ }
+}
Modified: trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/helper/DialogHelper.java
===================================================================
--- trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/helper/DialogHelper.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/helper/DialogHelper.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -126,6 +126,25 @@
return DialogDisplayer.getDefault().notify(nd);
}
+ public static UserSaveAnswer confirmSaveOrNot() {
+ return confirmSaveOrNot(
+ NbBundle.getMessage(DialogHelper.class, "SaveDialog.Title"), NbBundle.getMessage(DialogHelper.class, "SaveDialog.Content"),
+ NbBundle.getMessage(DialogHelper.class, "SaveDialog.SaveAction"),
+ NbBundle.getMessage(DialogHelper.class, "SaveDialog.DontSaveAction"));
+ }
+
+ public static UserSaveAnswer confirmSaveOrNot(String title, Object message, String messageSave, String messageNotSave) {
+ Object[] values = new Object[]{messageSave, messageNotSave, NbBundle.getMessage(DialogHelper.class, "dialog.cancel.label")};
+ Object showQuestion = showQuestion(title, message, values);
+ if (messageSave.equals(showQuestion)) {
+ return UserSaveAnswer.SAVE;
+ }
+ if (messageNotSave.equals(showQuestion)) {
+ return UserSaveAnswer.DONT_SAVE;
+ }
+ return UserSaveAnswer.CANCEL;
+ }
+
/**
* @return NotifyDescriptor.YES_OPTION, NotifyDescriptor.NO_OPTION or NotifyDescriptor.CANCEL_OPTION
*/
Added: trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/helper/UserSaveAnswer.java
===================================================================
--- trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/helper/UserSaveAnswer.java (rev 0)
+++ trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/helper/UserSaveAnswer.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -0,0 +1,16 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.fudaa.fudaa.crue.common.helper;
+
+/**
+ *
+ * @author deniger ( genesis)
+ */
+public enum UserSaveAnswer {
+
+ CANCEL,
+ DONT_SAVE,
+ SAVE;
+}
Modified: trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/services/AbstractPerspectiveService.java
===================================================================
--- trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/services/AbstractPerspectiveService.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/services/AbstractPerspectiveService.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -16,7 +16,8 @@
private final Perspective perspective;
private PropertyChangeSupport propertyChangeSupport;
- private PerspectiveState state = PerspectiveState.MODE_READ_ONLY;
+ private PerspectiveState state = PerspectiveState.MODE_READ_ONLY_TEMP;
+ private boolean dirty = false;
public AbstractPerspectiveService(Perspective perspective) {
this.perspective = perspective;
@@ -30,26 +31,63 @@
@Override
public void addStateListener(PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(listener);
+ propertyChangeSupport.addPropertyChangeListener("state", listener);
}
@Override
+ public void removeStateListener(PropertyChangeListener listener) {
+ propertyChangeSupport.removePropertyChangeListener("state", listener);
+ }
+ @Override
+ public void addDirtyListener(PropertyChangeListener listener) {
+ propertyChangeSupport.addPropertyChangeListener("dirty", listener);
+ }
+
+ @Override
+ public void removeDirtyListener(PropertyChangeListener listener) {
+ propertyChangeSupport.removePropertyChangeListener("dirty", listener);
+ }
+
+ @Override
public PerspectiveState getState() {
return state;
}
+ public boolean isDirty() {
+ return dirty;
+ }
+
+ public void setDirty(boolean dirty) {
+ boolean old=this.dirty;
+ this.dirty = dirty;
+ propertyChangeSupport.firePropertyChange("dirty", old, this.dirty);
+ }
+
+
+
+
+ /**
+ * si le mode courant est readOnlyAlways ne fait rien.
+ * @param state
+ */
@Override
public void setState(PerspectiveState state) {
- PerspectiveState old = this.state;
- this.state = state;
- propertyChangeSupport.firePropertyChange("state", old, state);
- editModeChanged();
+ if (PerspectiveState.MODE_READ_ONLY_ALWAYS.equals(this.state)) {
+ return;
+ }
+ if (modeChangedTo(state)) {
+ PerspectiveState old = this.state;
+ this.state = state;
+ propertyChangeSupport.firePropertyChange("state", old, state);
+ }
}
public boolean isInEditMode() {
return PerspectiveState.MODE_EDIT.equals(getState());
}
- protected void editModeChanged() {
- }
+ /**
+ * @return true si le mode a été changé
+ */
+ protected abstract boolean modeChangedTo(PerspectiveState state);
}
Modified: trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/services/PerspectiveService.java
===================================================================
--- trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/services/PerspectiveService.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/services/PerspectiveService.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -28,7 +28,21 @@
public void addStateListener(PropertyChangeListener listener);
+ public void removeStateListener(PropertyChangeListener listener);
+
+ public void addDirtyListener(PropertyChangeListener listener);
+
+ public void removeDirtyListener(PropertyChangeListener listener);
+
public PerspectiveState getState();
public void setState(PerspectiveState state);
+
+ /**
+ *
+ * @return true si la perspective supporte les modification edition/lecture seul
+ */
+ public boolean supportEdition();
+
+ public boolean isDirty();
}
Modified: trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/services/PerspectiveState.java
===================================================================
--- trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/services/PerspectiveState.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/services/PerspectiveState.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -9,10 +9,28 @@
* @author deniger ( genesis)
*/
public enum PerspectiveState {
+
+ MODE_READ(true),
+ /**
+ * utilise pour un mode readOnly temporaire
+ * par exemple si un scenario est chargée, la perspective passe en readonly temporaire
+ */
+ MODE_READ_ONLY_TEMP(false),
+ /**
+ * si une étude a été ouvertue en mode readonly. une perspective qui est dans ce mode ne doit jamais changer
+ * de mode.
+ */
+ MODE_READ_ONLY_ALWAYS(false),
+ MODE_EDIT(true);
- MODE_READ,
- MODE_READ_ONLY,
- MODE_EDIT;
-
+ private final boolean modifiable;
+
+ PerspectiveState(boolean isModifiable) {
+ this.modifiable = isModifiable;
+ }
+
+ public boolean isModifiable() {
+ return modifiable;
+ }
}
Modified: trunk/soft/fudaa-crue/ui-common/src/main/resources/org/fudaa/fudaa/crue/common/action/Bundle.properties
===================================================================
--- trunk/soft/fudaa-crue/ui-common/src/main/resources/org/fudaa/fudaa/crue/common/action/Bundle.properties 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-common/src/main/resources/org/fudaa/fudaa/crue/common/action/Bundle.properties 2012-01-19 11:03:35 UTC (rev 6928)
@@ -1,2 +1,3 @@
CTL_ResetWindowsAction=R\u00e9initialiser les fen\u00eatres
PerspectiveEditAction.Name=\u00e9dition
+CTL_EditPerspectiveAction=\u00c9dition
Modified: trunk/soft/fudaa-crue/ui-common/src/main/resources/org/fudaa/fudaa/crue/common/helper/Bundle.properties
===================================================================
--- trunk/soft/fudaa-crue/ui-common/src/main/resources/org/fudaa/fudaa/crue/common/helper/Bundle.properties 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-common/src/main/resources/org/fudaa/fudaa/crue/common/helper/Bundle.properties 2012-01-19 11:03:35 UTC (rev 6928)
@@ -1,5 +1,10 @@
NotifyOperationSucceed=Op\u00e9ration termin\u00e9e avec succ\u00e8s
dialog.ok.label=OK
dialog.cancel,label=Annuler
+dialog.cancel.label=Annuler
dialog.yes.label=Oui
dialog.no.label=Non
+SaveDialog.Title=Sauvegarde
+SaveDialog.Content=Voulez-vous sauvegarder vos modifications
+SaveDialog.SaveAction=Sauvegarder les modifications
+SaveDialog.DontSaveAction=Ne pas sauvegarder
Modified: trunk/soft/fudaa-crue/ui-common/src/main/resources/org/fudaa/fudaa/crue/common/layer.xml
===================================================================
--- trunk/soft/fudaa-crue/ui-common/src/main/resources/org/fudaa/fudaa/crue/common/layer.xml 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-common/src/main/resources/org/fudaa/fudaa/crue/common/layer.xml 2012-01-19 11:03:35 UTC (rev 6928)
@@ -2,12 +2,21 @@
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
- <folder name="Actions">
- <folder name="Window"/>
+ <folder name="Actions">
+ <folder name="Window"/>
+ </folder>
+ <folder name="Menu">
+ <folder name="Window">
+ <file name="org-netbeans-core-windows-actions-ResetWindowsAction.shadow_hidden"/>
</folder>
- <folder name="Menu">
- <folder name="Window">
- <file name="org-netbeans-core-windows-actions-ResetWindowsAction.shadow_hidden"/>
- </folder>
+ </folder>
+ <folder name="Toolbars">
+ <folder name="Persective">
+
+ <file name="org-fudaa-fudaa-crue-common-action-EditPerspectiveAction.shadow">
+ <attr name="originalFile" stringvalue="Actions/File/org-fudaa-fudaa-crue-common-action-EditPerspectiveAction.instance"/>
+ <attr intvalue="1" name="position"/>
+ </file>
</folder>
+ </folder>
</filesystem>
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/perspective/ActiveModelisation.java
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/perspective/ActiveModelisation.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/perspective/ActiveModelisation.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -16,7 +16,7 @@
public final class ActiveModelisation extends AbstractPerspectiveAction {
public ActiveModelisation() {
- super("CTL_ActiveModelisation", PerspectiveServiceModelling.class.getName(), Perspective.MODELLING,true);
+ super("CTL_ActiveModelisation", PerspectiveServiceModelling.class.getName(), Perspective.MODELLING);
setBooleanState(false);
}
}
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/perspective/PerspectiveServiceModelling.java
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/perspective/PerspectiveServiceModelling.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/perspective/PerspectiveServiceModelling.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -11,6 +11,7 @@
import org.fudaa.fudaa.crue.common.Perspective;
import org.fudaa.fudaa.crue.common.services.AbstractPerspectiveService;
import org.fudaa.fudaa.crue.common.services.PerspectiveService;
+import org.fudaa.fudaa.crue.common.services.PerspectiveState;
import org.openide.util.lookup.ServiceProvider;
/**
@@ -27,6 +28,20 @@
}
@Override
+ public boolean supportEdition() {
+ return true;
+ }
+
+ @Override
+ protected boolean modeChangedTo(PerspectiveState state) {
+ return true;
+ }
+
+
+
+
+
+ @Override
public boolean activate() {
return true;
}
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/layer.xml
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/layer.xml 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/layer.xml 2012-01-19 11:03:35 UTC (rev 6928)
@@ -11,7 +11,7 @@
<folder name="Persective">
<file name="org-fudaa-fudaa-crue-modelling-perspective-ActiveModelisation.shadow">
<attr name="originalFile" stringvalue="Actions/File/org-fudaa-fudaa-crue-modelling-perspective-ActiveModelisation.instance"/>
- <attr intvalue="2" name="position"/>
+ <attr intvalue="3" name="position"/>
</file>
</folder>
</folder>
Modified: trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/action/AbstractOtfaAction.java
===================================================================
--- trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/action/AbstractOtfaAction.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/action/AbstractOtfaAction.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -4,16 +4,10 @@
*/
package org.fudaa.fudaa.crue.otfa.action;
-import java.awt.event.ActionEvent;
-import java.io.File;
import javax.swing.AbstractAction;
import javax.swing.Action;
-import org.fudaa.fudaa.crue.otfa.filter.OtfaFileFilter;
import org.fudaa.fudaa.crue.otfa.node.OtfaCampagneNode;
-import org.fudaa.fudaa.crue.otfa.process.SaveOtfaCampagneProcess;
import org.fudaa.fudaa.crue.otfa.service.OtfaService;
-import org.netbeans.api.progress.ProgressUtils;
-import org.openide.filesystems.FileChooserBuilder;
import org.openide.util.Lookup;
import org.openide.util.Lookup.Result;
import org.openide.util.LookupEvent;
Modified: trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/perspective/ActiveOtfa.java
===================================================================
--- trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/perspective/ActiveOtfa.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/perspective/ActiveOtfa.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -12,7 +12,7 @@
public final class ActiveOtfa extends AbstractPerspectiveAction {
public ActiveOtfa() {
- super("CTL_ActiveOtfa", PerspectiveServiceOtfa.class.getName(), Perspective.TEST,true);
+ super("CTL_ActiveOtfa", PerspectiveServiceOtfa.class.getName(), Perspective.TEST);
setBooleanState(false);
}
}
Modified: trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/perspective/PerspectiveServiceOtfa.java
===================================================================
--- trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/perspective/PerspectiveServiceOtfa.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/perspective/PerspectiveServiceOtfa.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -9,8 +9,17 @@
import java.util.HashSet;
import java.util.Set;
import org.fudaa.fudaa.crue.common.Perspective;
+import org.fudaa.fudaa.crue.common.helper.DialogHelper;
+import org.fudaa.fudaa.crue.common.helper.UserSaveAnswer;
import org.fudaa.fudaa.crue.common.services.AbstractPerspectiveService;
import org.fudaa.fudaa.crue.common.services.PerspectiveService;
+import org.fudaa.fudaa.crue.common.services.PerspectiveState;
+import org.fudaa.fudaa.crue.otfa.node.OtfaCampagneNode;
+import org.fudaa.fudaa.crue.otfa.service.OtfaService;
+import org.openide.util.Lookup;
+import org.openide.util.Lookup.Result;
+import org.openide.util.LookupEvent;
+import org.openide.util.LookupListener;
import org.openide.util.lookup.ServiceProvider;
/**
@@ -18,27 +27,83 @@
* @author genesis
*/
@ServiceProvider(service = PerspectiveService.class)
-public class PerspectiveServiceOtfa extends AbstractPerspectiveService {
-
+public class PerspectiveServiceOtfa extends AbstractPerspectiveService implements LookupListener {
+
private final Set<String> components = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList("OtfaCampagneTopComponent", "properties")));
-
+ OtfaService otfaService = Lookup.getDefault().lookup(OtfaService.class);
+ private final Result<OtfaCampagneNode> lookupResult;
+ private final Result<Boolean> lookupDirtyResult;
+
public PerspectiveServiceOtfa() {
super(Perspective.TEST);
+ lookupResult = otfaService.getLookup().lookupResult(OtfaCampagneNode.class);
+ lookupDirtyResult = otfaService.getLookup().lookupResult(Boolean.class);
+ lookupResult.addLookupListener(this);
+ lookupDirtyResult.addLookupListener(new LookupListener() {
+
+ @Override
+ public void resultChanged(LookupEvent ev) {
+ setDirty(otfaService.getCurrentOTFA() != null && otfaService.isModified());
+ }
+ });
+ setState(PerspectiveState.MODE_READ_ONLY_ALWAYS);
}
+ @Override
+ public void resultChanged(LookupEvent ev) {
+ if (otfaService.getCurrentOTFA() != null) {
+ setState(PerspectiveState.MODE_READ);
+ setDirty(otfaService.isModified());
+ } else {
+ setState(PerspectiveState.MODE_READ_ONLY_TEMP);
+ setDirty(false);
+ }
+ }
+ @Override
+ public boolean supportEdition() {
+ return true;
+ }
-
@Override
+ protected boolean modeChangedTo(PerspectiveState state) {
+ if (otfaService.getCurrentOTFA() == null) {
+ return PerspectiveState.MODE_READ_ONLY_TEMP.equals(state);
+ }
+ if (PerspectiveState.MODE_EDIT.equals(state)) {
+ return true;
+ }
+ if (PerspectiveState.MODE_READ.equals(state)) {
+ if (otfaService.isModified()) {
+ UserSaveAnswer saveAnswer = DialogHelper.confirmSaveOrNot();
+ if (UserSaveAnswer.CANCEL.equals(saveAnswer)) {
+ return false;
+ }
+ if (UserSaveAnswer.SAVE.equals(saveAnswer)) {
+ return otfaService.saveCurrent();
+ } else {
+ otfaService.reloadCurrent();
+ }
+ }
+ return true;
+
+ }
+ return false;
+
+
+
+ }
+
+ @Override
public boolean activate() {
return true;
}
-
+
@Override
public boolean deactivate() {
- return true;
+ return !isDirty();
}
-
+
@Override
public Set<String> getTopComponents() {
return components;
Modified: trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/service/OtfaService.java
===================================================================
--- trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/service/OtfaService.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/service/OtfaService.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -242,6 +242,19 @@
return otfatLookup.lookup(OtfaCampagneNode.class);
}
+ /**
+ * Attention ne fait pas de sauvegarde.
+ */
+ public void reloadCurrent() {
+ OtfaCampagneContainer currentOTFA = getCurrentOTFA();
+ if (currentOTFA != null) {
+ File otfaFile = currentOTFA.getOtfaCampagne().getOtfaFile();
+ unsetCampagne();
+ open(otfaFile);
+
+ }
+ }
+
public boolean saveCurrent() {
if (getCurrentOTFA() != null && isModified()) {
validate(true);
Modified: trunk/soft/fudaa-crue/ui-otfa/src/main/resources/org/fudaa/fudaa/crue/otfa/layer.xml
===================================================================
--- trunk/soft/fudaa-crue/ui-otfa/src/main/resources/org/fudaa/fudaa/crue/otfa/layer.xml 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-otfa/src/main/resources/org/fudaa/fudaa/crue/otfa/layer.xml 2012-01-19 11:03:35 UTC (rev 6928)
@@ -5,7 +5,7 @@
<folder name="Persective">
<file name="org-fudaa-fudaa-crue-otfa-perspective-ActiveOtfa.shadow">
<attr name="originalFile" stringvalue="Actions/File/org-fudaa-fudaa-crue-otfa-perspective-ActiveOtfa.instance"/>
- <attr intvalue="4" name="position"/>
+ <attr intvalue="5" name="position"/>
</file>
</folder>
</folder>
Modified: trunk/soft/fudaa-crue/ui-post/src/main/java/org/fudaa/fudaa/crue/post/perspective/ActivePost.java
===================================================================
--- trunk/soft/fudaa-crue/ui-post/src/main/java/org/fudaa/fudaa/crue/post/perspective/ActivePost.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-post/src/main/java/org/fudaa/fudaa/crue/post/perspective/ActivePost.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -16,7 +16,7 @@
public final class ActivePost extends AbstractPerspectiveAction {
public ActivePost() {
- super("CTL_ActivePost", PerspectiveServicePost.class.getName(),Perspective.POST,false);
+ super("CTL_ActivePost", PerspectiveServicePost.class.getName(),Perspective.POST);
setBooleanState(false);
}
Modified: trunk/soft/fudaa-crue/ui-post/src/main/java/org/fudaa/fudaa/crue/post/perspective/PerspectiveServicePost.java
===================================================================
--- trunk/soft/fudaa-crue/ui-post/src/main/java/org/fudaa/fudaa/crue/post/perspective/PerspectiveServicePost.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-post/src/main/java/org/fudaa/fudaa/crue/post/perspective/PerspectiveServicePost.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -11,6 +11,7 @@
import org.fudaa.fudaa.crue.common.Perspective;
import org.fudaa.fudaa.crue.common.services.AbstractPerspectiveService;
import org.fudaa.fudaa.crue.common.services.PerspectiveService;
+import org.fudaa.fudaa.crue.common.services.PerspectiveState;
import org.openide.util.lookup.ServiceProvider;
/**
@@ -25,11 +26,18 @@
public PerspectiveServicePost() {
super(Perspective.POST);
}
-
-
-
@Override
+ public boolean supportEdition() {
+ return false;
+ }
+
+ @Override
+ protected boolean modeChangedTo(PerspectiveState state) {
+ return true;
+ }
+
+ @Override
public boolean activate() {
return true;
}
Modified: trunk/soft/fudaa-crue/ui-post/src/main/resources/org/fudaa/fudaa/crue/post/layer.xml
===================================================================
--- trunk/soft/fudaa-crue/ui-post/src/main/resources/org/fudaa/fudaa/crue/post/layer.xml 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-post/src/main/resources/org/fudaa/fudaa/crue/post/layer.xml 2012-01-19 11:03:35 UTC (rev 6928)
@@ -11,7 +11,7 @@
<folder name="Persective">
<file name="org-fudaa-fudaa-crue-post-perspective-ActivePost.shadow">
<attr name="originalFile" stringvalue="Actions/File/org-fudaa-fudaa-crue-post-perspective-ActivePost.instance"/>
- <attr intvalue="3" name="position"/>
+ <attr intvalue="4" name="position"/>
</file>
</folder>
</folder>
Modified: trunk/soft/fudaa-crue/ui-study/src/main/java/org/fudaa/fudaa/crue/study/perspective/ActiveStudy.java
===================================================================
--- trunk/soft/fudaa-crue/ui-study/src/main/java/org/fudaa/fudaa/crue/study/perspective/ActiveStudy.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-study/src/main/java/org/fudaa/fudaa/crue/study/perspective/ActiveStudy.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -17,6 +17,6 @@
public final class ActiveStudy extends AbstractPerspectiveAction {
public ActiveStudy() {
- super("CTL_ActiveStudy", PerspectiveServiceStudy.class.getName(),Perspective.STUDY,true);
+ super("CTL_ActiveStudy", PerspectiveServiceStudy.class.getName(),Perspective.STUDY);
}
}
Modified: trunk/soft/fudaa-crue/ui-study/src/main/java/org/fudaa/fudaa/crue/study/perspective/PerspectiveServiceStudy.java
===================================================================
--- trunk/soft/fudaa-crue/ui-study/src/main/java/org/fudaa/fudaa/crue/study/perspective/PerspectiveServiceStudy.java 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-study/src/main/java/org/fudaa/fudaa/crue/study/perspective/PerspectiveServiceStudy.java 2012-01-19 11:03:35 UTC (rev 6928)
@@ -43,7 +43,7 @@
@Override
public void resultChanged(LookupEvent ev) {
if (crueService.isAScenarioLoadedInModellingPerspective()) {
- setState(PerspectiveState.MODE_READ_ONLY);
+ setState(PerspectiveState.MODE_READ_ONLY_TEMP);
} else {
setState(PerspectiveState.MODE_READ);
}
@@ -51,19 +51,24 @@
}
@Override
- protected void editModeChanged() {
+ public boolean supportEdition() {
+ return true;
+ }
+
+ @Override
+ protected boolean modeChangedTo(PerspectiveState state) {
TopComponent activated = TopComponent.getRegistry().getActivated();
if (activated != null) {
reactivateTopComponent(activated);
- }
- else{
+ } else {
for (String string : components) {
TopComponent findTopComponent = WindowManager.getDefault().findTopComponent(string);
- if(findTopComponent!=null){
+ if (findTopComponent != null) {
findTopComponent.requestActive();
}
}
}
+ return true;
}
Modified: trunk/soft/fudaa-crue/ui-study/src/main/resources/org/fudaa/fudaa/crue/study/layer.xml
===================================================================
--- trunk/soft/fudaa-crue/ui-study/src/main/resources/org/fudaa/fudaa/crue/study/layer.xml 2012-01-19 09:56:27 UTC (rev 6927)
+++ trunk/soft/fudaa-crue/ui-study/src/main/resources/org/fudaa/fudaa/crue/study/layer.xml 2012-01-19 11:03:35 UTC (rev 6928)
@@ -72,7 +72,7 @@
<folder name="Persective">
<file name="org-fudaa-fudaa-crue-study-perspective-ActiveStudy.shadow">
<attr name="originalFile" stringvalue="Actions/File/org-fudaa-fudaa-crue-study-perspective-ActiveStudy.instance"/>
- <attr intvalue="1" name="position"/>
+ <attr intvalue="2" name="position"/>
</file>
</folder>
<folder name="State">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|