|
From: <de...@us...> - 2012-06-06 21:52:37
|
Revision: 7274
http://fudaa.svn.sourceforge.net/fudaa/?rev=7274&view=rev
Author: deniger
Date: 2012-06-06 21:52:30 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/BArbreCalque.java
trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/BArbreCalqueModel.java
Modified: trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/BArbreCalque.java
===================================================================
--- trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/BArbreCalque.java 2012-06-06 07:30:35 UTC (rev 7273)
+++ trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/BArbreCalque.java 2012-06-06 21:52:30 UTC (rev 7274)
@@ -1,6 +1,6 @@
/**
- * @creation 1998-09-02 @modification $Date$ @license GNU General Public License
- * 2 @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne @mail de...@fu...
+ * @creation 1998-09-02 @modification $Date$ @license GNU General Public License 2
+ * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne @mail de...@fu...
*/
package org.fudaa.ebli.calque;
@@ -71,7 +71,7 @@
}
class ZBArbreNormalMenu extends BuDynamicMenu {
-
+
BArbreCalqueModel arbre_;
boolean noLayer_;
@@ -117,20 +117,20 @@
* @author Guillaume Desnoix
*/
public class BArbreCalque extends JTree implements InternalFrameListener, Observer {
-
+
class ArbreCellEditor extends AbstractCellEditor implements TreeCellEditor {
-
+
ArbreCell1 editor_;
BCalque cqEdite_;
// la largeur par defaut pour la case a cocher 'visible'
int cbWidth_;
// la hauteur par defaut pour la case a cocher 'visible'
int cbHeight_;
-
+
ArbreCellEditor() {
editor_ = new ArbreCell1(true);
editor_.cbVisible_.addItemListener(new ItemListener() {
-
+
public void itemStateChanged(ItemEvent e) {
if (cqEdite_ != null) {;
cqEdite_.setVisible(editor_.cbVisible_.isSelected());
@@ -139,10 +139,10 @@
}
});
editor_.r1_.addKeyListener(new KeyListener() {
-
+
public void keyPressed(final KeyEvent _e) {
}
-
+
public void keyReleased(final KeyEvent _e) {
if (_e.getKeyCode() == KeyEvent.VK_ENTER && editor_.r1_.getText() != null
&& editor_.r1_.getText().trim().length() > 0) {
@@ -150,17 +150,17 @@
fireEditingStopped();
}
}
-
+
public void keyTyped(final KeyEvent _e) {
}
});
editor_.r1_.addFocusListener(new FocusListener() {
-
+
public void focusGained(final FocusEvent _e) {
editor_.r1_.setBackground(UIManager.getColor("TextField.background"));
editor_.r1_.setForeground(Color.BLACK);
}
-
+
public void focusLost(final FocusEvent _e) {
}
});
@@ -169,9 +169,9 @@
final Dimension d = editor_.cbVisible_.getPreferredSize();
cbHeight_ = d.height;
cbWidth_ = d.width;
-
+
}
-
+
public boolean isCellEditable(final EventObject _anEvent) {
// le calque est mis a null s'il n'est pas edite
if (_anEvent instanceof MouseEvent) {
@@ -213,25 +213,25 @@
&& cq.isTitleModifiable()) {
return true;
}
-
+
}
}
return false;
}
-
+
public boolean shouldSelectCell(final EventObject _anEvent) {
return false;
}
-
+
public Object getCellEditorValue() {
return null;
}
-
+
protected void fireEditingStopped() {
getArbreModel().getRootCalque().requestFocusInWindow();
super.fireEditingStopped();
}
-
+
public Component getTreeCellEditorComponent(final JTree _tree, final Object _value, final boolean _isSelected,
final boolean _expanded, final boolean _leaf, final int _row) {
cqEdite_ = (BCalque) _value;
@@ -240,11 +240,11 @@
return editor_;
}
}
-
+
public static BArbreNormalMenu buildNormalMenu(final BArbreCalqueModel _m) {
return new BArbreNormalMenu(_m);
}
-
+
public static ZBArbreNormalMenu buildZNormalMenu(final BArbreCalqueModel _m) {
return new ZBArbreNormalMenu(_m);
}
@@ -255,11 +255,22 @@
public BArbreCalque() {
this(true);
}
-
+
+ @Override
+ public void setEditable(boolean flag) {
+ boolean old = isEditable();
+ if (old != flag) {
+ super.setEditable(flag);
+ if (getArbreModel() != null) {
+ getArbreModel().editableChanged();
+ }
+ }
+ }
+
public BArbreCalque(final BArbreCalqueModel _m) {
this(_m, true);
}
-
+
public BArbreCalque(final BArbreCalqueModel _m, final boolean _editable) {
this(_editable);
setModel(_m);
@@ -272,22 +283,22 @@
setShowsRootHandles(true);
setFocusable(false);
setBorder(new EmptyBorder(5, 5, 5, 5));
-
+
final ArbreCell1 c = new ArbreCell1(_editable);
setCellRenderer(c);
if (_editable) {
setEditable(_editable);
setCellEditor(new ArbreCellEditor());
}
-
+
c.doLayout();
setRowHeight(35);
addMouseListener(new PopupListener());
setExpandsSelectedPaths(true);
}
-
+
class PopupListener extends EbliPopupListener {
-
+
public void popup(final Component _c, final int _xe, final int _ye) {
if (!BArbreCalque.this.isEditable()) {
return;
@@ -308,17 +319,17 @@
}
}
}
-
+
public JPopupMenu buildPopupMenu(final BCalque _calque) {
final CtuluPopupMenu r = new CtuluPopupMenu();
getArbreModel().fillPopupMenu(r);
return r;
}
-
+
public ZBArbreNormalMenu buildZNormalMenu() {
return new ZBArbreNormalMenu(getArbreModel());
}
-
+
public BArbreCalqueModel getArbreModel() {
return (BArbreCalqueModel) getModel();
}
@@ -368,7 +379,7 @@
}
}
}
-
+
public void internalFrameClosed(final InternalFrameEvent _e) {
final JInternalFrame f = _e.getInternalFrame();
if (f instanceof EbliFilleCalquesInterface) {
@@ -380,10 +391,10 @@
}
}
}
-
+
public void internalFrameClosing(final InternalFrameEvent _e) {
}
-
+
public void internalFrameDeactivated(final InternalFrameEvent _e) {
final JInternalFrame f = _e.getInternalFrame();
if (f instanceof EbliFilleCalquesInterface) {
@@ -394,13 +405,13 @@
}
}
}
-
+
public void internalFrameDeiconified(final InternalFrameEvent _e) {
}
-
+
public void internalFrameIconified(final InternalFrameEvent _e) {
}
-
+
public void internalFrameOpened(final InternalFrameEvent _e) {
}
@@ -456,7 +467,7 @@
public void setSelectionCalque(final BCalque _cq) {
getArbreModel().setSelectionCalque(_cq);
}
-
+
public void updateUI() {
super.updateUI();
setRowHeight(35);
@@ -467,7 +478,7 @@
* dessine aussi l'etat du calque (attenue, rapide, gele) sous la forme d'une chaine de caracteres. Utilisee pour tous les lnk
*/
public static class ArbreCell1 extends JPanel implements TreeCellRenderer {
-
+
private final Color treeForeground_ = UIManager.getColor("Tree.foreground");
private final Color treeBackground_ = UIManager.getColor("Tree.background");
private final Color treeSelectionForeground_ = UIManager.getColor("Tree.selectionForeground");
@@ -514,7 +525,7 @@
pnLeft.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
pnLeft.setLayout(new BuVerticalLayout(1, true, true));
pnLeft.setOpaque(false);
-
+
final JPanel r4 = new JPanel(new BuBorderLayout(2, 1, true, true));
r4.add(r1_, BuBorderLayout.CENTER);
r4.add(r2_, BuBorderLayout.SOUTH);
@@ -526,7 +537,7 @@
pnRight_.setLayout(new BuBorderLayout(2, 1, true, true));
pnRight_.add(r3_, BuBorderLayout.CENTER);
pnRight_.add(r4, BuBorderLayout.EAST);
-
+
if (_editable) {
cbVisible_ = new BuCheckBox3States();
cbVisible_.acceptOnly2StatesWhenClicked(true);
@@ -544,7 +555,7 @@
setOpaque(true);
}
final BuLightBorder light_ = new BuLightBorder(BuLightBorder.RAISED, 3);
-
+
public Component getTreeCellRendererComponent(final JTree _tree, final Object _value, final boolean _selected,
final boolean _expanded, final boolean _leaf, final int _row,
final boolean _hasFocus) {
@@ -565,7 +576,7 @@
s.append(calqueInfo);
}
if (calque instanceof BCalqueAffichage) {
-
+
final BCalqueAffichage ca = (BCalqueAffichage) calque;
if (ca.isRapide()) {
if (s.length() > 0) {
@@ -573,7 +584,7 @@
}
s.append(EbliResource.EBLI.getString("rapide"));
}
-
+
if (ca.isAttenue()) {
if (s.length() > 0) {
s.append(CtuluLibString.ESPACE);
@@ -593,7 +604,7 @@
if (calque instanceof ZCalqueAffichageDonneesAbstract) {
final ZCalqueAffichageDonneesAbstract cq = (ZCalqueAffichageDonneesAbstract) calque;
lbSelect_.setVisible(!cq.isSelectionEmpty());
-
+
if (!cq.isSelectable()) {
if (s.length() > 0) {
s.append(CtuluLibString.ESPACE);
@@ -663,12 +674,12 @@
} else {
tooltip.append("<a href=\"").append(link).append("\">").append(_value.toString()).append("</a>");
}
-
+
final String text = r2_.getText();
if (text.length() > 0) {
tooltip.append("<br>").append(text);
}
-
+
final Object val = cq.getClientProperty(Action.SHORT_DESCRIPTION);
if (val != null) {
tooltip.append("<br>").append(val.toString());
@@ -692,15 +703,15 @@
* looks Windows et Motif
*/
public static class ArbreCellLabel extends JLabel implements TreeCellRenderer {
-
+
Color selectedBack_ = UIManager.getColor("Tree.selectionBackground");
Color selectedFor_ = UIManager.getColor("Tree.selectionForeground");
-
+
public ArbreCellLabel() {
this.setOpaque(true);
setPreferredSize(new Dimension(120, 25));
}
-
+
public Component getTreeCellRendererComponent(final JTree _tree, final Object _value, final boolean _selected,
final boolean _expanded, final boolean _leaf, final int _row,
final boolean _hasFocus) {
Modified: trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/BArbreCalqueModel.java
===================================================================
--- trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/BArbreCalqueModel.java 2012-06-06 07:30:35 UTC (rev 7273)
+++ trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/BArbreCalqueModel.java 2012-06-06 21:52:30 UTC (rev 7274)
@@ -51,9 +51,9 @@
* @version $Id$
*/
public class BArbreCalqueModel implements TreeModel, PropertyChangeListener, ActionListener, ContainerListener {
+
public static final String LAYER_ADDED = "added";
public static final String LAYER_REMOVED = "removed";
-
private static final Object[] PROP_TO_LISTEN = CtuluLibArray.sort(
new String[]{"foreground", "visible", "attenue",
"rapide", "ajustement", "paletteCouleur", "iconeChanged", "title", "nodeEdit", "alpha", "model"});
@@ -618,6 +618,10 @@
}
Observable observable_;
+ void editableChanged() {
+ refresh();
+ }
+
static class SpecialObservable extends Observable {
protected synchronized void setChanged() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|