private JPanel createLicenseInfoTab(boolean supported) { ActionToolbar toolbar = ComponentUtils.createActionToolbar(licensesComponentsTree); licenseFilterMenu = new LicenseFilterMenu(project); FilterButton licensesFilterButton = new FilterButton(licenseFilterMenu, "License", "Select licenses to show"); licensesFilterButton.setAlignmentX(Component.LEFT_ALIGNMENT); SimpleToolWindowPanel filterPanel = new SimpleToolWindowPanel(false); filterPanel.setToolbar(toolbar.getComponent()); filterPanel.setContent(licensesFilterButton); JPanel licenseTab = new JBPanel(new BorderLayout()); licensesCentralVerticalSplit = new OnePixelSplitter(false, 0.3f); licensesCentralVerticalSplit.setFirstComponent(createLicensesComponentsTreeView()); licensesCentralVerticalSplit.setSecondComponent(createLicenseDetailsView(supported)); licenseTab.add(filterPanel, BorderLayout.NORTH); licenseTab.add(licensesCentralVerticalSplit, BorderLayout.CENTER); return licenseTab; }
private JComponent createIssuesComponentsTreeView() { issuesCount = new JBLabel("Issues (0) "); JPanel componentsTreePanel = new JBPanel(new BorderLayout()).withBackground(UIUtil.getTableBackground()); JLabel componentsTreeTitle = new JBLabel(" Components Tree"); componentsTreeTitle.setFont(componentsTreeTitle.getFont().deriveFont(TITLE_FONT_SIZE)); componentsTreePanel.add(componentsTreeTitle, BorderLayout.LINE_START); componentsTreePanel.add(issuesCount, BorderLayout.LINE_END); issuesCountPanel = new JBPanel().withBackground(UIUtil.getTableBackground()); issuesCountPanel.setLayout(new BoxLayout(issuesCountPanel, BoxLayout.Y_AXIS)); issuesComponentsTree.setCellRenderer(new IssuesTreeCellRenderer()); issuesComponentsTree.expandRow(0); issuesComponentsTree.setRootVisible(false); issuesTreeExpansionListener = new IssuesTreeExpansionListener(issuesComponentsTree, issuesCountPanel, issuesCountPanels); JBPanel treePanel = new JBPanel(new BorderLayout()).withBackground(UIUtil.getTableBackground()); TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(issuesComponentsTree); treePanel.add(treeSpeedSearch.getComponent(), BorderLayout.WEST); treePanel.add(issuesCountPanel, BorderLayout.CENTER); JScrollPane treeScrollPane = ScrollPaneFactory.createScrollPane(treePanel); treeScrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_BAR_SCROLLING_UNITS); return new TitledPane(JSplitPane.VERTICAL_SPLIT, TITLE_LABEL_SIZE, componentsTreePanel, treeScrollPane); }
private JComponent createLicensesComponentsTreeView() { JPanel componentsTreePanel = new JBPanel(new BorderLayout()); componentsTreePanel.setBackground(UIUtil.getTableBackground()); JLabel componentsTreeTitle = new JBLabel(" Components Tree"); componentsTreeTitle.setFont(componentsTreeTitle.getFont().deriveFont(TITLE_FONT_SIZE)); componentsTreePanel.add(componentsTreeTitle, BorderLayout.WEST); licensesComponentsTree.expandRow(0); licensesComponentsTree.setRootVisible(false); licensesComponentsTree.setCellRenderer(new LicensesTreeCellRenderer()); TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(licensesComponentsTree); JScrollPane treeScrollPane = ScrollPaneFactory.createScrollPane(treeSpeedSearch.getComponent()); treeScrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_BAR_SCROLLING_UNITS); return new TitledPane(JSplitPane.VERTICAL_SPLIT, TITLE_LABEL_SIZE, componentsTreePanel, treeScrollPane); }
public ToolWindowPanel(Project project) { super(false); this.project = project; mainContent = new JBPanel(new BorderLayout()); mainContent.setAutoscrolls(true); setContent(mainContent); this.rootNode = new DefaultMutableTreeNode(getDefaultRootNode()); createRepositoryTree(); createActionToolBar(); createStatusLine(); createExecutionCounter(); configureActions(); loadRepositories(); }
@NotNull public static JBSplitter createNavigationSplitter(@Nullable JComponent leftPanelContents, @Nullable JComponent rightPanelContents) { JBPanel navigationPanel = new JBPanel(new BorderLayout()); navigationPanel.setBackground(JBColor.background()); if (leftPanelContents != null) { navigationPanel.add(leftPanelContents, BorderLayout.CENTER); } JBPanel contextInformationPanel = new JBPanel(new BorderLayout()); contextInformationPanel.setBackground(JBColor.background()); if (rightPanelContents != null) { contextInformationPanel.add(rightPanelContents, BorderLayout.CENTER); } JBSplitter navigationSplitter = new JBSplitter(false); navigationSplitter.setFirstComponent(navigationPanel); navigationSplitter.setSecondComponent(contextInformationPanel); navigationSplitter.setDividerWidth(DIVIDER_WIDTH); return navigationSplitter; }
@Nullable @Override protected JComponent createCenterPanel() { JPanel iconPanel = new JBPanel(new BorderLayout()); iconPanel.add(new JBLabel(AllIcons.General.WarningDialog), BorderLayout.NORTH); myMessage = new JEditorPane(); myMessage.setEditorKit(UIUtil.getHTMLEditorKit()); myMessage.setEditable(false); myMessage.setPreferredSize(JBUI.size(500, 100)); myMessage.setBorder(BorderFactory.createLineBorder(Gray._200)); String text = "<div style='margin:5px;'>" + IdeaDecompilerBundle.message("legal.notice.text") + "</div>"; myMessage.setText(text); JPanel panel = new JBPanel(new BorderLayout(10, 0)); panel.add(iconPanel, BorderLayout.WEST); panel.add(myMessage, BorderLayout.CENTER); return panel; }
private void buildForOne(JBPanel panel, final FilePath root) { final GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0); c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = 2; final JBLabel comp = new JBLabel("Please select remote URL:"); comp.setFont(comp.getFont().deriveFont(Font.BOLD)); panel.add(comp, c); final JBTextField value = new JBTextField(); value.setColumns(100); final String preset = myCheckoutURLs.get(root.getIOFile()); if (preset != null) { value.setText(preset); } myFields.put(root.getIOFile(), value); ++ c.gridy; panel.add(value, c); addWarning(panel, c); }
public Component createTab(String text) { JPanel panel = new JBPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JLabel label = JBLabelDecorator.createJBLabelDecorator(text); label.setOpaque(false); panel.add(label); TabButton btn = new TabButton(); panel.add(btn); panel.setBackground(Color.black); panel.setOpaque(false); UIUtil.setNotOpaqueRecursively(panel); return panel; }
private JPanel createUnsupportedView() { JLabel label = new JBLabel(); label.setText("Unsupported project type, currently only Maven, Gradle and npm projects are supported."); JBPanel panel = new JBPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; panel.add(label, c); panel.setBackground(UIUtil.getTableBackground()); return panel; }
private JComponent createComponentsDetailsView(boolean supported) { if (!GlobalSettings.getInstance().isCredentialsSet()) { return createNoCredentialsView(); } if (!supported) { return createUnsupportedView(); } JLabel title = new JBLabel(" Component Details"); title.setFont(title.getFont().deriveFont(TITLE_FONT_SIZE)); issuesDetailsPanel = new JBPanel(new BorderLayout()).withBackground(UIUtil.getTableBackground()); issuesDetailsPanel.add(ComponentUtils.createDisabledTextLabel("Select component or issue for more details"), BorderLayout.CENTER); issuesDetailsScroll = ScrollPaneFactory.createScrollPane(issuesDetailsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); return new TitledPane(JSplitPane.VERTICAL_SPLIT, TITLE_LABEL_SIZE, title, issuesDetailsScroll); }
private JComponent createLicenseDetailsView(boolean supported) { if (!GlobalSettings.getInstance().isCredentialsSet()) { return createNoCredentialsView(); } if (!supported) { return createUnsupportedView(); } JLabel title = new JBLabel(" Details"); title.setFont(title.getFont().deriveFont(TITLE_FONT_SIZE)); licensesDetailsPanel = new JBPanel(new BorderLayout()).withBackground(UIUtil.getTableBackground()); licensesDetailsPanel.add(ComponentUtils.createDisabledTextLabel("Select component or issue for more details"), BorderLayout.CENTER); licensesDetailsScroll = ScrollPaneFactory.createScrollPane(licensesDetailsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); return new TitledPane(JSplitPane.VERTICAL_SPLIT, TITLE_LABEL_SIZE, title, licensesDetailsScroll); }
private JComponent createNoCredentialsView() { HyperlinkLabel link = new HyperlinkLabel(); link.setHyperlinkText("To start using the JFrog Plugin, please ", "configure", " your JFrog Xray details."); link.addHyperlinkListener(e -> ShowSettingsUtil.getInstance().showSettingsDialog(project, XrayGlobalConfiguration.class)); JBPanel panel = new JBPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; panel.add(link, c); panel.setBackground(UIUtil.getTableBackground()); return panel; }
private static JPanel createCommonGridPanel(JPanel panel, ScanTreeNode node) { if (node == null || node.getGeneralInfo() == null) { replaceAndUpdateUI(panel, createDisabledTextLabel("Component information is not available"), BorderLayout.CENTER); return null; } JPanel gridPanel = new JBPanel(new GridBagLayout()); gridPanel.setBackground(UIUtil.getTableBackground()); String pkgType = StringUtils.capitalize(node.getGeneralInfo().pkgType); if (StringUtils.isBlank(pkgType)) { // No package type addJtext(gridPanel, 0, "Group:", node.getGeneralInfo().getGroupId()); addJtext(gridPanel, 1, "Artifact:", node.getGeneralInfo().getArtifactId()); addJtext(gridPanel, 2, "Version:", node.getGeneralInfo().getVersion()); } else if (pkgType.equals("Npm")) { // Npm addJtext(gridPanel, 0, "Package:", node.getGeneralInfo().getGroupId()); addJtext(gridPanel, 1, "Version:", node.getGeneralInfo().getVersion()); addJtext(gridPanel, 2, "Type:", pkgType); } else { // Maven/Gradle addJtext(gridPanel, 0, "Group:", node.getGeneralInfo().getGroupId()); addJtext(gridPanel, 1, "Artifact:", node.getGeneralInfo().getArtifactId()); addJtext(gridPanel, 2, "Version:", node.getGeneralInfo().getVersion()); addJtext(gridPanel, 3, "Type:", StringUtils.capitalize(node.getGeneralInfo().pkgType)); } addLicenses(gridPanel, node.getLicenses()); return gridPanel; }
private static void addLicenses(JPanel panel, Set<License> licenses) { if (licenses == null) { return; } JPanel licensesPanel = new JBPanel(new HorizontalLayout(1)); licensesPanel.setBackground(UIUtil.getTableBackground()); for (License license : licenses) { if (CollectionUtils.isEmpty(license.moreInfoUrl)) { licensesPanel.add(createJTextArea(createLicenseString(license), false)); continue; } HyperlinkLabel hyperlinkLabel = new HyperlinkLabel(createLicenseString(license)); hyperlinkLabel.setBackground(UIUtil.getTableBackground()); hyperlinkLabel.setHyperlinkTarget(license.moreInfoUrl.get(0)); licensesPanel.add(hyperlinkLabel); } JBLabel headerLabel = new JBLabel("Licenses:"); headerLabel.setBackground(UIUtil.getTableBackground()); headerLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.ipadx = 20; c.ipady = 3; c.gridy = 4; panel.add(headerLabel, c); c.gridx = 1; c.weightx = 0.9; panel.add(licensesPanel, c); }
public static JPanel createIssueCountLabel(int issueCount, int rowHeight) { JPanel issueCountPanel = new JBPanel(new BorderLayout()).withBackground(UIUtil.getTableBackground()); JLabel issueCountLabel = new JBLabel(); issueCountPanel.add(issueCountLabel, BorderLayout.EAST); setIssueCountPanel(issueCount, issueCountPanel); issueCountLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); issueCountLabel.setMinimumSize(new JBDimension(issueCountLabel.getMinimumSize().width, rowHeight)); issueCountLabel.setMaximumSize(new JBDimension(issueCountLabel.getMaximumSize().width, rowHeight)); issueCountPanel.setMinimumSize(new JBDimension(issueCountPanel.getMinimumSize().width, rowHeight)); issueCountPanel.setMaximumSize(new JBDimension(issueCountPanel.getMaximumSize().width, rowHeight)); return issueCountPanel; }
public TabbedDebuggerWidget(Project project, Disposable disposable) { super(new BorderLayout()); mProject = project; mParent = disposable; mPanel = new JBPanel<>(new BorderLayout()); mPanel.add(this, BorderLayout.CENTER); }
private void addUiForGroup(@NotNull GradleEditorEntityGroup group) { JBPanel panel = new JBPanel(new BorderLayout()); panel.setBackground(UIUtil.getTableBackground()); panel.setBorder(IdeBorderFactory.createTitledBorder(group.getName())); GradleEditorEntityTable table = new GradleEditorEntityTable(myProject); for (GradleEditorEntity entity : group.getEntities()) { table.getModel().add(entity); } panel.add(table); addUiForGroup(group.getName(), panel, table); }
private void addUiForGroup(@NotNull String groupName, @NotNull JBPanel component, @NotNull GradleEditorEntityTable table) { GridBagConstraints constraints = new GridBag().weightx(1).anchor(GridBagConstraints.WEST).fillCellHorizontally().coverLine() .insets(8, 8, 8, 8); myCanvas.add(component, constraints); myTablesByGroupName.put(groupName, table); myPanelsByGroupName.put(groupName, component); }
private void initializeToolWindow() { JBPanel mainPanel = new JBPanel(new BorderLayout()); JBPanel addressPanel = new JBPanel(new FlowLayout(FlowLayout.LEFT)); ActionToolbar rightToolbar = createToolbar(); JBLabel addressLabel = new JBLabel("Location: "); addressTextField = new JBTextField(25); addressPanel.add(addressLabel); addressPanel.add(addressTextField); mainPanel.add(addressPanel, BorderLayout.NORTH); requestTextField = new EditorTextField(); responseTextField = new EditorTextField(); requestTextField.setPlaceholder("Request"); responseTextField.setPlaceholder("Response"); JBSplitter splitter = new JBSplitter(false, 0.5f); splitter.setShowDividerControls(true); splitter.setFirstComponent(requestTextField); splitter.setSecondComponent(responseTextField); mainPanel.add(splitter, BorderLayout.CENTER); setContent(mainPanel); setToolbar(rightToolbar.getComponent()); }
@Nullable @Override public JComponent createComponent() { final JBPanel panel = new JBPanel(new GridBagLayout()); if (myRoots.size() > 1) { buildForMultiple(panel); } else { buildForOne(panel, myRoots.iterator().next()); } return panel; }
private void buildForMultiple(JBPanel panel) { final GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0); c.gridwidth = 2; c.fill = GridBagConstraints.HORIZONTAL; final JBLabel comp = new JBLabel("Please select remote URLs for roots:"); comp.setFont(comp.getFont().deriveFont(Font.BOLD)); panel.add(comp, c); c.gridwidth = 1; for (FilePath root : myRoots) { c.weighty = 0; c.gridx = 0; ++ c.gridy; c.fill = GridBagConstraints.NONE; panel.add(new JBLabel(root.getName() + " (" + root.getParentPath() + ")"), c); ++ c.gridx; c.fill = GridBagConstraints.HORIZONTAL; c.weighty = 1; final JBTextField field = new JBTextField(); panel.add(field, c); myFields.put(root.getIOFile(), field); final String preset = myCheckoutURLs.get(root.getIOFile()); if (preset != null) { field.setText(preset); } } addWarning(panel, c); }
private void addWarning(JBPanel panel, GridBagConstraints c) { if (myWarning != null && myWarning.length() > 0) { ++ c.gridy; c.gridx = 0; c.gridwidth = 2; c.fill = GridBagConstraints.HORIZONTAL; final JLabel label = new JLabel(new TextUtil().insertLineCuts("Warning: " + myWarning)); label.setUI(new MultiLineLabelUI()); label.setForeground(SimpleTextAttributes.ERROR_ATTRIBUTES.getFgColor()); panel.add(label, c); } }
protected final Container createContentPane(){ myContentPane = new JBPanel(new BorderLayout()) { @Nullable @Override public Icon getCenterImage() { if (UIUtil.isUnderDarcula()) { String url = ApplicationInfoEx.getInstanceEx().getEditorBackgroundImageUrl(); if (url != null) { return IconLoader.getIcon(url); } } return null; } @Nullable @Override public Icon getBackgroundImage() { return UIUtil.isUnderDarcula() ? BG : null; } @Override public Color getBackground() { return UIUtil.isUnderDarcula() ? super.getBackground() : JBColor.GRAY; } }; return myContentPane; }
@Override public JComponent getWelcomePanel() { final JBPanel root = new JBPanel(new BorderLayout()) { @Override public Dimension getPreferredSize() { return new Dimension(940, 580); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); final int w = getWidth(); final int iw = logo.getIconWidth(); ((Graphics2D)g).setPaint(new RadialGradientPaint(w / 2, 80, Math.max(getWidth()/2, getHeight()), new float[]{0.0f, 1.0f}, new Color[]{Gray._255.withAlpha(70), Gray._255.withAlpha(0)})); ((Graphics2D)g).fillRect(0, 0, getWidth(), getHeight()); logo.paintIcon(this, g, w / 2 - iw /2, 30); final Font tahoma = new Font("Tahoma", Font.BOLD, 22); final int stringWidth = SwingUtilities2.stringWidth(this, getFontMetrics(tahoma), "Develop with Pleasure"); final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.setColor(Gray._255.withAlpha(40)); g.setFont(tahoma); ((Graphics2D)g).drawString("Develop with Pleasure", (w - stringWidth) / 2, getHeight() - 19); g.setColor(UIUtil.getPanelBackground()); ((Graphics2D)g).drawString("Develop with Pleasure", (w - stringWidth)/2, getHeight() - 20); config.restore(); } }; root.setBackgroundImage(IconLoader.getIcon("/frame_background.png")); root.setOpaque(false); root.setBorder(new LineBorder(Gray._128)); root.add(new DarculaWelcomeScreenForm(this).getComponent(), BorderLayout.CENTER); return root; }
private void createUIComponents() { myExplorerPanel = new JBPanel(new BorderLayout()) { @Override public void calcData(DataKey key, DataSink sink) { if (key == PlatformDataKeys.VIRTUAL_FILE_ARRAY) { sink.put(PlatformDataKeys.VIRTUAL_FILE_ARRAY, myExplorer.getSelectedFiles()); } else if (key == FileSystemTree.DATA_KEY) { sink.put(FileSystemTree.DATA_KEY, myExplorer); } } }; }
/** Create UI components. */ private void createUIComponents() { templatesListPanel = new TemplatesListPanel(); editorPanel = new EditorPanel(); editorPanel.setPreferredSize(new Dimension(Integer.MAX_VALUE, 200)); templatesSplitter = new Splitter(false, 0.3f); templatesSplitter.setFirstComponent(templatesListPanel); templatesSplitter.setSecondComponent(editorPanel); languagesTable = new JBTable(); languagesTable.setModel(new LanguagesTableModel()); languagesTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); languagesTable.setColumnSelectionAllowed(false); languagesTable.setRowHeight(22); languagesTable.setPreferredScrollableViewportSize(new Dimension(-1, languagesTable.getRowHeight() * IgnoreBundle.LANGUAGES.size() / 2)); languagesTable.setStriped(true); languagesTable.setShowGrid(false); languagesTable.setBorder(createEmptyBorder()); languagesTable.setDragEnabled(false); languagesPanel = ScrollPaneFactory.createScrollPane(languagesTable); donatePanel = new JBPanel(new BorderLayout()); donatePanel.setBorder(new EmptyBorder(10, 0, 10, 0)); donatePanel.add(new JBLabel(IgnoreBundle.message("settings.general.donate")), BorderLayout.WEST); donatePanel.add(createLink( "Donate with PayPal", "https://www.paypal.me/hsz" ), BorderLayout.CENTER); }
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, lookaheadInfo.startIndex, lookaheadInfo.stopIndex, false); } dialog.pack(); dialog.setVisible(true); }
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 = Disposer.newDisposable(); Disposer.register(parent, disposable); return new MyLoadingDecorator(targetComponent, myPanel, disposable, startDelayMs); }; createLoadingDecorator(); }
@NotNull public static EmmetPreviewHint createHint(@NotNull final EditorEx parentEditor, @NotNull String templateText, @NotNull FileType fileType) { EditorFactory editorFactory = EditorFactory.getInstance(); Document document = editorFactory.createDocument(templateText); final EditorEx previewEditor = (EditorEx)editorFactory.createEditor(document, parentEditor.getProject(), fileType, true); MarkupModelEx model = previewEditor.getMarkupModel(); if (model instanceof EditorMarkupModel) { ((EditorMarkupModel)model).setErrorStripeVisible(true); } final EditorSettings settings = previewEditor.getSettings(); settings.setLineNumbersShown(false); settings.setAdditionalLinesCount(1); settings.setAdditionalColumnsCount(1); settings.setRightMarginShown(false); settings.setFoldingOutlineShown(false); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setVirtualSpace(false); settings.setWheelFontChangeEnabled(false); settings.setAdditionalPageAtBottom(false); settings.setCaretRowShown(false); previewEditor.setCaretEnabled(false); previewEditor.setBorder(IdeBorderFactory.createEmptyBorder()); JBPanel panel = new JBPanel(new BorderLayout()) { @NotNull @Override public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); Dimension parentEditorSize = parentEditor.getScrollPane().getSize(); int maxWidth = (int)parentEditorSize.getWidth() / 3; int maxHeight = (int)parentEditorSize.getHeight() / 2; final int width = settings.isUseSoftWraps() ? maxWidth : Math.min((int)size.getWidth(), maxWidth); final int height = Math.min((int)size.getHeight(), maxHeight); return new Dimension(width, height); } @NotNull @Override public Insets getInsets() { return new Insets(1, 2, 0, 0); } }; panel.setBackground(previewEditor.getBackgroundColor()); panel.add(previewEditor.getComponent(), BorderLayout.CENTER); return new EmmetPreviewHint(panel, previewEditor, parentEditor); }
public JBPanel getTopPanel() { return myTopPanel; }
public JBPanel getDocsPanel() { return myDocsPanel; }
public DiagnosticPanel(Application application) { component = new JBPanel(new BorderLayout()); DefaultListModel<BundleDiagnosis> listModel = JBList.createDefaultListModel(); JBList list = new JBList(listModel); JBScrollPane scrollPane = new JBScrollPane(list); list.setSelectionModel(new DefaultListSelectionModel() { @Override public void setSelectionInterval(int index0, int index1) { super.setSelectionInterval(-1, -1); } }); list.getEmptyText().setText("No diagnosis is ready"); component.add(scrollPane, BorderLayout.CENTER); list.setCellRenderer(new ColoredListCellRenderer<BundleDiagnosis>() { @Override protected void customizeCellRenderer(JList jList, BundleDiagnosis o, int i, boolean b, boolean b1) { this.setBackground(null); if (o.getStatus() == BundleDiagnosis.Status.OK) { this.setIcon(AllIcons.RunConfigurations.TestPassed); append(o.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); } else { this.setIcon(AllIcons.RunConfigurations.TestError); append(o.getName(), SimpleTextAttributes.ERROR_ATTRIBUTES); } mySelected = false; append(" (" + o.getId() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES); } }); application.getMessageBus().connect() .subscribe(FinishedDiagnosticNotifier.DIAGNOSTIC_TOPIC, new FinishedDiagnosticNotifier() { @Override public void diagnosisSuccessful(java.util.List<BundleDiagnosis> bundles) { ApplicationManager.getApplication().invokeLater( () -> { listModel.clear(); bundles.stream().forEach(e -> listModel.addElement(e)); long errorBundles = bundles.stream().filter(e -> e.getStatus() == BundleDiagnosis.Status.NOT) .count(); if (errorBundles > 0) { Notification bundleErrorNotification = new Notification("wuff.diagnostic.error", "Wuff Diagnostic Error", errorBundles + " bundle" + (errorBundles != 1 ? "s" : "") + " not resolved", NotificationType.ERROR); bundleErrorNotification.setImportant(true); Notifications.Bus.notify(bundleErrorNotification); } }); } @Override public void diagnosisStarted() { ApplicationManager.getApplication().invokeLater(() -> { list.getEmptyText().setText("Diagnosis in progress..."); listModel.clear(); }); } @Override public void diagnosisFailed(String message) { ApplicationManager.getApplication().invokeLater(() -> { list.getEmptyText().setText("Diagnosis Failed"); listModel.clear(); }); } }); }
public DefaultWelcomeScreen(JComponent rootPane) { initApplicationSpecificImages(); myWelcomePanel = new JBPanel(new GridBagLayout()) { @Override public Dimension getPreferredSize() { return new Dimension(1024, 768); } }; myWelcomePanel.setBackgroundImage(IconLoader.getIcon("/frame_background.png")); String icon = ApplicationInfoEx.getInstanceEx().getEditorBackgroundImageUrl(); if (icon != null) myWelcomePanel.setCenterImage(IconLoader.getIcon(icon)); // Create caption pane JPanel topPanel = createCaptionPane(); // Create Main Panel for Quick Start and Documentation myMainPanel = new WelcomeScrollablePanel(new GridLayout(1, 2)); //myMainPanel.setBackground(MAIN_PANEL_BACKGROUND); setUpMainPanel(rootPane); JScrollPane mainScrollPane = scrollPane(myMainPanel, null); // Create Plugins Panel myPluginsPanel = new WelcomeScrollablePanel(new GridBagLayout()); myPluginsPanel.setBackground(PLUGINS_PANEL_BACKGROUND); setUpPluginsPanel(); JScrollPane pluginsScrollPane = scrollPane(myPluginsPanel, PLUGINS_PANEL_BORDER); // Create Welcome panel GridBagConstraints gBC; myWelcomePanel.setBackground(WELCOME_PANEL_BACKGROUND); gBC = new GridBagConstraints(0, 0, 2, 1, 1, 0, NORTHWEST, HORIZONTAL, new Insets(7, 7, 7, 7), 0, 0); myWelcomePanel.add(topPanel, gBC); gBC = new GridBagConstraints(0, 1, 1, 1, 0.7, 1, NORTHWEST, BOTH, new Insets(0, 7, 7, 7), 0, 0); myWelcomePanel.add(mainScrollPane, gBC); /* gBC = new GridBagConstraints(1, 1, 1, 1, 0.3, 1, NORTHWEST, BOTH, new Insets(0, 0, 7, 7), 0, 0); myWelcomePanel.add(pluginsScrollPane, gBC); */ }
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, ambigInfo.startIndex, ambigInfo.stopIndex, true); } dialog.pack(); dialog.setVisible(true); }
public void setTrees(PreviewState previewState, List<? extends RuleContext> trees, String title, int highlightTreeIndex, int startIndex, int stopIndex, boolean highlightDiffs) { this.previewState = previewState; this.ambiguousParseTrees = trees; if ( ambiguousParseTrees!=null ) { int numTrees = ambiguousParseTrees.size(); setTitle(title); treeViewers = new TreeViewer[ambiguousParseTrees.size()]; 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); // highlight root so people can see it across trees; might not be top node final Tree root = ParsingUtils.findOverriddenDecisionRoot(ctx); if ( root==null ) { // I saw this when a (...)+ exit branch was taken here // declarationSpecifiers // : declarationSpecifier+ // ; // TODO: display a message? } treeViewers[i].addHighlightedNodes(new ArrayList<Tree>() {{ add(root); }}); if ( ctx!=chosenTree ) { mark(chosenTree, ctx, startIndex, stopIndex); } JBPanel wrapper = new JBPanel(new BorderLayout()); if ( i==highlightTreeIndex ) { wrapper.setBackground(JBColor.white); } wrapper.add(treeViewers[i], BorderLayout.CENTER); panelOfTrees.add(wrapper); } // Wrap tree viewer components in scroll pane treeScrollPane.setViewportView(panelOfTrees); } }
MyInstancesView(@NotNull XDebugSession session) { super(new BorderLayout(0, JBUI.scale(BORDER_LAYOUT_DEFAULT_GAP))); Disposer.register(InstancesWindow.this.myDisposable, this); final XValueMarkers<?, ?> markers = getValueMarkers(session); if(markers != null) { final MyActionListener listener = new MyActionListener(markers); ActionManager.getInstance().addAnActionListener(listener, InstancesWindow.this.myDisposable); } session.addSessionListener(myDebugSessionListener, InstancesWindow.this.myDisposable); final JavaDebuggerEditorsProvider editorsProvider = new JavaDebuggerEditorsProvider(); myFilterConditionEditor = new ExpressionEditorWithHistory(myProject, myClassName, editorsProvider, InstancesWindow.this.myDisposable); myFilterButton.setBorder(BorderFactory.createEmptyBorder()); final Dimension filteringButtonSize = myFilterConditionEditor.getEditorComponent().getPreferredSize(); filteringButtonSize.width = JBUI.scale(FILTERING_BUTTON_ADDITIONAL_WIDTH) + myFilterButton.getPreferredSize().width; myFilterButton.setPreferredSize(filteringButtonSize); final JBPanel filteringPane = new JBPanel(new BorderLayout(JBUI.scale(BORDER_LAYOUT_DEFAULT_GAP), 0)); final JBLabel sideEffectsWarning = new JBLabel("Warning: filtering may have side effects", SwingConstants.RIGHT); sideEffectsWarning.setBorder(JBUI.Borders.empty(1, 0, 0, 0)); sideEffectsWarning.setComponentStyle(UIUtil.ComponentStyle.SMALL); sideEffectsWarning.setFontColor(UIUtil.FontColor.BRIGHTER); filteringPane.add(new JBLabel("Condition:"), BorderLayout.WEST); filteringPane.add(myFilterConditionEditor.getComponent(), BorderLayout.CENTER); filteringPane.add(myFilterButton, BorderLayout.EAST); filteringPane.add(sideEffectsWarning, BorderLayout.SOUTH); myProgress.addStopActionListener(this::cancelFilteringTask); myInstancesTree = new InstancesTree(myProject, editorsProvider, markers, this::updateInstances); myFilterButton.addActionListener(e -> { final String expression = myFilterConditionEditor.getExpression().getExpression(); if(!expression.isEmpty()) { myFilterConditionEditor.saveTextInHistory(); } myFilterButton.setEnabled(false); myInstancesTree.rebuildTree(InstancesTree.RebuildPolicy.RELOAD_INSTANCES); }); final StackFrameList list = new StackFrameList(myDebugProcess); list.addListSelectionListener(e -> list.navigateToSelectedValue(false)); new DoubleClickListener() { @Override protected boolean onDoubleClick(MouseEvent event) { list.navigateToSelectedValue(true); return true; } }.installOn(list); final InstancesWithStackFrameView instancesWithStackFrame = new InstancesWithStackFrameView(session, myInstancesTree, list, myClassName); add(filteringPane, BorderLayout.NORTH); add(instancesWithStackFrame.getComponent(), BorderLayout.CENTER); final JComponent focusedComponent = myFilterConditionEditor.getEditorComponent(); UiNotifyConnector.doWhenFirstShown(focusedComponent, () -> IdeFocusManager.findInstanceByComponent(focusedComponent).requestFocus(focusedComponent, true)); }