Update of /cvsroot/queryviewer/queryviewer/src/net/sourceforge/queryviewer/ui/swing
In directory sc8-pr-cvs1:/tmp/cvs-serv1481/swing
Modified Files:
QueryJPanel.java
Log Message:
adaptation à ViewInfo, ajout d'une méthode pour retrouver un onglet grâce à son nom
Index: QueryJPanel.java
===================================================================
RCS file: /cvsroot/queryviewer/queryviewer/src/net/sourceforge/queryviewer/ui/swing/QueryJPanel.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** QueryJPanel.java 22 Jun 2003 21:28:00 -0000 1.8
--- QueryJPanel.java 23 Jun 2003 14:42:02 -0000 1.9
***************
*** 14,17 ****
--- 14,18 ----
import net.sourceforge.queryviewer.ui.ViewInfo;
import net.sourceforge.queryviewer.ui.event.ControlerFactory;
+ import net.sourceforge.queryviewer.ui.event.QueryActions;
/**
***************
*** 63,85 ****
/**
* @see net.sourceforge.queryviewer.ui.swing.ConnectionListener#jdbcConnection(java.sql.Connection)
* @deprecated use the Actions... {@link net.sourceforge.queryviewer.ui.event.AbstractAction}.
*/
! /*
! public void jdbcConnection(Connection connection) {
try {
! this.it = new InfoTab(connection);
! this.jtp.addTab(QueryJPanel.INFO_TAB, this.it);
! Query q = new Query(new net.sourceforge.queryviewer.JDBCConnectionImpl(connection));
! this.qt = new QueryTab(q);
! //TODO Attention à qui écoute qui et quoi?
! //this.qt.addQueryListener(new JDBCQueryImpl(connection));
! this.jtp.addTab(QueryJPanel.QUERY_TAB, this.qt);
} catch ( QueryException qex ) {
! // ???
} // end of try-catch
}
- */
/**
--- 64,85 ----
/**
+ * ne PLUS UTILISER CETTE METHODE
* @see net.sourceforge.queryviewer.ui.swing.ConnectionListener#jdbcConnection(java.sql.Connection)
* @deprecated use the Actions... {@link net.sourceforge.queryviewer.ui.event.AbstractAction}.
*/
! public void jdbcConnection(Connection connection) {
try {
! this.it = new InfoTab(connection);
! this.jtp.addTab(QueryJPanel.INFO_TAB, this.it);
! Query q = new Query(new net.sourceforge.queryviewer.JDBCConnectionImpl(connection));
! this.qt = new QueryTab(q);
! //TODO Attention à qui écoute qui et quoi?
! //this.qt.addQueryListener(new JDBCQueryImpl(connection));
! this.jtp.addTab(QueryJPanel.QUERY_TAB, this.qt);
} catch ( QueryException qex ) {
! // ???
} // end of try-catch
}
/**
***************
*** 93,97 ****
}
! /* (non-Javadoc)
* @see net.sourceforge.queryviewer.ConnectionListener#connection(net.sourceforge.queryviewer.Connection)
*/
--- 93,97 ----
}
! /** À quoi sert cette méthode???
* @see net.sourceforge.queryviewer.ConnectionListener#connection(net.sourceforge.queryviewer.Connection)
*/
***************
*** 122,125 ****
--- 122,166 ----
public void setUserInputs(Map inputs) {
+ }
+
+ /**
+ * Retourne le nom de l'onglet affiché si la clé est bien {@link net.sourceforge.queryviewer.ui.event.QueryActions.CURRENT_TAB}.
+ * @param key la clé
+ * @return la valeur qu'il y a dans le composant
+ */
+ public String getUserValue(String key) {
+ String result = null;
+ if ( QueryActions.CURRENT_TAB.equals(key) ) {
+ result = this.jtp.getTitleAt( this.jtp.getSelectedIndex() );
+ } // end of if ()
+
+ return result;
+ }
+
+ /**
+ * Changement de l'onglet courrant si la clé est bien {@link net.sourceforge.queryviewer.ui.event.QueryActions.CURRENT_TAB}.
+ * @param key la clé
+ * @param value la valeur à mettre à jour dans le composant
+ */
+ public void putUserValue(String key, String value) {
+ if ( QueryActions.CURRENT_TAB.equals(key) ) {
+ this.jtp.setSelectedIndex( this.getIndexOf( value ) );
+ } // end of if ()
+
+ }
+
+ /**
+ * Retrouve l'index de l'onglet en fonction de son nom.
+ * @param name le nom de l'onglet
+ * @return l'index de l'onglet
+ */
+ private int getIndexOf( String name ) {
+ int tabs = this.jtp.getTabCount();
+ int index = -1;
+ boolean found = false;
+ while ( !found && index<tabs ) {
+ found = this.jtp.getTitleAt( ++index ).equals( name );
+ } // end of while ()
+ return (found) ? index : -1;
}
|