public EquationLogItemPanel(EquationLogItem equationLogItem) { myEquationLogItem = equationLogItem; setLayout(new GridBagLayout()); setBackground(Color.WHITE); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridy = 0; constraints.weighty = 0; constraints.weightx = 0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.NORTHWEST; JLabel label = new JLabel("equation"); add(label, constraints); constraints.gridx = 1; SNodeTree leftTree = new SNodeTree(myEquationLogItem.getLeftRepresentator()); add(leftTree, constraints); constraints.gridx = 2; SNodeTree rightTree = new SNodeTree(myEquationLogItem.getRightRepresentator()); add(rightTree, constraints); constraints.gridx = 3; constraints.weightx = 1; JLabel reasonLabel = new JLabel(myEquationLogItem.getReason()); reasonLabel.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.getClickCount() == 2) { String ruleModel = myEquationLogItem.getRuleModel(); final String ruleID = myEquationLogItem.getRuleId(); openRule(ruleModel, ruleID); } } }); add(reasonLabel, constraints); List<Pair<String, String>> causes = myEquationLogItem.getCauses(); if (!causes.isEmpty()) { constraints.gridx = 4; constraints.weightx = 0; CausesTree causesTree = new CausesTree(causes); add(causesTree, constraints); causesTree.rebuildNow(); } leftTree.rebuildNow(); rightTree.rebuildNow(); }
private void addEquationLog( JPanel panel, GridBagConstraints constraints, final EquationLogItem item) { constraints.weightx = 0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.gridx = 0; JLabel label = new JLabel("equation"); panel.add(label, constraints); constraints.gridx = 1; SNodeTree leftTree = new SNodeTree(item.getLeftRepresentator()); panel.add(leftTree, constraints); constraints.gridx = 2; SNodeTree rightTree = new SNodeTree(item.getRightRepresentator()); panel.add(rightTree, constraints); constraints.gridx = 3; constraints.weightx = 1; JLabel reasonLabel = new JLabel(item.getReason()); reasonLabel.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.getClickCount() == 2) { String ruleModel = item.getRuleModel(); final String ruleID = item.getRuleId(); openRule(ruleModel, ruleID); } } }); panel.add(reasonLabel, constraints); List<Pair<String, String>> causes = item.getCauses(); constraints.gridx = 4; constraints.weightx = 0; if (!causes.isEmpty()) { CausesTree causesTree = new CausesTree(causes); panel.add(causesTree, constraints); causesTree.rebuildNow(); } else { add(new JLabel(""), constraints); } leftTree.rebuildNow(); rightTree.rebuildNow(); }
private void rebuild() { removeAll(); setLayout(new GridBagLayout()); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.weightx = 1; gridBagConstraints.weighty = 0; gridBagConstraints.anchor = GridBagConstraints.NORTH; gridBagConstraints.fill = GridBagConstraints.BOTH; // upper panel JButton debugCurrentRootButton = new JButton( new AbstractAction("Debug Current Root") { public void actionPerformed(ActionEvent e) { Project project = ProjectHelper.toIdeaProject(myOperationContext.getProject()); Editor currentEditor = EditorsHelper.getSelectedEditors(FileEditorManager.getInstance(project)).get(0); if (currentEditor != null) { EditorComponent editorComponent = currentEditor.getCurrentEditorComponent(); if (editorComponent != null) { final SNode currentRoot = editorComponent.getEditedNode(); debugRoot(currentRoot); } } } }); JPanel upperPanel = new JPanel(); upperPanel.setLayout(new GridBagLayout()); GridBagConstraints upperPanelConstraints = new GridBagConstraints(); upperPanelConstraints.gridx = 0; upperPanelConstraints.gridy = 0; upperPanelConstraints.weightx = 0; upperPanelConstraints.weighty = 0; upperPanelConstraints.anchor = GridBagConstraints.NORTHWEST; upperPanel.add(debugCurrentRootButton, upperPanelConstraints); String text = "no info collected"; upperPanelConstraints.gridx = 1; upperPanel.add(new JLabel(text)); upperPanelConstraints.weightx = 1; upperPanelConstraints.gridx = 2; upperPanel.add(new JPanel(), upperPanelConstraints); add(upperPanel, gridBagConstraints); JPanel innerPanel = new JPanel(new GridBagLayout()); int y = 0; GridBagConstraints innerConstraints = new GridBagConstraints(); if (myNodeToSliceWith != null) { // initial node type innerConstraints.gridy = y; y++; innerConstraints.weighty = 0; innerConstraints.weightx = 0; innerConstraints.fill = GridBagConstraints.NONE; innerConstraints.anchor = GridBagConstraints.NORTHWEST; innerConstraints.gridx = 0; innerPanel.add(new JLabel("initial type: "), innerConstraints); innerConstraints.gridx = 1; innerConstraints.gridwidth = GridBagConstraints.REMAINDER; SNodeTree initialTypeTree = new SNodeTree(null); innerPanel.add(initialTypeTree, innerConstraints); initialTypeTree.rebuildNow(); // innerPanel.add(nodeTypePanel, gridBagConstraints); // slice items innerConstraints.gridwidth = 1; for (EquationLogItem equationLogItem : myCurrentSlice) { innerConstraints.gridy = y; addEquationLog(innerPanel, innerConstraints, equationLogItem); // innerPanel.add(new EquationLogItemPanel(equationLogItem), gridBagConstraints); y++; } } innerConstraints.gridy = y; innerConstraints.weighty = 1; JPanel gauge = new JPanel(); gauge.setBackground(Color.WHITE); innerPanel.add(gauge, innerConstraints); innerPanel.setBackground(Color.WHITE); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(innerPanel); scrollPane.setBackground(Color.WHITE); gridBagConstraints.weighty = 1; gridBagConstraints.gridy = 1; add(scrollPane, gridBagConstraints); }