Java Code Examples for com.intellij.ui.components.JBLabel#setForeground()

The following examples show how to use com.intellij.ui.components.JBLabel#setForeground() . 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: FileErrorNodeRenderer.java    From buck with Apache License 2.0 6 votes vote down vote up
@Override
public Component render(Object value) {

  JBLabel result =
      new JBLabel(
          ((BuckFileErrorNode) value).getText(),
          AllIcons.Ide.Warning_notifications,
          SwingConstants.HORIZONTAL);

  BuckFileErrorNode buckNode = (BuckFileErrorNode) value;
  for (int i = 0; i < buckNode.getChildCount(); i++) {
    BuckTextNode childNode = (BuckTextNode) buckNode.getChildAt(i);
    if (childNode.getTextType() == BuckTextNode.TextType.ERROR) {
      result.setIcon(AllIcons.Ide.Error);
      result.setForeground(Color.RED);
      break;
    }
  }
  return result;
}
 
Example 2
Source File: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void updateForEmptyContent(ToolWindow toolWindow) {
  // There's a possible race here where the tool window gets disposed while we're displaying contents.
  if (toolWindow.isDisposed()) {
    return;
  }

  toolWindow.setIcon(FlutterIcons.Flutter_13);

  // Display a 'No running applications' message.
  final ContentManager contentManager = toolWindow.getContentManager();
  final JPanel panel = new JPanel(new BorderLayout());
  final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER);
  label.setForeground(UIUtil.getLabelDisabledForeground());
  panel.add(label, BorderLayout.CENTER);
  emptyContent = contentManager.getFactory().createContent(panel, null, false);
  contentManager.addContent(emptyContent);
}
 
Example 3
Source File: TipPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public TipPanel() {
  setLayout(new BorderLayout());
  myBrowser = TipUIUtil.createTipBrowser();
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myBrowser, true);
  add(scrollPane, BorderLayout.CENTER);

  JPanel southPanel = new JPanel(new BorderLayout());

  myPoweredByLabel = new JBLabel();
  myPoweredByLabel.setHorizontalAlignment(SwingConstants.RIGHT);
  myPoweredByLabel.setForeground(SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES.getFgColor());

  southPanel.add(myPoweredByLabel, BorderLayout.EAST);
  add(southPanel, BorderLayout.SOUTH);

  myTips.addAll(TipAndTrickBean.EP_NAME.getExtensionList());
}
 
Example 4
Source File: ErrorPanel.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
public ErrorPanel(final Exception ex) {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    JBLabel comp = new JBLabel("Error during query execution:");
    comp.setForeground(JBColor.RED);
    add(comp);
    final HoverHyperlinkLabel hoverHyperlinkLabel = new HoverHyperlinkLabel("more detail...");
    hoverHyperlinkLabel.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
            if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                Messages.showErrorDialog(ex.toString(), "Error During Query Execution");
            }
        }
    });
    add(Box.createRigidArea(new Dimension(10, 10)));
    add(hoverHyperlinkLabel);

}
 
Example 5
Source File: FlutterPerformanceView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void updateForEmptyContent(ToolWindow toolWindow) {
  // There's a possible race here where the tool window gets disposed while we're displaying contents.
  if (toolWindow.isDisposed()) {
    return;
  }

  toolWindow.setIcon(FlutterIcons.Flutter_13);

  // Display a 'No running applications' message.
  final ContentManager contentManager = toolWindow.getContentManager();
  final JPanel panel = new JPanel(new BorderLayout());
  final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER);
  label.setForeground(UIUtil.getLabelDisabledForeground());
  panel.add(label, BorderLayout.CENTER);
  emptyContent = contentManager.getFactory().createContent(panel, null, false);
  contentManager.addContent(emptyContent);
}
 
Example 6
Source File: FlutterPerformanceView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void updateForEmptyContent(ToolWindow toolWindow) {
  // There's a possible race here where the tool window gets disposed while we're displaying contents.
  if (toolWindow.isDisposed()) {
    return;
  }

  toolWindow.setIcon(FlutterIcons.Flutter_13);

  // Display a 'No running applications' message.
  final ContentManager contentManager = toolWindow.getContentManager();
  final JPanel panel = new JPanel(new BorderLayout());
  final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER);
  label.setForeground(UIUtil.getLabelDisabledForeground());
  panel.add(label, BorderLayout.CENTER);
  emptyContent = contentManager.getFactory().createContent(panel, null, false);
  contentManager.addContent(emptyContent);
}
 
Example 7
Source File: AsyncPopupImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected JComponent createContent() {
  if (myPanel != null) return myPanel;
  myPanel = new JPanel(new BorderLayout());
  //myPanel.add(new AsyncProcessIcon("Async Popup Step"), BorderLayout.WEST);
  JBLabel label = new JBLabel("Loading...");
  label.setForeground(UIUtil.getLabelDisabledForeground());
  myPanel.add(label, BorderLayout.CENTER);
  myPanel.setBorder(new EmptyBorder(UIUtil.getListCellPadding()));
  myPanel.setBackground(UIUtil.getListBackground());
  myPanel.registerKeyboardAction(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      goBack();
    }
  }, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), JComponent.WHEN_FOCUSED);
  return myPanel;
}
 
Example 8
Source File: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void updateForEmptyContent(ToolWindow toolWindow) {
  // There's a possible race here where the tool window gets disposed while we're displaying contents.
  if (toolWindow.isDisposed()) {
    return;
  }

  toolWindow.setIcon(FlutterIcons.Flutter_13);

  // Display a 'No running applications' message.
  final ContentManager contentManager = toolWindow.getContentManager();
  final JPanel panel = new JPanel(new BorderLayout());
  final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER);
  label.setForeground(UIUtil.getLabelDisabledForeground());
  panel.add(label, BorderLayout.CENTER);
  emptyContent = contentManager.getFactory().createContent(panel, null, false);
  contentManager.addContent(emptyContent);
}
 
Example 9
Source File: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void addDisabledTab(String displayName,
                            JBRunnerTabs runnerTabs,
                            DefaultActionGroup toolbarGroup) {
  final JPanel panel = new JPanel(new BorderLayout());
  final JBLabel label = new JBLabel("Widget info not available in profile mode", SwingConstants.CENTER);
  label.setForeground(UIUtil.getLabelDisabledForeground());
  panel.add(label, BorderLayout.CENTER);

  final TabInfo tabInfo = new TabInfo(panel)
    .append(displayName, SimpleTextAttributes.GRAYED_ATTRIBUTES);
  runnerTabs.addTab(tabInfo);
}
 
Example 10
Source File: Unity3dWizardStep.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
public Unity3dWizardStep(UnityModuleImportContext context)
{
	super(context);

	String version = Unity3dProjectImportUtil.loadVersionFromProject(context.getPath());
	Unity3SdkPanel sdkPanel = new Unity3SdkPanel(context, version);
	myAdditionalContentPanel.add(sdkPanel.getPanel(), BorderLayout.NORTH);

	if(version != null)
	{
		JBLabel versionLabel = new JBLabel(Unity3dBundle.message("required.unity.version.is.0", version));
		versionLabel.setForeground(JBColor.GRAY);
		myAdditionalContentPanel.add(versionLabel, BorderLayout.SOUTH);
	}
}
 
Example 11
Source File: WidgetPerfTable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final Component getTableCellRendererComponent(JTable table, @Nullable Object value,
                                                     boolean isSelected, boolean hasFocus, int row, int col) {
  final JPanel panel = new JPanel();
  if (value == null) return panel;
  panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

  if (value instanceof SlidingWindowStatsSummary) {
    final SlidingWindowStatsSummary stats = (SlidingWindowStatsSummary)value;
    final SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
    final int count = stats.getValue(metric);

    final JBLabel label = new JBLabel(Integer.toString(count));
    panel.add(Box.createHorizontalGlue());
    panel.add(label);
    panel.add(Box.createHorizontalStrut(8));

    if (isSelected) {
      label.setForeground(table.getSelectionForeground());
    }
  }

  clear();
  setPaintFocusBorder(hasFocus && table.getCellSelectionEnabled());
  acquireState(table, isSelected, hasFocus, row, col);
  getCellState().updateRenderer(this);

  if (isSelected) {
    panel.setBackground(table.getSelectionBackground());
  }

  return panel;
}
 
Example 12
Source File: WidgetPerfTable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final Component getTableCellRendererComponent(JTable table, @Nullable Object value,
                                                     boolean isSelected, boolean hasFocus, int row, int col) {
  final JPanel panel = new JPanel();
  if (value == null) return panel;
  panel.setLayout(new BorderLayout());

  if (value instanceof SlidingWindowStatsSummary) {
    final SlidingWindowStatsSummary stats = (SlidingWindowStatsSummary)value;
    final SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
    final Location location = stats.getLocation();
    final String path = location.path;
    final String filename = PathUtil.getFileName(path);
    append(filename, attributes);

    final JBLabel label = new JBLabel(filename);
    label.setHorizontalAlignment(SwingConstants.RIGHT);
    panel.add(Box.createHorizontalGlue());
    panel.add(label, BorderLayout.CENTER);

    final JBLabel lineLabel = new JBLabel(":" + location.line);
    panel.add(lineLabel, BorderLayout.EAST);

    if (isSelected) {
      label.setForeground(table.getSelectionForeground());
      lineLabel.setForeground(table.getSelectionForeground());
    }
  }

  clear();
  setPaintFocusBorder(hasFocus && table.getCellSelectionEnabled());
  acquireState(table, isSelected, hasFocus, row, col);
  getCellState().updateRenderer(this);

  if (isSelected) {
    panel.setBackground(table.getSelectionBackground());
  }

  return panel;
}
 
Example 13
Source File: WidgetPerfTable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final Component getTableCellRendererComponent(JTable table, @Nullable Object value,
                                                     boolean isSelected, boolean hasFocus, int row, int col) {
  final JPanel panel = new JPanel();
  if (value == null) return panel;
  panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

  if (value instanceof SlidingWindowStatsSummary) {
    final SlidingWindowStatsSummary stats = (SlidingWindowStatsSummary)value;
    final SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;

    final JBLabel label = new JBLabel(stats.getLocation().name);
    if (isSelected) {
      label.setForeground(table.getSelectionForeground());
    }
    final int count = stats.getValue(PerfMetric.lastFrame);
    label.setIcon(getIconForCount(idle ? 0 : count, true));
    panel.add(Box.createHorizontalStrut(16));
    panel.add(label);
  }

  clear();
  setPaintFocusBorder(hasFocus && table.getCellSelectionEnabled());
  acquireState(table, isSelected, hasFocus, row, col);
  getCellState().updateRenderer(this);

  if (isSelected) {
    panel.setBackground(table.getSelectionBackground());
  }

  return panel;
}
 
Example 14
Source File: FlutterLogView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
@Override
public JComponent createCustomComponent(@NotNull Presentation presentation) {
  panel = new JPanel();

  label = new JBLabel();
  label.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
  label.setForeground(UIUtil.getInactiveTextColor());
  label.setBorder(JBUI.Borders.emptyRight(10));
  panel.add(label);

  logTree.addListener(this, FlutterLogView.this);

  return panel;
}
 
Example 15
Source File: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void addDisabledTab(String displayName,
                            JBRunnerTabs runnerTabs,
                            DefaultActionGroup toolbarGroup) {
  final JPanel panel = new JPanel(new BorderLayout());
  final JBLabel label = new JBLabel("Widget info not available in profile mode", SwingConstants.CENTER);
  label.setForeground(UIUtil.getLabelDisabledForeground());
  panel.add(label, BorderLayout.CENTER);

  final TabInfo tabInfo = new TabInfo(panel)
    .append(displayName, SimpleTextAttributes.GRAYED_ATTRIBUTES);
  runnerTabs.addTab(tabInfo);
}
 
Example 16
Source File: WidgetPerfTable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final Component getTableCellRendererComponent(JTable table, @Nullable Object value,
                                                     boolean isSelected, boolean hasFocus, int row, int col) {
  final JPanel panel = new JPanel();
  if (value == null) return panel;
  panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

  if (value instanceof SlidingWindowStatsSummary) {
    final SlidingWindowStatsSummary stats = (SlidingWindowStatsSummary)value;
    final SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
    final int count = stats.getValue(metric);

    final JBLabel label = new JBLabel(Integer.toString(count));
    panel.add(Box.createHorizontalGlue());
    panel.add(label);
    panel.add(Box.createHorizontalStrut(8));

    if (isSelected) {
      label.setForeground(table.getSelectionForeground());
    }
  }

  clear();
  setPaintFocusBorder(hasFocus && table.getCellSelectionEnabled());
  acquireState(table, isSelected, hasFocus, row, col);
  getCellState().updateRenderer(this);

  if (isSelected) {
    panel.setBackground(table.getSelectionBackground());
  }

  return panel;
}
 
Example 17
Source File: WidgetPerfTable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final Component getTableCellRendererComponent(JTable table, @Nullable Object value,
                                                     boolean isSelected, boolean hasFocus, int row, int col) {
  final JPanel panel = new JPanel();
  if (value == null) return panel;
  panel.setLayout(new BorderLayout());

  if (value instanceof SlidingWindowStatsSummary) {
    final SlidingWindowStatsSummary stats = (SlidingWindowStatsSummary)value;
    final SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
    final Location location = stats.getLocation();
    final String path = location.path;
    final String filename = PathUtil.getFileName(path);
    append(filename, attributes);

    final JBLabel label = new JBLabel(filename);
    label.setHorizontalAlignment(SwingConstants.RIGHT);
    panel.add(Box.createHorizontalGlue());
    panel.add(label, BorderLayout.CENTER);

    final JBLabel lineLabel = new JBLabel(":" + location.line);
    panel.add(lineLabel, BorderLayout.EAST);

    if (isSelected) {
      label.setForeground(table.getSelectionForeground());
      lineLabel.setForeground(table.getSelectionForeground());
    }
  }

  clear();
  setPaintFocusBorder(hasFocus && table.getCellSelectionEnabled());
  acquireState(table, isSelected, hasFocus, row, col);
  getCellState().updateRenderer(this);

  if (isSelected) {
    panel.setBackground(table.getSelectionBackground());
  }

  return panel;
}
 
Example 18
Source File: WidgetPerfTable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final Component getTableCellRendererComponent(JTable table, @Nullable Object value,
                                                     boolean isSelected, boolean hasFocus, int row, int col) {
  final JPanel panel = new JPanel();
  if (value == null) return panel;
  panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

  if (value instanceof SlidingWindowStatsSummary) {
    final SlidingWindowStatsSummary stats = (SlidingWindowStatsSummary)value;
    final SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;

    final JBLabel label = new JBLabel(stats.getLocation().name);
    if (isSelected) {
      label.setForeground(table.getSelectionForeground());
    }
    final int count = stats.getValue(PerfMetric.lastFrame);
    label.setIcon(getIconForCount(idle ? 0 : count, true));
    panel.add(Box.createHorizontalStrut(16));
    panel.add(label);
  }

  clear();
  setPaintFocusBorder(hasFocus && table.getCellSelectionEnabled());
  acquireState(table, isSelected, hasFocus, row, col);
  getCellState().updateRenderer(this);

  if (isSelected) {
    panel.setBackground(table.getSelectionBackground());
  }

  return panel;
}
 
Example 19
Source File: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void addInspectorViewContent(FlutterApp app, @Nullable InspectorService inspectorService, ToolWindow toolWindow) {
  final ContentManager contentManager = toolWindow.getContentManager();
  final SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(true);
  final JBRunnerTabs runnerTabs = new JBRunnerTabs(myProject, ActionManager.getInstance(), IdeFocusManager.getInstance(myProject), this);
  runnerTabs.setSelectionChangeHandler(this::onTabSelectionChange);
  final JPanel tabContainer = new JPanel(new BorderLayout());

  final String tabName;
  final FlutterDevice device = app.device();
  if (device == null) {
    tabName = app.getProject().getName();
  }
  else {
    final List<FlutterDevice> existingDevices = new ArrayList<>();
    for (FlutterApp otherApp : perAppViewState.keySet()) {
      existingDevices.add(otherApp.device());
    }
    tabName = device.getUniqueName(existingDevices);
  }

  final Content content = contentManager.getFactory().createContent(null, tabName, false);
  tabContainer.add(runnerTabs.getComponent(), BorderLayout.CENTER);
  content.setComponent(tabContainer);
  content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
  content.setIcon(FlutterIcons.Phone);
  contentManager.addContent(content);

  if (emptyContent != null) {
    contentManager.removeContent(emptyContent, true);
    emptyContent = null;
  }

  contentManager.setSelectedContent(content);

  final PerAppState state = getOrCreateStateForApp(app);
  assert (state.content == null);
  state.content = content;

  final DefaultActionGroup toolbarGroup = createToolbar(toolWindow, app, inspectorService);
  toolWindowPanel.setToolbar(ActionManager.getInstance().createActionToolbar("FlutterViewToolbar", toolbarGroup, true).getComponent());

  toolbarGroup.add(new OverflowAction(getOrCreateStateForApp(app), this, app));

  final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("InspectorToolbar", toolbarGroup, true);
  final JComponent toolbarComponent = toolbar.getComponent();
  toolbarComponent.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
  tabContainer.add(toolbarComponent, BorderLayout.NORTH);

  final boolean debugConnectionAvailable = app.getLaunchMode().supportsDebugConnection();
  final boolean hasInspectorService = inspectorService != null;

  // If the inspector is available (non-release mode), then show it.
  if (debugConnectionAvailable) {
    if (hasInspectorService) {
      final boolean detailsSummaryViewSupported = inspectorService.isDetailsSummaryViewSupported();
      addInspectorPanel(WIDGET_TAB_LABEL, runnerTabs, state, InspectorService.FlutterTreeType.widget, app, inspectorService, toolWindow,
                        toolbarGroup, true, detailsSummaryViewSupported);
      addInspectorPanel(RENDER_TAB_LABEL, runnerTabs, state, InspectorService.FlutterTreeType.renderObject, app, inspectorService,
                        toolWindow, toolbarGroup, false, false);
    }
    else {
      // If in profile mode, add disabled tabs for the inspector.
      addDisabledTab(WIDGET_TAB_LABEL, runnerTabs, toolbarGroup);
      addDisabledTab(RENDER_TAB_LABEL, runnerTabs, toolbarGroup);
    }
  }
  else {
    // Add a message about the inspector not being available in release mode.
    final JBLabel label = new JBLabel("Inspector not available in release mode", SwingConstants.CENTER);
    label.setForeground(UIUtil.getLabelDisabledForeground());
    tabContainer.add(label, BorderLayout.CENTER);
  }
}
 
Example 20
Source File: EarlyAccessProgramConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
  CheckBoxList checkBoxList = (CheckBoxList)list;
  EarlyAccessProgramDescriptor earlyAccessProgramDescriptor = (EarlyAccessProgramDescriptor)checkBoxList.getItemAt(index);

  JCheckBox checkbox = (JCheckBox)value;

  checkbox.setEnabled(list.isEnabled());
  checkbox.setFocusPainted(false);
  checkbox.setBorderPainted(true);

  if (earlyAccessProgramDescriptor == null) {
    return checkbox;
  }
  else {
    checkbox.setEnabled(earlyAccessProgramDescriptor.isAvailable());

    JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, true, true)) {
      @Override
      public Dimension getPreferredSize() {
        Dimension size = super.getPreferredSize();
        return new Dimension(Math.min(size.width, 200), size.height);
      }
    };
    panel.setEnabled(earlyAccessProgramDescriptor.isAvailable());

    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.add(checkbox, BorderLayout.WEST);

    if (earlyAccessProgramDescriptor.isRestartRequired()) {
      JBLabel comp = new JBLabel("Restart required");
      comp.setForeground(JBColor.GRAY);
      topPanel.add(comp, BorderLayout.EAST);
    }

    panel.add(topPanel);
    panel.setBorder(new CustomLineBorder(0, 0, 1, 0));

    String description = StringUtil.notNullizeIfEmpty(earlyAccessProgramDescriptor.getDescription(), "Description is not available");
    JTextPane textPane = new JTextPane();
    textPane.setText(description);
    textPane.setEditable(false);
    if (!earlyAccessProgramDescriptor.isAvailable()) {
      textPane.setForeground(JBColor.GRAY);
    }
    panel.add(textPane);
    return panel;
  }
}