Search in sources :

Example 1 with ViewDetailInfo

use of com.cubrid.common.core.common.model.ViewDetailInfo in project cubrid-manager by CUBRID.

the class ViewDashboardEditorPart method dropView.

public void dropView() {
    TableItem[] items = viewsDetailInfoTable.getTable().getSelection();
    if (items.length > 0) {
        List<ISchemaNode> selectNodeList = new ArrayList<ISchemaNode>();
        for (TableItem item : items) {
            ViewDetailInfo viewInfo = (ViewDetailInfo) item.getData();
            Set<String> typeSet = new HashSet<String>();
            typeSet.add(NodeType.USER_VIEW);
            ICubridNode viewNode = CommonUITool.findNode(database, typeSet, viewInfo.getViewName());
            selectNodeList.add((ISchemaNode) viewNode);
        }
        if (selectNodeList.size() > 0) {
            DropViewAction action = (DropViewAction) ActionManager.getInstance().getAction(DropViewAction.ID);
            ISchemaNode[] nodeArr = new ISchemaNode[selectNodeList.size()];
            action.run(selectNodeList.toArray(nodeArr));
            if (!action.isCanceledTask()) {
                refresh();
            }
        }
    } else {
        CommonUITool.openWarningBox(Messages.viewDetailInfoPartTableNoSelectionMsg);
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) ViewDetailInfo(com.cubrid.common.core.common.model.ViewDetailInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) HashSet(java.util.HashSet) DropViewAction(com.cubrid.common.ui.cubrid.table.action.DropViewAction)

Example 2 with ViewDetailInfo

use of com.cubrid.common.core.common.model.ViewDetailInfo in project cubrid-manager by CUBRID.

the class OpenViewsDetailInfoPartProgress method run.

/* (non-Javadoc)
	 * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
	 */
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    // FIXME move this logic to core module
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    try {
        viewList = new ArrayList<ViewDetailInfo>();
        conn = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true);
        StringBuilder sb = new StringBuilder();
        sb.append("SELECT c.class_name, v.vclass_def, c.owner_name \n");
        sb.append("FROM db_class c, db_attribute a, db_vclass v \n");
        sb.append("WHERE c.class_name=a.class_name \n");
        sb.append("AND c.class_name=v.vclass_name \n");
        sb.append("AND c.is_system_class='NO' \n");
        sb.append("AND a.from_class_name IS NULL \n");
        sb.append("AND c.class_type='VCLASS' \n");
        sb.append("GROUP BY c.class_name, c.class_type, \n");
        //8.2.2 need to group by these 2 column
        sb.append("v.vclass_def ,c.owner_name \n");
        sb.append("ORDER BY c.class_type, c.class_name");
        stmt = conn.createStatement();
        rs = stmt.executeQuery(sb.toString());
        while (rs.next()) {
            ViewDetailInfo view = new ViewDetailInfo(rs.getString(1));
            view.setViewDef(rs.getString(2));
            view.setViewOwnerName(rs.getString(3));
            viewList.add(view);
        }
        success = true;
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    } finally {
        QueryUtil.freeQuery(conn, stmt, rs);
    }
}
Also used : Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ViewDetailInfo(com.cubrid.common.core.common.model.ViewDetailInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with ViewDetailInfo

use of com.cubrid.common.core.common.model.ViewDetailInfo in project cubrid-manager by CUBRID.

the class ViewDashboardEditorPart method createViewsDetailInfoTable.

public void createViewsDetailInfoTable(Composite parent) {
    final Composite tableComposite = new Composite(parent, SWT.NONE);
    {
        tableComposite.setLayout(new FillLayout());
        tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    }
    viewsDetailInfoTable = new TableViewer(tableComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    viewsDetailInfoTable.getTable().setHeaderVisible(true);
    viewsDetailInfoTable.getTable().setLinesVisible(true);
    final TableViewerColumn columnViewName = new TableViewerColumn(viewsDetailInfoTable, SWT.LEFT);
    columnViewName.getColumn().setWidth(150);
    columnViewName.getColumn().setText(Messages.viewDetailInfoPartColViewName);
    final TableViewerColumn scriptDescColumn = new TableViewerColumn(viewsDetailInfoTable, SWT.LEFT);
    scriptDescColumn.getColumn().setWidth(200);
    scriptDescColumn.getColumn().setText(Messages.viewDetailInfoPartTableDefColumn);
    final TableViewerColumn ownerColumn = new TableViewerColumn(viewsDetailInfoTable, SWT.LEFT);
    ownerColumn.getColumn().setWidth(80);
    ownerColumn.getColumn().setText(Messages.viewDetailInfoPartTableOwnerColumn);
    viewsDetailInfoTable.setContentProvider(new ViewsDetailTableViewerContentProvider());
    viewsDetailInfoTable.setLabelProvider(new ViewsDetailTableViewerLabelProvider());
    viewsDetailInfoTable.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            ViewDetailInfo oneViewDetail = (ViewDetailInfo) selection.getFirstElement();
            //if had opend,set it selection
            for (CTabItem tabItem : tabFolder.getItems()) {
                if (tabItem.getText().equals(oneViewDetail.getViewName())) {
                    tabFolder.setSelection(tabItem);
                    return;
                }
            }
            //if a new view info,create a new tab
            ViewDashboardComposite viewComp = new ViewDashboardComposite(tabFolder, SWT.NONE);
            viewComp.initialize();
            SchemaInfo schemaInfo = database.getDatabaseInfo().getSchemaInfo(oneViewDetail.getViewName());
            viewComp.setInput(schemaInfo);
        }
    });
    viewsDetailInfoTable.getTable().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'c') {
            }
        }
    });
    registerContextMenu();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ViewDetailInfo(com.cubrid.common.core.common.model.ViewDetailInfo) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ViewsDetailInfoCTabItem(com.cubrid.common.ui.cubrid.view.editor.ViewDashboardComposite.ViewsDetailInfoCTabItem) CTabItem(org.eclipse.swt.custom.CTabItem) KeyEvent(org.eclipse.swt.events.KeyEvent) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 4 with ViewDetailInfo

use of com.cubrid.common.core.common.model.ViewDetailInfo in project cubrid-manager by CUBRID.

the class ViewDashboardEditorPart method editView.

public void editView() {
    TableItem[] items = viewsDetailInfoTable.getTable().getSelection();
    if (items.length != 0) {
        TableItem item = items[0];
        ViewDetailInfo viewInfo = (ViewDetailInfo) item.getData();
        Set<String> typeSet = new HashSet<String>();
        typeSet.add(NodeType.USER_VIEW);
        ICubridNode viewNode = CommonUITool.findNode(database, typeSet, viewInfo.getViewName());
        if (viewNode != null) {
            EditViewAction action = (EditViewAction) ActionManager.getInstance().getAction(EditViewAction.ID);
            if (action.run(database, (ISchemaNode) viewNode) == IDialogConstants.OK_ID) {
                refresh();
            }
        }
    } else {
        CommonUITool.openWarningBox(Messages.viewDetailInfoPartTableNoSelectionMsg);
    }
}
Also used : EditViewAction(com.cubrid.common.ui.cubrid.table.action.EditViewAction) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TableItem(org.eclipse.swt.widgets.TableItem) ViewDetailInfo(com.cubrid.common.core.common.model.ViewDetailInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) HashSet(java.util.HashSet)

Example 5 with ViewDetailInfo

use of com.cubrid.common.core.common.model.ViewDetailInfo in project cubrid-manager by CUBRID.

the class ViewDashboardEditorPart method setInputs.

public void setInputs() {
    viewsDetailInfoTable.setInput(viewList);
    viewsDetailInfoTable.refresh();
    pack();
    //if a new view info,create a new tab
    ViewDashboardComposite viewComp = new ViewDashboardComposite(tabFolder, SWT.NONE);
    viewComp.initialize();
    if (viewList.size() > 0) {
        ViewDetailInfo oneViewDetail = viewList.get(0);
        SchemaInfo schemaInfo = database.getDatabaseInfo().getSchemaInfo(oneViewDetail.getViewName());
        viewComp.setInput(schemaInfo);
    }
}
Also used : ViewDetailInfo(com.cubrid.common.core.common.model.ViewDetailInfo) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Aggregations

ViewDetailInfo (com.cubrid.common.core.common.model.ViewDetailInfo)5 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)2 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)2 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)2 HashSet (java.util.HashSet)2 TableItem (org.eclipse.swt.widgets.TableItem)2 DropViewAction (com.cubrid.common.ui.cubrid.table.action.DropViewAction)1 EditViewAction (com.cubrid.common.ui.cubrid.table.action.EditViewAction)1 ViewsDetailInfoCTabItem (com.cubrid.common.ui.cubrid.view.editor.ViewDashboardComposite.ViewsDetailInfoCTabItem)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 CTabItem (org.eclipse.swt.custom.CTabItem)1