@Override public void paint(Graphics g) { final Rectangle bounds = g.getClipBounds(); if (mySplitter instanceof OnePixelSplitter) { final Producer<Insets> blindZone = ((OnePixelSplitter)mySplitter).getBlindZone(); if (blindZone != null) { final Insets insets = blindZone.produce(); if (insets != null) { bounds.x += insets.left; bounds.y += insets.top; bounds.width -= insets.left + insets.right; bounds.height -= insets.top + insets.bottom; g.setColor(getBackground()); g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); return; } } } super.paint(g); }
@RequiredDispatchThread @Nullable @Override public JComponent createComponent() { PostfixTemplateProvider postfixTemplateProvider = myExtensionPoint.getInstance(); if (postfixTemplateProvider == null) { return null; } OnePixelSplitter splitter = new OnePixelSplitter(); splitter.setSplitterProportionKey("PostfixTemplatesChildConfigurable.splitter"); myCheckBoxList = new CheckBoxList<>(); splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myCheckBoxList, true)); myPostfixDescriptionPanel = new PostfixDescriptionPanel(); JPanel component = myPostfixDescriptionPanel.getComponent(); component.setBorder(JBUI.Borders.empty(0, 8, 0, 0)); splitter.setSecondComponent(component); myCheckBoxList.setItems(new ArrayList<>(postfixTemplateProvider.getTemplates()), PostfixTemplate::getPresentableName, postfixTemplate -> Boolean.TRUE); myCheckBoxList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { PostfixTemplate itemAt = myCheckBoxList.getItemAt(myCheckBoxList.getSelectedIndex()); myPostfixDescriptionPanel.reset(PostfixTemplateMetaData.createMetaData(itemAt)); } }); return splitter; }
public StudyToolWindow() { super(true, true); myCardLayout = new JBCardLayout(); myContentPanel = new JPanel(myCardLayout); mySplitPane = new OnePixelSplitter(myVertical = true); }
@Override public JComponent createComponent() { myComponent = new MyPanel(); mySplitter = Registry.is("ide.new.project.settings") ? new OnePixelSplitter(false, .15f) : new JBSplitter(false, .15f); mySplitter.setSplitterProportionKey("ProjectStructure.TopLevelElements"); mySplitter.setHonorComponentsMinimumSize(true); initSidePanel(); final JPanel left = new JPanel(new BorderLayout()) { @Override public Dimension getMinimumSize() { final Dimension original = super.getMinimumSize(); return new Dimension(Math.max(original.width, 100), original.height); } }; final DefaultActionGroup toolbarGroup = new DefaultActionGroup(); toolbarGroup.add(new BackAction(myComponent)); toolbarGroup.add(new ForwardAction(myComponent)); final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarGroup, true); toolbar.setTargetComponent(myComponent); myToolbarComponent = toolbar.getComponent(); if (Registry.is("ide.new.project.settings")) { left.setBackground(UIUtil.SIDE_PANEL_BACKGROUND); myToolbarComponent.setBackground(UIUtil.SIDE_PANEL_BACKGROUND); } left.add(myToolbarComponent, BorderLayout.NORTH); left.add(mySidePanel, BorderLayout.CENTER); mySplitter.setFirstComponent(left); mySplitter.setSecondComponent(myDetails); myComponent.add(mySplitter, BorderLayout.CENTER); if (!Registry.is("ide.new.project.settings")) { myErrorsComponent = new ConfigurationErrorsComponent(myProject); myComponent.add(myErrorsComponent, BorderLayout.SOUTH); } myUiInitialized = true; return myComponent; }
@Override public JPanel createComponentImpl() { final Module module = getModule(); final Project project = module.getProject(); myContentEntryEditorListener = new MyContentEntryEditorListener(); final JPanel mainPanel = new JPanel(new BorderLayout()); if (!Registry.is("ide.new.project.settings")) { mainPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); } addAdditionalSettingsToPanel(mainPanel); final JPanel entriesPanel = new JPanel(new BorderLayout()); final DefaultActionGroup group = new DefaultActionGroup(); final AddContentEntryAction action = new AddContentEntryAction(); action.registerCustomShortcutSet(KeyEvent.VK_C, InputEvent.ALT_DOWN_MASK, mainPanel); group.add(action); myEditorsPanel = new ScrollablePanel(new VerticalStackLayout()); myEditorsPanel.setBackground(BACKGROUND_COLOR); JScrollPane myScrollPane = ScrollPaneFactory.createScrollPane(myEditorsPanel, Registry.is("ide.new.project.settings")); final ToolbarPanel toolbarPanel = new ToolbarPanel(myScrollPane, group); if (Registry.is("ide.new.project.settings")) { toolbarPanel.setBorder(new CustomLineBorder(1,0,0,0)); } entriesPanel.add(toolbarPanel, BorderLayout.CENTER); final JBSplitter splitter = Registry.is("ide.new.project.settings") ? new OnePixelSplitter(false) : new JBSplitter(false); splitter.setProportion(0.6f); splitter.setHonorComponentsMinimumSize(true); myRootTreeEditor = createContentEntryTreeEditor(project); final JComponent component = myRootTreeEditor.createComponent(); if (Registry.is("ide.new.project.settings")) { component.setBorder(new CustomLineBorder(1,0,0,0)); } splitter.setFirstComponent(component); splitter.setSecondComponent(entriesPanel); JPanel contentPanel = new JPanel(new GridBagLayout()); if (!Registry.is("ide.new.project.settings")) { contentPanel.setBorder(BorderFactory.createEtchedBorder()); } final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, myRootTreeEditor.getEditingActionsGroup(), true); contentPanel.add(new JLabel("Mark as:"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, 0, new Insets(0, 10, 0, 10), 0, 0)); contentPanel.add(actionToolbar.getComponent(), new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); contentPanel.add(splitter, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add(contentPanel, BorderLayout.CENTER); final JPanel innerPanel = createBottomControl(module); if (innerPanel != null) { mainPanel.add(innerPanel, BorderLayout.SOUTH); } final ModifiableRootModel model = getModel(); if (model != null) { final ContentEntry[] contentEntries = model.getContentEntries(); if (contentEntries.length > 0) { for (final ContentEntry contentEntry : contentEntries) { addContentEntryPanel(contentEntry.getUrl()); } selectContentEntry(contentEntries[0].getUrl()); } } return mainPanel; }
@NotNull @Override public JComponent getComponent() { DefaultMutableTreeNode root = new DefaultMutableTreeNode(); for(CSharpAssemblyBlock block : myBlocks) { DefaultMutableTreeNode newChild = new DefaultMutableTreeNode(block); root.add(newChild); } final SimpleTree simpleTree = new SimpleTree(new DefaultTreeModel(root)); simpleTree.setRootVisible(false); simpleTree.setCellRenderer(new ColoredTreeCellRenderer() { @RequiredDispatchThread @Override public void customizeCellRenderer(JTree jTree, Object o, boolean b, boolean b2, boolean b3, int i, boolean b4) { Object object = ((DefaultMutableTreeNode) o).getUserObject(); if(object instanceof CSharpAssemblyBlock) { append(((CSharpAssemblyBlock) object).getTitle()); } } }); final OnePixelSplitter splitter = new OnePixelSplitter(); simpleTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { List<CSharpAssemblyBlock> cSharpAssemblyBlocks = TreeUtil.collectSelectedObjectsOfType(simpleTree, CSharpAssemblyBlock.class); CSharpAssemblyBlock firstItem = ContainerUtil.getFirstItem(cSharpAssemblyBlocks); if(firstItem == null) { splitter.setSecondComponent(new JPanel()); } else { splitter.setSecondComponent(firstItem.createAndLoadComponent(myPsiFile, !myIsReadonlyFile)); } } }); splitter.setAndLoadSplitterProportionKey("CSharpAssemblyFileEditor"); splitter.setFirstComponent(simpleTree); splitter.setSecondComponent(new JPanel()); return ScrollPaneFactory.createScrollPane(splitter); }
public ServersToolWindowContent(@Nonnull Project project) { super(new BorderLayout()); myProject = project; myTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode()); myTree = new Tree(myTreeModel); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setCellRenderer(new NodeRenderer()); myTree.setLineStyleAngled(); getMainPanel().add(createToolbar(), BorderLayout.WEST); Splitter splitter = new OnePixelSplitter(false, 0.3f); splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree, SideBorder.LEFT)); myPropertiesPanelLayout = new CardLayout(); myPropertiesPanel = new JPanel(myPropertiesPanelLayout); myMessageLabel = new JLabel(EMPTY_SELECTION_MESSAGE, SwingConstants.CENTER); myPropertiesPanel.add(MESSAGE_CARD, new Wrapper(myMessageLabel)); splitter.setSecondComponent(myPropertiesPanel); getMainPanel().add(splitter, BorderLayout.CENTER); setupBuilder(project); for (RemoteServersViewContributor contributor : RemoteServersViewContributor.EP_NAME.getExtensions()) { contributor.setupTree(myProject, myTree, myBuilder); } myTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { onSelectionChanged(); } }); new DoubleClickListener() { @Override protected boolean onDoubleClick(MouseEvent event) { Set<ServersTreeStructure.RemoteServerNode> nodes = getSelectedRemoteServerNodes(); if (nodes.size() == 1) { RemoteServer<?> server = nodes.iterator().next().getValue(); ServerConnectionManager.getInstance().getOrCreateConnection(server).computeDeployments(EmptyRunnable.INSTANCE); return true; } return false; } }.installOn(myTree); }
@Nonnull @Override protected JComponent createComponentImpl() { JPanel rootPane = new JPanel(new BorderLayout()); mySplitter = new OnePixelSplitter(); myTree = new CheckboxTreeNoPolicy(new ExtensionTreeCellRenderer(), new ExtensionCheckedTreeNode(null, myState, this)) { @Override protected void adjustParentsAndChildren(CheckedTreeNode node, boolean checked) { if (!checked) { changeNodeState(node, false); checkOrUncheckChildren(node, false); } else { // we need collect parents, and enable it in right order // A // - B // -- C // when we enable C, ill be calls like A -> B -> C List<CheckedTreeNode> parents = new ArrayList<CheckedTreeNode>(); TreeNode parent = node.getParent(); while (parent != null) { if (parent instanceof CheckedTreeNode) { parents.add((CheckedTreeNode)parent); } parent = parent.getParent(); } Collections.reverse(parents); for (CheckedTreeNode checkedTreeNode : parents) { checkNode(checkedTreeNode, true); } changeNodeState(node, true); } repaint(); } }; myTree.setRootVisible(false); myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); myTree.addTreeSelectionListener(new TreeSelectionListener() { @Override @RequiredDispatchThread public void valueChanged(final TreeSelectionEvent e) { final List<MutableModuleExtension> selected = TreeUtil.collectSelectedObjectsOfType(myTree, MutableModuleExtension.class); updateSecondComponent(ContainerUtil.<MutableModuleExtension>getFirstItem(selected)); } }); TreeUtil.expandAll(myTree); mySplitter.setFirstComponent(myTree); rootPane.add(new JBScrollPane(mySplitter), BorderLayout.CENTER); return rootPane; }
public IntentionSettingsPanel() { myIntentionSettingsTree = new IntentionSettingsTree() { @Override protected void selectionChanged(Object selected) { if (selected instanceof IntentionActionMetaData) { final IntentionActionMetaData actionMetaData = (IntentionActionMetaData)selected; final Runnable runnable = new Runnable() { @Override public void run() { intentionSelected(actionMetaData); } }; myResetAlarm.cancelAllRequests(); myResetAlarm.addRequest(runnable, 100); } else { categorySelected((String)selected); } } @Override protected List<IntentionActionMetaData> filterModel(String filter, final boolean force) { final List<IntentionActionMetaData> list = IntentionManagerSettings.getInstance().getMetaData(); if (filter == null || filter.length() == 0) return list; final HashSet<String> quoted = new HashSet<String>(); List<Set<String>> keySetList = SearchUtil.findKeys(filter, quoted); List<IntentionActionMetaData> result = new ArrayList<IntentionActionMetaData>(); for (IntentionActionMetaData metaData : list) { if (isIntentionAccepted(metaData, filter, force, keySetList, quoted)){ result.add(metaData); } } final Set<String> filters = SearchableOptionsRegistrar.getInstance().getProcessedWords(filter); if (force && result.isEmpty()){ if (filters.size() > 1){ result = filterModel(filter, false); } } return result; } }; myComponent = new OnePixelSplitter(false, 0.4f); myComponent.setFirstComponent(myIntentionSettingsTree.getComponent()); myComponent.setSecondComponent(myIntentionDescriptionPanel.getComponent()); }
@Nonnull @Override public JPanel createComponentImpl() { final Module module = getModule(); final Project project = module.getProject(); myContentEntryEditorListener = new MyContentEntryEditorListener(); final JPanel mainPanel = new JPanel(new BorderLayout()); final JPanel entriesPanel = new JPanel(new BorderLayout()); final DefaultActionGroup group = new DefaultActionGroup(); final AddContentEntryAction action = new AddContentEntryAction(); action.registerCustomShortcutSet(KeyEvent.VK_C, InputEvent.ALT_DOWN_MASK, mainPanel); group.add(action); myEditorsPanel = new ScrollablePanel(new VerticalStackLayout()); myEditorsPanel.setBackground(BACKGROUND_COLOR); JScrollPane myScrollPane = ScrollPaneFactory.createScrollPane(myEditorsPanel, true); entriesPanel.add(new ToolbarPanel(myScrollPane, group), BorderLayout.CENTER); final JBSplitter splitter = new OnePixelSplitter(false); splitter.setProportion(0.6f); splitter.setHonorComponentsMinimumSize(true); myRootTreeEditor = new ContentEntryTreeEditor(project, myState); JComponent component = myRootTreeEditor.createComponent(); component.setBorder(new CustomLineBorder(JBUI.scale(1),0,0,0)); splitter.setFirstComponent(component); splitter.setSecondComponent(entriesPanel); JPanel contentPanel = new JPanel(new GridBagLayout()); final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, myRootTreeEditor.getEditingActionsGroup(), true); contentPanel.add(new JLabel("Mark as:"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, 0, new JBInsets(0, 5, 0, 5), 0, 0)); contentPanel.add(actionToolbar.getComponent(), new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new JBInsets(0, 0, 0, 0), 0, 0)); contentPanel.add(splitter, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new JBInsets(0, 0, 0, 0), 0, 0)); mainPanel.add(contentPanel, BorderLayout.CENTER); final ModifiableRootModel model = getModel(); if (model != null) { final ContentEntry[] contentEntries = model.getContentEntries(); if (contentEntries.length > 0) { for (final ContentEntry contentEntry : contentEntries) { addContentEntryPanel(contentEntry); } selectContentEntry(contentEntries[0]); } } return mainPanel; }