List of usage examples for javax.swing DefaultListModel DefaultListModel
DefaultListModel
From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java
/** * create the query builder UI./* w w w .j ava 2s .co m*/ */ protected void createUI() { removeAll(); JMenuItem saveItem = new JMenuItem(UIRegistry.getResourceString("QB_SAVE")); Action saveActionListener = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (saveQuery(false)) { try { String selId = null; if (selectedQFP != null && selectedQFP.getQueryField() != null) { selId = selectedQFP.getQueryField().getStringId(); } final String selectedFldId = selId; setupUI(true); SwingUtilities.invokeLater(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { if (selectedFldId != null) { for (QueryFieldPanel qfp : queryFieldItems) { if (qfp.getQueryField() != null && selectedFldId.equals(qfp.getQueryField().getStringId())) { selectQFP(qfp); return; } } selectQFP(queryFieldItems.get(0)); } } }); } catch (Exception ex) { } setSaveBtnEnabled(false); } } }; saveItem.addActionListener(saveActionListener); JMenuItem saveAsItem = new JMenuItem(UIRegistry.getResourceString("QB_SAVE_AS")); Action saveAsActionListener = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (saveQuery(true)) { setSaveBtnEnabled(false); } } }; saveAsItem.addActionListener(saveAsActionListener); JComponent[] itemSample = { saveItem, saveAsItem }; saveBtn = new DropDownButton(UIRegistry.getResourceString("QB_SAVE"), null, 1, java.util.Arrays.asList(itemSample)); saveBtn.addActionListener(saveActionListener); String ACTION_KEY = "SAVE"; KeyStroke ctrlS = KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); InputMap inputMap = saveBtn.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(ctrlS, ACTION_KEY); ActionMap actionMap = saveBtn.getActionMap(); actionMap.put(ACTION_KEY, saveActionListener); ACTION_KEY = "SAVE_AS"; KeyStroke ctrlA = KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); inputMap.put(ctrlA, ACTION_KEY); actionMap.put(ACTION_KEY, saveAsActionListener); saveBtn.setActionMap(actionMap); UIHelper.setControlSize(saveBtn); //saveBtn.setOverrideBorder(true, BasicBorders.getButtonBorder()); listBoxPanel = new JPanel(new HorzLayoutManager(2, 2)); Vector<TableQRI> list = new Vector<TableQRI>(); for (int k = 0; k < tableTree.getKids(); k++) { list.add(tableTree.getKid(k).getTableQRI()); } Collections.sort(list); DefaultListModel model = new DefaultListModel(); for (TableQRI qri : list) { model.addElement(qri); } tableList = new JList(model); QryListRenderer qr = new QryListRenderer(IconManager.IconSize.Std16); qr.setDisplayKidIndicator(false); tableList.setCellRenderer(qr); JScrollPane spt = new JScrollPane(tableList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); Dimension pSize = spt.getPreferredSize(); pSize.height = 200; spt.setPreferredSize(pSize); JPanel topPanel = new JPanel(new BorderLayout()); scrollPane = new JScrollPane(listBoxPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); tableList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int inx = tableList.getSelectedIndex(); if (inx > -1) { fillNextList(tableList); } else { listBoxPanel.removeAll(); } } } }); addBtn = new JButton(IconManager.getImage("PlusSign", IconManager.IconSize.Std16)); addBtn.setEnabled(false); addBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { BaseQRI qri = (BaseQRI) listBoxList.get(currentInx).getSelectedValue(); if (qri.isInUse) { return; } try { FieldQRI fieldQRI = buildFieldQRI(qri); if (fieldQRI == null) { throw new Exception("null FieldQRI"); } SpQueryField qf = new SpQueryField(); qf.initialize(); qf.setFieldName(fieldQRI.getFieldName()); qf.setStringId(fieldQRI.getStringId()); query.addReference(qf, "fields"); if (!isExportMapping) { addQueryFieldItem(fieldQRI, qf, false); } else { addNewMapping(fieldQRI, qf, null, false); } } catch (Exception ex) { log.error(ex); UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(QueryBldrPane.class, ex); return; } } }); contextPanel = new JPanel(new BorderLayout()); contextPanel.add(createLabel("Search Context", SwingConstants.CENTER), BorderLayout.NORTH); // I18N contextPanel.add(spt, BorderLayout.CENTER); contextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); JPanel schemaPanel = new JPanel(new BorderLayout()); schemaPanel.add(scrollPane, BorderLayout.CENTER); topPanel.add(contextPanel, BorderLayout.WEST); topPanel.add(schemaPanel, BorderLayout.CENTER); add(topPanel, BorderLayout.NORTH); queryFieldsPanel = new JPanel(); queryFieldsPanel.setLayout(new NavBoxLayoutManager(0, 2)); queryFieldsScroll = new JScrollPane(queryFieldsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); queryFieldsScroll.setBorder(null); add(queryFieldsScroll); //if (!isExportMapping) //{ final JPanel mover = buildMoverPanel(false); add(mover, BorderLayout.EAST); // } String searchLbl = schemaMapping == null ? getResourceString("QB_SEARCH") : getResourceString("QB_EXPORT_PREVIEW"); searchBtn = createButton(searchLbl); searchBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { // int m = ae.getModifiers(); // boolean ors = (m & ActionEvent.ALT_MASK) > 0 && (m & ActionEvent.CTRL_MASK) > 0 && (m & ActionEvent.SHIFT_MASK) > 0; // if (ors) // { // System.out.println("Disjunctional conjoinment desire gesture detected"); // } // doSearch(ors); doSearch(false); } }); distinctChk = createCheckBox(UIRegistry.getResourceString("QB_DISTINCT")); distinctChk.setVisible(schemaMapping == null); if (schemaMapping == null) { distinctChk.setSelected(false); distinctChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new SwingWorker() { /* (non-Javadoc) * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { if (distinctChk.isSelected()) { UsageTracker.incrUsageCount("QB.DistinctOn"); } else { UsageTracker.incrUsageCount("QB.DistinctOff"); } if ((isTreeLevelSelected() || isAggFieldSelected()) && countOnly && distinctChk.isSelected()) { countOnlyChk.setSelected(false); countOnly = false; } query.setCountOnly(countOnly); query.setSelectDistinct(distinctChk.isSelected()); setSaveBtnEnabled(thereAreItems()); return null; } }.start(); } }); } countOnlyChk = createCheckBox(UIRegistry.getResourceString("QB_COUNT_ONLY")); countOnlyChk.setSelected(false); countOnlyChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new SwingWorker() { /* (non-Javadoc) * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { //Don't allow change while query is running. if (runningResults.get() == null) { countOnly = !countOnly; if (countOnly) { UsageTracker.incrUsageCount("QB.CountOnlyOn"); } else { UsageTracker.incrUsageCount("QB.CountOnlyOff"); } if ((isTreeLevelSelected() || isAggFieldSelected()) && countOnly && (distinctChk.isSelected() || searchSynonymyChk.isSelected())) { distinctChk.setSelected(false); searchSynonymyChk.setSelected(false); } } else { //This might be awkward and/or klunky... countOnlyChk.setSelected(countOnly); } query.setCountOnly(countOnly); query.setSelectDistinct(distinctChk.isSelected()); setSaveBtnEnabled(thereAreItems()); return null; } }.start(); } }); searchSynonymyChk = createCheckBox(UIRegistry.getResourceString("QB_SRCH_SYNONYMS")); searchSynonymyChk.setSelected(searchSynonymy); searchSynonymyChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new SwingWorker() { /* (non-Javadoc) * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { searchSynonymy = !searchSynonymy; if (!searchSynonymy) { UsageTracker.incrUsageCount("QB.SearchSynonymyOff"); } else { UsageTracker.incrUsageCount("QB.SearchSynonymyOn"); } if (isTreeLevelSelected() && countOnly && searchSynonymyChk.isSelected()) { countOnlyChk.setSelected(false); countOnly = false; } query.setSearchSynonymy(searchSynonymy); setSaveBtnEnabled(thereAreItems()); return null; } }.start(); } }); smushedChk = createCheckBox(UIRegistry.getResourceString("QB_SMUSH_RESULTS")); smushedChk.setVisible(isSmushableContext()); if (isSmushableContext()) { smushedChk.setSelected(smushed); smushedChk.setToolTipText( String.format(UIRegistry.getResourceString("QB_SMUSH_RESULTS_HINT"), getCatalogNumberTitle())); smushedChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new SwingWorker() { /* * (non-Javadoc) * * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { smushed = !smushed; if (!smushed) { UsageTracker.incrUsageCount("QB.SmushedOff"); } else { UsageTracker.incrUsageCount("QB.SmushedOn"); } query.setSmushed(smushed); setSaveBtnEnabled(thereAreItems()); return null; } }.start(); } }); } PanelBuilder outer = new PanelBuilder( new FormLayout("p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 6dlu, p", "p")); CellConstraints cc = new CellConstraints(); outer.add(smushedChk, cc.xy(1, 1)); outer.add(searchSynonymyChk, cc.xy(3, 1)); outer.add(distinctChk, cc.xy(5, 1)); outer.add(countOnlyChk, cc.xy(7, 1)); outer.add(searchBtn, cc.xy(9, 1)); outer.add(saveBtn, cc.xy(11, 1)); JPanel bottom = new JPanel(new BorderLayout()); bottom.add(outer.getPanel(), BorderLayout.EAST); JButton helpBtn = UIHelper.createHelpIconButton(getHelpBtnContext()); bottom.add(helpBtn, BorderLayout.WEST); add(bottom, BorderLayout.SOUTH); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:GUI.MainWindow.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./*w w w. j a v a2 s .c o m*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { ImportScanScreen = new javax.swing.JDialog(); jLabel1 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); ImportFile = new javax.swing.JList(); jLabel2 = new javax.swing.JLabel(); FileType = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); FileSize = new javax.swing.JTextField(); ProgressBar = new javax.swing.JProgressBar(); VulnTreeContextMenu = new javax.swing.JPopupMenu(); MergeButton = new javax.swing.JMenuItem(); LookupCVE = new javax.swing.JMenuItem(); AddToPersonalVulns = new javax.swing.JMenuItem(); ClearHash = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JPopupMenu.Separator(); DeleteButton = new javax.swing.JMenuItem(); VulnAffectedHostsContextMenu = new javax.swing.JPopupMenu(); AddHostsButton = new javax.swing.JMenuItem(); EditHostname = new javax.swing.JMenuItem(); jSeparator2 = new javax.swing.JPopupMenu.Separator(); DeleteHost = new javax.swing.JMenuItem(); VulnReferencesContextMenu = new javax.swing.JPopupMenu(); InsertReference = new javax.swing.JMenuItem(); EditReferenceOption = new javax.swing.JMenuItem(); LaunchInBrowser = new javax.swing.JMenuItem(); jSeparator3 = new javax.swing.JPopupMenu.Separator(); DeleteReferenceOption = new javax.swing.JMenuItem(); ManageAffectedHosts = new javax.swing.JDialog(); jScrollPane5 = new javax.swing.JScrollPane(); ListOfHosts = new javax.swing.JList(); jScrollPane9 = new javax.swing.JScrollPane(); ListOfOpenPorts = new javax.swing.JList(); jLabel5 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); MainScreenBottomPanel = new javax.swing.JPanel(); jLabel20 = new javax.swing.JLabel(); VulnTreeFilter = new javax.swing.JTextField(); ExtraInfoLabel = new javax.swing.JLabel(); jSplitPane2 = new javax.swing.JSplitPane(); ViewModeTabPane = new javax.swing.JTabbedPane(); jScrollPane1 = new javax.swing.JScrollPane(); VulnTree = new javax.swing.JTree(); jScrollPane3 = new javax.swing.JScrollPane(); HostTree = new javax.swing.JTree(); RightPanelCardLayout = new javax.swing.JPanel(); RightPanelVulnView = new javax.swing.JPanel(); VulnerabilityTopPanel = new javax.swing.JPanel(); jPanel8 = new javax.swing.JPanel(); jLabel9 = new javax.swing.JLabel(); VulnTitleTextField = new javax.swing.JTextField(); jPanel9 = new javax.swing.JPanel(); jLabel10 = new javax.swing.JLabel(); VulnCVSSVectorTextField = new javax.swing.JTextField(); jLabel11 = new javax.swing.JLabel(); VulnRiskCategory = new javax.swing.JTextField(); jLabel12 = new javax.swing.JLabel(); VulnScore = new javax.swing.JTextField(); EditRiskButton = new javax.swing.JButton(); jSplitPane1 = new javax.swing.JSplitPane(); jSplitPane3 = new javax.swing.JSplitPane(); VulnRecommendationsPanel = new javax.swing.JPanel(); jLabel8 = new javax.swing.JLabel(); jScrollPane7 = new javax.swing.JScrollPane(); VulnRecommendationTextPane = new javax.swing.JTextPane(); jSplitPane4 = new javax.swing.JSplitPane(); VulnReferencesPanel = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jScrollPane6 = new javax.swing.JScrollPane(); VulnReferencesList = new javax.swing.JList(); jScrollPane4 = new javax.swing.JScrollPane(); VulnAffectedHostsTable = new javax.swing.JTable(); VulnDescriptionPanel = new javax.swing.JPanel(); jLabel6 = new javax.swing.JLabel(); jScrollPane8 = new javax.swing.JScrollPane(); VulnDescriptionTextPane = new javax.swing.JTextPane(); RightPanelHostsView = new javax.swing.JPanel(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); jMenuItem3 = new javax.swing.JMenuItem(); jMenuItem4 = new javax.swing.JMenuItem(); jMenuItem5 = new javax.swing.JMenuItem(); jMenuItem11 = new javax.swing.JMenuItem(); exitButton = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); jMenuItem2 = new javax.swing.JMenuItem(); jMenuItem7 = new javax.swing.JMenuItem(); jMenuItem10 = new javax.swing.JMenuItem(); jMenu4 = new javax.swing.JMenu(); jMenuItem9 = new javax.swing.JMenuItem(); jMenu3 = new javax.swing.JMenu(); jMenuItem8 = new javax.swing.JMenuItem(); jMenu5 = new javax.swing.JMenu(); increaseFont = new javax.swing.JMenuItem(); decreaseFont = new javax.swing.JMenuItem(); ImportScanScreen.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); ImportScanScreen.setTitle("Report Compiler - Import Scan Screen"); ImportScanScreen.setMinimumSize(new java.awt.Dimension(382, 220)); ImportScanScreen.setModal(true); ImportScanScreen.addWindowListener(new java.awt.event.WindowAdapter() { public void windowActivated(java.awt.event.WindowEvent evt) { ImportScanScreenWindowActivated(evt); } }); jLabel1.setText("File Name:"); ImportFile.setModel(new javax.swing.AbstractListModel() { String[] strings = { "One" }; public int getSize() { return strings.length; } public Object getElementAt(int i) { return strings[i]; } }); ImportFile.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); ImportFile.setEnabled(false); jScrollPane2.setViewportView(ImportFile); jLabel2.setText("File Type:"); FileType.setEnabled(false); jLabel3.setText("File Size:"); FileSize.setEnabled(false); ProgressBar.setIndeterminate(true); javax.swing.GroupLayout ImportScanScreenLayout = new javax.swing.GroupLayout( ImportScanScreen.getContentPane()); ImportScanScreen.getContentPane().setLayout(ImportScanScreenLayout); ImportScanScreenLayout .setHorizontalGroup( ImportScanScreenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ImportScanScreenLayout.createSequentialGroup().addGap(10, 10, 10) .addGroup(ImportScanScreenLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2) .addComponent(FileType, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3) .addComponent(FileSize, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE)))); ImportScanScreenLayout.setVerticalGroup(ImportScanScreenLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ImportScanScreenLayout.createSequentialGroup().addGap(10, 10, 10).addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel2) .addGap(6, 6, 6) .addComponent(FileType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0).addComponent(jLabel3).addGap(6, 6, 6) .addComponent(FileSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(10, 10, 10).addComponent(ProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); MergeButton.setText("Merge"); MergeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { MergeButtonActionPerformed(evt); } }); VulnTreeContextMenu.add(MergeButton); LookupCVE.setText("Lookup CVE(s)"); LookupCVE.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LookupCVEActionPerformed(evt); } }); VulnTreeContextMenu.add(LookupCVE); AddToPersonalVulns.setText("Add to Personal Vulns"); AddToPersonalVulns.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AddToPersonalVulnsActionPerformed(evt); } }); VulnTreeContextMenu.add(AddToPersonalVulns); ClearHash.setText("Clear Hash(s)"); ClearHash.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ClearHashActionPerformed(evt); } }); VulnTreeContextMenu.add(ClearHash); VulnTreeContextMenu.add(jSeparator1); DeleteButton.setText("Delete"); DeleteButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DeleteButtonActionPerformed(evt); } }); VulnTreeContextMenu.add(DeleteButton); VulnAffectedHostsContextMenu.setMinimumSize(new java.awt.Dimension(20, 20)); AddHostsButton.setText("Add Host"); AddHostsButton.setActionCommand("AddHost"); AddHostsButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AddHostsButtonActionPerformed(evt); } }); VulnAffectedHostsContextMenu.add(AddHostsButton); EditHostname.setText("Edit Hostname"); EditHostname.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EditHostnameActionPerformed(evt); } }); VulnAffectedHostsContextMenu.add(EditHostname); VulnAffectedHostsContextMenu.add(jSeparator2); DeleteHost.setText("Delete Host ('del' is hotkey)"); DeleteHost.setActionCommand("DeleteHost"); DeleteHost.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DeleteHostActionPerformed(evt); } }); VulnAffectedHostsContextMenu.add(DeleteHost); InsertReference.setText("Insert Reference"); InsertReference.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { InsertReferenceActionPerformed(evt); } }); VulnReferencesContextMenu.add(InsertReference); EditReferenceOption.setText("Edit Reference"); EditReferenceOption.setToolTipText(""); EditReferenceOption.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EditReferenceOptionActionPerformed(evt); } }); VulnReferencesContextMenu.add(EditReferenceOption); LaunchInBrowser.setText("Launch in Browser"); LaunchInBrowser.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LaunchInBrowserActionPerformed(evt); } }); VulnReferencesContextMenu.add(LaunchInBrowser); VulnReferencesContextMenu.add(jSeparator3); DeleteReferenceOption.setText("Delete Reference"); DeleteReferenceOption.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DeleteReferenceOptionActionPerformed(evt); } }); VulnReferencesContextMenu.add(DeleteReferenceOption); ManageAffectedHosts.setTitle("Report Compiler - Manage Affected Hosts"); ManageAffectedHosts.addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(java.awt.event.WindowEvent evt) { ManageAffectedHostsWindowOpened(evt); } }); jScrollPane5.setViewportView(ListOfHosts); jScrollPane9.setViewportView(ListOfOpenPorts); jLabel5.setText("Hosts"); jLabel13.setText("Ports"); javax.swing.GroupLayout ManageAffectedHostsLayout = new javax.swing.GroupLayout( ManageAffectedHosts.getContentPane()); ManageAffectedHosts.getContentPane().setLayout(ManageAffectedHostsLayout); ManageAffectedHostsLayout.setHorizontalGroup( ManageAffectedHostsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ManageAffectedHostsLayout.createSequentialGroup().addGap(25, 25, 25) .addGroup(ManageAffectedHostsLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) .addGap(18, 18, 18) .addGroup(ManageAffectedHostsLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel13).addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); ManageAffectedHostsLayout.setVerticalGroup( ManageAffectedHostsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ManageAffectedHostsLayout.createSequentialGroup().addContainerGap() .addGroup(ManageAffectedHostsLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5).addComponent(jLabel13)) .addGap(13, 13, 13) .addGroup(ManageAffectedHostsLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE) .addComponent(jScrollPane9)) .addContainerGap(36, Short.MAX_VALUE))); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Report Compiler - Main Window"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); jLabel20.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel20.setText("Tree Filter:"); VulnTreeFilter.addCaretListener(new javax.swing.event.CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent evt) { VulnTreeFilterCaretUpdate(evt); } }); ExtraInfoLabel.setFont( ExtraInfoLabel.getFont().deriveFont(ExtraInfoLabel.getFont().getStyle() | java.awt.Font.BOLD)); ExtraInfoLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); javax.swing.GroupLayout MainScreenBottomPanelLayout = new javax.swing.GroupLayout(MainScreenBottomPanel); MainScreenBottomPanel.setLayout(MainScreenBottomPanelLayout); MainScreenBottomPanelLayout.setHorizontalGroup(MainScreenBottomPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(MainScreenBottomPanelLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel20) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(VulnTreeFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 354, Short.MAX_VALUE) .addComponent(ExtraInfoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 556, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); MainScreenBottomPanelLayout.setVerticalGroup(MainScreenBottomPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(MainScreenBottomPanelLayout.createSequentialGroup().addContainerGap() .addGroup(MainScreenBottomPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(MainScreenBottomPanelLayout.createSequentialGroup() .addComponent(ExtraInfoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(20, 20, 20)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, MainScreenBottomPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel20).addComponent(VulnTreeFilter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); getContentPane().add(MainScreenBottomPanel, java.awt.BorderLayout.SOUTH); jSplitPane2.setDividerLocation(200); jSplitPane2.setDividerSize(20); jSplitPane2.setOneTouchExpandable(true); ViewModeTabPane.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { ViewModeTabPaneStateChanged(evt); } }); javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode( "NOT IMPLEMENTED"); VulnTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1)); VulnTree.setCellRenderer(new VulnerabilityViewTreeCellRenderer(true)); VulnTree.setRootVisible(false); VulnTree.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { VulnTreeMouseClicked(evt); } }); VulnTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() { public void valueChanged(javax.swing.event.TreeSelectionEvent evt) { VulnTreeValueChanged(evt); } }); VulnTree.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { VulnTreeKeyPressed(evt); } }); jScrollPane1.setViewportView(VulnTree); ViewModeTabPane.addTab("Vuln View", jScrollPane1); jScrollPane3.setEnabled(false); treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root"); HostTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1)); HostTree.setRootVisible(false); jScrollPane3.setViewportView(HostTree); ViewModeTabPane.addTab("Host View", jScrollPane3); jSplitPane2.setLeftComponent(ViewModeTabPane); RightPanelCardLayout.setLayout(new java.awt.CardLayout()); RightPanelVulnView.setLayout(new java.awt.BorderLayout()); VulnerabilityTopPanel.setLayout(new java.awt.BorderLayout()); jPanel8.setLayout(new javax.swing.BoxLayout(jPanel8, javax.swing.BoxLayout.LINE_AXIS)); jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabel9.setLabelFor(VulnTitleTextField); jLabel9.setText("Title: "); jPanel8.add(jLabel9); VulnTitleTextField.setColumns(80); jPanel8.add(VulnTitleTextField); VulnerabilityTopPanel.add(jPanel8, java.awt.BorderLayout.NORTH); jPanel9.setLayout(new javax.swing.BoxLayout(jPanel9, javax.swing.BoxLayout.LINE_AXIS)); jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel10.setText("CVSS:"); jPanel9.add(jLabel10); VulnCVSSVectorTextField.setEditable(false); VulnCVSSVectorTextField.setColumns(81); jPanel9.add(VulnCVSSVectorTextField); jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel11.setText("Category:"); jPanel9.add(jLabel11); VulnRiskCategory.setEditable(false); VulnRiskCategory.setColumns(8); jPanel9.add(VulnRiskCategory); jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel12.setText("Score:"); jPanel9.add(jLabel12); VulnScore.setEditable(false); VulnScore.setColumns(4); jPanel9.add(VulnScore); EditRiskButton.setText("Edit Risk"); EditRiskButton.setToolTipText("Click here to see the Risk Calculator where scores can be modified"); EditRiskButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EditRiskButtonActionPerformed(evt); } }); jPanel9.add(EditRiskButton); VulnerabilityTopPanel.add(jPanel9, java.awt.BorderLayout.CENTER); RightPanelVulnView.add(VulnerabilityTopPanel, java.awt.BorderLayout.NORTH); jSplitPane1.setDividerLocation(200); jSplitPane1.setDividerSize(20); jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane1.setOneTouchExpandable(true); jSplitPane3.setDividerLocation(200); jSplitPane3.setDividerSize(20); jSplitPane3.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane3.setOneTouchExpandable(true); VulnRecommendationsPanel.setLayout(new java.awt.BorderLayout()); jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel8.setText("Recommendation"); VulnRecommendationsPanel.add(jLabel8, java.awt.BorderLayout.PAGE_START); jScrollPane7.setViewportView(VulnRecommendationTextPane); VulnRecommendationsPanel.add(jScrollPane7, java.awt.BorderLayout.CENTER); jSplitPane3.setLeftComponent(VulnRecommendationsPanel); jSplitPane4.setDividerSize(20); jSplitPane4.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane4.setOneTouchExpandable(true); VulnReferencesPanel.setLayout(new java.awt.BorderLayout()); jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel4.setText("Affected Hosts"); VulnReferencesPanel.add(jLabel4, java.awt.BorderLayout.PAGE_END); jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel7.setText("References"); VulnReferencesPanel.add(jLabel7, java.awt.BorderLayout.PAGE_START); VulnReferencesList.setModel(new DefaultListModel()); VulnReferencesList.setToolTipText("Right click on this area to see options for references."); VulnReferencesList.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { VulnReferencesListMouseClicked(evt); } }); VulnReferencesList.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { VulnReferencesListKeyPressed(evt); } }); jScrollPane6.setViewportView(VulnReferencesList); VulnReferencesPanel.add(jScrollPane6, java.awt.BorderLayout.CENTER); jSplitPane4.setTopComponent(VulnReferencesPanel); jScrollPane4.setToolTipText( "Right click on this area to insert new affected hosts. Select one or more and press 'del' to delete or use the right click 'delete' option."); jScrollPane4.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jScrollPane4MouseClicked(evt); } }); jScrollPane4.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jScrollPane4KeyPressed(evt); } }); VulnAffectedHostsTable.setAutoCreateRowSorter(true); VulnAffectedHostsTable.setModel(new AffectedHostsTableModel()); /*new javax.swing.table.DefaultTableModel( new Object[][]{}, new String[]{ "IP Address", "Hostname", "Portnumber", "Protocol" } ) { Class[] types = new Class[]{ Host.class, java.lang.String.class, java.lang.Integer.class, java.lang.String.class }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } }*///); VulnAffectedHostsTable.setToolTipText(""); VulnAffectedHostsTable.setCellSelectionEnabled(true); VulnAffectedHostsTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { VulnAffectedHostsTableMouseClicked(evt); } }); VulnAffectedHostsTable.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { VulnAffectedHostsTableKeyPressed(evt); } }); jScrollPane4.setViewportView(VulnAffectedHostsTable); VulnAffectedHostsTable.getColumnModel().getSelectionModel() .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION); jSplitPane4.setRightComponent(jScrollPane4); jSplitPane3.setRightComponent(jSplitPane4); jSplitPane1.setBottomComponent(jSplitPane3); VulnDescriptionPanel.setMinimumSize(new java.awt.Dimension(0, 50)); VulnDescriptionPanel.setLayout(new java.awt.BorderLayout()); jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel6.setText("Description"); VulnDescriptionPanel.add(jLabel6, java.awt.BorderLayout.PAGE_START); jScrollPane8.setViewportView(VulnDescriptionTextPane); VulnDescriptionPanel.add(jScrollPane8, java.awt.BorderLayout.CENTER); jSplitPane1.setTopComponent(VulnDescriptionPanel); RightPanelVulnView.add(jSplitPane1, java.awt.BorderLayout.CENTER); RightPanelCardLayout.add(RightPanelVulnView, "vulnView"); javax.swing.GroupLayout RightPanelHostsViewLayout = new javax.swing.GroupLayout(RightPanelHostsView); RightPanelHostsView.setLayout(RightPanelHostsViewLayout); RightPanelHostsViewLayout.setHorizontalGroup(RightPanelHostsViewLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 1103, Short.MAX_VALUE)); RightPanelHostsViewLayout.setVerticalGroup(RightPanelHostsViewLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 739, Short.MAX_VALUE)); RightPanelCardLayout.add(RightPanelHostsView, "hostView"); jSplitPane2.setRightComponent(RightPanelCardLayout); getContentPane().add(jSplitPane2, java.awt.BorderLayout.CENTER); jMenu1.setMnemonic('F'); jMenu1.setText("File"); jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem3.setText("New (Clear Tree)"); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); jMenu1.add(jMenuItem3); jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem4.setText("Open"); jMenuItem4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem4ActionPerformed(evt); } }); jMenu1.add(jMenuItem4); jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem5.setText("Save"); jMenuItem5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem5ActionPerformed(evt); } }); jMenu1.add(jMenuItem5); jMenuItem11.setText("Save As"); jMenuItem11.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem11ActionPerformed(evt); } }); jMenu1.add(jMenuItem11); exitButton.setText("Exit"); exitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitButtonActionPerformed(evt); } }); jMenu1.add(exitButton); jMenuBar1.add(jMenu1); jMenu2.setMnemonic('V'); jMenu2.setText("Vulnerabilities"); jMenu2.setToolTipText( "All vulnerability related operations. Import from a tool, create an entirely new one etc"); jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); jMenuItem1.setText("Import from Tool"); jMenuItem1.setToolTipText("Select one or more files to import simultaneously. "); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu2.add(jMenuItem1); jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_INSERT, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); jMenuItem2.setText("Create New Vulnerability"); jMenuItem2.setToolTipText( "Add a new vulnerability to your test. When finished you can save it to your Personal Vulnerability database by right clicking on the issue in the tree"); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu2.add(jMenuItem2); jMenuItem7.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); jMenuItem7.setText("Manage Personal Vulns"); jMenuItem7.setToolTipText( "Allows you to delete or edit the text for vulnerabilities in your Personal Database"); jMenuItem7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem7ActionPerformed(evt); } }); jMenu2.add(jMenuItem7); jMenuItem10.setText("Auto Merge"); jMenuItem10.setToolTipText( "Use this to automatically replace the title, description, recommendation, references, and risk score with vulnerabilities in your personal database."); jMenuItem10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem10ActionPerformed(evt); } }); jMenu2.add(jMenuItem10); jMenuBar1.add(jMenu2); jMenu4.setText("Hosts"); jMenuItem9.setText("Import Hosts by Nmap"); jMenuItem9.setEnabled(false); jMenu4.add(jMenuItem9); jMenuBar1.add(jMenu4); jMenu3.setMnemonic('E'); jMenu3.setText("Export"); jMenuItem8.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); jMenuItem8.setText("Excel Vulnerability List"); jMenuItem8.setToolTipText( "This can be used to send a high level debrief to clients in a spreadsheet format. Report Compiler also imports vulnerabilities back from these excel files if necessary."); jMenuItem8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem8ActionPerformed(evt); } }); jMenu3.add(jMenuItem8); jMenuBar1.add(jMenu3); jMenu5.setText("Options"); increaseFont.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_EQUALS, java.awt.event.InputEvent.CTRL_MASK)); increaseFont.setText("Increase Font"); increaseFont.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { increaseFontActionPerformed(evt); } }); jMenu5.add(increaseFont); decreaseFont.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_MINUS, java.awt.event.InputEvent.CTRL_MASK)); decreaseFont.setText("Decrease Font"); decreaseFont.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { decreaseFontActionPerformed(evt); } }); jMenu5.add(decreaseFont); jMenuBar1.add(jMenu5); setJMenuBar(jMenuBar1); pack(); setLocationRelativeTo(null); }
From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java
private JList buildJList(final Dimension dimension, final Object[] items, final JList list, final boolean sort) { if (items == null) { return null; }/*w w w . j a va 2 s. co m*/ list.setModel(new DefaultListModel() { @Override public void addElement(Object obj) { boolean inserted = false; if (sort) { for (int i = 0; i < this.getSize() && !inserted; i++) { try { final String comparator = ((obj == null) ? "" : obj.toString()); if (this.get(i).toString().compareTo(comparator) > 0) { this.add(i, obj); inserted = true; } } catch (Throwable t) { log.error("Error al ordenar a " + obj + " y no lo incluimos", t); inserted = true; } } } if (!inserted) { super.addElement(obj); } } }); log.trace("Lista con " + items.length + " objetos"); for (Object obj : items) { ((DefaultListModel) list.getModel()).addElement(obj); } list.setCellRenderer(new DefaultListCellRenderer() { private static final long serialVersionUID = -987995602141400182L; @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel c = new JLabel(); c.setText(value.toString()); if (isSelected) { c.setOpaque(true); c.setBackground(Color.YELLOW); } return c; } }); list.setMinimumSize(dimension); list.setFixedCellHeight(22); return list; }
From source file:com.wesley.urban_cuts.client.urbancuts.myFrame.java
private void populate_barbers() { List<Staff> allStaff = staffCrudService.findAll(); if (allStaff != null) { DefaultListModel<String> model = new DefaultListModel<>(); for (int i = 0; i < staffCrudService.count(); i++) { model.addElement(allStaff.get(i).getName()); }/*w w w . j av a 2s . c o m*/ jList2.setModel(model); } }
From source file:gtu._work.ui.ExportSVNModificationFilesUI.java
void reflushOutputList() { DefaultListModel model = (DefaultListModel) srcList.getModel(); LineParser lineParser = null;//from w w w.j a v a 2 s.com OutputFile outputFile = null; List<File> list = new ArrayList<File>(); for (int ii = 0; ii < model.size(); ii++) { lineParser = (LineParser) model.getElementAt(ii); list.add(lineParser.file); } File baseDir = FileUtil.exportReceiveBaseDir(list); Validate.notNull(baseDir, "no common base directory!"); DefaultListModel outputModel = new DefaultListModel(); for (int ii = 0; ii < model.size(); ii++) { lineParser = (LineParser) model.getElementAt(ii); outputFile = new OutputFile(); outputFile.srcFile = lineParser.file; outputFile.destFile = FileUtil.exportFileToTargetPath(lineParser.file, baseDir, outputDir); outputModel.addElement(outputFile); } outPutList.setModel(outputModel); }
From source file:gtu._work.ui.PropertyEditUI.java
void loadCurrentFile(File file) { if (file == null) { file = PropertiesUtil.getJarCurrentPath(getClass()); JCommonUtil._jOptionPane_showMessageDialog_info("load current !"); }//from w w w . ja v a2s. c o m DefaultListModel model = new DefaultListModel(); backupFileList.clear(); for (File f : file.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".properties"); } })) { File_ ff = new File_(); ff.file = f; model.addElement(ff); backupFileList.add(f); } fileList.setModel(model); }
From source file:com.wesley.urban_cuts.client.urbancuts.myFrame.java
private void populate_styles() { List<Style> allStyles = styleCrudService.findAll(); if (allStyles != null) { DefaultListModel<String> model = new DefaultListModel<>(); for (int i = 0; i < styleCrudService.count(); i++) { model.addElement(allStyles.get(i).getStyle_name()); }//w w w. j a v a 2 s . c o m jList3.setModel(model); } }
From source file:gtu._work.ui.ExportSVNModificationFilesUI.java
void loadSrcTextarea() throws IOException { String srcText = null;/*from w w w . ja v a 2 s. co m*/ Validate.notEmpty((srcText = srcArea.getText()), "src textarea can't empty"); Validate.notNull(manualBaseDir, "src base directory not set!"); BufferedReader reader = new BufferedReader(new StringReader(srcText)); ParseMode mode = null; LineParser lineParser = null; Set<LineParser> set = new HashSet<LineParser>(); DefaultListModel errorLogModel = new DefaultListModel(); for (String line = null; (line = reader.readLine()) != null;) { mode = ((ParseMode) exportModeCombo.getSelectedItem()); if (mode == null) { continue; } lineParser = mode.parse(line, errorLogModel); System.out.println("lineParser = " + lineParser); if (lineParser != null) { set.add(lineParser); } } errorLogList.setModel(errorLogModel); if (errorLogModel.getSize() != 0) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("same error occor!,\n check out error log panel", "ERROR"); } DefaultListModel srcModel = new DefaultListModel(); for (LineParser line : set) { srcModel.addElement(line); } srcList.setModel(srcModel); copySrcListForQuerySet = Collections.unmodifiableSet(set); }
From source file:edu.ku.brc.af.ui.db.TextFieldWithQuery.java
/** * * @param advanceFocus/*from w w w.j a v a 2 s . com*/ */ protected void showDialog(final int advanceFocus) { final Vector<Integer> idListLocal = (Vector<Integer>) idList.clone(); final Vector<String> listLocal = (Vector<String>) list.clone(); final String enteredText = StringUtils.isEmpty(prevEnteredText) ? cachedPrevText : prevEnteredText; DefaultListModel<String> model = new DefaultListModel<String>(); if (doAddAddItem) { model.addElement(UIRegistry.getResourceString("TFWQ_ADD_LABEL")); //$NON-NLS-1$ } for (String val : list) { model.addElement(val); } final JList<String> listBox = new JList<String>(model); JPanel panel = new JPanel(new BorderLayout()); panel.add(createLabel(UIRegistry.getResourceString("TFWQ_CHOOSE_LABEL"), SwingConstants.CENTER), //$NON-NLS-1$ BorderLayout.NORTH); panel.add(UIHelper.createScrollPane(listBox, true), BorderLayout.CENTER); panel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); // Had to do inner class in order to get it to select an item // before being shown class PopUpDialog extends CustomDialog { protected JList<String> pListBox; public PopUpDialog(final Frame frame, final boolean isModal, final Component contentPanel, JList<String> pListBoxArg) throws HeadlessException { super(frame, UIRegistry.getResourceString("TFWQ_CHOOSE_TITLE"), isModal, contentPanel); //$NON-NLS-1$ this.pListBox = pListBoxArg; initialize(); } public PopUpDialog(final Dialog dialog, final boolean isModal, final Component contentPanel, JList<String> pListBoxArg) throws HeadlessException { super(dialog, UIRegistry.getResourceString("TFWQ_CHOOSE_TITLE"), isModal, OK_BTN | CANCEL_BTN, //$NON-NLS-1$ contentPanel); this.pListBox = pListBoxArg; initialize(); } /** * */ protected void initialize() { pListBox.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (okBtn != null && pListBox != null) { okBtn.setEnabled(listBox.getSelectedIndex() != -1); } } } }); pListBox.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if (e.getClickCount() == 2) { okBtn.setEnabled(true); okBtn.doClick(); } } }); } @Override public void setVisible(final boolean visible) { if (visible) { listBox.setSelectedIndex(doAddAddItem ? 1 : 0); } super.setVisible(visible); } } hasNewText = false; Window mostRecent = UIRegistry.getMostRecentWindow(); CustomDialog dlg; if (mostRecent instanceof Dialog) { dlg = new PopUpDialog((Dialog) UIRegistry.getMostRecentWindow(), true, panel, listBox); } else { dlg = new PopUpDialog((Frame) UIRegistry.getMostRecentWindow(), true, panel, listBox); } dlg.setVisible(true); if (!dlg.isCancelled()) { int inx = listBox.getSelectedIndex(); boolean isDoingAdd = inx == 0 && doAddAddItem; inx = doAddAddItem ? inx - 1 : inx; if (!isDoingAdd && inx < idListLocal.size()) { selectedId = idListLocal.get(inx); setText(listLocal.get(inx)); } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { transferFocus(advanceFocus); notifyListenersOfChange(isDoingAdd ? new AddItemEvent(enteredText) : listBox); } }); } else { setText(""); //$NON-NLS-1$ } }
From source file:edu.ucla.stat.SOCR.analyses.gui.Survival.java
protected void setMappingPanel() { //////////////System.out.println("Survival mappingPanel = " + mappingPanel); listIndex = new int[dataTable.getColumnCount()]; for (int j = 0; j < listIndex.length; j++) listIndex[j] = 1;//from ww w .j a v a2 s . c om bPanel = new JPanel(new BorderLayout()); mappingInnerPanel = new JPanel(new GridLayout(1, 3)); mappingPanel.add(mappingInnerPanel, BorderLayout.CENTER); mappingInnerPanel.setBackground(Color.WHITE); addButton1.addActionListener(this); addButton2.addActionListener(this); addButton3.addActionListener(this); removeButton1.addActionListener(this); removeButton2.addActionListener(this); removeButton3.addActionListener(this); ////////////////System.out.println("Survival mappingPanel = " + mappingPanel); lModel1 = new DefaultListModel(); lModel2 = new DefaultListModel(); lModel3 = new DefaultListModel(); lModel4 = new DefaultListModel(); int cellWidth = 10; listAdded = new JList(lModel1); listAdded.setSelectedIndex(0); listTime = new JList(lModel2); listCensor = new JList(lModel3); listGroupNames = new JList(lModel4); paintTable(listIndex); listAdded.setFixedCellWidth(cellWidth); listTime.setFixedCellWidth(cellWidth); listCensor.setFixedCellWidth(cellWidth); listGroupNames.setFixedCellWidth(cellWidth); //tools1.setBackground(Color.RED); //tools2.setBackground(Color.GREEN); //tools3.setBackground(Color.BLUE); listAdded.setBackground(Color.WHITE); listTime.setBackground(Color.WHITE); listCensor.setBackground(Color.WHITE); listGroupNames.setBackground(Color.WHITE); tools1.add(timeLabel); tools2.add(censorLabel); tools3.add(groupNameLabel); tools1.add(addButton1); tools1.add(removeButton1); tools2.add(addButton2); tools2.add(removeButton2); tools3.add(addButton3); tools3.add(removeButton3); JPanel panelLeft = new JPanel(new GridLayout(3, 1, 50, 50)); JPanel panelCenter = new JPanel(new GridLayout(3, 1, 50, 50)); JPanel panelRight = new JPanel(new GridLayout(3, 1, 50, 50)); //JPanel dummyPanelLeft1 = null;//new JPanel(); //JPanel dummyPanelBottom = null;//new JPanel(); //dummyPanelMiddle.setVisible(false); //dummyPanelBottom.setVisible(false); mappingInnerPanel.add(panelLeft, BorderLayout.WEST); mappingInnerPanel.add(panelCenter, BorderLayout.CENTER); mappingInnerPanel.add(panelRight, BorderLayout.EAST); panelLeft.add(new JScrollPane(listAdded)); // var cadidates. panelCenter.add(tools1); panelRight.add(new JScrollPane(listTime)); panelCenter.add(tools2); panelRight.add(new JScrollPane(listCensor)); panelCenter.add(tools3); panelRight.add(new JScrollPane(listGroupNames)); }