From: <had...@us...> - 2009-01-16 08:14:43
|
Revision: 4366 http://fudaa.svn.sourceforge.net/fudaa/?rev=4366&view=rev Author: hadouxad Date: 2009-01-16 08:14:38 +0000 (Fri, 16 Jan 2009) Log Message: ----------- Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostActionFusionGraphes.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostProfileAction.java Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostActionFusionGraphes.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostActionFusionGraphes.java 2009-01-16 08:14:16 UTC (rev 4365) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostActionFusionGraphes.java 2009-01-16 08:14:38 UTC (rev 4366) @@ -30,6 +30,7 @@ import org.fudaa.ctulu.image.CtuluLibImage; import org.fudaa.ebli.courbe.EGGraphe; import org.fudaa.ebli.courbe.EGGrapheDuplicator; +import org.fudaa.ebli.courbe.EGGrapheModel; import org.fudaa.ebli.courbe.EGGrapheTreeModel; import org.fudaa.ebli.ressource.EbliResource; import org.fudaa.ebli.visuallibrary.EbliNode; @@ -41,6 +42,7 @@ import org.fudaa.ebli.visuallibrary.graphe.GrapheCellRenderer; import org.fudaa.fudaa.meshviewer.profile.MvProfileTreeModel; import org.fudaa.fudaa.tr.common.TrResource; +import org.fudaa.fudaa.tr.post.ScopCourbeTreeModel; import org.fudaa.fudaa.tr.post.TrPostCourbeTreeModel; import org.fudaa.fudaa.tr.post.TrPostProjet; @@ -55,248 +57,340 @@ */ public class TrPostActionFusionGraphes extends EbliWidgetActionSimple { - TrPostProjet projet_; - EbliWidgetGraphe widgetGraphe_; - EbliNode nodeGraphe_; - JList jListeGraphes_; - ArrayList<JLabel> listeObjetsCalques; - ArrayList<EbliNode> listeGraphesPossibles; - JComponent content_; - BuDialog dialog_; - DefaultListModel modelGraphesPossibles_; + TrPostProjet projet_; + EbliWidgetGraphe widgetGraphe_; + EbliNode nodeGraphe_; + JList jListeGraphes_; + ArrayList<JLabel> listeObjetsCalques; + ArrayList<EbliNode> listeGraphesPossibles; + JComponent content_; + BuDialog dialog_; + DefaultListModel modelGraphesPossibles_; - public TrPostActionFusionGraphes(final EbliWidgetGraphe widget, final EbliNode nodeGraphe, final TrPostProjet projet) { - super(widget.getEbliScene(), TrResource.getS("Fusion avec un autre graphe"), CtuluResource.CTULU.getIcon("cible"), - "ADDPOINTWIDGET"); + public TrPostActionFusionGraphes(final EbliWidgetGraphe widget, final EbliNode nodeGraphe, final TrPostProjet projet) { + super(widget.getEbliScene(), TrResource.getS("Fusion avec un autre graphe"), CtuluResource.CTULU.getIcon("cible"), + "ADDPOINTWIDGET"); - widgetGraphe_ = widget; - nodeGraphe_ = nodeGraphe; - projet_ = projet; + widgetGraphe_ = widget; + nodeGraphe_ = nodeGraphe; + projet_ = projet; - // -- ajout de la combo dans la toolbar de la widget --// - if (!((EbliWidgetControllerGraphe) widgetGraphe_.getController()).hasAlreadyFusion) { - widgetGraphe_.getController().getPopup().add(this); - ((EbliWidgetControllerGraphe) widgetGraphe_.getController()).hasAlreadyFusion = true; - } + // -- ajout de la combo dans la toolbar de la widget --// + if (!((EbliWidgetControllerGraphe) widgetGraphe_.getController()).hasAlreadyFusion) { + widgetGraphe_.getController().getPopup().add(this); + ((EbliWidgetControllerGraphe) widgetGraphe_.getController()).hasAlreadyFusion = true; + } - } + } - /** - * remplissage de la combo avec les graphes disponibles et compatibles - * - * @param scene - */ - private void remplirCombo() { - final Map params = new HashMap(); - CtuluLibImage.setCompatibleImageAsked(params); - listeGraphesPossibles = new ArrayList<EbliNode>(); - listeObjetsCalques = new ArrayList<JLabel>(); + /** + * remplissage de la combo avec les graphes disponibles et compatibles + * + * @param scene + */ + private void remplirCombo() { + final Map params = new HashMap(); + CtuluLibImage.setCompatibleImageAsked(params); + listeGraphesPossibles = new ArrayList<EbliNode>(); + listeObjetsCalques = new ArrayList<JLabel>(); - // -- remplissage de la liste a partir de l ecoute de la scene--// - final Set<EbliNode> listeNode = (Set<EbliNode>) scene_.getObjects(); - for (final Iterator<EbliNode> it = listeNode.iterator(); it.hasNext();) { - final EbliNode currentNode = it.next(); + // -- remplissage de la liste a partir de l ecoute de la scene--// + final Set<EbliNode> listeNode = (Set<EbliNode>) scene_.getObjects(); + for (final Iterator<EbliNode> it = listeNode.iterator(); it.hasNext();) { + final EbliNode currentNode = it.next(); - if (currentNode != nodeGraphe_ && currentNode.getCreator() instanceof EbliWidgetCreatorGraphe) { - final EbliWidgetCreatorGraphe new_name = (EbliWidgetCreatorGraphe) currentNode.getCreator(); + if (currentNode != nodeGraphe_ && currentNode.getCreator() instanceof EbliWidgetCreatorGraphe) { + final EbliWidgetCreatorGraphe new_name = (EbliWidgetCreatorGraphe) currentNode.getCreator(); - if (isCompatibleWithGraphe(new_name.getGraphe())) { + if (isCompatibleWithGraphe(new_name.getGraphe())) { - final JLabel label = new JLabel(); - final BufferedImage image = new_name.getGraphe().produceImage(70, 30, params); - final Icon icone = new ImageIcon(image); + final JLabel label = new JLabel(); + final BufferedImage image = new_name.getGraphe().produceImage(70, 30, params); + final Icon icone = new ImageIcon(image); - label.setIcon(icone); - label.setText("Fusionner avec " + currentNode.getTitle()); - listeObjetsCalques.add(label); - listeGraphesPossibles.add(currentNode); - } - } + label.setIcon(icone); + label.setText("Fusionner avec " + currentNode.getTitle()); + listeObjetsCalques.add(label); + listeGraphesPossibles.add(currentNode); + } + } - } + } - // -- creation graphique --// - if (jListeGraphes_ == null) jListeGraphes_ = new JList(); + // -- creation graphique --// + if (jListeGraphes_ == null) jListeGraphes_ = new JList(); - modelGraphesPossibles_ = new DefaultListModel(); + modelGraphesPossibles_ = new DefaultListModel(); - jListeGraphes_.setModel(modelGraphesPossibles_); + jListeGraphes_.setModel(modelGraphesPossibles_); - for (final Iterator<JLabel> it = listeObjetsCalques.iterator(); it.hasNext();) { + for (final Iterator<JLabel> it = listeObjetsCalques.iterator(); it.hasNext();) { - modelGraphesPossibles_.addElement(it.next()); + modelGraphesPossibles_.addElement(it.next()); - } - jListeGraphes_.setSize(250, 350); - jListeGraphes_.setBorder(BorderFactory.createTitledBorder(TrResource.TR.getString("Graphes possibles"))); - jListeGraphes_.setCellRenderer(new GrapheCellRenderer()); + } + jListeGraphes_.setSize(250, 350); + jListeGraphes_.setBorder(BorderFactory.createTitledBorder(TrResource.TR.getString("Graphes possibles"))); + jListeGraphes_.setCellRenderer(new GrapheCellRenderer()); - } + } - /** - * verifie si les graphes sont compatibles - * - * @param graphe - * @return - */ - public boolean isCompatibleWithGraphe(final EGGraphe graphe) { - return (this.widgetGraphe_.getGraphe().getModel() instanceof TrPostCourbeTreeModel && graphe.getModel() instanceof TrPostCourbeTreeModel) - || (this.widgetGraphe_.getGraphe().getModel() instanceof MvProfileTreeModel && graphe.getModel() instanceof MvProfileTreeModel); - } + /** + * verifie si les graphes sont compatibles + * + * @param graphe + * @return + */ + public boolean isCompatibleWithGraphe(final EGGraphe graphe) { - JComponent constructPanel() { - final JPanel content = new JPanel(new BorderLayout()); + //-- cas scop gene, compatible avec tout le monde --// + if(graphe.getModel() instanceof ScopCourbeTreeModel || this.widgetGraphe_.getGraphe().getModel() instanceof ScopCourbeTreeModel) + return true; - content.add(new JLabel(TrResource.getS("Fusion avec un autre graphe")), BorderLayout.NORTH); - content.add(new BuScrollPane(jListeGraphes_), BorderLayout.CENTER); - final JButton valide = new JButton(TrResource.getS("R\xE9aliser la fusion"), EbliResource.EBLI - .getIcon("crystal_valider")); - valide.addActionListener(new ActionListener() { + return (this.widgetGraphe_.getGraphe().getModel() instanceof TrPostCourbeTreeModel && graphe.getModel() instanceof TrPostCourbeTreeModel) + || (this.widgetGraphe_.getGraphe().getModel() instanceof MvProfileTreeModel && graphe.getModel() instanceof MvProfileTreeModel); + } - public void actionPerformed(final ActionEvent _e) { - if (jListeGraphes_.getSelectedIndex() != -1) { - mergeGraph(); - dialog_.dispose(); - } - } + JComponent constructPanel() { + final JPanel content = new JPanel(new BorderLayout()); - }); - jListeGraphes_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + content.add(new JLabel(TrResource.getS("Fusion avec un autre graphe")), BorderLayout.NORTH); + content.add(new BuScrollPane(jListeGraphes_), BorderLayout.CENTER); + final JButton valide = new JButton(TrResource.getS("R\xE9aliser la fusion"), EbliResource.EBLI + .getIcon("crystal_valider")); + valide.addActionListener(new ActionListener() { - final JPanel operations = new JPanel(new FlowLayout(FlowLayout.CENTER)); + public void actionPerformed(final ActionEvent _e) { + if (jListeGraphes_.getSelectedIndex() != -1) { + mergeGraph(); + dialog_.dispose(); + } + } - operations.add(valide); - content.add(operations, BorderLayout.SOUTH); + }); + jListeGraphes_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - return content; - } + final JPanel operations = new JPanel(new FlowLayout(FlowLayout.CENTER)); - /** - * Methode qui: merge le graphe choisi dans la combo avec el ndoe actuel degage le node choisi de la scene remet a - * jour al combo actuelle - */ - private void mergeGraph() { + operations.add(valide); + content.add(operations, BorderLayout.SOUTH); - final int selected = jListeGraphes_.getSelectedIndex(); - if (selected == -1) { return; } - final EbliNode nodeToMerge = listeGraphesPossibles.get(selected); + return content; + } - // --recuperation de son graphe --// - EbliWidgetGraphe grapheWidget = null; - if (nodeToMerge.getWidget() instanceof EbliWidgetBordureSingle) grapheWidget = (EbliWidgetGraphe) ((EbliWidgetBordureSingle) nodeToMerge - .getWidget()).getIntern(); - else grapheWidget = (EbliWidgetGraphe) nodeToMerge.getWidget(); + /** + * Methode qui: merge le graphe choisi dans la combo avec el ndoe actuel degage le node choisi de la scene remet a + * jour al combo actuelle + */ + private void mergeGraph() { - // -- cas des graphes temporels - if (widgetGraphe_.getGraphe().getModel() instanceof TrPostCourbeTreeModel) { - final TrPostCourbeTreeModel grapheToMerge = (TrPostCourbeTreeModel) grapheWidget.getGraphe().getModel(); - final TrPostCourbeTreeModel grapheModel = (TrPostCourbeTreeModel) widgetGraphe_.getGraphe().getModel(); - final EGGrapheTreeModel saveModel = (EGGrapheTreeModel) grapheModel.duplicate(new EGGrapheDuplicator()); - // --ajout de la courbe au widget de base --// - new CtuluTaskOperationGUI(projet_.impl_, TrResource.getS("Fusion avec un autre graphe")) { + final int selected = jListeGraphes_.getSelectedIndex(); + if (selected == -1) { return; } + final EbliNode nodeToMerge = listeGraphesPossibles.get(selected); - @Override - public void act() { - final ProgressionInterface prog = new ProgressionBuAdapter(this); + // --recuperation de son graphe --// + EbliWidgetGraphe grapheWidget = null; + if (nodeToMerge.getWidget() instanceof EbliWidgetBordureSingle) grapheWidget = (EbliWidgetGraphe) ((EbliWidgetBordureSingle) nodeToMerge + .getWidget()).getIntern(); + else grapheWidget = (EbliWidgetGraphe) nodeToMerge.getWidget(); - grapheModel.mergeWithAnotherTreeModel(grapheToMerge); - } - }.start();; - scene_.getCmdMng().addCmd(new CtuluCommand() { - public void redo() { - grapheModel.mergeWithAnotherTreeModel(grapheToMerge); - scene_.removeNodeWithEdges(nodeToMerge); - scene_.refresh(); - } + // -- cas des graphes temporels + if (widgetGraphe_.getGraphe().getModel() instanceof TrPostCourbeTreeModel && !(grapheWidget.getGraphe().getModel() instanceof MvProfileTreeModel)) { + final TrPostCourbeTreeModel grapheToMerge = (TrPostCourbeTreeModel) grapheWidget.getGraphe().getModel(); + final TrPostCourbeTreeModel grapheModel = (TrPostCourbeTreeModel) widgetGraphe_.getGraphe().getModel(); + final EGGrapheTreeModel saveModel = (EGGrapheTreeModel) grapheModel.duplicate(new EGGrapheDuplicator()); + // --ajout de la courbe au widget de base --// + new CtuluTaskOperationGUI(projet_.impl_, TrResource.getS("Fusion avec un autre graphe")) { - public void undo() { + @Override + public void act() { + final ProgressionInterface prog = new ProgressionBuAdapter(this); - widgetGraphe_.getGraphe().setModel(saveModel); - grapheModel.fireStructureChanged(); - scene_.addNode(nodeToMerge); - scene_.refresh(); - } + //-- cas merge avec un scope --// + if(grapheToMerge instanceof ScopCourbeTreeModel) + grapheModel.mergeWithAScopeTreeModel((ScopCourbeTreeModel)grapheToMerge); + else + grapheModel.mergeWithAnotherTreeModel(grapheToMerge); - }); + } + }.start();; - } else { - // -- cas des grapehs spatiaux --// - final MvProfileTreeModel grapheToMerge = (MvProfileTreeModel) grapheWidget.getGraphe().getModel(); - final MvProfileTreeModel grapheModel = (MvProfileTreeModel) widgetGraphe_.getGraphe().getModel(); - final EGGrapheTreeModel saveModel = (EGGrapheTreeModel) grapheModel.duplicate(new EGGrapheDuplicator()); - // --ajout de la courbe au widget de base --// - new CtuluTaskOperationGUI(projet_.impl_, TrResource.getS("Fusion avec un autre graphe")) { + scene_.getCmdMng().addCmd(new CtuluCommand() { - @Override - public void act() { - final ProgressionInterface prog = new ProgressionBuAdapter(this); + public void redo() { + grapheModel.mergeWithAnotherTreeModel(grapheToMerge); + scene_.removeNodeWithEdges(nodeToMerge); + scene_.refresh(); + } - grapheModel.mergeWithAnotherTreeModel(grapheToMerge); + public void undo() { - } - }.start(); + widgetGraphe_.getGraphe().setModel(saveModel); + grapheModel.fireStructureChanged(); + scene_.addNode(nodeToMerge); + scene_.refresh(); + } - scene_.getCmdMng().addCmd(new CtuluCommand() { + }); - public void redo() { - grapheModel.mergeWithAnotherTreeModel(grapheToMerge); - scene_.removeNodeWithEdges(nodeToMerge); - scene_.refresh(); - } + } else if(widgetGraphe_.getGraphe().getModel() instanceof MvProfileTreeModel){ + // -- cas des graphes spatiaux --// - public void undo() { + if(grapheWidget.getGraphe().getModel() instanceof MvProfileTreeModel){ + //-- cas de graphe spatial a graphe spatial --// + + final MvProfileTreeModel grapheToMerge = (MvProfileTreeModel) grapheWidget.getGraphe().getModel(); + final MvProfileTreeModel grapheModel = (MvProfileTreeModel) widgetGraphe_.getGraphe().getModel(); + final EGGrapheTreeModel saveModel = (EGGrapheTreeModel) grapheModel.duplicate(new EGGrapheDuplicator()); + // --ajout de la courbe au widget de base --// + new CtuluTaskOperationGUI(projet_.impl_, TrResource.getS("Fusion avec un autre graphe")) { - widgetGraphe_.getGraphe().setModel(saveModel); - grapheModel.fireStructureChanged(); - scene_.addNode(nodeToMerge); - scene_.refresh(); - } + @Override + public void act() { + final ProgressionInterface prog = new ProgressionBuAdapter(this); - }); + grapheModel.mergeWithAnotherTreeModel(grapheToMerge); - } + } + }.start(); - // -- v\xE9rification pour les l\xE9gendes --// - if (((EbliWidgetControllerGraphe) grapheWidget.getController()).hasLegende()) scene_.removeNode(grapheWidget - .getNodeLegende()); + scene_.getCmdMng().addCmd(new CtuluCommand() { - // --suppression du graphe merge --// - scene_.removeNodeWithEdges(nodeToMerge); + public void redo() { + grapheModel.mergeWithAnotherTreeModel(grapheToMerge); + scene_.removeNodeWithEdges(nodeToMerge); + scene_.refresh(); + } - scene_.refresh(); + public void undo() { - // -- maj de la combo --// - remplirCombo(); + widgetGraphe_.getGraphe().setModel(saveModel); + grapheModel.fireStructureChanged(); + scene_.addNode(nodeToMerge); + scene_.refresh(); + } - if (((EbliWidgetControllerGraphe) widgetGraphe_.getController()).hasLegende()) { - scene_.removeNode(widgetGraphe_.getNodeLegende()); - scene_.refresh(); - ((EbliWidgetControllerGraphe) widgetGraphe_.getController()).ajoutLegende(); - scene_.refresh(); - } + }); - } + } - @Override - public void actionPerformed(final ActionEvent _e) { + else if(grapheWidget.getGraphe().getModel() instanceof ScopCourbeTreeModel) { + //-- cas de fusion entre un spatial et un scop --// + final ScopCourbeTreeModel grapheToMerge = (ScopCourbeTreeModel) grapheWidget.getGraphe().getModel(); + final MvProfileTreeModel grapheModel = (MvProfileTreeModel) widgetGraphe_.getGraphe().getModel(); + final EGGrapheTreeModel saveModel = (EGGrapheTreeModel) grapheModel.duplicate(new EGGrapheDuplicator()); + // --ajout de la courbe au widget de base --// + new CtuluTaskOperationGUI(projet_.impl_, TrResource.getS("Fusion avec un autre graphe")) { - // -- remplisage combo --// - remplirCombo(); + @Override + public void act() { + final ProgressionInterface prog = new ProgressionBuAdapter(this); - dialog_ = new BuDialogConfirmation(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), TrResource - .getS("Fusion avec un autre graphe")); - if (content_ == null) content_ = constructPanel(); + grapheModel.mergeWithAnotherScopeTreeModel(grapheToMerge); - dialog_.setContentPane(content_); - dialog_.setSize(400, 250); + } + }.start(); - dialog_.setModal(true); + scene_.getCmdMng().addCmd(new CtuluCommand() { - // dialog_.setLocation(widgetGraphe_.getLocation()); - dialog_.activate(); - } + public void redo() { + grapheModel.mergeWithAnotherScopeTreeModel(grapheToMerge); + scene_.removeNodeWithEdges(nodeToMerge); + scene_.refresh(); + } -} + public void undo() { + + widgetGraphe_.getGraphe().setModel(saveModel); + grapheModel.fireStructureChanged(); + scene_.addNode(nodeToMerge); + scene_.refresh(); + } + + }); + + } + }else{ + + //-- dernier cas: un scope avec un mvprofil spatial: on inverse le cas precedent --// + //-- cas de fusion entre un spatial et un scop --// + final ScopCourbeTreeModel grapheToMerge =(ScopCourbeTreeModel) widgetGraphe_.getGraphe().getModel(); + final MvProfileTreeModel grapheModel = (MvProfileTreeModel) grapheWidget.getGraphe().getModel(); + final EGGrapheTreeModel saveModel = (EGGrapheTreeModel) grapheModel.duplicate(new EGGrapheDuplicator()); + // --ajout de la courbe au widget de base --// + new CtuluTaskOperationGUI(projet_.impl_, TrResource.getS("Fusion avec un autre graphe")) { + + @Override + public void act() { + final ProgressionInterface prog = new ProgressionBuAdapter(this); + + grapheToMerge.mergeWithAnotherMvProfileTreeModel(grapheModel); + + } + }.start(); + + scene_.getCmdMng().addCmd(new CtuluCommand() { + + public void redo() { + grapheToMerge.mergeWithAnotherMvProfileTreeModel(grapheModel); + scene_.removeNodeWithEdges(nodeToMerge); + scene_.refresh(); + } + + public void undo() { + + widgetGraphe_.getGraphe().setModel(saveModel); + grapheModel.fireStructureChanged(); + scene_.addNode(nodeToMerge); + scene_.refresh(); + } + + }); + + } + + + // -- v\xE9rification pour les l\xE9gendes --// + if (((EbliWidgetControllerGraphe) grapheWidget.getController()).hasLegende()) scene_.removeNode(grapheWidget + .getNodeLegende()); + + // --suppression du graphe merge --// + scene_.removeNodeWithEdges(nodeToMerge); + + scene_.refresh(); + + // -- maj de la combo --// + remplirCombo(); + + if (((EbliWidgetControllerGraphe) widgetGraphe_.getController()).hasLegende()) { + scene_.removeNode(widgetGraphe_.getNodeLegende()); + scene_.refresh(); + ((EbliWidgetControllerGraphe) widgetGraphe_.getController()).ajoutLegende(); + scene_.refresh(); + } + + } + + @Override + public void actionPerformed(final ActionEvent _e) { + + // -- remplisage combo --// + remplirCombo(); + + dialog_ = new BuDialogConfirmation(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), TrResource + .getS("Fusion avec un autre graphe")); + if (content_ == null) content_ = constructPanel(); + + dialog_.setContentPane(content_); + dialog_.setSize(400, 250); + + dialog_.setModal(true); + + // dialog_.setLocation(widgetGraphe_.getLocation()); + dialog_.activate(); + } + + } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostProfileAction.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostProfileAction.java 2009-01-16 08:14:16 UTC (rev 4365) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostProfileAction.java 2009-01-16 08:14:38 UTC (rev 4366) @@ -33,7 +33,7 @@ /** * @author deniger */ - protected static class ProfileAdapter implements MvProfileTarget { + public static class ProfileAdapter implements MvProfileTarget { final TrPostProjet proj_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |