Java Code Examples for com.intellij.ui.components.JBPanel#setLayout()

The following examples show how to use com.intellij.ui.components.JBPanel#setLayout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestcasePanel.java    From leetcode-editor with Apache License 2.0 5 votes vote down vote up
public TestcasePanel(@Nullable Project project) {
    super(project, true);
    jpanel = new JBPanel();
    jpanel.setLayout(new BorderLayout());
    caseText = new JTextArea();
    caseText.setMinimumSize(new Dimension(400, 200));
    caseText.setPreferredSize(new Dimension(400, 200));
    jpanel.add(new JBScrollPane(caseText, JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
    setModal(true);
    init();
}
 
Example 2
Source File: ShowAmbigTreesDialog.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void setTrees(PreviewState previewState,
					 List<? extends RuleContext> ambiguousParseTrees,
					 String title,
					 int highlightTreeIndex,
					 boolean highlightDiffs) {
	if ( ambiguousParseTrees!=null ) {
		int numTrees = ambiguousParseTrees.size();
		setTitle(title);
		treeViewers = new TreeViewer[numTrees];
		JBPanel panelOfTrees = new JBPanel();
		PreviewInterpreterRuleContext chosenTree =
			(PreviewInterpreterRuleContext) ambiguousParseTrees.get(highlightTreeIndex);
		panelOfTrees.setLayout(new BoxLayout(panelOfTrees, BoxLayout.X_AXIS));
		for (int i = 0; i<numTrees; i++) {
			if ( i>0 ) {
				panelOfTrees.add(new JSeparator(JSeparator.VERTICAL));
			}
			PreviewInterpreterRuleContext ctx = (PreviewInterpreterRuleContext) ambiguousParseTrees.get(i);
			treeViewers[i] = new TrackpadZoomingTreeView(null, null, highlightDiffs); // && ctx != chosenTree);
			AltLabelTextProvider treeText =
				new AltLabelTextProvider(previewState.parsingResult.parser, previewState.g);
			treeViewers[i].setTreeTextProvider(treeText);
			treeViewers[i].setTree(ctx);
			treeViewers[i].setHighlightedBoxColor(new JBColor(JBColor.lightGray, JBColor.GREEN));

			// highlight root so people can see it across trees; might not be top node
			treeViewers[i].addHighlightedNodes(singletonList(ParsingUtils.findOverriddenDecisionRoot(ctx)));
			if ( ctx!=chosenTree ) {
				mark(chosenTree, ctx);
			}
			JBPanel wrapper = new JBPanel(new BorderLayout());
			if ( i==highlightTreeIndex ) {
				wrapper.setBackground(JBColor.white);
			} else if ( UIUtil.isUnderDarcula() ) {
				wrapper.setBackground(Gray._43);
			}
			wrapper.add(treeViewers[i], BorderLayout.CENTER);
			panelOfTrees.add(wrapper);
		}

		// Wrap tree viewer components in scroll pane
		treeScrollPane.setViewportView(panelOfTrees);
	}
}