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

The following examples show how to use com.intellij.ui.components.JBLabel#setHorizontalAlignment() . 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: 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 2
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 3
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 4
Source File: QueryPlanPanel.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 5 votes vote down vote up
public void initialize(Container container) {
    JTextArea queryLabel = new JTextArea(originalQuery);
    queryLabel.setRows(3);
    queryLabel.setEditable(false);

    GraphQueryPlan graphQueryPlan = result.getPlan()
            .orElseThrow(() ->
                    new ShouldNeverHappenException("Sergey Ishchenko",
                            "GraphQueryPanel is initialized when explain or profile queries are executed"));

    ListTreeTableModelOnColumns model = createModel(graphQueryPlan, result.isProfilePlan());

    treeTable = new TreeTableView(model);
    treeTable.setAutoCreateColumnsFromModel(true);
    treeTable.setRootVisible(true);
    treeTable.setCellSelectionEnabled(false);
    treeTable.setRowSelectionAllowed(true);
    treeTable.setAutoResizeMode(TreeTableView.AUTO_RESIZE_OFF);

    treeTable.getTree().setShowsRootHandles(true);

    DefaultTreeExpander expander = new DefaultTreeExpander(treeTable.getTree());
    expander.expandAll();
    initTreeCellRenderer(model);

    JBLabel infoLabel = new JBLabel(getStatusText(result));
    infoLabel.setHorizontalAlignment(SwingConstants.LEFT);

    container.add(new JBScrollPane(queryLabel), BorderLayout.NORTH);
    // scroll pane is needed to correctly fit all the tree content and to show table header
    container.add(new JBScrollPane(treeTable, JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JBScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
    container.add(infoLabel, BorderLayout.SOUTH);

    new ColumnResizer(treeTable).resize();
}
 
Example 5
Source File: ReferencesPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
protected JBLabel createLabel(@Nonnull String text, @Nullable Icon icon) {
  JBLabel label = new JBLabel(text, icon, SwingConstants.LEFT);
  label.setFont(getLabelsFont());
  label.setIconTextGap(0);
  label.setHorizontalAlignment(SwingConstants.LEFT);
  return label;
}