public QueryResultWindow(Project project, ConnectionManager connectionManager) { this.project = project; // DataKeys.PROJECT.getData(DataManager.getInstance().getDataContext()); this.connectionManager = connectionManager; if (connectionManager.isConnected()) { // statusLine.setSchemaName(ConnectionManagerImpl.getInstance().getDbUrl().getUserHostPortServiceName().toLowerCase()); isConnected = true; } else { // statusLine.setSchemaName("Not logged in"); // throw new IllegalStateException(); } connectionManager.addStateListener(this); }
public void close() { connectionManager.removeStateListener(this); // getTabComponent(Content content) // Project project = // DataKeys.PROJECT.getData(DataManager.getInstance().getDataContext()); ToolWindowManager toolWindowManager = null; try { toolWindowManager = ToolWindowManager.getInstance(project); } catch (Throwable e) { // todo -- fix me } if (toolWindowManager != null) { toolWindowManager.unregisterToolWindow(QUERY_RESULT_PANE); } }
/** * Set the requested content "selected" and show ToolWindow if it hided * * @param displayName * @param wait */ public void showContent(String displayName, final int wait) { // Project project = // DataKeys.PROJECT.getData(DataManager.getInstance().getDataContext()); ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); ToolWindow wm = toolWindowManager.getToolWindow(QUERY_RESULT_PANE); if (wm == null) { wm = toolWindowManager.registerToolWindow(QUERY_RESULT_PANE, true, ToolWindowAnchor.BOTTOM); wm.setIcon(Icons.QUERY_RESULT_PANE); wm.setToHideOnEmptyContent(true); } String contentName = connectionManager.getDbUrl().getUserHostPortServiceName().toLowerCase(); Content content = wm.getContentManager().findContent(contentName); if (content == null) { return; } wm.getContentManager().setSelectedContent(content); JTabbedPane tabbedPane = getTabComponent(content); int index = tabbedPane.indexOfTab(displayName); if (index == -1) { return; } tabbedPane.requestFocusInWindow(); tabbedPane.setSelectedIndex(index); if (!wm.isVisible()) { wm.activate( new Runnable() { public void run() { try { Thread.sleep(wait); } catch (InterruptedException e1) { } } // }, false); }, true); } }
@NotNull public QueryResultPanel createResultPanel( int panelType, SqlStatementMarker sqlMarker, Icon icon, String toolTip) { String contentName = connectionManager.getDbUrl().getUserHostPortServiceName().toLowerCase(); Content content = createContent(contentName); Component component = getTab(content, sqlMarker.getName()); if (panelType == QueryResultPanel.SELECT_RESULT) { if (component == null) { assertTabCount(content); return addGridPanelTab(content, sqlMarker, icon, toolTip); // } else if (component instanceof DataGridPanel) { // return (QueryResultPanel) component; } else { // component != null && !(component instanceof DataGridPanel) // replace old panel with new one removeTab(content, sqlMarker.getName()); return addGridPanelTab(content, sqlMarker, icon, toolTip); } } else if (panelType == QueryResultPanel.DML_QUERY_RESULT) { if (component == null) { assertTabCount(content); return addDMLStatsTab(content, sqlMarker, icon, toolTip); // } else if (component instanceof QueryResultPanel) { // return (QueryResultPanel) component; } else { // component != null && !(component instanceof DataGridPanel) // replace old panel with new one removeTab(content, sqlMarker.getName()); return addDMLStatsTab(content, sqlMarker, icon, toolTip); } } else { throw new NotSupportedException(); } }