void setMemoryIndicatorVisible(final boolean visible) { if (myMemoryWidget != null) { myMemoryWidget.setShowing(visible); if (!SystemInfo.isMac) { myStatusBar.setBorder(BorderFactory.createEmptyBorder(1, 4, 0, visible ? 0 : 2)); } } }
@Override public JComponent createCustomComponent(final Presentation presentation) { ComboBoxButton button = createComboBoxButton(presentation); button.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout()); panel.setBorder(IdeBorderFactory.createEmptyBorder(0, 0, 0, 2)); panel.add(button); return panel; }
@Override public void actionPerformed(AnActionEvent e) { JPanel result = new JPanel(new BorderLayout()); JLabel label = new JLabel("Lines around:"); label.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 0)); JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(label, BorderLayout.NORTH); result.add(wrapper, BorderLayout.WEST); final JSlider slider = new JSlider(JSlider.HORIZONTAL, 1, 5, 1); slider.setMinorTickSpacing(1); slider.setPaintTicks(true); slider.setPaintTrack(true); slider.setSnapToTicks(true); UIUtil.setSliderIsFilled(slider, true); slider.setPaintLabels(true); slider.setLabelTable(LABELS); result.add(slider, BorderLayout.CENTER); final VcsConfiguration configuration = VcsConfiguration.getInstance(myProject); for (int i = 0; i < ourMarks.length; i++) { int mark = ourMarks[i]; if (mark == configuration.SHORT_DIFF_EXTRA_LINES) { slider.setValue(i + 1); } } JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(result, slider).createPopup(); popup.setFinalRunnable( new Runnable() { @Override public void run() { int value = slider.getModel().getValue(); if (configuration.SHORT_DIFF_EXTRA_LINES != ourMarks[value - 1]) { configuration.SHORT_DIFF_EXTRA_LINES = ourMarks[value - 1]; myFragmentedContent.recalculate(); refreshData(myFragmentedContent); } } }); InputEvent inputEvent = e.getInputEvent(); if (inputEvent instanceof MouseEvent) { int width = result.getPreferredSize().width; MouseEvent inputEvent1 = (MouseEvent) inputEvent; Point point1 = new Point(inputEvent1.getX() - width / 2, inputEvent1.getY()); RelativePoint point = new RelativePoint(inputEvent1.getComponent(), point1); popup.show(point); } else { popup.showInBestPositionFor(e.getDataContext()); } }
private AntBuildMessageView(Project project, AntBuildFileBase buildFile, String[] targets) { super(new BorderLayout(2, 0)); myProject = project; setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); myPlainTextView = new PlainTextView(project); myTreeView = new TreeView(project, buildFile); myMessagePanel = new JPanel(new BorderLayout()); myBuildFile = buildFile; myTargets = targets; showAntView(AntBuildFileImpl.TREE_VIEW.value(buildFile.getAllOptions())); setVerboseMode(AntBuildFileImpl.VERBOSE.value(buildFile.getAllOptions())); add(createToolbarPanel(), BorderLayout.WEST); add(myMessagePanel, BorderLayout.CENTER); }
private static class TableItemRenderer extends ColoredTableCellRenderer { private final Border NO_FOCUS_BORDER = BorderFactory.createEmptyBorder(1, 1, 1, 1); private StructureConfigurableContext myContext; public TableItemRenderer(StructureConfigurableContext context) { myContext = context; } @Override protected void customizeCellRenderer( JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) { setPaintFocusBorder(false); setFocusBorderAroundIcon(true); setBorder(NO_FOCUS_BORDER); if (value instanceof ClasspathTableItem<?>) { final ClasspathTableItem<?> tableItem = (ClasspathTableItem<?>) value; getCellAppearance(tableItem, myContext, selected).customize(this); setToolTipText(tableItem.getTooltipText()); } } }
public void buildUi() { myTopPanel = new JPanel(new BorderLayout()); final JPanel wrapper = new JPanel(); // final BoxLayout boxLayout = new BoxLayout(wrapper, BoxLayout.X_AXIS); wrapper.setLayout(new BorderLayout()); myTitleLabel.setBorder(BorderFactory.createEmptyBorder(1, 2, 0, 0)); wrapper.add(myTitleLabel, BorderLayout.WEST); DefaultActionGroup dag = new DefaultActionGroup(); myPreviousDiff.copyShortcutFrom(ActionManager.getInstance().getAction("PreviousDiff")); myNextDiff.copyShortcutFrom(ActionManager.getInstance().getAction("NextDiff")); dag.add(new MyChangeContextAction()); dag.add(myPreviousDiff); dag.add(myNextDiff); myPreviousDiff.registerCustomShortcutSet(myPreviousDiff.getShortcutSet(), myPanel); myNextDiff.registerCustomShortcutSet(myNextDiff.getShortcutSet(), myPanel); dag.add(new PopupAction()); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, dag, true); wrapper.add(toolbar.getComponent(), BorderLayout.EAST); myTopPanel.add(wrapper, BorderLayout.CENTER); final JPanel wrapperDiffs = new JPanel(new GridBagLayout()); final JPanel oneMore = new JPanel(new BorderLayout()); oneMore.add(wrapperDiffs, BorderLayout.NORTH); myCurrentHorizontal = myConfiguration.SHORT_DIFF_HORISONTALLY; myHorizontal = createPanel(true); myVertical = createPanel(false); myPanel.add(myTopPanel, BorderLayout.NORTH); myPanel.add(getCurrentPanel().getComponent(), BorderLayout.CENTER); myPreviousDiff.registerCustomShortcutSet(myPreviousDiff.getShortcutSet(), myParent); myNextDiff.registerCustomShortcutSet(myNextDiff.getShortcutSet(), myParent); }
public DocumentationComponent( final DocumentationManager manager, final AnAction[] additionalActions) { myManager = manager; myIsEmpty = true; myIsShown = false; myEditorPane = new JEditorPane(UIUtil.HTML_MIME, "") { @Override public Dimension getPreferredScrollableViewportSize() { if (getWidth() == 0 || getHeight() == 0) { setSize(MAX_WIDTH, MAX_HEIGHT); } Insets ins = myEditorPane.getInsets(); View rootView = myEditorPane.getUI().getRootView(myEditorPane); rootView.setSize( MAX_WIDTH, MAX_HEIGHT); // Necessary! Without this line, size will not increase then you go // from small page to bigger one int prefHeight = (int) rootView.getPreferredSpan(View.Y_AXIS); prefHeight += ins.bottom + ins.top + myScrollPane.getHorizontalScrollBar().getMaximumSize().height; return new Dimension(MAX_WIDTH, Math.max(MIN_HEIGHT, Math.min(MAX_HEIGHT, prefHeight))); } { enableEvents(AWTEvent.KEY_EVENT_MASK); } @Override protected void processKeyEvent(KeyEvent e) { KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(e); ActionListener listener = myKeyboardActions.get(keyStroke); if (listener != null) { listener.actionPerformed(new ActionEvent(DocumentationComponent.this, 0, "")); e.consume(); return; } super.processKeyEvent(e); } @Override protected void paintComponent(Graphics g) { GraphicsUtil.setupAntialiasing(g); super.paintComponent(g); } }; DataProvider helpDataProvider = new DataProvider() { @Override public Object getData(@NonNls String dataId) { return PlatformDataKeys.HELP_ID.is(dataId) ? DOCUMENTATION_TOPIC_ID : null; } }; myEditorPane.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, helpDataProvider); myText = ""; myEditorPane.setEditable(false); myEditorPane.setBackground(HintUtil.INFORMATION_COLOR); myEditorPane.setEditorKit(UIUtil.getHTMLEditorKit()); myScrollPane = new JBScrollPane(myEditorPane) { @Override protected void processMouseWheelEvent(MouseWheelEvent e) { if (!EditorSettingsExternalizable.getInstance().isWheelFontChangeEnabled() || !EditorUtil.isChangeFontSize(e)) { super.processMouseWheelEvent(e); return; } int change = Math.abs(e.getWheelRotation()); boolean increase = e.getWheelRotation() <= 0; EditorColorsManager colorsManager = EditorColorsManager.getInstance(); EditorColorsScheme scheme = colorsManager.getGlobalScheme(); FontSize newFontSize = scheme.getQuickDocFontSize(); for (; change > 0; change--) { if (increase) { newFontSize = newFontSize.larger(); } else { newFontSize = newFontSize.smaller(); } } if (newFontSize == scheme.getQuickDocFontSize()) { return; } scheme.setQuickDocFontSize(newFontSize); applyFontSize(); setFontSizeSliderSize(newFontSize); } }; myScrollPane.setBorder(null); myScrollPane.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, helpDataProvider); final MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { myManager.requestFocus(); myShowSettingsButton.hideSettings(); } }; myEditorPane.addMouseListener(mouseAdapter); Disposer.register( this, new Disposable() { @Override public void dispose() { myEditorPane.removeMouseListener(mouseAdapter); } }); final FocusAdapter focusAdapter = new FocusAdapter() { @Override public void focusLost(FocusEvent e) { Component previouslyFocused = WindowManagerEx.getInstanceEx() .getFocusedComponent(manager.getProject(getElement())); if (!(previouslyFocused == myEditorPane)) { if (myHint != null && !myHint.isDisposed()) myHint.cancel(); } } }; myEditorPane.addFocusListener(focusAdapter); Disposer.register( this, new Disposable() { @Override public void dispose() { myEditorPane.removeFocusListener(focusAdapter); } }); setLayout(new BorderLayout()); JLayeredPane layeredPane = new JBLayeredPane() { @Override public void doLayout() { final Rectangle r = getBounds(); for (Component component : getComponents()) { if (component instanceof JScrollPane) { component.setBounds(0, 0, r.width, r.height); } else { int insets = 2; Dimension d = component.getPreferredSize(); component.setBounds(r.width - d.width - insets, insets, d.width, d.height); } } } @Override public Dimension getPreferredSize() { Dimension editorPaneSize = myEditorPane.getPreferredScrollableViewportSize(); Dimension controlPanelSize = myControlPanel.getPreferredSize(); return new Dimension( Math.max(editorPaneSize.width, controlPanelSize.width), editorPaneSize.height + controlPanelSize.height); } }; layeredPane.add(myScrollPane); layeredPane.setLayer(myScrollPane, 0); mySettingsPanel = createSettingsPanel(); layeredPane.add(mySettingsPanel); layeredPane.setLayer(mySettingsPanel, JLayeredPane.POPUP_LAYER); add(layeredPane, BorderLayout.CENTER); setOpaque(true); myScrollPane.setViewportBorder(JBScrollPane.createIndentBorder()); final DefaultActionGroup actions = new DefaultActionGroup(); final BackAction back = new BackAction(); final ForwardAction forward = new ForwardAction(); actions.add(back); actions.add(forward); actions.add(myExternalDocAction = new ExternalDocAction()); back.registerCustomShortcutSet(CustomShortcutSet.fromString("LEFT"), this); forward.registerCustomShortcutSet(CustomShortcutSet.fromString("RIGHT"), this); myExternalDocAction.registerCustomShortcutSet(CustomShortcutSet.fromString("UP"), this); if (additionalActions != null) { for (final AnAction action : additionalActions) { actions.add(action); } } myToolBar = ActionManager.getInstance() .createActionToolbar(ActionPlaces.JAVADOC_TOOLBAR, actions, true); myControlPanel = new JPanel(); myControlPanel.setLayout(new BorderLayout()); myControlPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); JPanel dummyPanel = new JPanel(); myElementLabel = new JLabel(); dummyPanel.setLayout(new BorderLayout()); dummyPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); dummyPanel.add(myElementLabel, BorderLayout.EAST); myControlPanel.add(myToolBar.getComponent(), BorderLayout.WEST); myControlPanel.add(dummyPanel, BorderLayout.CENTER); myControlPanel.add(myShowSettingsButton = new MyShowSettingsButton(), BorderLayout.EAST); myControlPanelVisible = false; final HyperlinkListener hyperlinkListener = new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { HyperlinkEvent.EventType type = e.getEventType(); if (type == HyperlinkEvent.EventType.ACTIVATED) { manager.navigateByLink(DocumentationComponent.this, e.getDescription()); } } }; myEditorPane.addHyperlinkListener(hyperlinkListener); Disposer.register( this, new Disposable() { @Override public void dispose() { myEditorPane.removeHyperlinkListener(hyperlinkListener); } }); registerActions(); updateControlState(); }
protected void reInitWholePanelIfNeeded() { if (!myToReInitWholePanel) return; myWholePanel = new JPanel(new BorderLayout()) { public void addNotify() { super.addNotify(); MasterDetailsComponent.this.addNotify(); TreeModel m = myTree.getModel(); if (m instanceof DefaultTreeModel) { DefaultTreeModel model = (DefaultTreeModel) m; for (int eachRow = 0; eachRow < myTree.getRowCount(); eachRow++) { TreePath eachPath = myTree.getPathForRow(eachRow); Object component = eachPath.getLastPathComponent(); if (component instanceof TreeNode) { model.nodeChanged((TreeNode) component); } } } } }; mySplitter.setHonorComponentsMinimumSize(true); myWholePanel.add(mySplitter, BorderLayout.CENTER); JPanel left = new JPanel(new BorderLayout()) { public Dimension getMinimumSize() { final Dimension original = super.getMinimumSize(); return new Dimension(Math.max(original.width, 100), original.height); } }; if (isNewProjectSettings()) { ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree); DefaultActionGroup group = createToolbarActionGroup(); if (group != null) { decorator.setActionGroup(group); } // left.add(myNorthPanel, BorderLayout.NORTH); myMaster = decorator.setAsUsualTopToolbar().setPanelBorder(JBUI.Borders.empty()).createPanel(); myNorthPanel.setVisible(false); } else { left.add(myNorthPanel, BorderLayout.NORTH); myMaster = ScrollPaneFactory.createScrollPane(myTree); } left.add(myMaster, BorderLayout.CENTER); mySplitter.setFirstComponent(left); final JPanel right = new JPanel(new BorderLayout()); right.add(myDetails.getComponent(), BorderLayout.CENTER); if (!isNewProjectSettings()) { myWholePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); } mySplitter.setSecondComponent(right); GuiUtils.replaceJSplitPaneWithIDEASplitter(myWholePanel); myToReInitWholePanel = false; }