Skip to content

Commit

Permalink
topcat: fix CDS upload window to require table metadata
Browse files Browse the repository at this point in the history
Now the Go button in this window is only enabled (and coverage
information displayed) when table metadata has been successfully
downloaded for the selected table.
Thomas Boch advises this is a reliable indicator of whether the
table can be successfully matched.
  • Loading branch information
mbtaylor committed Jul 3, 2014
1 parent b56a358 commit ed25c1f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 35 deletions.
8 changes: 5 additions & 3 deletions topcat/src/docs/sun253.xml
Expand Up @@ -16323,9 +16323,9 @@ field, and may be in one of the following forms:
<p>When a table name has been entered, additional information
(Name, Alias, Description and Row Count)
will be downloaded from CDS and displayed in the lower part of the
Remote Table panel. If something shows up here, it is a good indication
that you have a legal table name, though occasionally this metadata
is not available.
Remote Table panel. If nothing shows up here, then the table name
is not legal for the X-Match service, and the <label>Go</label> button
will be disabled.
</p>

<p>Sky coverage information is also displayed, including the proportion
Expand Down Expand Up @@ -16402,6 +16402,8 @@ about how the match will operate:
button and the match will start; progress will be logged in the progress
bar at the bottom of the window. To stop the match before it has
completed, hit the <label>Stop</label> button.
Note that the <label>Go</label> button is only enabled when a legal
table name has been entered at the top.
</p>

<p>The remote table in most cases contains only a subset of the
Expand Down
77 changes: 46 additions & 31 deletions topcat/src/main/uk/ac/starlink/topcat/join/CdsTableSelector.java
Expand Up @@ -169,6 +169,17 @@ public void setEnabled( boolean isEnabled ) {
nameSelector_.setEnabled( isEnabled );
}

/**
* Returns the object that manages metadata downloads for the
* currently-selected table.
*
* @return metadata downloader; this will not change over the
* lifetime of this object
*/
public Downloader<VizierMeta> getMetadataDownloader() {
return metaDownloader_;
}

/**
* Invoked when the selected table name may have changed.
* Updates the display accordingly.
Expand All @@ -177,6 +188,8 @@ public void setEnabled( boolean isEnabled ) {
private void updateTableName() {
String tableName = (String) nameSelector_.getSelectedItem();
tableName_ = tableName;
setMetadata( null );
setMoc( null );

/* Reset the downloaded coverage information. Action will be taken
* by the setMetadata method to populate this with non-empty
Expand Down Expand Up @@ -235,45 +248,47 @@ private void setMetadata( VizierMeta meta ) {
if ( alias != null && alias.equals( name ) ) {
alias = null;
}

/* Having got the metadata we can now get the MOC,
* asynchronously if required.
* It would be more straightforward and reliable to get the MOC
* concurrently as soon as the alias-or-id entered by the user
* is known, but Thomas Boch (CDS) advises/requests that by
* preference the table name rather than alias should be used
* for MOC retrieval (though by alias usually seems to work),
* and we may not have the name until we have the metadata.
* But if the name is not available for some reason, fall back
* to what we have, which is whatever the user entered. */
String mocName = name == null ? getTableName() : name;
mocDownloader_.setTableName( mocName );
if ( mocDownloader_.isComplete() ) {
setMoc( mocDownloader_.getData() );
}
else {
if ( mocFuture_ != null ) {
mocFuture_.cancel( true );
}
mocFuture_ = mocExecutor_.submit( new Runnable() {
public final void run() {
final MocCoverage moc = mocDownloader_.waitForData();
SwingUtilities.invokeLater( new Runnable() {
public void run() {
setMoc( moc );
}
} );
}
} );
}
}

/* Populate the metadata fields. */
setMetaField( nameField_, name );
setMetaField( aliasField_, alias );
setMetaField( descField_, description );
setMetaField( nrowField_,
nrow == null
? null
: TopcatUtils.formatLong( nrow.longValue() ) );

/* Having got the metadata (successfully or otherwise)
* we can now get the MOC, asynchronously if required.
* It would be more straightforward and reliable to get the MOC
* concurrently as soon as the alias-or-id entered by the user
* is known, but Thomas Boch (CDS) advises/requests that by
* preference the table name rather than alias should be used
* for MOC retrieval (though by alias usually seems to work),
* and we may not have the name until we have the metadata.
* But if the name is not available for some reason, fall back
* to what we have, which is whatever the user entered. */
String mocName = name == null ? getTableName() : name;
mocDownloader_.setTableName( mocName );
if ( mocDownloader_.isComplete() ) {
setMoc( mocDownloader_.getData() );
}
else {
if ( mocFuture_ != null ) {
mocFuture_.cancel( true );
}
mocFuture_ = mocExecutor_.submit( new Runnable() {
public final void run() {
final MocCoverage moc = mocDownloader_.waitForData();
SwingUtilities.invokeLater( new Runnable() {
public void run() {
setMoc( moc );
}
} );
}
} );
}
}

/**
Expand Down
15 changes: 14 additions & 1 deletion topcat/src/main/uk/ac/starlink/topcat/join/UploadMatchPanel.java
Expand Up @@ -54,6 +54,7 @@
import uk.ac.starlink.ttools.cone.UploadMatcher;
import uk.ac.starlink.ttools.cone.WrapperQuerySequence;
import uk.ac.starlink.util.gui.ComboBoxBumper;
import uk.ac.starlink.util.gui.Downloader;
import uk.ac.starlink.util.gui.ShrinkWrapper;
import uk.ac.starlink.vo.DoubleValueField;

Expand All @@ -77,6 +78,7 @@ public class UploadMatchPanel extends JPanel {
private final Action startAction_;
private final Action stopAction_;
private final ToggleButtonModel coverageModel_;
private final Downloader<CdsUploadMatcher.VizierMeta> metaDownloader_;
private TopcatModel tcModel_;
private volatile MatchWorker matchWorker_;

Expand Down Expand Up @@ -109,6 +111,16 @@ public UploadMatchPanel( JProgressBar progBar ) {
BorderFactory.createEmptyBorder( 5, 5, 5, 5 ) ) );
cList.add( cdsTableSelector_ );

/* Make sure the Start button is only enabled when there is metadata
* for the table. This should be an indicator of whether a legal
* table name is selected. */
metaDownloader_ = cdsTableSelector_.getMetadataDownloader();
metaDownloader_.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent evt ) {
updateState();
}
} );

/* Containers for different input fields. */
JComponent localBox = Box.createVerticalBox();
JComponent paramBox = Box.createVerticalBox();
Expand Down Expand Up @@ -344,7 +356,8 @@ private void setActive( MatchWorker worker ) {
*/
private void updateState() {
boolean isActive = matchWorker_ != null;
startAction_.setEnabled( ! isActive );
boolean hasMeta = metaDownloader_.getData() != null;
startAction_.setEnabled( ! isActive && hasMeta );
stopAction_.setEnabled( isActive );
for ( int i = 0; i < components_.length; i++ ) {
components_[ i ].setEnabled( ! isActive );
Expand Down

0 comments on commit ed25c1f

Please sign in to comment.