@Override public VcsDependentHistoryComponents getUICustomization( final VcsHistorySession session, JComponent forShortcutRegistration) { final ColumnInfo[] columns; final Consumer<VcsFileRevision> listener; final JComponent addComp; if (((SvnHistorySession) session).isHaveMergeSources()) { final MergeSourceColumnInfo mergeSourceColumn = new MergeSourceColumnInfo((SvnHistorySession) session); columns = new ColumnInfo[] {new CopyFromColumnInfo(), mergeSourceColumn}; final JPanel panel = new JPanel(new BorderLayout()); final JTextArea field = new JTextArea(); field.setEditable(false); field.setBackground(UIUtil.getComboBoxDisabledBackground()); field.setWrapStyleWord(true); listener = new Consumer<VcsFileRevision>() { @Override public void consume(VcsFileRevision vcsFileRevision) { field.setText(mergeSourceColumn.getText(vcsFileRevision)); } }; final MergeSourceDetailsAction sourceAction = new MergeSourceDetailsAction(); sourceAction.registerSelf(forShortcutRegistration); JPanel fieldPanel = new ToolbarDecorator() { @Override protected JComponent getComponent() { return field; } @Override protected void updateButtons() {} @Override protected void installDnDSupport() {} @Override protected boolean isModelEditable() { return false; } }.initPosition().addExtraAction(AnActionButton.fromAction(sourceAction)).createPanel(); fieldPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.TOP)); panel.add(fieldPanel, BorderLayout.CENTER); panel.add(new JLabel("Merge Sources:"), BorderLayout.NORTH); addComp = panel; } else { columns = new ColumnInfo[] {new CopyFromColumnInfo()}; addComp = null; listener = null; } return new VcsDependentHistoryComponents(columns, listener, addComp); }
public RegistryUi() { myContent.setLayout(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP)); myModel = new MyTableModel(); myTable = new JBTable(myModel); myTable.setCellSelectionEnabled(true); myTable.setEnableAntialiasing(true); final MyRenderer r = new MyRenderer(); final TableColumn c0 = myTable.getColumnModel().getColumn(0); c0.setCellRenderer(r); c0.setMaxWidth(RESTART_ICON.getIconWidth() + 12); c0.setMinWidth(RESTART_ICON.getIconWidth() + 12); c0.setHeaderValue(null); final TableColumn c1 = myTable.getColumnModel().getColumn(1); c1.setCellRenderer(r); c1.setHeaderValue("Key"); final TableColumn c2 = myTable.getColumnModel().getColumn(2); c2.setCellRenderer(r); c2.setHeaderValue("Value"); c2.setCellEditor(new MyEditor()); myTable.setStriped(true); myDescriptionLabel = new JTextArea(3, 50); myDescriptionLabel.setEditable(false); final JScrollPane label = ScrollPaneFactory.createScrollPane(myDescriptionLabel); final JPanel descriptionPanel = new JPanel(new BorderLayout()); descriptionPanel.add(label, BorderLayout.CENTER); descriptionPanel.setBorder( IdeBorderFactory.createTitledBorder("Description", false, false, true)); myContent.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER); myContent.add(descriptionPanel, BorderLayout.SOUTH); myTable .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; final int selected = myTable.getSelectedRow(); if (selected != -1) { final RegistryValue value = myModel.getRegistryValue(selected); String desc = value.getDescription(); if (value.isRestartRequired()) { String required = "Requires IDE restart."; if (desc.endsWith(".")) { desc += required; } else { desc += (". " + required); } } myDescriptionLabel.setText(desc); } else { myDescriptionLabel.setText(null); } } }); myRestoreDefaultsAction = new RestoreDefaultsAction(); final DefaultActionGroup tbGroup = new DefaultActionGroup(); tbGroup.add(new EditAction()); tbGroup.add(new RevertAction()); final ActionToolbar tb = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, tbGroup, true); tb.setTargetComponent(myTable); myContent.add(tb.getComponent(), BorderLayout.NORTH); new TableSpeedSearch(myTable).setComparator(new SpeedSearchComparator(false)); }
public MavenArchetypesStep(MavenModuleBuilder builder, @Nullable StepAdapter step) { myBuilder = builder; myStep = step; Disposer.register(this, myLoadingIcon); myArchetypesTree = new Tree(); myArchetypesTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode())); JScrollPane archetypesScrollPane = ScrollPaneFactory.createScrollPane(myArchetypesTree); myArchetypesPanel.add(archetypesScrollPane, "archetypes"); JPanel loadingPanel = new JPanel(new GridBagLayout()); JPanel bp = new JPanel(new BorderLayout(10, 10)); bp.add(new JLabel("Loading archetype list..."), BorderLayout.NORTH); bp.add(myLoadingIcon, BorderLayout.CENTER); loadingPanel.add(bp, new GridBagConstraints()); myArchetypesPanel.add(ScrollPaneFactory.createScrollPane(loadingPanel), "loading"); ((CardLayout) myArchetypesPanel.getLayout()).show(myArchetypesPanel, "archetypes"); myUseArchetypeCheckBox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateComponents(); archetypeMayBeChanged(); } }); myAddArchetypeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { doAddArchetype(); } }); myArchetypesTree.setRootVisible(false); myArchetypesTree.setShowsRootHandles(true); myArchetypesTree.setCellRenderer(new MyRenderer()); myArchetypesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); myArchetypesTree .getSelectionModel() .addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { updateArchetypeDescription(); archetypeMayBeChanged(); } }); new TreeSpeedSearch( myArchetypesTree, new Convertor<TreePath, String>() { public String convert(TreePath path) { MavenArchetype info = getArchetypeInfoFromPathComponent(path.getLastPathComponent()); return info.groupId + ":" + info.artifactId + ":" + info.version; } }) .setComparator(new SpeedSearchComparator(false)); myArchetypeDescriptionField.setEditable(false); myArchetypeDescriptionField.setBackground(UIUtil.getPanelBackground()); requestUpdate(); updateComponents(); }
public VcsDependentHistoryComponents getUICustomization( final VcsHistorySession session, JComponent forShortcutRegistration) { final ColumnInfo[] columns; final Consumer<VcsFileRevision> listener; final JComponent addComp; if (((MyHistorySession) session).isSupports15()) { final MergeSourceColumnInfo mergeSourceColumn = new MergeSourceColumnInfo((MyHistorySession) session); columns = new ColumnInfo[] {new CopyFromColumnInfo(), mergeSourceColumn}; final JTextArea field = new JTextArea(); field.setEditable(false); field.setBackground(UIUtil.getComboBoxDisabledBackground()); field.setWrapStyleWord(true); listener = new Consumer<VcsFileRevision>() { public void consume(VcsFileRevision vcsFileRevision) { field.setText(mergeSourceColumn.getText(vcsFileRevision)); } }; final JPanel panel = new JPanel(new GridBagLayout()); final GridBagConstraints gb = new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0); final JLabel mergeLabel = new JLabel("Merge Sources:"); final MergeSourceDetailsAction sourceAction = new MergeSourceDetailsAction(); sourceAction.registerSelf(forShortcutRegistration); final DefaultActionGroup group = new DefaultActionGroup(); group.add(sourceAction); final JComponent toolbar = ActionManager.getInstance() .createActionToolbar(ActionPlaces.UNKNOWN, group, true) .getComponent(); panel.add(mergeLabel, gb); ++gb.gridx; gb.insets.left = 10; gb.anchor = GridBagConstraints.NORTHWEST; panel.add(toolbar, gb); ++gb.gridy; gb.insets.left = 0; gb.gridx = 0; gb.gridwidth = 2; gb.weightx = gb.weighty = 1; gb.fill = GridBagConstraints.BOTH; JScrollPane pane = ScrollPaneFactory.createScrollPane(field); pane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.TOP)); panel.add(pane, gb); addComp = panel; } else { columns = new ColumnInfo[] {new CopyFromColumnInfo()}; addComp = null; listener = null; } return new VcsDependentHistoryComponents(columns, listener, addComp); }
private void updateViewerForSelection() { if (myAllContents.isEmpty()) return; String fullString = getSelectedText(); if (myViewer != null) { EditorFactory.getInstance().releaseEditor(myViewer); } if (myUseIdeaEditor) { myViewer = createIdeaEditor(fullString); JComponent component = myViewer.getComponent(); component.setPreferredSize(JBUI.size(300, 500)); mySplitter.setSecondComponent(component); } else { final JTextArea textArea = new JTextArea(fullString); textArea.setRows(3); textArea.setWrapStyleWord(true); textArea.setLineWrap(true); textArea.setSelectionStart(0); textArea.setSelectionEnd(textArea.getText().length()); textArea.setEditable(false); mySplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(textArea)); } mySplitter.revalidate(); }