arcgissamples\trackinganalyst\commands\DisplayTrackingServerLayerCommand.java—ArcObjects 10.4 Help for Java | ArcGIS for Desktop
Display tracking server layer
arcgissamples\trackinganalyst\commands\DisplayTrackingServerLayerCommand.java
/* Copyright 2015 ESRI
* 
* All rights reserved under the copyright laws of the United States
* and applicable international laws, treaties, and conventions.
* 
* You may freely redistribute and use this sample code, with or
* without modification, provided you include the original copyright
* notice and use restrictions.
* 
* See the use restrictions at <your ArcGIS install location>/DeveloperKit10.4/userestrictions.txt.
* 
*/
package arcgissamples.trackinganalyst.commands;

import java.io.IOException;

import arcgissamples.trackinganalyst.ui.ServerInfoDialog;

import com.esri.arcgis.controls.BaseCommand;
import com.esri.arcgis.controls.GlobeHookHelper;
import com.esri.arcgis.controls.IGlobeHookHelper;

public class DisplayTrackingServerLayerCommand extends BaseCommand {
  private IGlobeHookHelper globeHookHelper = null;

  public DisplayTrackingServerLayerCommand() {
    try {
      caption = "Add Tracking Server Layer";
      category = "Java Tracking Server Samples";
      message = "Add Tracking Server Temporal Layer";
      name = "AddTSLayerCommand";
      toolTip = "Add Tracking Server Temporal Layer to a globe.";
      helpFile = "";
      enabled = true;
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  /**
   * OnCreate - invoked when the command is created
   */
  public void onCreate(Object hook) {
    try {
      globeHookHelper = new GlobeHookHelper();
      globeHookHelper.setHookByRef(hook);

      if (globeHookHelper.getActiveViewer() == null) {
        globeHookHelper = null;
        enabled = false;
      }
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }

  /**
   * onClick - invoked when user clicks on the AddTSLayerCommand command in
   * application
   */
  public void onClick() {
    try {
      ServerInfoDialog dlg = new ServerInfoDialog("Server Info", globeHookHelper);
      dlg.setModal(true);
      dlg.setVisible(true);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

}