public void reload() { tableModel = new DependencyTableModel(new ArrayList<DependencyDTO>(), dataControl); fromModuleScrollPane.setBorder(new TitledBorder(dataControl.translate("FromModuleTreeTitle"))); toModuleScrollPane.setBorder(new TitledBorder(dataControl.translate("ToModuleTreeTitle"))); dependencyScrollPane.setBorder(new TitledBorder(dataControl.translate("DependencyTableTitle"))); filterPanel.setBorder(new TitledBorder(dataControl.translate("AnalyseDependencyFilter"))); this.indirectFilterBox.setText(dataControl.translate("ShowIndirectDependencies")); toModuleScrollPane.repaint(); fromModuleScrollPane.repaint(); dependencyScrollPane.repaint(); filterPanel.repaint(); updateTableModel(); this.repaint(); }
private void initialiseTrees() { AnalysedModuleDTO rootModule = new AnalysedModuleDTO("", "", "", ""); DefaultMutableTreeNode rootTo = new DefaultMutableTreeNode(rootModule); DefaultMutableTreeNode rootFrom = new DefaultMutableTreeNode(rootModule); this.fromModuleTree = new JTree(rootTo); createTreeLayout(fromModuleTree); fromModuleTree.addTreeSelectionListener(this); this.toModuleTree = new JTree(rootFrom); createTreeLayout(toModuleTree); toModuleTree.addTreeSelectionListener(this); List<AnalysedModuleDTO> rootModules = dataControl.getRootModules(); for (AnalysedModuleDTO module : rootModules) { DefaultMutableTreeNode toNode = new DefaultMutableTreeNode(module); DefaultMutableTreeNode fromNode = new DefaultMutableTreeNode(module); rootTo.add(toNode); fillNode(toNode); rootFrom.add(fromNode); fillNode(fromNode); } this.expandLeaf(toModuleTree, 1); this.expandLeaf(fromModuleTree, 1); fromModuleScrollPane.setBackground(UIManager.getColor("Panel.background")); fromModuleScrollPane.setViewportView(fromModuleTree); toModuleScrollPane.setBackground(UIManager.getColor("Panel.background")); toModuleScrollPane.setViewportView(toModuleTree); }
private void hideIndirectDependencies() { List<DependencyDTO> filteredList = new ArrayList<DependencyDTO>(); List<DependencyDTO> allDependencies = dataControl.listDependencies(fromSelected, toSelected); for (DependencyDTO dependency : allDependencies) { if (!dependency.isIndirect) filteredList.add(dependency); } dependencyTable.setModel(new DependencyTableModel(filteredList, dataControl)); dependencyTable.repaint(); }
private void fillNode(DefaultMutableTreeNode node) { AnalysedModuleDTO module = (AnalysedModuleDTO) node.getUserObject(); List<AnalysedModuleDTO> children = dataControl.getModulesInModules(module.uniqueName); if (!children.isEmpty()) { for (AnalysedModuleDTO child : children) { DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(child); fillNode(childNode); node.add(childNode); } } }
@Override public void valueChanged(TreeSelectionEvent eventTree) { DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) analyzedCodeTree.getLastSelectedPathComponent(); AnalysedModuleDTO selectedModule = (AnalysedModuleDTO) currentNode.getUserObject(); List<AnalysedModuleDTO> children = dataControl.getModulesInModules(selectedModule.uniqueName); if (!children.isEmpty()) { for (AnalysedModuleDTO child : children) { DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(child); currentNode.add(childNode); } } }
private void createPanel() { AnalysedModuleDTO rootModule = new AnalysedModuleDTO("Application", "Application", "root", "public"); DefaultMutableTreeNode root = new DefaultMutableTreeNode(rootModule); List<AnalysedModuleDTO> rootModules = dataControl.getRootModules(); for (AnalysedModuleDTO module : rootModules) { DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(module); root.add(rootNode); } analyzedCodeTree = new JTree(root); analyzedCodeTree.setBackground(UIManager.getColor("Panel.background")); analyzedCodeTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); analyzedCodeTree.addTreeSelectionListener(this); jScrollPaneTree = new JScrollPane(analyzedCodeTree); jScrollPaneTree.setBorder(null); jScrollPaneTree.setBackground(getBackground()); jScrollPaneTree.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); GroupLayout groupLayout = new GroupLayout(this); groupLayout.setHorizontalGroup( groupLayout .createParallelGroup(Alignment.LEADING) .addGroup( groupLayout .createSequentialGroup() .addContainerGap() .addComponent(jScrollPaneTree, GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE) .addContainerGap())); groupLayout.setVerticalGroup( groupLayout .createParallelGroup(Alignment.LEADING) .addGroup( groupLayout .createSequentialGroup() .addGap(5) .addComponent(jScrollPaneTree, GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE) .addContainerGap())); DefaultTreeCellRenderer renderer = new SoftwareTreeCellRenderer(); renderer.setBackground(UIManager.getColor("Panel.background")); renderer.setBackgroundNonSelectionColor(UIManager.getColor("Panel.background")); renderer.setBackgroundSelectionColor(UIManager.getColor("Panel.background")); renderer.setTextNonSelectionColor(Color.black); renderer.setTextSelectionColor(Color.black); analyzedCodeTree.setCellRenderer(renderer); setLayout(groupLayout); }
public DependencyPanel() { dataControl = new AnalyseUIController(); this.indirectFilterBox = new JCheckBox(dataControl.translate("ShowIndirectDependencies")); this.indirectFilterBox.addActionListener(this); createLayout(); dependencyTable = new JTable(); tableModel = new DependencyTableModel(new ArrayList<DependencyDTO>(), dataControl); dependencyTable.setModel(tableModel); dependencyScrollPane.setViewportView(dependencyTable); dependencyTable.setBackground(UIManager.getColor("Panel.background")); dependencyTable.setAutoCreateRowSorter(true); initialiseTrees(); setLayout(theLayout); }
private void updateTableModel() { List<DependencyDTO> allFoundDependencies = dataControl.listDependencies(fromSelected, toSelected); dependencyTable.setModel(new DependencyTableModel(allFoundDependencies, dataControl)); dependencyTable.repaint(); }
private void createLayout() { fromModuleScrollPane = new JScrollPane(); fromModuleScrollPane.setBorder(new TitledBorder(dataControl.translate("FromModuleTreeTitle"))); toModuleScrollPane = new JScrollPane(); toModuleScrollPane.setBorder(new TitledBorder(dataControl.translate("ToModuleTreeTitle"))); dependencyScrollPane = new JScrollPane(); dependencyScrollPane.setBorder(new TitledBorder(dataControl.translate("DependencyTableTitle"))); this.filterPanel = new JPanel(); FlowLayout flowLayout = (FlowLayout) filterPanel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); filterPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); filterPanel.setBorder(new TitledBorder(dataControl.translate("AnalyseDependencyFilter"))); theLayout = new GroupLayout(this); theLayout.setHorizontalGroup( theLayout .createParallelGroup(Alignment.TRAILING) .addGroup( theLayout .createSequentialGroup() .addContainerGap() .addGroup( theLayout .createParallelGroup(Alignment.TRAILING) .addComponent( dependencyScrollPane, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE) .addComponent( filterPanel, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE) .addGroup( theLayout .createSequentialGroup() .addComponent( fromModuleScrollPane, GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE) .addGap(18) .addComponent( toModuleScrollPane, GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE))) .addContainerGap())); theLayout.setVerticalGroup( theLayout .createParallelGroup(Alignment.LEADING) .addGroup( theLayout .createSequentialGroup() .addContainerGap() .addGroup( theLayout .createParallelGroup(Alignment.LEADING) .addComponent( fromModuleScrollPane, GroupLayout.DEFAULT_SIZE, 235, Short.MAX_VALUE) .addComponent( toModuleScrollPane, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( filterPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( dependencyScrollPane, GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE) .addContainerGap())); indirectFilterBox.setSelected(true); indirectFilterBox.setHorizontalAlignment(SwingConstants.LEFT); filterPanel.add(indirectFilterBox); fromModuleScrollPane.setBackground(PANELBACKGROUND); toModuleScrollPane.setBackground(PANELBACKGROUND); dependencyScrollPane.setBackground(UIManager.getColor("Panel.background")); }