@Nullable @Override protected JComponent createCenterPanel() { JPanel mainPanel = new JPanel(new BorderLayout()); JBSplitter splitPane = new JBSplitter(0.3f); splitPane.setSplitterProportionKey(getSplitterProportionKey()); splitPane.setFirstComponent(createMasterView()); splitPane.setSecondComponent(createDetailView()); mainPanel.add(splitPane, BorderLayout.CENTER); return mainPanel; }
@Override protected JComponent createCenterPanel() { final int selectionMode = myAllowMultipleSelections ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION : ListSelectionModel.SINGLE_SELECTION; myList.setSelectionMode(selectionMode); if (myUseIdeaEditor) { EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); myList.setFont(scheme.getFont(EditorFontType.PLAIN)); Color fg = ObjectUtils.chooseNotNull(scheme.getDefaultForeground(), UIUtil.getListForeground()); Color bg = ObjectUtils.chooseNotNull(scheme.getDefaultBackground(), UIUtil.getListBackground()); myList.setForeground(fg); myList.setBackground(bg); } new DoubleClickListener() { @Override protected boolean onDoubleClick(MouseEvent e) { close(OK_EXIT_CODE); return true; } }.installOn(myList); myList.setCellRenderer(new MyListCellRenderer()); myList.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { int newSelectionIndex = -1; for (Object o : myList.getSelectedValues()) { int i = ((Item) o).index; removeContentAt(myAllContents.get(i)); if (newSelectionIndex < 0) { newSelectionIndex = i; } } rebuildListContent(); if (myAllContents.isEmpty()) { close(CANCEL_EXIT_CODE); return; } newSelectionIndex = Math.min(newSelectionIndex, myAllContents.size() - 1); myList.setSelectedIndex(newSelectionIndex); } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { doOKAction(); } else { final char aChar = e.getKeyChar(); if (aChar >= '0' && aChar <= '9') { int idx = aChar == '0' ? 9 : aChar - '1'; if (idx < myAllContents.size()) { myList.setSelectedIndex(idx); e.consume(); doOKAction(); } } } } }); mySplitter.setFirstComponent( ListWithFilter.wrap( myList, ScrollPaneFactory.createScrollPane(myList), new Function<Object, String>() { @Override public String fun(Object o) { return ((Item) o).longText; } })); mySplitter.setSecondComponent(new JPanel()); rebuildListContent(); ScrollingUtil.installActions(myList); ScrollingUtil.ensureSelectionExists(myList); updateViewerForSelection(); myList.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { myUpdateAlarm.cancelAllRequests(); myUpdateAlarm.addRequest( new Runnable() { @Override public void run() { updateViewerForSelection(); } }, 100); } }); mySplitter.setPreferredSize(JBUI.size(500, 500)); SplitterProportionsData d = new SplitterProportionsDataImpl(); d.externalizeToDimensionService(getClass().getName()); d.restoreSplitterProportions(mySplitter); return mySplitter; }
protected void reInitWholePanelIfNeeded() { if (!myToReInitWholePanel) return; myWholePanel = new JPanel(new BorderLayout()) { public void addNotify() { super.addNotify(); MasterDetailsComponent.this.addNotify(); TreeModel m = myTree.getModel(); if (m instanceof DefaultTreeModel) { DefaultTreeModel model = (DefaultTreeModel) m; for (int eachRow = 0; eachRow < myTree.getRowCount(); eachRow++) { TreePath eachPath = myTree.getPathForRow(eachRow); Object component = eachPath.getLastPathComponent(); if (component instanceof TreeNode) { model.nodeChanged((TreeNode) component); } } } } }; mySplitter.setHonorComponentsMinimumSize(true); myWholePanel.add(mySplitter, BorderLayout.CENTER); JPanel left = new JPanel(new BorderLayout()) { public Dimension getMinimumSize() { final Dimension original = super.getMinimumSize(); return new Dimension(Math.max(original.width, 100), original.height); } }; if (isNewProjectSettings()) { ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree); DefaultActionGroup group = createToolbarActionGroup(); if (group != null) { decorator.setActionGroup(group); } // left.add(myNorthPanel, BorderLayout.NORTH); myMaster = decorator.setAsUsualTopToolbar().setPanelBorder(JBUI.Borders.empty()).createPanel(); myNorthPanel.setVisible(false); } else { left.add(myNorthPanel, BorderLayout.NORTH); myMaster = ScrollPaneFactory.createScrollPane(myTree); } left.add(myMaster, BorderLayout.CENTER); mySplitter.setFirstComponent(left); final JPanel right = new JPanel(new BorderLayout()); right.add(myDetails.getComponent(), BorderLayout.CENTER); if (!isNewProjectSettings()) { myWholePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); } mySplitter.setSecondComponent(right); GuiUtils.replaceJSplitPaneWithIDEASplitter(myWholePanel); myToReInitWholePanel = false; }