/// <summary> /// Constructor. </summary> /// <param name="annotationDataList"> list of annotation data, if available (can pass null and reset the list /// later by calling setAnnotationData()). </param> /// <param name="hideIfEmpty"> if true, set the panel to not visible if the list is empty - this may be appropriate /// if UI real estate is in short supply and annotations should only be shown if used </param> public StateMod_Network_AnnotationDataListJPanel(IList <StateMod_Network_AnnotationData> annotationDataList, StateMod_Network_JComponent networkJComponent, bool hideIfEmpty) : base() { // Set up the layout manager this.setLayout(new GridBagLayout()); this.setBorder(BorderFactory.createTitledBorder("Annotations")); int y = 0; Insets insetsTLBR = new Insets(0, 0, 0, 0); __annotationJList = new JList(); if (annotationDataList != null) { setAnnotationData(annotationDataList); } JGUIUtil.addComponent(this, new JScrollPane(__annotationJList), 0, y, 1, 1, 1.0, 1.0, insetsTLBR, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); __hideIfEmpty = hideIfEmpty; __networkJComponent = networkJComponent; // Add popup for actions on annotations //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final javax.swing.JPopupMenu popupMenu = new javax.swing.JPopupMenu(); JPopupMenu popupMenu = new JPopupMenu(); JMenuItem removeAllAnnotationsJMenuItem = new JMenuItem(__RemoveAllAnnotationsString); removeAllAnnotationsJMenuItem.addActionListener(this); popupMenu.add(removeAllAnnotationsJMenuItem); __annotationJList.addMouseListener(new MouseAdapterAnonymousInnerClass(this, popupMenu)); checkVisibility(); }
/// <summary> /// Sets up the GUI. /// </summary> private void setupGUI() { __fileJList = new JList(); __fileJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); __fileJList.addListSelectionListener(this); __fileJList.setToolTipText("<HTML>To view an output file, select a file and press " + "View/Edit.<br>Notepad will be used to view the file.</HTML>"); // REVISIT - SAM 2003-10-26 if a better help system is enabled. //__helpJButton = new JButton(__BUTTON_HELP); //__helpJButton.setEnabled(false); __closeJButton = new JButton(__BUTTON_CLOSE); __viewEditJButton = new JButton(__BUTTON_VIEW_EDIT); __viewEditJButton.setToolTipText("<HTML>Use Notepad to view/edit the selected file.</HTML>"); GridBagLayout gb = new GridBagLayout(); JPanel mainPanel = new JPanel(); mainPanel.setLayout(gb); FlowLayout fl = new FlowLayout(FlowLayout.CENTER); JPanel final_panel = new JPanel(); final_panel.setLayout(fl); Font orig = __fileJList.getFont(); Font @fixed = null; if (orig != null) { @fixed = new Font("Courier", orig.getStyle(), orig.getSize()); } else { @fixed = new Font("Courier", Font.PLAIN, 11); } __fileJList.setFont(@fixed); __fileJList.addMouseListener(this); JGUIUtil.addComponent(mainPanel, new JScrollPane(__fileJList), 0, 0, 10, 12, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.CENTER); // add contents to the list box fillFileJListContents(); final_panel.add(__viewEditJButton); __viewEditJButton.addActionListener(this); __viewEditJButton.setEnabled(false); // Change state when something // is selected. //final_panel.add(__helpJButton); //__helpJButton.addActionListener(this); final_panel.add(__closeJButton); __closeJButton.addActionListener(this); JGUIUtil.addComponent(mainPanel, final_panel, 0, 12, 10, 5, 0, 0, GridBagConstraints.NONE, GridBagConstraints.SOUTH); getContentPane().add("Center", mainPanel); pack(); setSize(700, 300); JGUIUtil.center(this); setVisible(true); }