From: <de...@us...> - 2012-12-19 16:34:02
|
Revision: 8157 http://fudaa.svn.sourceforge.net/fudaa/?rev=8157&view=rev Author: deniger Date: 2012-12-19 16:33:55 +0000 (Wed, 19 Dec 2012) Log Message: ----------- Modified Paths: -------------- trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuTableCellEditor.java trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuTextField.java trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGTableGraphePanel.java Modified: trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuTableCellEditor.java =================================================================== --- trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuTableCellEditor.java 2012-12-19 16:33:20 UTC (rev 8156) +++ trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuTableCellEditor.java 2012-12-19 16:33:55 UTC (rev 8157) @@ -1,17 +1,17 @@ /** * @modification $Date: 2006-09-19 14:35:10 $ - * @statut unstable - * @file BuTableCellEditor.java - * @version 0.43 - * @author Axel von Arnim - * @email axe...@eq... - * @license GNU General Public License 2 (GPL2) - * @copyright 1998-2005 Guillaume Desnoix + * @statut unstable + * @file BuTableCellEditor.java + * @version 0.43 + * @author Axel von Arnim + * @email axe...@eq... + * @license GNU General Public License 2 (GPL2) + * @copyright 1998-2005 Guillaume Desnoix */ - package com.memoire.bu; import java.awt.Component; +import java.awt.EventQueue; import java.util.Enumeration; import java.util.EventObject; import java.util.Vector; @@ -22,66 +22,71 @@ import javax.swing.table.TableCellEditor; /** - * An editor for table cells, which controls input through - * input validators like date or integer validators. + * An editor for table cells, which controls input through input validators like date or integer validators. + * * @author Axel von Arnim, axe...@eq... */ public class BuTableCellEditor - implements TableCellEditor -{ - Object oldValue_; + implements TableCellEditor { + + Object oldValue_; BuTextField tf_; - Vector listeners_; - - public BuTableCellEditor(BuTextField _tf) - { - if(_tf==null) - throw new IllegalArgumentException /*System.err.println*/ - ("BuTableCellEditor: param _tf is null in the constructor"); - - tf_=_tf; - listeners_=new Vector(1,1); + Vector listeners_; + + public BuTableCellEditor(BuTextField _tf) { + if (_tf == null) { + throw new IllegalArgumentException /*System.err.println*/("BuTableCellEditor: param _tf is null in the constructor"); + } + + tf_ = _tf; + listeners_ = new Vector(1, 1); } - - public Component getTableCellEditorComponent - (JTable _table, Object _value, boolean _selected, int _row, int _column) - { - oldValue_=_value; + + public void setSelectAll(boolean selectAll) { + tf_.setSelectAllIsGainFocus(selectAll); + } + + public Component getTableCellEditorComponent(JTable _table, Object _value, boolean _selected, int _row, int _column) { + oldValue_ = _value; tf_.setValue(_value); return tf_; } - - public void addCellEditorListener(CellEditorListener _l) - { - if(!listeners_.contains(_l)) + + public void addCellEditorListener(CellEditorListener _l) { + if (!listeners_.contains(_l)) { listeners_.addElement(_l); + } } - - public void cancelCellEditing() - { + + public void cancelCellEditing() { tf_.setValue(oldValue_); - ChangeEvent evt=new ChangeEvent(this); - for(Enumeration e=listeners_.elements(); e.hasMoreElements();) - ((CellEditorListener)e.nextElement()).editingCanceled(evt); + ChangeEvent evt = new ChangeEvent(this); + for (Enumeration e = listeners_.elements(); e.hasMoreElements();) { + ((CellEditorListener) e.nextElement()).editingCanceled(evt); + } } - - public Object getCellEditorValue() - { return tf_.getValue(); } - - public boolean isCellEditable(EventObject _evt) - { return true; } - - public void removeCellEditorListener(CellEditorListener _l) - { listeners_.removeElement(_l); } - - public boolean shouldSelectCell(EventObject _evt) - { return true; } - - public boolean stopCellEditing() - { - ChangeEvent evt=new ChangeEvent(this); - for(Enumeration e=listeners_.elements(); e.hasMoreElements();) - ((CellEditorListener)e.nextElement()).editingStopped(evt); + + public Object getCellEditorValue() { + return tf_.getValue(); + } + + public boolean isCellEditable(EventObject _evt) { + return true; + } + + public void removeCellEditorListener(CellEditorListener _l) { + listeners_.removeElement(_l); + } + + public boolean shouldSelectCell(EventObject _evt) { + return true; + } + + public boolean stopCellEditing() { + ChangeEvent evt = new ChangeEvent(this); + for (Enumeration e = listeners_.elements(); e.hasMoreElements();) { + ((CellEditorListener) e.nextElement()).editingStopped(evt); + } return false; } } Modified: trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuTextField.java =================================================================== --- trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuTextField.java 2012-12-19 16:33:20 UTC (rev 8156) +++ trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuTextField.java 2012-12-19 16:33:55 UTC (rev 8157) @@ -1,12 +1,12 @@ /** * @modification $Date: 2007-05-04 13:41:58 $ - * @statut unstable - * @file BuTextField.java - * @version 0.43 - * @author Guillaume Desnoix - * @email gui...@de... - * @license GNU General Public License 2 (GPL2) - * @copyright 1998-2005 Guillaume Desnoix + * @statut unstable + * @file BuTextField.java + * @version 0.43 + * @author Guillaume Desnoix + * @email gui...@de... + * @license GNU General Public License 2 (GPL2) + * @copyright 1998-2005 Guillaume Desnoix */ package com.memoire.bu; @@ -36,13 +36,14 @@ * An extended text field which takes validators. */ public class BuTextField extends JTextField implements DtDragSensible { + private Color textFg_; private Color errorFg_; - private Format displayFormat_ ; + private Format displayFormat_; private boolean focusSelection_; - private String realText_ ; - private String previousText_ ; - + private String realText_; + private String previousText_; + private boolean selectAllIsGainFocus; private BuCharValidator charValidator_; private BuStringValidator stringValidator_; private BuValueValidator valueValidator_; @@ -51,6 +52,10 @@ this(null, -1); } + public void setSelectAllIsGainFocus(boolean selectAllIsGainFocus) { + this.selectAllIsGainFocus = selectAllIsGainFocus; + } + public BuTextField(int _cols) { this(null, _cols); } @@ -65,27 +70,31 @@ // Avoid using the text as a command setActionCommand("TEXT_CHANGED"); - if (_cols > 0) setColumns(_cols); + if (_cols > 0) { + setColumns(_cols); + } setText(_text == null ? "" : _text); errorFg_ = UIManager.getColor("TextField.errorForeground"); - if (errorFg_ == null) errorFg_ = BuLib.getColor(Color.red); + if (errorFg_ == null) { + errorFg_ = BuLib.getColor(Color.red); + } } // Property Display Format - public Format getDisplayFormat() { return displayFormat_; } public void setDisplayFormat(Format _format) { - if (_format == null) realText_ = null; + if (_format == null) { + realText_ = null; + } displayFormat_ = _format; } // Property Selection Mode - public boolean isFocusSelection() { return focusSelection_; } @@ -95,26 +104,34 @@ } // Property Text - public String getText() { String r; - if ((displayFormat_ != null) && !hasFocus()) r = realText_; - else + if ((displayFormat_ != null) && !hasFocus()) { + r = realText_; + } else { r = super.getText(); + } return r; } public void setAcceptEmptyValue() { - if (valueValidator_ != null) valueValidator_ = new BuValueValidator.EmptyValueValidator(valueValidator_); - if (stringValidator_ != null) stringValidator_ = BuStringValidator.getEmptyEnable(stringValidator_); + if (valueValidator_ != null) { + valueValidator_ = new BuValueValidator.EmptyValueValidator(valueValidator_); + } + if (stringValidator_ != null) { + stringValidator_ = BuStringValidator.getEmptyEnable(stringValidator_); + } } public void setText(String _text) { boolean ok = true; String s = _text; - if (!isStringValid(s)) ok = false; - else if (!isValueValid(stringToValue(s))) ok = false; + if (!isStringValid(s)) { + ok = false; + } else if (!isValueValid(stringToValue(s))) { + ok = false; + } if (ok && !hasFocus()) { Object v = stringToValue(s); @@ -127,22 +144,25 @@ } } - if (!ok) super.setForeground(errorFg_); - else + if (!ok) { + super.setForeground(errorFg_); + } else { super.setForeground(textFg_); + } super.setText(s); - if (!isEditable()) setCaretPosition(0); + if (!isEditable()) { + setCaretPosition(0); + } } // Properties Validators - public BuCharValidator getCharValidator() { return charValidator_; } /** - * Ce validator est sert \xE0 accepter ou non un caract\xE8re saisi. Il est - * consult\xE9 \xE0 chaque caract\xE8re saisi. + * Ce validator est sert \xE0 accepter ou non un caract\xE8re saisi. Il est consult\xE9 \xE0 chaque caract\xE8re saisi. + * * @param _validator Le validator. */ public void setCharValidator(BuCharValidator _validator) { @@ -154,8 +174,8 @@ } /** - * Ce validator sert \xE0 accepter ou non le format de la chaine saisie. - * Il est consult\xE9 lors de la perte de focus. + * Ce validator sert \xE0 accepter ou non le format de la chaine saisie. Il est consult\xE9 lors de la perte de focus. + * * @param _validator Le validator */ public void setStringValidator(BuStringValidator _validator) { @@ -167,8 +187,8 @@ } /** - * Ce validator sert \xE0 accepter la valeur de la chaine saisie. Il peut limiter - * la plage de valeurs. Il est consult\xE9 lors de la perte de focus. + * Ce validator sert \xE0 accepter la valeur de la chaine saisie. Il peut limiter la plage de valeurs. Il est consult\xE9 lors de la perte de focus. + * * @param _validator Le validator */ public void setValueValidator(BuValueValidator _validator) { @@ -176,9 +196,13 @@ } public void setEditable(boolean _editable) { - if (_editable == isEditable()) return; + if (_editable == isEditable()) { + return; + } super.setEditable(_editable); - if (!isEditable()) setCaretPosition(0); + if (!isEditable()) { + setCaretPosition(0); + } } public void setForeground(Color _c) { @@ -193,16 +217,23 @@ public void replaceSelection(String _s) { boolean b = true; - for (int i = 0; i < _s.length(); i++) + for (int i = 0; i < _s.length(); i++) { b &= isCharValid(_s.charAt(i)); + } - if (b) super.replaceSelection(_s); - else + if (b) { + super.replaceSelection(_s); + } else { getToolkit().beep(); + } } protected void processKeyEvent(KeyEvent _evt) { - if (_evt.getID() == KeyEvent.KEY_TYPED) if (!isCharValid(_evt.getKeyChar())) return; + if (_evt.getID() == KeyEvent.KEY_TYPED) { + if (!isCharValid(_evt.getKeyChar())) { + return; + } + } super.setForeground(textFg_); super.processKeyEvent(_evt); @@ -213,10 +244,15 @@ if (_evt.getID() == FocusEvent.FOCUS_LOST) { String s = super.getText(); - if (!isStringValid(s)) ok = false; - else if (!isValueValid(stringToValue(s))) ok = false; + if (!isStringValid(s)) { + ok = false; + } else if (!isValueValid(stringToValue(s))) { + ok = false; + } - if (displayFormat_ != null) realText_ = s; + if (displayFormat_ != null) { + realText_ = s; + } if (ok) { Object v = stringToValue(s); @@ -228,11 +264,16 @@ s = displayFormat_.format(v); } - if (s != null && !s.equals(super.getText())) super.setText(s); + if (s != null && !s.equals(super.getText())) { + super.setText(s); + } - if (((previousText_ == null) && (s != null)) || ((previousText_ != null) && !previousText_.equals(s))) fireActionPerformed(); - } else + if (((previousText_ == null) && (s != null)) || ((previousText_ != null) && !previousText_.equals(s))) { + fireActionPerformed(); + } + } else { getToolkit().beep(); + } } if (_evt.getID() == FocusEvent.FOCUS_GAINED) { @@ -247,7 +288,9 @@ p = getCaretPosition(); s = valueToString(v); previousText_ = s; - if (!s.equals(super.getText())) super.setText(s); + if (!s.equals(super.getText())) { + super.setText(s); + } } } @@ -255,7 +298,9 @@ setSelectionStart(0); setSelectionEnd(s.length()); } else { - if (p >= 0) setCaretPosition(Math.max(0, Math.min(p, s.length()))); + if (p >= 0) { + setCaretPosition(Math.max(0, Math.min(p, s.length()))); + } } Container parent = getParent(); @@ -266,11 +311,16 @@ r = getBounds(); ((JComponent) parent).scrollRectToVisible(r); } + if(selectAllIsGainFocus){ + selectAll(); + } } - if (!ok) super.setForeground(errorFg_); - else + if (!ok) { + super.setForeground(errorFg_); + } else { super.setForeground(textFg_); + } repaint(); super.processFocusEvent(_evt); @@ -281,9 +331,12 @@ if ((r != null) && (stringValidator_ != null)) { if (isStringValid(_string)) { r = stringValidator_.stringToValue(_string); - if (!isValueValid(r)) r = null; - } else + if (!isValueValid(r)) { + r = null; + } + } else { r = null; + } } return r; } @@ -291,32 +344,47 @@ public String valueToString(Object _value) { String r = null; - if (isValueValid(_value)) if (stringValidator_ != null) r = stringValidator_.valueToString(_value); + if (isValueValid(_value)) { + if (stringValidator_ != null) { + r = stringValidator_.valueToString(_value); + } + } - if (_value == null) r = ""; - else if (r == null) r = "" + _value; + if (_value == null) { + r = ""; + } else if (r == null) { + r = "" + _value; + } return r; } private boolean isCharValid(char _char) { boolean r = true; - if (_char == 8) r = true; - else if (_char == 255) r = false; - else if (charValidator_ != null) r = charValidator_.isCharValid(_char); + if (_char == 8) { + r = true; + } else if (_char == 255) { + r = false; + } else if (charValidator_ != null) { + r = charValidator_.isCharValid(_char); + } return r; } private boolean isStringValid(String _value) { boolean r = true; - if (stringValidator_ != null) r = stringValidator_.isStringValid(_value); + if (stringValidator_ != null) { + r = stringValidator_.isStringValid(_value); + } return r; } private boolean isValueValid(Object _value) { boolean r = true; - if (valueValidator_ != null) r = valueValidator_.isValueValid(_value); + if (valueValidator_ != null) { + r = valueValidator_.isValueValid(_value); + } return r; } @@ -329,7 +397,6 @@ } // Anti-aliasing - public void paint(Graphics _g) { BuLib.setAntialiasing(this, _g); super.paint(_g); @@ -344,20 +411,20 @@ } // Drop - public void setDropTarget(DropTarget _dt) { super.setDropTarget(_dt); if (_dt != null) { // FuLog.debug("BTF: setDropTarget"); try { _dt.removeDropTargetListener(DtDragSensible.SINGLETON); - } catch (IllegalArgumentException ex) {} + } catch (IllegalArgumentException ex) { + } try { _dt.addDropTargetListener(DtDragSensible.SINGLETON); - } catch (TooManyListenersException ex) {} + } catch (TooManyListenersException ex) { + } } } - protected boolean drop_; protected Rectangle getDropRect() { @@ -387,7 +454,6 @@ } // Factory - public static BuTextField createIntegerField() { BuTextField r = new BuTextField(); r.setCharValidator(BuCharValidator.INTEGER); @@ -469,7 +535,6 @@ } // Test - public static final JComponent launch(String argv[]) { JComponent content = new JPanel(); Modified: trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGTableGraphePanel.java =================================================================== --- trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGTableGraphePanel.java 2012-12-19 16:33:20 UTC (rev 8156) +++ trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGTableGraphePanel.java 2012-12-19 16:33:55 UTC (rev 8157) @@ -14,6 +14,7 @@ import java.awt.Dimension; import java.awt.Insets; import java.awt.event.ActionEvent; +import java.awt.event.FocusEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; @@ -35,7 +36,6 @@ import org.fudaa.ctulu.CtuluDoubleParser; import org.fudaa.ctulu.CtuluLibString; import org.fudaa.ctulu.editor.CtuluValueEditorI; -import org.fudaa.ctulu.gui.CtuluCellDecorator; import org.fudaa.ctulu.gui.CtuluCellTextRenderer; import org.fudaa.ctulu.gui.CtuluLibSwing; import org.fudaa.ctulu.gui.CtuluSelectionListTableModelUpdater; @@ -51,36 +51,42 @@ * @version $Id: EGTableGraphePanel.java,v 1.31 2007-06-05 08:58:39 deniger Exp $ */ public class EGTableGraphePanel extends BuPanel implements EGSelectionListener, EGGrapheModelListener { - + + public BuTextField createEditorDoubleTextField() { + BuTextField r = BuTextField.createDoubleField(); + r.setSelectAllIsGainFocus(true); + return r; + } + public static class SpecTableModel extends EGTableModel { - + private EGTableGraphePanel graphePanel; Double newX_; Double newY_; - + public SpecTableModel(EGTableGraphePanel graphePanel) { this.graphePanel = graphePanel; } - + @Override public void fireTableRowsDeleted(int firstRow, int lastRow) { newX_ = null; newY_ = null; super.fireTableRowsDeleted(firstRow, lastRow); } - + @Override protected void selectedCourbeChanged(final EGCourbe _a) { newX_ = null; newY_ = null; super.selectedCourbeChanged(_a); } - + @Override public Class getColumnClass(final int _columnIndex) { return Double.class; } - + @Override public int getRowCount() { final EGAxeHorizontal h = getH(); @@ -92,7 +98,7 @@ } return super.getRowCount(); } - + @Override public Object getValueAt(final int _rowIndex, final int _columnIndex) { if (c_ == null) { @@ -109,7 +115,7 @@ return super.getValueAt(_rowIndex, _columnIndex); } boolean updating_; - + @Override public void setValueAt(final Object _value, final int _rowIndex, final int _columnIndex) { if (updating_ || c_ == null || _value == null || _value.toString().trim().length() == 0) { @@ -117,7 +123,7 @@ } if (_rowIndex == c_.getModel().getNbValues()) { try { - + final Double d = CtuluDoubleParser.parseValue(_value.toString()); if (d == null) { return; @@ -157,7 +163,7 @@ } } } - + private static Action getEnterAction() { return new AbstractAction() { @Override @@ -169,7 +175,7 @@ if (t.isEditing()) { t.getCellEditor().stopCellEditing(); } - + if (col == tableModel.yColIndex) { col = tableModel.xColIndex; row++; @@ -184,11 +190,11 @@ t.getColumnModel().getSelectionModel().setSelectionInterval(col, col); t.scrollRectToVisible(t.getCellRect(row, col, true)); } - + } }; } - + public static void setDefaultEnterAction(final JTable _t) { final ActionMap map = _t.getActionMap(); map.put("theSuperActionOfTheyear", EGTableGraphePanel.getEnterAction()); @@ -212,17 +218,17 @@ * @version $Id: EGTableGraphePanel.java,v 1.31 2007-06-05 08:58:39 deniger Exp $ */ public static class EvolTable extends CtuluTable { - + Action deleteAction; - + public EvolTable() { super(); setTransferHandler(new EgCourbeTransfertHandler()); } - + @Override protected String transformToString(Object value) { - + return super.transformToString(value); } @@ -242,20 +248,20 @@ super(_model); setTransferHandler(new EgCourbeTransfertHandler()); } - + void setDeleteAction(Action deleteAction) { this.deleteAction = deleteAction; } - + protected void delete() { deleteAction.actionPerformed(null); } - + @Override public TransferHandler getTransferHandler() { return super.getTransferHandler(); } - + public EGTableModel getEGTableModel() { return (EGTableModel) super.getModel(); } @@ -272,7 +278,7 @@ int selectedColumm = getSelectedColumn(); int selectedRow = getSelectedRow(); final CtuluDoubleParser doubleParser = new CtuluDoubleParser(); - + final CtuluCommandComposite cmp = new CtuluCommandComposite(); if (selectedRow >= 0) { int maxUpdate = updateLines(_tab, model, selectedColumm, selectedRow, doubleParser, cmp); @@ -284,7 +290,7 @@ } model.a_.getCmd().addCmd(cmp.getSimplify()); } - + public void cut() { // vide on fait rien if (getSelectionModel().isSelectionEmpty()) { @@ -301,7 +307,7 @@ model.c_.getModel().removeValue(row, model.a_.getCmd()); } } - + private void addValuesInModel(final List _tab, final EGTableModel _model, final CtuluDoubleParser _doubleParser, final CtuluCommandComposite _cmp, final int _maxUpdate) { final int nbLine = _tab.size(); @@ -343,15 +349,15 @@ newX.add(x); newY.add(y); } - + } - + } if (newX.size() > 0) { _model.addValueAt(newX.toNativeArray(), newY.toNativeArray(), _cmp); } } - + private int updateLines(final List _tab, final EGTableModel _model, final int _selectedColumm, final int _selectedRow, final CtuluDoubleParser _doubleParser, final CtuluCommandComposite _cmp) { final int nbLine = _tab.size(); @@ -386,7 +392,7 @@ return maxUpdate; } private boolean canEdit_; - + @Override protected boolean processKeyBinding(final KeyStroke _ks, final KeyEvent _e, final int _condition, final boolean _pressed) { @@ -396,7 +402,7 @@ if (action != null) { return SwingUtilities.notifyAction(action, _ks, _e, this, _e.getModifiers()); - + } } final int keyCode = _ks.getKeyCode(); @@ -421,7 +427,7 @@ } return super.processKeyBinding(_ks, _e, _condition, _pressed); } - + @Override public boolean editCellAt(final int _row, final int _column) { if (canEdit_) { @@ -431,14 +437,10 @@ return false; } } - + public CtuluCellTextRenderer getDefaultRenderer() { return renderer_; } - - - - final CtuluCellTextRenderer renderer_ = new CtuluCellTextRenderer() { @Override public Component getTableCellRendererComponent(JTable _table, Object _value, boolean _isSelected, @@ -463,7 +465,7 @@ } return this; } - + @Override protected void setValue(final Object _value) { if (_value == null) { @@ -475,16 +477,16 @@ }; EGInteractionSelection selection_; EvolTable t_; - + public EGTableGraphePanel() { this(true); } - + public EvolTable getTable() { return t_; } boolean afficheNomCourbe_ = true; - + public BuLabel getTitleLabel() { return lb_; } @@ -511,16 +513,21 @@ return null; } CtuluValueEditorI r = null; - if (_column == 0 && a_ != null && a_.getTransformer().getXAxe() != null) { + SpecTableModel tableModel = (SpecTableModel) t_.getModel(); + if (_column == tableModel.getXColIndex() && a_ != null && a_.getTransformer().getXAxe() != null) { r = a_.getTransformer().getXAxe().getValueEditor(); - } else if (_column == 1 && a_ != null && a_.getSelectedComponent() != null) { + } else if (_column == tableModel.getYColIndex() && a_ != null && a_.getSelectedComponent() != null) { r = a_.getSelectedComponent().getAxeY().getValueEditor(); - + } final TableCellEditor ed = r == null ? null : r.createTableEditorComponent(); - return ed == null ? super.getCellEditor(_row, _column) : ed; + final TableCellEditor finalCellEditor = ed == null ? super.getCellEditor(_row, _column) : ed; + if (finalCellEditor instanceof BuTableCellEditor) { + ((BuTableCellEditor) finalCellEditor).setSelectAll(true); + } + return finalCellEditor; } - + @Override public TableCellRenderer getDefaultRenderer(final Class _columnClass) { if (Double.class @@ -532,7 +539,7 @@ }; t_.setDeleteAction(getActionDelete()); setDefaultEnterAction(t_); - final BuTextField txt = BuTextField.createDoubleField(); + final BuTextField txt = createEditorDoubleTextField(); txt.setColumns(10); t_ .setDefaultEditor(Double.class, new BuTableCellEditor(txt) { @@ -544,7 +551,7 @@ return true; } }); - + t_.setModel(createValuesTableModel()); t_.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); t_.setCellSelectionEnabled(true); @@ -562,11 +569,11 @@ add(pn, BuBorderLayout.SOUTH); setPreferredSize(new Dimension(150, 200)); } - + protected SpecTableModel createValuesTableModel() { return new SpecTableModel(this); } - + private void eventReceived() { if (t_.getCellEditor() != null) { t_.getCellEditor().cancelCellEditing(); @@ -589,7 +596,7 @@ } } } - + void updateButtons() { final EGCourbe c = a_.getSelectedComponent(); if (btAdd_ != null) { @@ -619,7 +626,7 @@ } } } - + private void updateDatas(final EGCourbe _c) { if (t_.getCellEditor() != null) { t_.getCellEditor().cancelCellEditing(); @@ -631,7 +638,7 @@ TableColumn column = t_.getColumnModel().getColumn(i); column.setHeaderValue(getSpecTableModel().getColumnName(i)); } - + if (_c == null) { lb_.setText(CtuluLibString.ESPACE); lbCourbeInfo_.setText(CtuluLibString.ESPACE); @@ -656,60 +663,60 @@ doLayout(); repaint(); } - + protected void tableCopy() { t_.copy(); } - + protected void tableCut() { t_.cut(); } - + protected void tablePaste() { t_.paste(); } EbliActionSimple actionDelete; - + public EbliActionSimple getActionDelete() { if (actionDelete == null) { actionDelete = new DeleteAction(); } return actionDelete; - - + + } - + public class DeleteAction extends EbliActionSimple { - + public DeleteAction() { super(EbliLib.getS("Supprimer des points"), EbliResource.EBLI.getToolIcon("node-delete"), "REMOVE_POINTS"); putValue(ACCELERATOR_KEY, getDeleteKeyStroke()); } - + @Override public void updateStateBeforeShow() { setEnabled(btRemove_.isEnabled()); } - + @Override public void actionPerformed(ActionEvent _e) { btRemove_.doClick(); } } - + public static KeyStroke getDeleteKeyStroke() { return KeyStroke.getKeyStroke("control D"); } boolean addTopButtons = true; - + public boolean isAddTopButtons() { return addTopButtons; } - + public void setAddTopButtons(boolean addTopButtons) { this.addTopButtons = addTopButtons; } - + public void addPanelAction(final EGFillePanel _p) { // si le contenu n'est pas modifiable ou si les boutons ont deja ete // initialise on oublie .... @@ -761,51 +768,51 @@ btRemove_.doClick(); } }); - + } - + public static void removeButton(JButton bt) { if (bt != null && bt.getParent() != null) { bt.getParent().remove(bt); } } - + public void removeEditButtons() { removeButton(btAdd_); removeButton(btAlign_); removeButton(btRemove_); } - + public void setLabel(final BuLabel _lb) { lbXyInfo_ = _lb; } - + @Override public void axeAspectChanged(final EGAxe _c) { } - + @Override public void axeContentChanged(final EGAxe _c) { (getSpecTableModel()).fireTableChanged(new TableModelEvent(getSpecTableModel(), 0, getSpecTableModel().getRowCount() - 1, TableModelEvent.ALL_COLUMNS, TableModelEvent.UPDATE)); repaint(); } - + public SpecTableModel getSpecTableModel() { return (SpecTableModel) t_.getModel(); } - + @Override public void courbeAspectChanged(final EGObject _c, final boolean _visibil) { } - + @Override public void courbeContentChanged(final EGObject _c, final boolean _mustRestore) { eventReceived(); } - + public void intervalAdded(final ListDataEvent _e) { } - + public void intervalRemoved(final ListDataEvent _e) { } @@ -827,7 +834,7 @@ updateDatas(_a.getSelectedComponent()); eventReceived(); } - + public void updateState() { updateDatas(a_.getSelectedComponent()); updateButtons(); @@ -843,7 +850,7 @@ return; } if (selection_ != null && updater_ != null) { - + selection_.getSelection().removeListeSelectionListener(updater_); t_.getSelectionModel().removeListSelectionListener(updater_); } @@ -853,7 +860,7 @@ protected void doAfterCtuluListSectionChanged() { updateButtons(); } - + @Override protected void doAfterTableSectionChanged() { updateButtons(); @@ -861,7 +868,7 @@ } }; } - + protected void updateRowSelection() { final int[] rows = t_.getSelectedRows(); if (rows != null) { @@ -888,18 +895,18 @@ t_.getColumnModel().getColumn(1).setHeaderValue(_t); revalidate(); } - + @Override public void structureChanged() { } - + @Override public void valueChanged(final ListSelectionEvent _e) { updateDatas(a_.getSelectedComponent()); updateButtons(); - + } - + @Override public void valueChanged(final TreeSelectionEvent _e) { final Object o = _e.getPath().getLastPathComponent(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |