List of usage examples for com.intellij.openapi.ui ComponentWithActions getComponent
@NotNull JComponent getComponent();
From source file:com.android.tools.idea.monitor.MonitorPanel.java
License:Apache License
MonitorPanel(@NotNull BaseMonitorView[] monitors) { super(new GridBagLayout()); myMonitors = Arrays.asList(monitors); // Sort the monitors according to their ordering. Collections.sort(myMonitors, new Comparator<BaseMonitorView>() { @Override/*from www . ja v a 2s . com*/ public int compare(BaseMonitorView left, BaseMonitorView right) { return left.getPosition() - right.getPosition(); } }); // Fixup the positions in case the saved data is in an invalid state. for (int i = 0; i < monitors.length; ++i) { monitors[i].setPosition(i); } // Find the longest title label to align to. JLabel titleLengthLabel = new JLabel(); int largestLabelWidth = 0; for (BaseMonitorView monitor : monitors) { titleLengthLabel.setText(monitor.getTitleName()); titleLengthLabel.setIcon(monitor.getTitleIcon()); largestLabelWidth = Math.max(titleLengthLabel.getPreferredSize().width, largestLabelWidth); } myHiddenMonitorLookup = new HashMap<Component, Component>(monitors.length); myConstraintsLookup = new HashMap<Component, GridBagConstraints>(monitors.length); for (BaseMonitorView monitor : monitors) { ComponentWithActions monitorComponentWithActions = monitor.createComponent(); ActionGroup actions = monitorComponentWithActions.getToolbarActions(); assert actions != null; layoutMonitor(monitorComponentWithActions.getComponent(), actions, monitor, largestLabelWidth); } JPanel spacerPanel = new JPanel(); spacerPanel.setMinimumSize(new Dimension(0, 0)); spacerPanel.setPreferredSize(new Dimension(0, 0)); spacerPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); // Use a tiny value for the vertical weight so when everything is minimized (implies 0 weight on those components), this component will // take up the rest of the panel. add(spacerPanel, new GridBagConstraints(0, getComponentCount(), 1, 1, 1.0, 0.000000001, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); }
From source file:com.intellij.execution.ui.layout.impl.RunnerLayoutUiImpl.java
License:Apache License
@Override @NotNull/*w ww . j a va 2s . co m*/ public Content createContent(@NotNull final String contentId, @NotNull final ComponentWithActions withActions, @NotNull final String displayName, @Nullable final Icon icon, @Nullable final JComponent toFocus) { final Content content = getContentFactory().createContent(withActions.getComponent(), displayName, false); content.putUserData(CONTENT_TYPE, contentId); content.putUserData(ViewImpl.ID, contentId); content.setIcon(icon); if (toFocus != null) { content.setPreferredFocusableComponent(toFocus); } if (!withActions.isContentBuiltIn()) { content.setSearchComponent(withActions.getSearchComponent()); content.setActions(withActions.getToolbarActions(), withActions.getToolbarPlace(), withActions.getToolbarContextComponent()); } return content; }