/** @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { // 1. Retrieve selected table. DefaultMutableTreeNode node = (DefaultMutableTreeNode) (((BookmarkView) getComponent()).getConnectTree().getLastSelectedPathComponent()); Identifier userOb = (Identifier) (node.getUserObject()); if (userOb == null || (userOb.getType() != BookMarkPubInfo.NODE_VIEW && userOb.getType() != BookMarkPubInfo.NODE_TABLE)) { return; } EntityImpl entity = (EntityImpl) userOb.getDataObject(); Bookmark bookmark = userOb.getBookmark(); // 2. Execute the operator for SQL executing . Operatable operator = null; try { operator = OperatorFactory.getOperator( com.cattsoft.coolsql.sql.commonoperator.SQLResultProcessOperator.class); } catch (Exception e1) { LogProxy.internalError(e1); return; } String sql = ""; if (bookmark.getAdapter() != null) { sql = bookmark.getAdapter().getCountQuery(entity.getQualifiedName()); } else { sql = "SELECT count(*) FROM " + entity.getQualifiedName(); return; } List<Object> argList = new ArrayList<Object>(); argList.add(bookmark); argList.add(sql); argList.add(new Integer(ResultSetDataProcess.EXECUTE)); try { operator.operate(argList); } catch (UnifyException e2) { LogProxy.errorReport(e2); } catch (SQLException e2) { LogProxy.SQLErrorReport(e2); } }
/** * ����¼�����,��ȡ��ǰ�������ı�ؼ� * * @param e --�¼����� * @return --�������ı�ؼ� */ protected DataSetTable getCurrentTable(ActionEvent e) { if (!(e.getSource() instanceof JMenuItem)) return null; JPopupMenu popMenu = GUIUtil.getTopMenu((JMenuItem) e.getSource()); if (popMenu == null) return null; DataSetTable table = (DataSetTable) popMenu.getClientProperty(ResultSetView.DataTable); if (table == null) { LogProxy.errorMessage("can't get data table object!"); return null; } return table; }
@Override public void executeAction(ActionEvent e) { EditorPanel pane = ViewManage.getInstance().getSqlEditor().getEditorPane(); int startLine = pane.getSelectionStartLine(); int endLine = pane.getSelectionEndLine(); int lineCount = pane.getLineCount(); int endOffset = 0; int startOffset = pane.getLineStartOffset(startLine); if (lineCount - 1 == endLine) { endOffset = pane.getLineEndOffset(endLine) - 1; } else { endOffset = pane.getLineEndOffset(endLine); } try { int length = endOffset - startOffset; pane.getDocument().remove(startOffset, length); } catch (BadLocationException e1) { LogProxy.errorLog(e1.getMessage(), e1); } }