001/* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2018 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 private JComboBox serverSelector; 105 private JRadioButton localBtn; 106 private JRadioButton addeBtn; 107 private JRadioButton urlBtn; 108 private JLabel descLabel; 109 List<JComponent> addeList = new ArrayList<JComponent>(); 110 111 /** Manages the pull down list of URLs. */ 112 private PreferenceList prefList; 113 114 /** List of URLs. */ 115 private JComboBox box; 116 private JTextField boxEditor; 117 118 private boolean propsOk = false; 119 120 /** Text type. */ 121 private static final String TLE_TYPE = "text"; 122 123 /** Property ID used to get the list or URLs. */ 124 public static final String PREF_URLLIST = "idv.urllist"; 125 126 /** Property ID used to determine the last {@literal "source"}. */ 127 public static final String PROP_LAST_SOURCE = "mcidasv.chooser.tle.lastsource"; 128 129 /** Property value that represents the {@literal "local"} button. */ 130 public static final String FILE_SOURCE = "FILE"; 131 132 /** Property value that represents the {@literal "ADDE"} button. */ 133 public static final String ADDE_SOURCE = "ADDE"; 134 135 /** Property value that represents the {@literal "URL"} button. */ 136 public static final String URL_SOURCE = "URL"; 137 138 /** 139 * Property for the tle server name key. 140 * @see #getServer() 141 */ 142 public static String TLE_SERVER_NAME_KEY = "tle_server"; 143 public static String URL_NAME_KEY = "url_name"; 144 public static String LOCAL_FILE_KEY = "file_object"; 145 146 /** 147 * Property for the TLE group name key. 148 * @see #getGroup() 149 */ 150 public static String TLE_GROUP_NAME_KEY = "tle_group"; 151 152 /** Property for the TLE user ID. */ 153 public static String TLE_USER_ID_KEY = "tle_user"; 154 155 /** Property for the TLE project number. */ 156 public static String TLE_PROJECT_NUMBER_KEY = "tle_proj"; 157 158 /** TLE data source identifier. */ 159 public static final String TLE_DATA_SOURCE_ID = "TLE"; 160 161 /** TLE display type. */ 162 public static final String TLE_DISPLAY_TYPE = "tledisplay"; 163 164 /** TLE data source type. */ 165 public static final String TLE_DATA_TYPE = "TEXT"; 166 167 /** 168 * Construct an Adde image selection widget 169 * 170 * @param mgr The chooser manager 171 * @param root The chooser.xml node 172 */ 173 public PolarOrbitTrackChooser(IdvChooserManager mgr, Element root) { 174 super(mgr, root); 175 serverSelector = getServerSelector(); 176 showServers(); 177 } 178 179 /** 180 * Return the data source ID. 181 * 182 * @return {@link #TLE_DATA_SOURCE_ID} 183 */ 184 @Override protected String getDataSourceId() { 185 return TLE_DATA_SOURCE_ID; 186 } 187 188 /** 189 * Make the UI for this selector. 190 * 191 * @return The gui 192 */ 193 @Override public JComponent doMakeContents() { 194 logger.debug("doMakeContents() in..."); 195 JPanel outerPanel = new JPanel(); 196 JPanel addePanel = new JPanel(); 197 addePanel = (JPanel)makeAddePanel(); 198 199 // retrieve our last visited directory 200 String path = (String)getIdv().getStateManager().getPreference(IdvChooser.PREF_DEFAULTDIR + getId()); 201 String file = (String)getIdv().getStateManager().getPreference(IdvChooser.PREF_DEFAULTDIR + getId() + ".file"); 202 tlefc = new TLEFileChooser(this, path, file); 203// tlefc.setPotc(this); 204 205 JButton helpButton = McVGuiUtils.makeImageButton(ICON_HELP, "Show help"); 206 helpButton.setActionCommand(GuiUtils.CMD_HELP); 207 helpButton.addActionListener(this); 208 209 JButton refreshButton = McVGuiUtils.makeImageButton(ICON_REFRESH, "Refresh"); 210 refreshButton.setActionCommand(GuiUtils.CMD_UPDATE); 211 refreshButton.addActionListener(this); 212 213 McVGuiUtils.setComponentWidth(loadButton, Width.DOUBLE); 214 215 outerPanel.setLayout(new BorderLayout()); 216 JPanel choicePanel = new JPanel(new BorderLayout()); 217 JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING)); 218 219 // load the local and remote choices in a Box in center panel 220 JPanel centerPanel = new JPanel(); 221 centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.PAGE_AXIS)); 222 JPanel localPanel = new JPanel(new BorderLayout()); 223 224 // create border like the remote panel (titled) but include the 225 // gap that remote panel creates with various GroupLayout effects 226 localPanel.setBorder(BorderFactory.createCompoundBorder( 227 BorderFactory.createTitledBorder("Local"), 228 BorderFactory.createEmptyBorder(GAP_RELATED, GAP_RELATED, GAP_RELATED, GAP_RELATED))); 229 230 JPanel remotePanel = new JPanel(); 231 remotePanel.setBorder(BorderFactory.createTitledBorder("Remote")); 232 233 // populate the local access panel 234 localPanel.add(localBtn, BorderLayout.NORTH); 235 localPanel.add(tlefc, BorderLayout.CENTER); 236 237 // populate the remote access panel 238 remotePanel.add(addePanel); 239 240 centerPanel.add(localPanel); 241 centerPanel.add(remotePanel); 242 choicePanel.add(centerPanel, BorderLayout.CENTER); 243 244 outerPanel.add(choicePanel, BorderLayout.CENTER); 245 246 // populate and add the control panel 247 controlPanel.add(helpButton); 248 controlPanel.add(Box.createHorizontalStrut(5)); 249 controlPanel.add(refreshButton); 250 controlPanel.add(Box.createHorizontalStrut(5)); 251 controlPanel.add(cancelButton); 252 controlPanel.add(Box.createHorizontalStrut(5)); 253 controlPanel.add(loadButton); 254 outerPanel.add(controlPanel, BorderLayout.PAGE_END); 255 256 final XmlObjectStore store = getIdv().getStore(); 257 String lastSource = store.get(PROP_LAST_SOURCE, FILE_SOURCE); 258 if (FILE_SOURCE.equals(lastSource)) { 259 localBtn.setSelected(true); 260 for (ActionListener a: localBtn.getActionListeners()) { 261 a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) { 262 // nothing to do in here 263 }); 264 } 265 } else if (ADDE_SOURCE.equals(lastSource)) { 266 addeBtn.setSelected(true); 267 for (ActionListener a: addeBtn.getActionListeners()) { 268 a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) { 269 // nothing to do in here 270 }); 271 } 272 } else if (URL_SOURCE.equals(lastSource)) { 273 urlBtn.setSelected(true); 274 for (ActionListener a: urlBtn.getActionListeners()) { 275 a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) { 276 // nothing to do in here 277 }); 278 } 279 } else { 280 logger.trace("should not be able to arrive here; defaulting to file. (lastSource={})", lastSource); 281 localBtn.setSelected(true); 282 } 283 284 if (localBtn.isSelected()) { 285 File tmp = new File(path + File.separatorChar + file); 286// logger.trace("attempting to select '{}'", tmp.getAbsolutePath()); 287// tlefc.setSelectedFile(tmp); 288 try { 289 FileChooserUI fcUi = tlefc.getUI(); 290 tlefc.setSelectedFile(tmp); 291 Class<? extends FileChooserUI> fcClass = fcUi.getClass(); 292// logger.trace("classname={}", fcClass.getCanonicalName()); 293 Method setFileName = fcClass.getMethod("setFileName", String.class); 294 setFileName.invoke(fcUi, tmp.getName()); 295// final JList list = McVGuiUtils.getDescendantOfType(JList.class, this, "Enabled", true); 296// list.requestFocus(); 297 } catch (Exception e) { 298 logger.warn("Could not dynamically invoke setFileName", e); 299 } 300// logger.trace("selected='{}'", tlefc.getSelectedFile()); 301 302 303 } 304 return outerPanel; 305 } 306 307 /** 308 * Used by the local file chooser to make sure we are in Local Mode 309 * (the radio button is selected). Helps to retain cleaner state. 310 * 311 * @return true if Local File Mode radio button is selected 312 */ 313 public boolean localMode() { 314 if (localBtn.isSelected()) { 315 return true; 316 } else { 317 return false; 318 } 319 } 320 321 private JComponent makeAddePanel() { 322 JPanel outerPanel = new JPanel(); 323 324 localBtn = new JRadioButton("File", false); 325 addeBtn = new JRadioButton("ADDE", true); 326 urlBtn = new JRadioButton("URL", false); 327 GuiUtils.buttonGroup(localBtn, addeBtn, urlBtn); 328 329 final XmlObjectStore store = getIdv().getStore(); 330 331 localBtn.addActionListener(new ActionListener() { 332 public void actionPerformed(ActionEvent e) { 333 enableLoadFromFile(false); 334 // enable the file chooser 335 if (tlefc != null) { 336 tlefc.setEnabled(true); 337 tlefc.handleFileChanged(); 338 } 339 340 // disable everything else? Just following pattern below 341 for (int i = 0; i < 5; i++) { 342 JComponent comp = addeList.get(i); 343 comp.setEnabled(false); 344 enableDescriptors(false); 345 } 346 for (int i = 5; i < 7; i++) { 347 JComponent comp = addeList.get(i); 348 comp.setEnabled(false); 349 } 350 store.put(PROP_LAST_SOURCE, FILE_SOURCE); 351 store.save(); 352 } 353 }); 354 355 // TJJ Nov 2013, I need to figure out what these 356 // hardcoded component ids are! 357 addeBtn.addActionListener(new ActionListener() { 358 public void actionPerformed(ActionEvent e) { 359 // disable the file chooser 360 if (tlefc != null) { 361 tlefc.setEnabled(false); 362 } 363 enableLoadFromAdde(true); 364 for (int i = 0; i < 5; i++) { 365 JComponent comp = addeList.get(i); 366 comp.setEnabled(true); 367 enableDescriptors(true); 368 } 369 for (int i = 5; i < 7; i++) { 370 JComponent comp = addeList.get(i); 371 comp.setEnabled(false); 372 } 373 store.put(PROP_LAST_SOURCE, ADDE_SOURCE); 374 store.save(); 375 } 376 }); 377 378 final JLabel urlLabel = new JLabel("URL:"); 379 // TJJ Nov 2013, I need to figure out what these 380 // hardcoded component ids are! 381 urlBtn.addActionListener(new ActionListener() { 382 public void actionPerformed(ActionEvent e) { 383// logger.trace("url button"); 384 // disable the file chooser 385 if (tlefc != null) { 386 tlefc.setEnabled(false); 387 } 388 for (int i = 5; i < 7; i++) { 389 JComponent comp = addeList.get(i); 390 comp.setEnabled(true); 391 } 392 enableLoadFromUrl(true); 393 for (int i = 0; i < 5; i++) { 394 JComponent comp = addeList.get(i); 395 comp.setEnabled(false); 396 enableDescriptors(false); 397 } 398 urlLabel.setEnabled(true); 399 box.setEnabled(true); 400 store.put(PROP_LAST_SOURCE, URL_SOURCE); 401 store.save(); 402 } 403 }); 404 JLabel serverLabel = new JLabel("Server:"); 405 406 descLabel = new JLabel("Descriptor:"); 407 descLabel.setEnabled(false); 408 descriptorComboBox.setEnabled(false); 409 410 clearOnChange(serverSelector); 411 McVGuiUtils.setComponentWidth(serverSelector, Width.DOUBLE); 412 413 JLabel groupLabel = McVGuiUtils.makeLabelRight("Dataset:"); 414 415 groupSelector.setEditable(isGroupEditable()); 416 clearOnChange(groupSelector); 417 McVGuiUtils.setComponentWidth(groupSelector, Width.DOUBLE); 418 419 McVGuiUtils.setComponentWidth(connectButton, Width.DOUBLE); 420 connectButton.setActionCommand(CMD_CONNECT); 421 connectButton.addActionListener(this); 422 423 prefList = getPreferenceList(PREF_URLLIST); 424 box = prefList.createComboBox(CMD_LOAD, this); 425 boxEditor = (JTextField) box.getEditor().getEditorComponent(); 426 boxEditor.addKeyListener(new KeyListener() { 427 public void keyPressed(KeyEvent e) {} 428 public void keyReleased(KeyEvent e) {} 429 public void keyTyped(KeyEvent e) {} 430 }); 431 urlLabel.setEnabled(false); 432 box.setEnabled(false); 433 434 GroupLayout layout = new GroupLayout(outerPanel); 435 outerPanel.setLayout(layout); 436 layout.setHorizontalGroup( 437 layout.createParallelGroup(LEADING) 438 .addGroup(TRAILING, layout.createSequentialGroup() 439 .addGroup(layout.createParallelGroup(TRAILING) 440 .addGroup(LEADING, layout.createSequentialGroup() 441 .addGroup(layout.createParallelGroup(LEADING) 442 .addComponent(addeBtn) 443 .addGroup(layout.createSequentialGroup() 444 .addComponent(serverLabel) 445 .addGap(GAP_RELATED) 446 .addComponent(serverSelector) 447 .addGap(GAP_RELATED) 448 .addComponent(manageButton) 449 .addGap(GAP_RELATED) 450 .addComponent(groupLabel) 451 .addGap(GAP_RELATED) 452 .addComponent(groupSelector) 453 .addGap(GAP_RELATED) 454 .addComponent(publicButton) 455 .addPreferredGap(RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 456 .addComponent(connectButton)) 457 .addGroup(layout.createSequentialGroup() 458 .addComponent(descLabel) 459 .addGap(GAP_RELATED) 460 .addComponent(descriptorComboBox)) 461 .addGap(GAP_RELATED) 462 .addComponent(urlBtn) 463 .addGroup(layout.createSequentialGroup() 464 .addComponent(urlLabel) 465 .addGap(GAP_RELATED) 466 .addComponent(box)))))) 467 ); 468 469 layout.setVerticalGroup( 470 layout.createParallelGroup(LEADING) 471 .addGroup(layout.createSequentialGroup() 472 .addComponent(addeBtn) 473 .addGroup(layout.createParallelGroup(BASELINE) 474 .addComponent(serverLabel) 475 .addComponent(serverSelector) 476 .addComponent(manageButton) 477 .addComponent(groupLabel) 478 .addComponent(groupSelector) 479 .addComponent(publicButton) 480 .addComponent(connectButton)) 481 .addPreferredGap(RELATED) 482 .addGroup(layout.createParallelGroup(BASELINE) 483 .addComponent(descLabel) 484 .addComponent(descriptorComboBox)) 485 .addPreferredGap(UNRELATED) 486 .addComponent(urlBtn) 487 .addGroup(layout.createParallelGroup(BASELINE) 488 .addComponent(urlLabel) 489 .addComponent(box))) 490 ); 491 492 addeList.add(serverLabel); 493 addeList.add(serverSelector); 494 addeList.add(groupLabel); 495 addeList.add(groupSelector); 496 addeList.add(connectButton); 497 McVGuiUtils.setComponentWidth(descriptorComboBox, Width.DOUBLEDOUBLE); 498 addeList.add(urlLabel); 499 addeList.add(box); 500 501// String lastSource = store.get(PROP_LAST_SOURCE, FILE_SOURCE); 502// if (FILE_SOURCE.equals(lastSource)) { 503// localBtn.setSelected(true); 504// for (ActionListener a: localBtn.getActionListeners()) { 505// a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) { 506// // nothing to do in here 507// }); 508// } 509// } else if (ADDE_SOURCE.equals(lastSource)) { 510// addeBtn.setSelected(true); 511// for (ActionListener a: addeBtn.getActionListeners()) { 512// a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) { 513// // nothing to do in here 514// }); 515// } 516// } else if (URL_SOURCE.equals(lastSource)) { 517// urlBtn.setSelected(true); 518// for (ActionListener a: urlBtn.getActionListeners()) { 519// a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) { 520// // nothing to do in here 521// }); 522// } 523// } else { 524// logger.trace("should not be able to arrive here; defaulting to file. (lastSource={})", lastSource); 525// localBtn.setSelected(true); 526// } 527 528 return outerPanel; 529 } 530 531 public void enableLoadFromFile(boolean val) { 532// logger.trace("val={}", val); 533 loadButton.setEnabled(val); 534 if (tlefc != null && tlefc.getSelectedFile() != null) { 535 setHaveData(val); 536 } 537 } 538 539 public void enableLoadFromAdde(boolean val) { 540// logger.trace("val={}", val); 541 if (val && descriptorComboBox.isEnabled() && getSelectedDescriptor() != null) { 542 loadButton.setEnabled(val); 543 } else { 544 loadButton.setEnabled(val); 545 } 546 } 547 548 public void enableLoadFromUrl(boolean val) { 549// logger.trace("val={}", val); 550 loadButton.setEnabled(val); 551 String url = (String)box.getSelectedItem(); 552 if (val && url != null && !url.isEmpty()) { 553 setHaveData(true); 554 } else { 555 setHaveData(val); 556 } 557 } 558 559 public void enableFileLoad(boolean val) { 560// logger.trace("loadButton={}", val); 561 loadButton.setEnabled(val); 562 } 563 564 private void enableDescriptors(boolean val) { 565// logger.trace("descriptors={}", val); 566 if (val) { 567 boolean connected; 568 if (getState() == STATE_CONNECTED) { 569 connected = true; 570 } else { 571 connected = false; 572 } 573 if (connected) { 574 descLabel.setEnabled(true); 575 descriptorComboBox.setEnabled(true); 576 } else { 577 descLabel.setEnabled(false); 578 descriptorComboBox.setEnabled(false); 579 } 580 } else { 581 descLabel.setEnabled(false); 582 descriptorComboBox.setEnabled(false); 583 } 584 } 585 586 @Override protected boolean getGoodToGo() { 587 final XmlObjectStore store = getIdv().getStore(); 588 String lastSource = store.get(PROP_LAST_SOURCE, FILE_SOURCE); 589 boolean goodToGo = false; 590 if (URL_SOURCE.equals(lastSource)) { 591 goodToGo = true; 592 } 593 return goodToGo; 594 } 595 596 /** 597 * Update labels, enable widgets, etc. 598 */ 599 @Override protected void updateStatus() { 600// if (localBtn != null && addeBtn != null && urlBtn != null) { 601// logger.trace("updating status fromFile={} fromAdde={} fromUrl={}", localBtn.isSelected(), addeBtn.isSelected(), urlBtn.isSelected()); 602// } 603 super.updateStatus(); 604 enableWidgets(); 605 if ((addeBtn != null) && addeBtn.isSelected()) { 606 enableLoadFromAdde(true); 607 } 608 } 609 610 /** 611 * Get the data type ID. 612 * 613 * @return {@link #TLE_DATA_TYPE} 614 */ 615 @Override public String getDataType() { 616 return TLE_DATA_TYPE; 617 } 618 619 /** 620 * Get the adde server group type to use. 621 * 622 * @return {@link #TLE_TYPE} 623 */ 624 @Override protected String getGroupType() { 625 return TLE_TYPE; 626 } 627 628 /** 629 * User said go, we go. 630 * Create the TLE DataSource 631 */ 632 @Override public void doLoadInThread() { 633 prefList.saveState(box); 634 String dsName = TLE_DATA_SOURCE_ID; 635 if (tlefc.getSelectedFile() != null) { 636 dsName = tlefc.getSelectedFile().getName(); 637 } 638 Hashtable ht = new Hashtable(); 639 getDataSourceProperties(ht); 640 if (propsOk) { 641 makeDataSource(dsName, TLE_DATA_SOURCE_ID, ht); 642 saveServerState(); 643 } 644 } 645 646 /** 647 * Get the DataSource properties 648 * 649 * @param ht Hashtable of properties 650 */ 651 @Override protected void getDataSourceProperties(Hashtable ht) { 652 653 // Local data 654 if (localBtn.isSelected()) { 655 if (tlefc.getSelectedFile() != null) { 656 // local file, set a new key... 657 ht.put(LOCAL_FILE_KEY, tlefc.getSelectedFile()); 658 propsOk = true; 659 } else { 660 JOptionPane.showMessageDialog(this, "No file selected."); 661 propsOk = false; 662 } 663 } 664 665 // Remote data, ADDE 666 if (addeBtn.isSelected()) { 667 if (getState() == STATE_CONNECTED) { 668 super.getDataSourceProperties(ht); 669 ht.put(DATASET_NAME_KEY, getDatasetName()); 670 String server = getServer(); 671 ht.put(TLE_SERVER_NAME_KEY, server); 672 String group = getGroup(); 673 ht.put(TLE_GROUP_NAME_KEY, group); 674 Map<String, String> acct = getAccounting(server, group); 675 String user = acct.get("user"); 676 String proj = acct.get("proj"); 677 ht.put(TLE_USER_ID_KEY, user); 678 ht.put(TLE_PROJECT_NUMBER_KEY, proj); 679 propsOk = true; 680 } else { 681 JOptionPane.showMessageDialog(this, "No ADDE server connection."); 682 propsOk = false; 683 } 684 } 685 686 // Remote or Local, URL 687 if (urlBtn.isSelected()) { 688 String s = (String) box.getSelectedItem(); 689 if ((s != null) && !s.isEmpty()) { 690 // TJJ Nov 2018 691 // Until we can update Java 8 distributed with McV, Celestrak cert authority 692 // isn't recognized, so revert to HTTP whenever HTTPS is used 693 s = s.replaceAll("(?i)https", "http"); 694 ht.put(URL_NAME_KEY, s); 695 propsOk = true; 696 } else { 697 JOptionPane.showMessageDialog(this, "Please provide a valid URL."); 698 propsOk = false; 699 } 700 } 701 } 702 703 /* (non-Javadoc) 704 * @see edu.wisc.ssec.mcidasv.chooser.adde.AddeChooser#showGroups() 705 */ 706 @Override 707 public void showGroups() { 708 super.showGroups(); 709 } 710 711 private String getDatasetName() { 712 String dsName = (String) descriptorComboBox.getSelectedItem(); 713 // strip out description part 714 dsName = dsName.substring(0, dsName.indexOf(" ")); 715 return dsName; 716 } 717 718 @Override public void handleConnectFromThread() { 719 super.handleConnectFromThread(); 720 enableDescriptors(true); 721 } 722 723 /** 724 * Get the default display type. 725 * 726 * @return {@link #TLE_DISPLAY_TYPE} 727 */ 728 @Override protected String getDefaultDisplayType() { 729 return TLE_DISPLAY_TYPE; 730 } 731}