Java Code Examples for com.intellij.ui.components.JBPanel#add()
The following examples show how to use
com.intellij.ui.components.JBPanel#add() .
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: SubmissionsPanel.java From leetcode-editor with Apache License 2.0 | 7 votes |
public SubmissionsPanel(@Nullable Project project, TableModel tableModel) { super(project, true); jpanel = new JBPanel(new BorderLayout()); jpanel.setMinimumSize(new Dimension(400, 400)); jpanel.setPreferredSize(new Dimension(400, 400)); table = new JBTable(tableModel); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.getTableHeader().setReorderingAllowed(false); table.setRowSelectionAllowed(true); table.setRowSelectionInterval(0, 0); table.getColumnModel().getColumn(0).setPreferredWidth(350); table.getColumnModel().getColumn(1).setPreferredWidth(200); table.getColumnModel().getColumn(2).setPreferredWidth(100); table.getColumnModel().getColumn(3).setPreferredWidth(200); table.getColumnModel().getColumn(4).setPreferredWidth(100); jpanel.add(new JBScrollPane(table, JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER); setModal(true); init(); }
Example 2
Source File: ClearAllAction.java From leetcode-editor with Apache License 2.0 | 5 votes |
public ClearAllWarningPanel(@Nullable Project project) { super(project, true); jpanel = new JBPanel(); jpanel.add(new JLabel("Clear All File?")); jpanel.setMinimumSize(new Dimension(200, 100)); setModal(true); init(); }
Example 3
Source File: TestcasePanel.java From leetcode-editor with Apache License 2.0 | 5 votes |
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 4
Source File: ShowAmbigTreesDialog.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void popupAmbigTreesDialog(PreviewState previewState, AmbiguityInfo ambigInfo) { // pop up subtrees for ambig intrepretation ShowAmbigTreesDialog dialog = new ShowAmbigTreesDialog(); Parser parser = previewState.parsingResult.parser; int startRuleIndex = parser.getRuleIndex(previewState.startRuleName); List<ParserRuleContext> ambiguousParseTrees = null; try { ambiguousParseTrees = GrammarParserInterpreter.getAllPossibleParseTrees(previewState.g, parser, parser.getTokenStream(), ambigInfo.decision, ambigInfo.ambigAlts, ambigInfo.startIndex, ambigInfo.stopIndex, startRuleIndex); } catch (ParseCancellationException pce) { // should be no errors for ambiguities, unless original // input itself has errors. Just display error in this case. JBPanel errPanel = new JBPanel(new BorderLayout()); errPanel.add(new JBLabel("Cannot display ambiguous trees while there are syntax errors in your input.")); dialog.treeScrollPane.setViewportView(errPanel); } if ( ambiguousParseTrees!=null ) { TokenStream tokens = previewState.parsingResult.parser.getInputStream(); String phrase = tokens.getText(Interval.of(ambigInfo.startIndex, ambigInfo.stopIndex)); if ( phrase.length()>MAX_PHRASE_WIDTH ) { phrase = phrase.substring(0, MAX_PHRASE_WIDTH)+"..."; } String title = ambiguousParseTrees.size()+ " Interpretations of Ambiguous Input Phrase: "+ phrase; dialog.ambigPhraseLabel.setText(title); dialog.setTrees(previewState, ambiguousParseTrees, title, 0, true); } dialog.pack(); dialog.setVisible(true); }
Example 5
Source File: ShowAmbigTreesDialog.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void popupLookaheadTreesDialog(PreviewState previewState, LookaheadEventInfo lookaheadInfo) { // pop up subtrees for lookahead ShowAmbigTreesDialog dialog = new ShowAmbigTreesDialog(); ParserInterpreter parser = (ParserInterpreter) previewState.parsingResult.parser; int startRuleIndex = parser.getRuleIndex(previewState.startRuleName); List<ParserRuleContext> lookaheadParseTrees = GrammarParserInterpreter.getLookaheadParseTrees(previewState.g, parser, parser.getTokenStream(), startRuleIndex, lookaheadInfo.decision, lookaheadInfo.startIndex, lookaheadInfo.stopIndex); if ( parser.getNumberOfSyntaxErrors()>0 ) { // should be no errors for ambiguities, unless original // input itself has errors. Just display error in this case. JBPanel errPanel = new JBPanel(new BorderLayout()); errPanel.add(new JBLabel("Cannot display lookahead trees while there are syntax errors in your input.")); dialog.treeScrollPane.setViewportView(errPanel); lookaheadParseTrees = null; } if ( lookaheadParseTrees!=null ) { Interval range = Interval.of(lookaheadInfo.startIndex, lookaheadInfo.stopIndex); String phrase = parser.getTokenStream().getText(range); if ( phrase.length()>MAX_PHRASE_WIDTH ) { phrase = phrase.substring(0, MAX_PHRASE_WIDTH)+"..."; } String title = lookaheadParseTrees.size()+ " Interpretations of Lookahead Phrase: "+ phrase; dialog.ambigPhraseLabel.setText(title); dialog.setTrees(previewState, lookaheadParseTrees, title, lookaheadInfo.predictedAlt-1, false); } dialog.pack(); dialog.setVisible(true); }
Example 6
Source File: ProgressStripe.java From consulo with Apache License 2.0 | 5 votes |
public ProgressStripe(@Nonnull JComponent targetComponent, @Nonnull Disposable parent, int startDelayMs) { super(new BorderLayout()); myPanel = new JBPanel(new BorderLayout()); myPanel.setOpaque(false); myPanel.add(targetComponent); myCreateLoadingDecorator = () -> { Disposable disposable = Disposable.newDisposable(); Disposer.register(parent, disposable); return new MyLoadingDecorator(targetComponent, myPanel, disposable, startDelayMs); }; createLoadingDecorator(); }
Example 7
Source File: ShowAmbigTreesDialog.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 4 votes |
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); } }