arcgissamples\trackinganalyst\ui\ServiceInfoDialog.java
/* Copyright 2010 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. * */ package arcgissamples.trackinganalyst.ui; import java.awt.Dimension; import java.awt.event.KeyEvent; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.*; import com.esri.arcgis.controls.IGlobeHookHelper; import com.esri.arcgis.trackinganalyst.AMSWorkspace; public class ServiceInfoDialog extends JDialog { JComboBox serviceComboBox = null; IGlobeHookHelper globeHookHelper = null; String[] nameList = null; AMSWorkspace amsWorkspace = null; public ServiceInfoDialog(String title, IGlobeHookHelper ghh, String[] list, AMSWorkspace amsWS) { super(); this.globeHookHelper = ghh; this.nameList = list; this.amsWorkspace = amsWS; setTitle(title); getContentPane().add(createPanel()); pack(); setSize(325, 120); setVisible(true); } private JPanel createPanel() { JPanel panel = new JPanel(); panel.setPreferredSize(new Dimension(250, 75)); panel.setSize(new Dimension(250, 75)); panel.setLayout(new GridBagLayout()); GridBagConstraints serverLabelGBConstraints = new GridBagConstraints(); serverLabelGBConstraints.gridx = 2; serverLabelGBConstraints.gridy = 2; serverLabelGBConstraints.insets = new Insets(10, 10, 5, 0); serverLabelGBConstraints.weightx = 1.0D; serverLabelGBConstraints.weighty = 1.0D; serverLabelGBConstraints.fill = GridBagConstraints.HORIZONTAL; serverLabelGBConstraints.anchor = GridBagConstraints.NORTHWEST; JLabel serverLabel = new JLabel("Select Service: "); panel.add(serverLabel, serverLabelGBConstraints); GridBagConstraints serviceComboboxGBConstraints = new GridBagConstraints(); serviceComboboxGBConstraints.gridx = 3; serviceComboboxGBConstraints.gridy = 2; serviceComboboxGBConstraints.insets = new Insets(10, 0, 5, 5); serviceComboboxGBConstraints.weightx = 1.0D; serviceComboboxGBConstraints.weighty = 1.0D; serviceComboboxGBConstraints.fill = GridBagConstraints.HORIZONTAL; serviceComboboxGBConstraints.anchor = GridBagConstraints.NORTHWEST; ServiceInfoListener listener = new ServiceInfoListener(this, globeHookHelper, amsWorkspace); serviceComboBox = new JComboBox(nameList); serviceComboBox.addActionListener(listener); serviceComboBox.setActionCommand("selectLayer"); serviceComboBox.setSelectedIndex(0); panel.add(serviceComboBox, serviceComboboxGBConstraints); GridBagConstraints addLayerButtonGBConstraints = new GridBagConstraints(); addLayerButtonGBConstraints.gridx = 2; addLayerButtonGBConstraints.gridy = 3; addLayerButtonGBConstraints.insets = new Insets(5, 5, 10, 5); addLayerButtonGBConstraints.weightx = 1.0D; addLayerButtonGBConstraints.weighty = 1.0D; addLayerButtonGBConstraints.fill = GridBagConstraints.HORIZONTAL; addLayerButtonGBConstraints.anchor = GridBagConstraints.NORTHWEST; JButton addLayerButton = new JButton("Add as Layer"); addLayerButton.setMnemonic(KeyEvent.VK_A); addLayerButton.setActionCommand("addLayer"); addLayerButton.setEnabled(true); addLayerButton.addActionListener(listener); panel.add(addLayerButton, addLayerButtonGBConstraints); GridBagConstraints cancelButtonGBConstraints = new GridBagConstraints(); cancelButtonGBConstraints.gridx = 3; cancelButtonGBConstraints.gridy = 3; cancelButtonGBConstraints.insets = new Insets(5, 5, 10, 5); cancelButtonGBConstraints.weightx = 1.0D; cancelButtonGBConstraints.weighty = 1.0D; cancelButtonGBConstraints.fill = GridBagConstraints.HORIZONTAL; cancelButtonGBConstraints.anchor = GridBagConstraints.NORTHWEST; JButton cancelButton = new JButton("Cancel"); cancelButton.setMnemonic(KeyEvent.VK_C); cancelButton.setActionCommand("cancel"); cancelButton.setEnabled(true); cancelButton.addActionListener(listener); panel.add(cancelButton, cancelButtonGBConstraints); return panel; } public JComboBox getServiceComboBox() { return this.serviceComboBox; } }