private void initToolWindow() { myToolWindowPanel = new MyToolWindowPanel(); myComponentTree = new ComponentTree(myProject); for (TreeSelectionListener listener : myPendingListeners) { myComponentTree.addTreeSelectionListener(listener); } myPendingListeners.clear(); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myComponentTree); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); scrollPane.setPreferredSize(new Dimension(250, -1)); myComponentTree.initQuickFixManager(scrollPane.getViewport()); myPropertyInspector= new PropertyInspector(myProject, myComponentTree); myToolWindowPanel.setFirstComponent(scrollPane); myToolWindowPanel.setSecondComponent(myPropertyInspector); myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(UIDesignerBundle.message("toolwindow.ui.designer"), myToolWindowPanel, ToolWindowAnchor.LEFT, myProject, true); myToolWindow.setIcon(UIDesignerIcons.ToolWindowUIDesigner); myToolWindow.setAvailable(false, null); }
public TopBottomComponentWrapper(JComponent component, boolean top) { super(new BorderLayout()); myWrappee = component; setOpaque(false); setBorder(new SideBorder(null, top ? SideBorder.BOTTOM : SideBorder.TOP) { @Override public Color getLineColor() { Color result = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.TEARLINE_COLOR); return result == null ? JBColor.BLACK : result; } }); add(component); }
@Override public String setupUIComponentPresentation(String text, int highlightStartOffset, int highlightEndOffset, boolean isDisabled, boolean strikeout, boolean isDisabledBeforeHighlight, Color background) { final String resultedText = myPanels[i].setup(text, myEscapeFunction, highlightStartOffset, highlightEndOffset, isDisabled, strikeout, isDisabledBeforeHighlight, background); myPanels[i].setBorder(isLastParameterOwner() ? BACKGROUND_BORDER : new SideBorder(new JBColor(JBColor.LIGHT_GRAY, Gray._90), SideBorder.BOTTOM)); return resultedText; }
private void initConsoleUI(Process process) { // Init console view myConsoleView = createConsoleView(); if (myConsoleView instanceof JComponent) { ((JComponent)myConsoleView).setBorder(new SideBorder(JBColor.border(), SideBorder.LEFT)); } myProcessHandler = createProcessHandler(process); myConsoleExecuteActionHandler = createExecuteActionHandler(); ProcessTerminatedListener.attach(myProcessHandler); myProcessHandler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(ProcessEvent event) { finishConsole(); } }); // Attach to process myConsoleView.attachToProcess(myProcessHandler); // Runner creating createContentDescriptorAndActions(); // Run myProcessHandler.startNotify(); }
@Override protected JComponent createCenterPanel() { JComponent mainPanel = myEditor.createComponent(); mainPanel.setPreferredSize(new Dimension(600, 400)); mainPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.ALL)); return mainPanel; }
@Override protected JComponent createToolbar() { JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); // Create a layout where there are three toolbars: // +----------------------------------------------------------------------------+ // | Normal toolbar, minus dynamic actions | // +---------------------------------------------+------------------------------+ // | Dynamic layout actions | Zoom actions and file status | // +---------------------------------------------+------------------------------+ ActionManager actionManager = ActionManager.getInstance(); ActionToolbar actionToolbar = actionManager.createActionToolbar(TOOLBAR, getActionGroup(), true); actionToolbar.setLayoutPolicy(ActionToolbar.WRAP_LAYOUT_POLICY); panel.add(actionToolbar.getComponent(), BorderLayout.NORTH); ActionToolbar layoutToolBar = actionManager.createActionToolbar(TOOLBAR, getDynamicActionGroup(), true); layoutToolBar.setLayoutPolicy(ActionToolbar.WRAP_LAYOUT_POLICY); // The default toolbar layout adds too much spacing between the buttons. Switch to mini mode, // but also set a minimum size which will add *some* padding for our 16x16 icons. layoutToolBar.setMiniMode(true); layoutToolBar.setMinimumButtonSize(new Dimension(22, 24)); ActionToolbar zoomToolBar = actionManager.createActionToolbar(TOOLBAR, getRhsActions(), true); JPanel bottom = new JPanel(new BorderLayout()); bottom.add(layoutToolBar.getComponent(), BorderLayout.WEST); RenderContext context = (AndroidDesignerEditorPanel)myDesigner; RenderOptionsMenuBuilder optionsMenuBuilder = RenderOptionsMenuBuilder.create(context); ActionToolbar optionsToolBar = optionsMenuBuilder.addPreferXmlOption().addDeviceFrameOption().addRetinaOption().build(); JPanel combined = new JPanel(new BorderLayout()); combined.add(zoomToolBar.getComponent(), BorderLayout.WEST); combined.add(optionsToolBar.getComponent(), BorderLayout.EAST); bottom.add(combined, BorderLayout.EAST); panel.add(bottom, BorderLayout.SOUTH); return panel; }
public void initContent() { final ActionManager actionManager = ActionManager.getInstance(); final ActionGroup actionGroup = (ActionGroup)actionManager.getAction(TOOL_WINDOW_TOOLBAR_ID); ActionToolbar actionToolbar = actionManager.createActionToolbar(myPlace, actionGroup, true); JPanel toolbarControl = new JPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.weightx = 1; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.WEST; toolbarControl.add(actionToolbar.getComponent(), constraints); for (JComponent component : getToolbarControls()) { component.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP)); toolbarControl.add(component, constraints); } setToolbar(toolbarControl); final JComponent payloadControl = buildContent(); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(payloadControl); JScrollBar scrollBar = scrollPane.getVerticalScrollBar(); scrollBar.setUnitIncrement(scrollBar.getUnitIncrement() * 7); myContent.add(scrollPane, CONTENT_CARD_NAME); RichTextControlBuilder builder = new RichTextControlBuilder(); builder.setBackgroundColor(payloadControl.getBackground()); builder.setForegroundColor(UIUtil.getInactiveTextColor()); builder.setFont(payloadControl.getFont()); builder.setText(GradleBundle.message("gradle.toolwindow.text.no.linked.project")); final JComponent noLinkedProjectControl = builder.build(); myContent.add(noLinkedProjectControl, NON_LINKED_CARD_NAME); update(); }
public DesignerToolWindow(Project project) { myComponentTree = new ComponentTree(project); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myComponentTree); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); scrollPane.setPreferredSize(new Dimension(250, -1)); myComponentTree.initQuickFixManager(scrollPane.getViewport()); myPropertyInspector = new PropertyInspector(project, myComponentTree); myToolWindowPanel.setFirstComponent(scrollPane); myToolWindowPanel.setSecondComponent(myPropertyInspector); }
protected JComponent createToolbar() { ActionManager actionManager = ActionManager.getInstance(); ActionToolbar actionToolbar = actionManager.createActionToolbar(TOOLBAR, myActionGroup, true); actionToolbar.setLayoutPolicy(ActionToolbar.WRAP_LAYOUT_POLICY); JComponent toolbar = actionToolbar.getComponent(); toolbar.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); toolbar.setVisible(false); return toolbar; }
public TopBottomComponentWrapper(JComponent component, boolean top) { super(new BorderLayout()); setOpaque(false); setBorder(new SideBorder(null, top ? SideBorder.BOTTOM : SideBorder.TOP, true) { @Override public Color getLineColor() { Color result = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.TEARLINE_COLOR); return result == null ? Color.black : result; } }); add(component); }
@Override public void setupUIComponentPresentation(String text, int highlightStartOffset, int highlightEndOffset, boolean isDisabled, boolean strikeout, boolean isDisabledBeforeHighlight, Color background) { myPanels[i].setup(text, highlightStartOffset, highlightEndOffset, isDisabled, strikeout, isDisabledBeforeHighlight, background); myPanels[i].setBorder(isLastParameterOwner() ? BACKGROUND_BORDER : new SideBorder(new JBColor(JBColor.LIGHT_GRAY, Gray._90), SideBorder.BOTTOM)); }
public DesignerToolWindow(Project project, boolean updateOrientation) { myComponentTree = new ComponentTree(); JScrollPane treeScrollPane = ScrollPaneFactory.createScrollPane(myComponentTree); treeScrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); treeScrollPane.setPreferredSize(new Dimension(250, -1)); myComponentTree.initQuickFixManager(treeScrollPane.getViewport()); myPropertyTablePanel = new PropertyTablePanel(project); myToolWindowPanel = new Splitter(true, 0.42f); myToolWindowPanel.setDividerWidth(3); myToolWindowPanel.setShowDividerControls(false); myToolWindowPanel.setShowDividerIcon(false); myToolWindowPanel.setFirstComponent(treeScrollPane); myToolWindowPanel.setSecondComponent(myPropertyTablePanel); if (updateOrientation) { myToolWindowPanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { Dimension size = myToolWindowPanel.getSize(); boolean newVertical = size.width < size.height; if (myToolWindowPanel.getOrientation() != newVertical) { myToolWindowPanel.setOrientation(newVertical); } } }); } }
public CordovaDesignerToolWindow(Project project, boolean updateOrientation) { myComponentTree = new ComponentTree(); JScrollPane treeScrollPane = ScrollPaneFactory.createScrollPane(myComponentTree); treeScrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); treeScrollPane.setPreferredSize(new Dimension(250, -1)); myComponentTree.initQuickFixManager(treeScrollPane.getViewport()); myPropertyTablePanel = new PropertyTablePanel(project); myToolWindowPanel = new Splitter(true, 0.42f); myToolWindowPanel.setDividerWidth(3); myToolWindowPanel.setShowDividerControls(false); myToolWindowPanel.setShowDividerIcon(false); myToolWindowPanel.setFirstComponent(treeScrollPane); myToolWindowPanel.setSecondComponent(myPropertyTablePanel); if (updateOrientation) { myToolWindowPanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { Dimension size = myToolWindowPanel.getSize(); boolean newVertical = size.width < size.height; if (myToolWindowPanel.getOrientation() != newVertical) { myToolWindowPanel.setOrientation(newVertical); } } }); } }
@Nonnull private static SideBorder createTopBottomSideBorder(boolean top) { return new SideBorder(null, top ? SideBorder.BOTTOM : SideBorder.TOP) { @Override public Color getLineColor() { Color result = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.TEARLINE_COLOR); return result == null ? JBColor.BLACK : result; } }; }
/** * Launch process, setup history, actions etc. * * @throws ExecutionException */ public void initAndRun() throws ExecutionException { // Create Server process final Process process = createProcess(); UIUtil.invokeLaterIfNeeded(() -> { // Init console view myConsoleView = createConsoleView(); if (myConsoleView instanceof JComponent) { ((JComponent)myConsoleView).setBorder(new SideBorder(JBColor.border(), SideBorder.LEFT)); } myProcessHandler = createProcessHandler(process); myConsoleExecuteActionHandler = createExecuteActionHandler(); ProcessTerminatedListener.attach(myProcessHandler); myProcessHandler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(ProcessEvent event) { finishConsole(); } }); // Attach to process myConsoleView.attachToProcess(myProcessHandler); // Runner creating createContentDescriptorAndActions(); // Run myProcessHandler.startNotify(); }); }
public ThreadDumpPanel(Project project, final ConsoleView consoleView, final DefaultActionGroup toolbarActions, final List<ThreadState> threadDump) { super(new BorderLayout()); final ThreadState[] data = threadDump.toArray(new ThreadState[threadDump.size()]); DefaultListModel model = new DefaultListModel(); for (ThreadState threadState : data) { model.addElement(threadState); } myThreadList = new JBList(model); myThreadList.setCellRenderer(new ThreadListCellRenderer()); myThreadList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myThreadList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { int index = myThreadList.getSelectedIndex(); if (index >= 0) { ThreadState selection = (ThreadState)myThreadList.getModel().getElementAt(index); AnalyzeStacktraceUtil.printStacktrace(consoleView, selection.getStackTrace()); } else { AnalyzeStacktraceUtil.printStacktrace(consoleView, ""); } myThreadList.repaint(); } }); toolbarActions.add(new CopyToClipboardAction(threadDump, project)); toolbarActions.add(new SortThreadsAction()); //toolbarActions.add(new ShowRecentlyChanged()); add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false).getComponent(), BorderLayout.WEST); final Splitter splitter = new Splitter(false, 0.3f); splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myThreadList, SideBorder.LEFT | SideBorder.RIGHT)); splitter.setSecondComponent(consoleView.getComponent()); add(splitter, BorderLayout.CENTER); new ListSpeedSearch(myThreadList).setComparator(new SpeedSearchComparator(false, true)); }
public NewErrorTreeViewPanel(Project project, String helpId, boolean createExitAction, boolean createToolbar, @Nullable Runnable rerunAction) { myProject = project; myHelpId = helpId; myCreateExitAction = createExitAction; myConfiguration = ErrorTreeViewConfiguration.getInstance(project); setLayout(new BorderLayout()); myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return myConfiguration.isAutoscrollToSource(); } @Override protected void setAutoScrollMode(boolean state) { myConfiguration.setAutoscrollToSource(state); } }; myMessagePanel = new JPanel(new BorderLayout()); myErrorViewStructure = new ErrorViewStructure(project, canHideWarnings()); DefaultMutableTreeNode root = new DefaultMutableTreeNode(); root.setUserObject(myErrorViewStructure.createDescriptor(myErrorViewStructure.getRootElement(), null)); final DefaultTreeModel treeModel = new DefaultTreeModel(root); myTree = new Tree(treeModel) { @Override public void setRowHeight(int i) { super.setRowHeight(0); // this is needed in order to make UI calculate the height for each particular row } }; myBuilder = new ErrorViewTreeBuilder(myTree, treeModel, myErrorViewStructure); myExporterToTextFile = new ErrorViewTextExporter(myErrorViewStructure); myOccurrenceNavigatorSupport = new MyOccurrenceNavigatorSupport(myTree); myAutoScrollToSourceHandler.install(myTree); TreeUtil.installActions(myTree); UIUtil.setLineStyleAngled(myTree); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setLargeModel(true); JScrollPane scrollPane = NewErrorTreeRenderer.install(myTree); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); myMessagePanel.add(scrollPane, BorderLayout.CENTER); if (createToolbar) { add(createToolbarPanel(rerunAction), BorderLayout.WEST); } add(myMessagePanel, BorderLayout.CENTER); myTree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { navigateToSource(false); } } }); myTree.addMouseListener(new PopupHandler() { @Override public void invokePopup(Component comp, int x, int y) { popupInvoked(comp, x, y); } }); EditSourceOnDoubleClickHandler.install(myTree); }
private void setChangeDetailsPanel(@Nullable final JComponent component) { mySplitter.setSecondComponent(component); mySplitter.getFirstComponent().setBorder(component == null ? null : IdeBorderFactory.createBorder(SideBorder.RIGHT)); mySplitter.revalidate(); mySplitter.repaint(); }
@Override public String setupUIComponentPresentation(final String[] texts, final EnumSet<Flag>[] flags, final Color background) { final String resultedText = myPanels[i].setup(texts, myEscapeFunction, flags, background); myPanels[i].setBorder(isLastParameterOwner() ? BACKGROUND_BORDER : new SideBorder(new JBColor(JBColor.LIGHT_GRAY, Gray._90), SideBorder.BOTTOM)); return resultedText; }
@Override public void navigateInPreviewEditor(PreviewEditorState editorState) { final VirtualFile file = editorState.getFile(); final LogicalPosition positionToNavigate = editorState.getNavigate(); final TextAttributes lineAttributes = editorState.getAttributes(); Document document = FileDocumentManager.getInstance().getDocument(file); Project project = myProject; clearEditor(); myEditorState = editorState; remove(myLabel); if (document != null) { if (getEditor() == null || getEditor().getDocument() != document) { setEditor(EditorFactory.getInstance().createViewer(document, project)); final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project); ((EditorEx)getEditor()).setFile(file); ((EditorEx)getEditor()).setHighlighter(highlighter); getEditor().getSettings().setAnimatedScrolling(false); getEditor().getSettings().setRefrainFromScrolling(false); getEditor().getSettings().setLineNumbersShown(true); getEditor().getSettings().setFoldingOutlineShown(false); ((EditorEx)getEditor()).getFoldingModel().setFoldingEnabled(false); add(getEditor().getComponent(), BorderLayout.CENTER); } if (positionToNavigate != null) { getEditor().getCaretModel().moveToLogicalPosition(positionToNavigate); validate(); getEditor().getScrollingModel().scrollToCaret(ScrollType.CENTER); } getEditor().setBorder(IdeBorderFactory.createBorder(SideBorder.TOP)); clearHighlighting(); if (lineAttributes != null && positionToNavigate != null && positionToNavigate.line < getEditor().getDocument().getLineCount()) { myHighlighter = getEditor().getMarkupModel().addLineHighlighter(positionToNavigate.line, HighlighterLayer.SELECTION - 1, lineAttributes); } } else { myLabel.setText("Navigate to selected " + (file.isDirectory() ? "directory " : "file ") + "in Project View"); add(myLabel, BorderLayout.CENTER); validate(); } }
public static JScrollPane install(JTree tree) { JScrollPane scrollPane = MultilineTreeCellRenderer.installRenderer(tree, new MessageTreeRenderer()); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); return scrollPane; }
public PropertyInspector(Project project, @NotNull final ComponentTree componentTree) { super(new CardLayout()); myInspectorTable = new PropertyInspectorTable(project, componentTree); myComponentTree = componentTree; // Card with property inspector final JPanel inspectorCard = new JPanel(new GridBagLayout()); final JScrollPane inspectorScrollPane = ScrollPaneFactory.createScrollPane(myInspectorTable); inspectorScrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); inspectorCard.add(inspectorScrollPane, new GridBagConstraints(0, 0, 0, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0) ); final JCheckBox chkShowExpertProperties = new JCheckBox(UIDesignerBundle.message("chk.show.expert.properties")); inspectorCard.add( chkShowExpertProperties, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0) ); chkShowExpertProperties.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { myInspectorTable.setShowExpertProperties(chkShowExpertProperties.isSelected()); } } ); add(inspectorCard, INSPECTOR_CARD); // Empty card final MultiLineLabel label = new MultiLineLabel(UIDesignerBundle.message("label.select.single.component.to.edit.its.properties")){ public void updateUI() { super.updateUI(); setBackground(myInspectorTable.getBackground()); } }; label.setOpaque(true); label.setHorizontalAlignment(SwingConstants.CENTER); add(label, EMPTY_CARD); add(myCustomPropertiesScrollPane, CUSTOM_CARD); myComponentSelectionListener = new MyComponentSelectionListener(); synchWithTree(false); // Install light bulb myQuickFixManager = new QuickFixManagerImpl(null, myInspectorTable, inspectorScrollPane.getViewport()); myCustomPropertiesChangeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { if (myPropertiesPanelContainer != null) { myPropertiesPanelContainer.revalidate(); } if (myEditor.ensureEditable()) { myEditor.refreshAndSave(true); } } }; }
public DesignerToolWindow(Project project, boolean updateOrientation) { myComponentTree = new ComponentTree(); JScrollPane treeScrollPane = ScrollPaneFactory.createScrollPane(myComponentTree); treeScrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); treeScrollPane.setPreferredSize(new Dimension(250, -1)); myComponentTree.initQuickFixManager(treeScrollPane.getViewport()); myPropertyTablePanel = new PropertyTablePanel(project); myToolWindowPanel = new Splitter(true, 0.42f) { @Override public void doLayout() { super.doLayout(); JComponent firstComponent = getFirstComponent(); JComponent secondComponent = getSecondComponent(); if (firstComponent == null || secondComponent == null) { return; } int firstHeight = firstComponent.getHeight(); int dividerHeight = getDivider().getHeight(); int height = getSize().height; if (firstHeight + dividerHeight + secondComponent.getHeight() != height) { Rectangle bounds = secondComponent.getBounds(); bounds.height = height - firstHeight - dividerHeight; secondComponent.setBounds(bounds); } } }; myToolWindowPanel.setDividerWidth(3); myToolWindowPanel.setShowDividerControls(false); myToolWindowPanel.setShowDividerIcon(false); myToolWindowPanel.setFirstComponent(treeScrollPane); myToolWindowPanel.setSecondComponent(myPropertyTablePanel); if (updateOrientation) { myToolWindowPanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { Dimension size = myToolWindowPanel.getSize(); boolean newVertical = size.width < size.height; if (myToolWindowPanel.getOrientation() != newVertical) { myToolWindowPanel.setOrientation(newVertical); } } }); } }
public PropertyTablePanel(final Project project) { myPropertyTable = new RadPropertyTable(project) { @Override protected void updateEditActions() { updateActions(); } }; setLayout(new GridBagLayout()); int gridX = 0; myTitleLabel = new JLabel(DesignerBundle.message("designer.properties.title")); myTitleLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); add(myTitleLabel, new GridBagConstraints(gridX++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 10), 0, 0) ); ActionManager actionManager = ActionManager.getInstance(); DefaultActionGroup actionGroup = new DefaultActionGroup(); ShowJavadoc showJavadoc = new ShowJavadoc(myPropertyTable); showJavadoc.registerCustomShortcutSet(actionManager.getAction(IdeActions.ACTION_QUICK_JAVADOC).getShortcutSet(), myPropertyTable); actionGroup.add(showJavadoc); actionGroup.addSeparator(); RestoreDefault restoreDefault = new RestoreDefault(myPropertyTable); restoreDefault.registerCustomShortcutSet(actionManager.getAction(IdeActions.ACTION_DELETE).getShortcutSet(), myPropertyTable); actionGroup.add(restoreDefault); actionGroup.add(new ShowExpert(myPropertyTable)); myTabPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0)); add(myTabPanel, new GridBagConstraints(gridX++, 0, 1, 1, 1, 0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0) ); myActionPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0)); add(myActionPanel, new GridBagConstraints(gridX++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(2, 0, 2, 2), 0, 0) ); myActions = actionGroup.getChildren(null); for (AnAction action : myActions) { if (action instanceof Separator) { continue; } Presentation presentation = action.getTemplatePresentation(); ActionButton button = new ActionButton(action, presentation, ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); myActionPanel.add(button); presentation.putClientProperty(BUTTON_KEY, button); } actionGroup.add(new ShowColumns(myPropertyTable)); PopupHandler.installPopupHandler(myPropertyTable, actionGroup, ActionPlaces.GUI_DESIGNER_PROPERTY_INSPECTOR_POPUP, actionManager); myPropertyTable.getSelectionModel().addListSelectionListener(this); valueChanged(null); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myPropertyTable); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP)); myPropertyTable.initQuickFixManager(scrollPane.getViewport()); add(scrollPane, new GridBagConstraints(0, 1, gridX, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); myPropertyTable.setPropertyTablePanel(this); addMouseListener(new MouseAdapter() { public void mouseReleased(final MouseEvent e) { IdeFocusManager.getInstance(project).requestFocus(myPropertyTable, true); } }); }
public PantsConsoleViewPanel(Project project) { myProject = project; myConfiguration = ErrorTreeViewConfiguration.getInstance(project); setLayout(new BorderLayout()); myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return myConfiguration.isAutoscrollToSource(); } @Override protected void setAutoScrollMode(boolean state) { myConfiguration.setAutoscrollToSource(state); } }; JPanel myMessagePanel = new JPanel(new BorderLayout()); DefaultMutableTreeNode root = new DefaultMutableTreeNode(); final DefaultTreeModel treeModel = new DefaultTreeModel(root); myTree = createTree(treeModel); myTree.getEmptyText().setText(IdeBundle.message("errortree.noMessages")); myAutoScrollToSourceHandler.install(myTree); TreeUtil.installActions(myTree); UIUtil.setLineStyleAngled(myTree); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setLargeModel(true); JScrollPane scrollPane = NewErrorTreeRenderer.install(myTree); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); myMessagePanel.add(PantsConsoleManager.getOrMakeNewConsole(myProject).getComponent(), BorderLayout.CENTER); add(createToolbarPanel(), BorderLayout.WEST); add(myMessagePanel, BorderLayout.CENTER); EditSourceOnDoubleClickHandler.install(myTree); }
private TablessBorder() { super(UIUtil.getBorderColor(), SideBorder.ALL); }
public NewErrorTreeViewPanel(Project project, String helpId, boolean createExitAction, boolean createToolbar, @Nullable Runnable rerunAction) { myProject = project; myHelpId = helpId; myCreateExitAction = createExitAction; myConfiguration = ErrorTreeViewConfiguration.getInstance(project); setLayout(new BorderLayout()); myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { protected boolean isAutoScrollMode() { return myConfiguration.isAutoscrollToSource(); } protected void setAutoScrollMode(boolean state) { myConfiguration.setAutoscrollToSource(state); } }; myMessagePanel = new JPanel(new BorderLayout()); myErrorViewStructure = new ErrorViewStructure(project, canHideWarnings()); DefaultMutableTreeNode root = new DefaultMutableTreeNode(); root.setUserObject(myErrorViewStructure.createDescriptor(myErrorViewStructure.getRootElement(), null)); final DefaultTreeModel treeModel = new DefaultTreeModel(root); myTree = new Tree(treeModel) { public void setRowHeight(int i) { super.setRowHeight(0); // this is needed in order to make UI calculate the height for each particular row } }; myBuilder = new ErrorViewTreeBuilder(myTree, treeModel, myErrorViewStructure); myExporterToTextFile = new ErrorViewTextExporter(myErrorViewStructure); myOccurenceNavigatorSupport = new MyOccurenceNavigatorSupport(myTree); myAutoScrollToSourceHandler.install(myTree); TreeUtil.installActions(myTree); UIUtil.setLineStyleAngled(myTree); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setLargeModel(true); JScrollPane scrollPane = NewErrorTreeRenderer.install(myTree); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); myMessagePanel.add(scrollPane, BorderLayout.CENTER); if (createToolbar) { add(createToolbarPanel(rerunAction), BorderLayout.WEST); } add(myMessagePanel, BorderLayout.CENTER); myTree.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { navigateToSource(false); } } }); myTree.addMouseListener(new PopupHandler() { public void invokePopup(Component comp, int x, int y) { popupInvoked(comp, x, y); } }); EditSourceOnDoubleClickHandler.install(myTree); }
@Override public void setupUIComponentPresentation(final String[] texts, final EnumSet<Flag>[] flags, final Color background) { myPanels[i].setup(texts, flags, background); myPanels[i].setBorder(isLastParameterOwner() ? BACKGROUND_BORDER : new SideBorder(new JBColor(JBColor.LIGHT_GRAY, Gray._90), SideBorder.BOTTOM)); }
private void initConsoleUI(Process process) { // Init console view myConsoleView = createConsoleView(); myConsoleView.setBorder(new SideBorder(UIUtil.getBorderColor(), SideBorder.LEFT)); myProcessHandler = createProcessHandler(process); myConsoleExecuteActionHandler = createConsoleExecuteActionHandler(); ProcessTerminatedListener.attach(myProcessHandler); myProcessHandler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(ProcessEvent event) { finishConsole(); } }); // Attach to process myConsoleView.attachToProcess(myProcessHandler); // Runner creating final Executor defaultExecutor = DefaultRunExecutor.getRunExecutorInstance(); final DefaultActionGroup toolbarActions = new DefaultActionGroup(); final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false); // Runner creating final JPanel panel = new JPanel(new BorderLayout()); panel.add(actionToolbar.getComponent(), BorderLayout.WEST); panel.add(myConsoleView.getComponent(), BorderLayout.CENTER); actionToolbar.setTargetComponent(panel); final RunContentDescriptor contentDescriptor = new RunContentDescriptor(myConsoleView, myProcessHandler, panel, constructConsoleTitle(myConsoleTitle)); contentDescriptor.setFocusComputable(new Computable<JComponent>() { @Override public JComponent compute() { final EditorEx editor = getLanguageConsole().getConsoleEditor(); return editor != null ? editor.getContentComponent() : null; } }); contentDescriptor.setAutoFocusContent(isAutoFocusContent()); // tool bar actions final List<AnAction> actions = fillToolBarActions(toolbarActions, defaultExecutor, contentDescriptor); registerActionShortcuts(actions, getLanguageConsole().getConsoleEditor().getComponent()); registerActionShortcuts(actions, panel); panel.updateUI(); showConsole(defaultExecutor, contentDescriptor); // Run myProcessHandler.startNotify(); }
@Override public void navigateInPreviewEditor(PreviewEditorState editorState) { myEditorState = editorState; final VirtualFile file = editorState.getFile(); final LogicalPosition positionToNavigate = editorState.getNavigate(); final TextAttributes lineAttributes = editorState.getAttributes(); Document document = FileDocumentManager.getInstance().getDocument(file); Project project = myProject; clearEditor(); remove(myLabel); if (document != null) { if (getEditor() == null || getEditor().getDocument() != document) { setEditor(EditorFactory.getInstance().createViewer(document, project)); final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project); ((EditorEx)getEditor()).setFile(file); ((EditorEx)getEditor()).setHighlighter(highlighter); getEditor().getSettings().setAnimatedScrolling(false); getEditor().getSettings().setRefrainFromScrolling(false); getEditor().getSettings().setLineNumbersShown(true); getEditor().getSettings().setFoldingOutlineShown(false); add(getEditor().getComponent(), BorderLayout.CENTER); } getEditor().getCaretModel().moveToLogicalPosition(positionToNavigate); validate(); getEditor().getScrollingModel().scrollToCaret(ScrollType.CENTER); getEditor().setBorder(IdeBorderFactory.createBorder(SideBorder.TOP)); clearHightlighting(); if (lineAttributes != null) { myHighlighter = getEditor().getMarkupModel().addLineHighlighter(positionToNavigate.line, HighlighterLayer.SELECTION - 1, lineAttributes); } } else { myLabel.setText("Navigate to selected " + (file.isDirectory() ? "directory " : "file ") + "in Project View"); add(myLabel, BorderLayout.CENTER); validate(); } }
private void createUI() { if (cellRenderer == null || list == null) { cellRenderer = new ThumbnailListCellRenderer(); ImageComponent imageComponent = cellRenderer.getImageComponent(); VirtualFileManager.getInstance().addVirtualFileListener(vfsListener); Options options = OptionsManager.getInstance().getOptions(); EditorOptions editorOptions = options.getEditorOptions(); // Set options TransparencyChessboardOptions chessboardOptions = editorOptions.getTransparencyChessboardOptions(); imageComponent.setTransparencyChessboardVisible(chessboardOptions.isShowDefault()); imageComponent.setTransparencyChessboardCellSize(chessboardOptions.getCellSize()); imageComponent.setTransparencyChessboardWhiteColor(chessboardOptions.getWhiteColor()); imageComponent.setTransparencyChessboardBlankColor(chessboardOptions.getBlackColor()); options.addPropertyChangeListener(optionsListener); list = new JBList(); list.setModel(new DefaultListModel()); list.setLayoutOrientation(JList.HORIZONTAL_WRAP); list.setVisibleRowCount(-1); list.setCellRenderer(cellRenderer); list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); ThumbnailsMouseAdapter mouseListener = new ThumbnailsMouseAdapter(); list.addMouseListener(mouseListener); list.addMouseMotionListener(mouseListener); ThumbnailComponentUI componentUI = (ThumbnailComponentUI) UIManager.getUI(cellRenderer); Dimension preferredSize = componentUI.getPreferredSize(cellRenderer); list.setFixedCellWidth(preferredSize.width); list.setFixedCellHeight(preferredSize.height); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP)); ActionManager actionManager = ActionManager.getInstance(); ActionGroup actionGroup = (ActionGroup) actionManager.getAction(ThumbnailViewActions.GROUP_TOOLBAR); ActionToolbar actionToolbar = actionManager.createActionToolbar( ThumbnailViewActions.ACTION_PLACE, actionGroup, true ); actionToolbar.setTargetComponent(this); JComponent toolbar = actionToolbar.getComponent(); FocusRequester focusRequester = new FocusRequester(); toolbar.addMouseListener(focusRequester); scrollPane.addMouseListener(focusRequester); add(toolbar, BorderLayout.NORTH); add(scrollPane, BorderLayout.CENTER); } }
public PropertyTablePanel(final Project project) { myPropertyTable = new RadPropertyTable(project); setLayout(new GridBagLayout()); int gridX = 0; myTitleLabel = new JLabel(DesignerBundle.message("designer.properties.title")); myTitleLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); add(myTitleLabel, new GridBagConstraints(gridX++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 10), 0, 0)); ActionManager actionManager = ActionManager.getInstance(); DefaultActionGroup actionGroup = new DefaultActionGroup(); ShowJavadoc showJavadoc = new ShowJavadoc(myPropertyTable); showJavadoc.registerCustomShortcutSet(actionManager.getAction(IdeActions.ACTION_QUICK_JAVADOC).getShortcutSet(), myPropertyTable); actionGroup.add(showJavadoc); actionGroup.addSeparator(); RestoreDefault restoreDefault = new RestoreDefault(myPropertyTable); restoreDefault.registerCustomShortcutSet(actionManager.getAction(IdeActions.ACTION_DELETE).getShortcutSet(), null); actionGroup.add(restoreDefault); actionGroup.add(new ShowExpert(myPropertyTable)); myTabPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0)); add(myTabPanel, new GridBagConstraints(gridX++, 0, 1, 1, 1, 0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0)); myActionPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0)); add(myActionPanel, new GridBagConstraints(gridX++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(2, 0, 2, 2), 0, 0)); myActions = actionGroup.getChildren(null); for (int i = 0; i < myActions.length; i++) { AnAction action = myActions[i]; if (!(action instanceof Separator)) { Presentation presentation = action.getTemplatePresentation(); ActionButton button = new ActionButton(action, presentation, ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); myActionPanel.add(button); presentation.putClientProperty(BUTTON_KEY, button); } } actionGroup.add(new ShowColumns(myPropertyTable)); PopupHandler.installPopupHandler(myPropertyTable, actionGroup, ActionPlaces.GUI_DESIGNER_PROPERTY_INSPECTOR_POPUP, actionManager); myPropertyTable.getSelectionModel().addListSelectionListener(this); valueChanged(null); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myPropertyTable); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP)); myPropertyTable.initQuickFixManager(scrollPane.getViewport()); add(scrollPane, new GridBagConstraints(0, 1, gridX, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); myPropertyTable.setPropertyTablePanel(this); addMouseListener(new MouseAdapter() { public void mouseReleased(final MouseEvent e) { IdeFocusManager.getInstance(project).requestFocus(myPropertyTable, true); } }); }