001/* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2016 005 * Space Science and Engineering Center (SSEC) 006 * University of Wisconsin - Madison 007 * 1225 W. Dayton Street, Madison, WI 53706, USA 008 * https://www.ssec.wisc.edu/mcidas 009 * 010 * All Rights Reserved 011 * 012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and 013 * some McIDAS-V source code is based on IDV and VisAD source code. 014 * 015 * McIDAS-V is free software; you can redistribute it and/or modify 016 * it under the terms of the GNU Lesser Public License as published by 017 * the Free Software Foundation; either version 3 of the License, or 018 * (at your option) any later version. 019 * 020 * McIDAS-V is distributed in the hope that it will be useful, 021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 023 * GNU Lesser Public License for more details. 024 * 025 * You should have received a copy of the GNU Lesser Public License 026 * along with this program. If not, see http://www.gnu.org/licenses. 027 */ 028 029package edu.wisc.ssec.mcidasv.chooser; 030 031import static javax.swing.GroupLayout.Alignment.BASELINE; 032import static javax.swing.GroupLayout.Alignment.LEADING; 033import static javax.swing.GroupLayout.Alignment.TRAILING; 034import static javax.swing.LayoutStyle.ComponentPlacement.RELATED; 035import static javax.swing.LayoutStyle.ComponentPlacement.UNRELATED; 036 037import java.awt.BorderLayout; 038import java.awt.FlowLayout; 039import java.awt.event.ActionEvent; 040import java.awt.event.ActionListener; 041import java.awt.event.KeyEvent; 042import java.awt.event.KeyListener; 043import java.io.File; 044import java.lang.reflect.Method; 045import java.util.ArrayList; 046import java.util.Hashtable; 047import java.util.List; 048import java.util.Map; 049 050import javax.swing.BorderFactory; 051import javax.swing.Box; 052import javax.swing.BoxLayout; 053import javax.swing.GroupLayout; 054import javax.swing.JButton; 055import javax.swing.JComboBox; 056import javax.swing.JComponent; 057import javax.swing.JLabel; 058import javax.swing.JOptionPane; 059import javax.swing.JPanel; 060import javax.swing.JRadioButton; 061import javax.swing.JTextField; 062import javax.swing.plaf.FileChooserUI; 063 064import org.slf4j.Logger; 065import org.slf4j.LoggerFactory; 066import org.w3c.dom.Element; 067 068import ucar.unidata.idv.chooser.IdvChooser; 069import ucar.unidata.idv.chooser.IdvChooserManager; 070import ucar.unidata.util.GuiUtils; 071import ucar.unidata.util.PreferenceList; 072import edu.wisc.ssec.mcidasv.Constants; 073import edu.wisc.ssec.mcidasv.chooser.adde.AddeChooser; 074import edu.wisc.ssec.mcidasv.util.McVGuiUtils; 075import edu.wisc.ssec.mcidasv.util.McVGuiUtils.Width; 076import ucar.unidata.xml.XmlObjectStore; 077 078/** 079 * Polar Orbit Track Chooser 080 * Allows user to load TLE files for display in McIDAS-V via three methods: 081 * Remote: ADDE or URL 082 * Local: file 083 * 084 * @author Gail Dengel and Tommy Jasmin 085 */ 086 087public class PolarOrbitTrackChooser extends AddeChooser implements Constants { 088 089 private static final long serialVersionUID = 1L; 090 091 private static final Logger logger = LoggerFactory.getLogger(PolarOrbitTrackChooser.class); 092 093 // chooser for local files 094 TLEFileChooser tlefc = null; 095 096 /** Connect button--we need to be able to disable this. */ 097 JButton connectButton = McVGuiUtils.makeImageTextButton(ICON_CONNECT_SMALL, "Connect"); 098 099 /** Manage button. */ 100 JButton manageButton = 101 McVGuiUtils.makeImageButton("/edu/wisc/ssec/mcidasv/resources/icons/toolbar/preferences-system22.png", 102 this, "doManager", null, "Manage servers"); 103 104 /** Public button--we need to draw a menu from this. */ 105 JButton publicButton = 106 McVGuiUtils.makeImageButton("/edu/wisc/ssec/mcidasv/resources/icons/toolbar/show-layer-controls22.png", 107 this, "showGroups", null, "List public datasets"); 108 109 private JComboBox serverSelector; 110 private JRadioButton localBtn; 111 private JRadioButton addeBtn; 112 private JRadioButton urlBtn; 113 private JLabel descLabel; 114 List<JComponent> addeList = new ArrayList<JComponent>(); 115 116 /** Manages the pull down list of URLs. */ 117 private PreferenceList prefList; 118 119 /** List of URLs. */ 120 private JComboBox box; 121 private JTextField boxEditor; 122 123 private boolean propsOk = false; 124 125 /** Text type. */ 126 private static final String TLE_TYPE = "text"; 127 128 /** Property ID used to get the list or URLs. */ 129 public static final String PREF_URLLIST = "idv.urllist"; 130 131 /** Property ID used to determine the last {@literal "source"}. */ 132 public static final String PROP_LAST_SOURCE = "mcidasv.chooser.tle.lastsource"; 133 134 /** Property value that represents the {@literal "local"} button. */ 135 public static final String FILE_SOURCE = "FILE"; 136 137 /** Property value that represents the {@literal "ADDE"} button. */ 138 public static final String ADDE_SOURCE = "ADDE"; 139 140 /** Property value that represents the {@literal "URL"} button. */ 141 public static final String URL_SOURCE = "URL"; 142 143 /** 144 * Property for the tle server name key. 145 * @see #getServer() 146 */ 147 public static String TLE_SERVER_NAME_KEY = "tle_server"; 148 public static String URL_NAME_KEY = "url_name"; 149 public static String LOCAL_FILE_KEY = "file_object"; 150 151 /** 152 * Property for the TLE group name key. 153 * @see #getGroup() 154 */ 155 public static String TLE_GROUP_NAME_KEY = "tle_group"; 156 157 /** Property for the TLE user ID. */ 158 public static String TLE_USER_ID_KEY = "tle_user"; 159 160 /** Property for the TLE project number. */ 161 public static String TLE_PROJECT_NUMBER_KEY = "tle_proj"; 162 163 /** TLE data source identifier. */ 164 public static final String TLE_DATA_SOURCE_ID = "TLE"; 165 166 /** TLE display type. */ 167 public static final String TLE_DISPLAY_TYPE = "tledisplay"; 168 169 /** TLE data source type. */ 170 public static final String TLE_DATA_TYPE = "TEXT"; 171 172 /** 173 * Construct an Adde image selection widget 174 * 175 * @param mgr The chooser manager 176 * @param root The chooser.xml node 177 */ 178 public PolarOrbitTrackChooser(IdvChooserManager mgr, Element root) { 179 super(mgr, root); 180 serverSelector = getServerSelector(); 181 showServers(); 182 } 183 184 /** 185 * Return the data source ID. 186 * 187 * @return {@link #TLE_DATA_SOURCE_ID} 188 */ 189 @Override protected String getDataSourceId() { 190 return TLE_DATA_SOURCE_ID; 191 } 192 193 /** 194 * Make the UI for this selector. 195 * 196 * @return The gui 197 */ 198 @Override public JComponent doMakeContents() { 199 logger.debug("doMakeContents() in..."); 200 JPanel outerPanel = new JPanel(); 201 JPanel addePanel = new JPanel(); 202 addePanel = (JPanel)makeAddePanel(); 203 204 // retrieve our last visited directory 205 String path = (String)getIdv().getStateManager().getPreference(IdvChooser.PREF_DEFAULTDIR + getId()); 206 String file = (String)getIdv().getStateManager().getPreference(IdvChooser.PREF_DEFAULTDIR + getId() + ".file"); 207 tlefc = new TLEFileChooser(this, path, file); 208// tlefc.setPotc(this); 209 210 JButton helpButton = McVGuiUtils.makeImageButton(ICON_HELP, "Show help"); 211 helpButton.setActionCommand(GuiUtils.CMD_HELP); 212 helpButton.addActionListener(this); 213 214 JButton refreshButton = McVGuiUtils.makeImageButton(ICON_REFRESH, "Refresh"); 215 refreshButton.setActionCommand(GuiUtils.CMD_UPDATE); 216 refreshButton.addActionListener(this); 217 218 McVGuiUtils.setComponentWidth(loadButton, Width.DOUBLE); 219 220 outerPanel.setLayout(new BorderLayout()); 221 JPanel choicePanel = new JPanel(new BorderLayout()); 222 JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING)); 223 224 // load the local and remote choices in a Box in center panel 225 JPanel centerPanel = new JPanel(); 226 centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.PAGE_AXIS)); 227 JPanel localPanel = new JPanel(new BorderLayout()); 228 229 // create border like the remote panel (titled) but include the 230 // gap that remote panel creates with various GroupLayout effects 231 localPanel.setBorder(BorderFactory.createCompoundBorder( 232 BorderFactory.createTitledBorder("Local"), 233 BorderFactory.createEmptyBorder(GAP_RELATED, GAP_RELATED, GAP_RELATED, GAP_RELATED))); 234 235 JPanel remotePanel = new JPanel(); 236 remotePanel.setBorder(BorderFactory.createTitledBorder("Remote")); 237 238 // populate the local access panel 239 localPanel.add(localBtn, BorderLayout.NORTH); 240 localPanel.add(tlefc, BorderLayout.CENTER); 241 242 // populate the remote access panel 243 remotePanel.add(addePanel); 244 245 centerPanel.add(localPanel); 246 centerPanel.add(remotePanel); 247 choicePanel.add(centerPanel, BorderLayout.CENTER); 248 249 outerPanel.add(choicePanel, BorderLayout.CENTER); 250 251 // populate and add the control panel 252 controlPanel.add(helpButton); 253 controlPanel.add(Box.createHorizontalStrut(5)); 254 controlPanel.add(refreshButton); 255 controlPanel.add(Box.createHorizontalStrut(5)); 256 controlPanel.add(cancelButton); 257 controlPanel.add(Box.createHorizontalStrut(5)); 258 controlPanel.add(loadButton); 259 outerPanel.add(controlPanel, BorderLayout.PAGE_END); 260 261 final XmlObjectStore store = getIdv().getStore(); 262 String lastSource = store.get(PROP_LAST_SOURCE, FILE_SOURCE); 263 if (FILE_SOURCE.equals(lastSource)) { 264 localBtn.setSelected(true); 265 for (ActionListener a: localBtn.getActionListeners()) { 266 a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) { 267 // nothing to do in here 268 }); 269 } 270 } else if (ADDE_SOURCE.equals(lastSource)) { 271 addeBtn.setSelected(true); 272 for (ActionListener a: addeBtn.getActionListeners()) { 273 a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) { 274 // nothing to do in here 275 }); 276 } 277 } else if (URL_SOURCE.equals(lastSource)) { 278 urlBtn.setSelected(true); 279 for (ActionListener a: urlBtn.getActionListeners()) { 280 a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) { 281 // nothing to do in here 282 }); 283 } 284 } else { 285 logger.trace("should not be able to arrive here; defaulting to file. (lastSource={})", lastSource); 286 localBtn.setSelected(true); 287 } 288 289 if (localBtn.isSelected()) { 290 File tmp = new File(path + File.separatorChar + file); 291// logger.trace("attempting to select '{}'", tmp.getAbsolutePath()); 292// tlefc.setSelectedFile(tmp); 293 try { 294 FileChooserUI fcUi = tlefc.getUI(); 295 tlefc.setSelectedFile(tmp); 296 Class<? extends FileChooserUI> fcClass = fcUi.getClass(); 297// logger.trace("classname={}", fcClass.getCanonicalName()); 298 Method setFileName = fcClass.getMethod("setFileName", String.class); 299 setFileName.invoke(fcUi, tmp.getName()); 300// final JList list = McVGuiUtils.getDescendantOfType(JList.class, this, "Enabled", true); 301// list.requestFocus(); 302 } catch (Exception e) { 303 logger.warn("Could not dynamically invoke setFileName", e); 304 } 305// logger.trace("selected='{}'", tlefc.getSelectedFile()); 306 307 308 } 309 return outerPanel; 310 } 311 312 /** 313 * Used by the local file chooser to make sure we are in Local Mode 314 * (the radio button is selected). Helps to retain cleaner state. 315 * 316 * @return true if Local File Mode radio button is selected 317 */ 318 public boolean localMode() { 319 if (localBtn.isSelected()) { 320 return true; 321 } else { 322 return false; 323 } 324 } 325 326 private JComponent makeAddePanel() { 327 JPanel outerPanel = new JPanel(); 328 329 localBtn = new JRadioButton("File", false); 330 addeBtn = new JRadioButton("ADDE", true); 331 urlBtn = new JRadioButton("URL", false); 332 GuiUtils.buttonGroup(localBtn, addeBtn, urlBtn); 333 334 final XmlObjectStore store = getIdv().getStore(); 335 336 localBtn.addActionListener(new ActionListener() { 337 public void actionPerformed(ActionEvent e) { 338 enableLoadFromFile(false); 339 // enable the file chooser 340 if (tlefc != null) { 341 tlefc.setEnabled(true); 342 tlefc.handleFileChanged(); 343 } 344 345 // disable everything else? Just following pattern below 346 for (int i = 0; i < 5; i++) { 347 JComponent comp = addeList.get(i); 348 comp.setEnabled(false); 349 enableDescriptors(false); 350 } 351 for (int i = 5; i < 7; i++) { 352 JComponent comp = addeList.get(i); 353 comp.setEnabled(false); 354 } 355 store.put(PROP_LAST_SOURCE, FILE_SOURCE); 356 store.save(); 357 } 358 }); 359 360 // TJJ Nov 2013, I need to figure out what these 361 // hardcoded component ids are! 362 addeBtn.addActionListener(new ActionListener() { 363 public void actionPerformed(ActionEvent e) { 364 // disable the file chooser 365 if (tlefc != null) { 366 tlefc.setEnabled(false); 367 } 368 enableLoadFromAdde(true); 369 for (int i = 0; i < 5; i++) { 370 JComponent comp = addeList.get(i); 371 comp.setEnabled(true); 372 enableDescriptors(true); 373 } 374 for (int i = 5; i < 7; i++) { 375 JComponent comp = addeList.get(i); 376 comp.setEnabled(false); 377 } 378 store.put(PROP_LAST_SOURCE, ADDE_SOURCE); 379 store.save(); 380 } 381 }); 382 383 final JLabel urlLabel = new JLabel("URL:"); 384 // TJJ Nov 2013, I need to figure out what these 385 // hardcoded component ids are! 386 urlBtn.addActionListener(new ActionListener() { 387 public void actionPerformed(ActionEvent e) { 388// logger.trace("url button"); 389 // disable the file chooser 390 if (tlefc != null) { 391 tlefc.setEnabled(false); 392 } 393 for (int i = 5; i < 7; i++) { 394 JComponent comp = addeList.get(i); 395 comp.setEnabled(true); 396 } 397 enableLoadFromUrl(true); 398 for (int i = 0; i < 5; i++) { 399 JComponent comp = addeList.get(i); 400 comp.setEnabled(false); 401 enableDescriptors(false); 402 } 403 urlLabel.setEnabled(true); 404 box.setEnabled(true); 405 store.put(PROP_LAST_SOURCE, URL_SOURCE); 406 store.save(); 407 } 408 }); 409 JLabel serverLabel = new JLabel("Server:"); 410 411 descLabel = new JLabel("Descriptor:"); 412 descLabel.setEnabled(false); 413 descriptorComboBox.setEnabled(false); 414 415 clearOnChange(serverSelector); 416 McVGuiUtils.setComponentWidth(serverSelector, Width.DOUBLE); 417 418 JLabel groupLabel = McVGuiUtils.makeLabelRight("Dataset:"); 419 420 groupSelector.setEditable(isGroupEditable()); 421 clearOnChange(groupSelector); 422 McVGuiUtils.setComponentWidth(groupSelector, Width.DOUBLE); 423 424 McVGuiUtils.setComponentWidth(connectButton, Width.DOUBLE); 425 connectButton.setActionCommand(CMD_CONNECT); 426 connectButton.addActionListener(this); 427 428 prefList = getPreferenceList(PREF_URLLIST); 429 box = prefList.createComboBox(CMD_LOAD, this); 430 boxEditor = (JTextField) box.getEditor().getEditorComponent(); 431 boxEditor.addKeyListener(new KeyListener() { 432 public void keyPressed(KeyEvent e) {} 433 public void keyReleased(KeyEvent e) {} 434 public void keyTyped(KeyEvent e) {} 435 }); 436 urlLabel.setEnabled(false); 437 box.setEnabled(false); 438 439 GroupLayout layout = new GroupLayout(outerPanel); 440 outerPanel.setLayout(layout); 441 layout.setHorizontalGroup( 442 layout.createParallelGroup(LEADING) 443 .addGroup(TRAILING, layout.createSequentialGroup() 444 .addGroup(layout.createParallelGroup(TRAILING) 445 .addGroup(LEADING, layout.createSequentialGroup() 446 .addGroup(layout.createParallelGroup(LEADING) 447 .addComponent(addeBtn) 448 .addGroup(layout.createSequentialGroup() 449 .addComponent(serverLabel) 450 .addGap(GAP_RELATED) 451 .addComponent(serverSelector) 452 .addGap(GAP_RELATED) 453 .addComponent(manageButton) 454 .addGap(GAP_RELATED) 455 .addComponent(groupLabel) 456 .addGap(GAP_RELATED) 457 .addComponent(groupSelector) 458 .addGap(GAP_RELATED) 459 .addComponent(publicButton) 460 .addPreferredGap(RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 461 .addComponent(connectButton)) 462 .addGroup(layout.createSequentialGroup() 463 .addComponent(descLabel) 464 .addGap(GAP_RELATED) 465 .addComponent(descriptorComboBox)) 466 .addGap(GAP_RELATED) 467 .addComponent(urlBtn) 468 .addGroup(layout.createSequentialGroup() 469 .addComponent(urlLabel) 470 .addGap(GAP_RELATED) 471 .addComponent(box)))))) 472 ); 473 474 layout.setVerticalGroup( 475 layout.createParallelGroup(LEADING) 476 .addGroup(layout.createSequentialGroup() 477 .addComponent(addeBtn) 478 .addGroup(layout.createParallelGroup(BASELINE) 479 .addComponent(serverLabel) 480 .addComponent(serverSelector) 481 .addComponent(manageButton) 482 .addComponent(groupLabel) 483 .addComponent(groupSelector) 484 .addComponent(publicButton) 485 .addComponent(connectButton)) 486 .addPreferredGap(RELATED) 487 .addGroup(layout.createParallelGroup(BASELINE) 488 .addComponent(descLabel) 489 .addComponent(descriptorComboBox)) 490 .addPreferredGap(UNRELATED) 491 .addComponent(urlBtn) 492 .addGroup(layout.createParallelGroup(BASELINE) 493 .addComponent(urlLabel) 494 .addComponent(box))) 495 ); 496 497 addeList.add(serverLabel); 498 addeList.add(serverSelector); 499 addeList.add(groupLabel); 500 addeList.add(groupSelector); 501 addeList.add(connectButton); 502 McVGuiUtils.setComponentWidth(descriptorComboBox, Width.DOUBLEDOUBLE); 503 addeList.add(urlLabel); 504 addeList.add(box); 505 506// String lastSource = store.get(PROP_LAST_SOURCE, FILE_SOURCE); 507// if (FILE_SOURCE.equals(lastSource)) { 508// localBtn.setSelected(true); 509// for (ActionListener a: localBtn.getActionListeners()) { 510// a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) { 511// // nothing to do in here 512// }); 513// } 514// } else if (ADDE_SOURCE.equals(lastSource)) { 515// addeBtn.setSelected(true); 516// for (ActionListener a: addeBtn.getActionListeners()) { 517// a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) { 518// // nothing to do in here 519// }); 520// } 521// } else if (URL_SOURCE.equals(lastSource)) { 522// urlBtn.setSelected(true); 523// for (ActionListener a: urlBtn.getActionListeners()) { 524// a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) { 525// // nothing to do in here 526// }); 527// } 528// } else { 529// logger.trace("should not be able to arrive here; defaulting to file. (lastSource={})", lastSource); 530// localBtn.setSelected(true); 531// } 532 533 return outerPanel; 534 } 535 536 public void enableLoadFromFile(boolean val) { 537// logger.trace("val={}", val); 538 loadButton.setEnabled(val); 539 if (tlefc != null && tlefc.getSelectedFile() != null) { 540 setHaveData(val); 541 } 542 } 543 544 public void enableLoadFromAdde(boolean val) { 545// logger.trace("val={}", val); 546 if (val && descriptorComboBox.isEnabled() && getSelectedDescriptor() != null) { 547 loadButton.setEnabled(val); 548 } else { 549 loadButton.setEnabled(val); 550 } 551 } 552 553 public void enableLoadFromUrl(boolean val) { 554// logger.trace("val={}", val); 555 loadButton.setEnabled(val); 556 String url = (String)box.getSelectedItem(); 557 if (val && url != null && !url.isEmpty()) { 558 setHaveData(true); 559 } else { 560 setHaveData(val); 561 } 562 } 563 564 public void enableFileLoad(boolean val) { 565// logger.trace("loadButton={}", val); 566 loadButton.setEnabled(val); 567 } 568 569 private void enableDescriptors(boolean val) { 570// logger.trace("descriptors={}", val); 571 if (val) { 572 boolean connected; 573 if (getState() == STATE_CONNECTED) { 574 connected = true; 575 } else { 576 connected = false; 577 } 578 if (connected) { 579 descLabel.setEnabled(true); 580 descriptorComboBox.setEnabled(true); 581 } else { 582 descLabel.setEnabled(false); 583 descriptorComboBox.setEnabled(false); 584 } 585 } else { 586 descLabel.setEnabled(false); 587 descriptorComboBox.setEnabled(false); 588 } 589 } 590 591 @Override protected boolean getGoodToGo() { 592 final XmlObjectStore store = getIdv().getStore(); 593 String lastSource = store.get(PROP_LAST_SOURCE, FILE_SOURCE); 594 boolean goodToGo = false; 595 if (URL_SOURCE.equals(lastSource)) { 596 goodToGo = true; 597 } 598 return goodToGo; 599 } 600 601 /** 602 * Update labels, enable widgets, etc. 603 */ 604 @Override protected void updateStatus() { 605// if (localBtn != null && addeBtn != null && urlBtn != null) { 606// logger.trace("updating status fromFile={} fromAdde={} fromUrl={}", localBtn.isSelected(), addeBtn.isSelected(), urlBtn.isSelected()); 607// } 608 super.updateStatus(); 609 enableWidgets(); 610 if ((addeBtn != null) && addeBtn.isSelected()) { 611 enableLoadFromAdde(true); 612 } 613 } 614 615 /** 616 * Get the data type ID. 617 * 618 * @return {@link #TLE_DATA_TYPE} 619 */ 620 @Override public String getDataType() { 621 return TLE_DATA_TYPE; 622 } 623 624 /** 625 * Get the adde server group type to use. 626 * 627 * @return {@link #TLE_TYPE} 628 */ 629 @Override protected String getGroupType() { 630 return TLE_TYPE; 631 } 632 633 /** 634 * User said go, we go. 635 * Create the TLE DataSource 636 */ 637 @Override public void doLoadInThread() { 638 prefList.saveState(box); 639 String dsName = TLE_DATA_SOURCE_ID; 640 if (tlefc.getSelectedFile() != null) { 641 dsName = tlefc.getSelectedFile().getName(); 642 } 643 Hashtable ht = new Hashtable(); 644 getDataSourceProperties(ht); 645 if (propsOk) { 646 makeDataSource(dsName, TLE_DATA_SOURCE_ID, ht); 647 saveServerState(); 648 } 649 } 650 651 /** 652 * Get the DataSource properties 653 * 654 * @param ht Hashtable of properties 655 */ 656 @Override protected void getDataSourceProperties(Hashtable ht) { 657 658 // Local data 659 if (localBtn.isSelected()) { 660 if (tlefc.getSelectedFile() != null) { 661 // local file, set a new key... 662 ht.put(LOCAL_FILE_KEY, tlefc.getSelectedFile()); 663 propsOk = true; 664 } else { 665 JOptionPane.showMessageDialog(this, "No file selected."); 666 propsOk = false; 667 } 668 } 669 670 // Remote data, ADDE 671 if (addeBtn.isSelected()) { 672 if (getState() == STATE_CONNECTED) { 673 super.getDataSourceProperties(ht); 674 ht.put(DATASET_NAME_KEY, getDatasetName()); 675 String server = getServer(); 676 ht.put(TLE_SERVER_NAME_KEY, server); 677 String group = getGroup(); 678 ht.put(TLE_GROUP_NAME_KEY, group); 679 Map<String, String> acct = getAccounting(server, group); 680 String user = acct.get("user"); 681 String proj = acct.get("proj"); 682 ht.put(TLE_USER_ID_KEY, user); 683 ht.put(TLE_PROJECT_NUMBER_KEY, proj); 684 propsOk = true; 685 } else { 686 JOptionPane.showMessageDialog(this, "No ADDE server connection."); 687 propsOk = false; 688 } 689 } 690 691 // Remote or Local, URL 692 if (urlBtn.isSelected()) { 693 String s = (String) box.getSelectedItem(); 694 if ((s != null) && !s.isEmpty()) { 695 ht.put(URL_NAME_KEY, box.getSelectedItem()); 696 propsOk = true; 697 } else { 698 JOptionPane.showMessageDialog(this, "Please provide a valid URL."); 699 propsOk = false; 700 } 701 } 702 } 703 704 private String getDatasetName() { 705 return (String) descriptorComboBox.getSelectedItem(); 706 } 707 708 @Override public void handleConnectFromThread() { 709 super.handleConnectFromThread(); 710 enableDescriptors(true); 711 } 712 713 /** 714 * Get the default display type. 715 * 716 * @return {@link #TLE_DISPLAY_TYPE} 717 */ 718 @Override protected String getDefaultDisplayType() { 719 return TLE_DISPLAY_TYPE; 720 } 721}