Search in sources :

Example 91 with ISchemaNode

use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.

the class CreateSerialAction method run.

/**
	 * Open the createSerial dialog and create serial
	 */
public void run() {
    Object[] objArr = this.getSelectedObj();
    if (!isSupported(objArr)) {
        setEnabled(false);
        return;
    }
    ISchemaNode schemaNode = (ISchemaNode) objArr[0];
    CubridDatabase database = schemaNode.getDatabase();
    run(database);
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 92 with ISchemaNode

use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.

the class EditSerialAction method run.

/**
	 * get edit serial node
	 */
public void run() {
    Object[] objArr = this.getSelectedObj();
    final ISchemaNode schemaNode = (ISchemaNode) objArr[0];
    CubridDatabase database = schemaNode.getDatabase();
    run(database, schemaNode);
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 93 with ISchemaNode

use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.

the class SerialDashboardEditorPart method dropSerial.

public void dropSerial() {
    TableItem[] items = serialsDetailInfoTable.getTable().getSelection();
    if (items.length > 0) {
        List<ISchemaNode> selectNodeList = new ArrayList<ISchemaNode>();
        for (TableItem item : items) {
            SerialInfo serialInfo = (SerialInfo) item.getData();
            Set<String> typeSet = new HashSet<String>();
            typeSet.add(NodeType.SERIAL);
            ICubridNode serialNode = CommonUITool.findNode(database, typeSet, serialInfo.getName());
            selectNodeList.add((ISchemaNode) serialNode);
        }
        if (selectNodeList.size() > 0) {
            DeleteSerialAction action = (DeleteSerialAction) ActionManager.getInstance().getAction(DeleteSerialAction.ID);
            if (action == null) {
                LOGGER.error("DeleteSerialAction is a null.");
                return;
            }
            ISchemaNode[] nodeArr = new ISchemaNode[selectNodeList.size()];
            action.run(selectNodeList.toArray(nodeArr));
            refresh();
        }
    } else {
        CommonUITool.openWarningBox(Messages.errSerialNoSelection);
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DeleteSerialAction(com.cubrid.common.ui.cubrid.serial.action.DeleteSerialAction) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) SerialInfo(com.cubrid.common.core.common.model.SerialInfo) HashSet(java.util.HashSet)

Example 94 with ISchemaNode

use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.

the class ColumnSelectCountAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

        public void run() {
            Object[] obj = getSelectedObj();
            if (!isSupported(obj)) {
                setEnabled(false);
                return;
            }
            ISchemaNode column = (ISchemaNode) obj[0];
            ISchemaNode table = (ISchemaNode) column.getParent().getParent();
            String columnName = column.getName().split(",")[0];
            if ("".equals(columnName)) {
                // FIXME
                return;
            }
            CubridDatabase db = table.getDatabase();
            DatabaseInfo dbInfo = db.getDatabaseInfo();
            GetRecordCountTask task = new GetRecordCountTask(dbInfo);
            int count = task.getRecordCount(table.getName(), columnName, null);
            String[] bindings = new String[] { columnName, table.getName(), String.valueOf(count) };
            if (count > 1) {
                message = Messages.bind(Messages.columnSelectCountResult2, bindings);
            } else {
                message = Messages.bind(Messages.columnSelectCountResult1, bindings);
            }
        }
    });
    CommonUITool.openInformationBox(Messages.selectCountTitle, message);
}
Also used : GetRecordCountTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetRecordCountTask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 95 with ISchemaNode

use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.

the class ColumnSelectSqlAction method run.

public void run() {
    Object[] objs = this.getSelectedObj();
    if (!isSupported(objs)) {
        setEnabled(false);
        return;
    }
    ISchemaNode table = (ISchemaNode) ((ISchemaNode) objs[0]).getParent().getParent();
    StringBuilder buf = new StringBuilder();
    for (int i = 0; i < objs.length; i++) {
        ISchemaNode columnNode = (ISchemaNode) objs[i];
        String column = columnNode.getName().split(",")[0];
        buf.append(QuerySyntax.escapeKeyword(column));
        if (i != objs.length - 1) {
            buf.append(',');
        }
    }
    String cols = buf.toString();
    if (StringUtil.isEmpty(cols)) {
        return;
    }
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    QueryUnit input = new QueryUnit();
    input.setDatabase(table.getDatabase());
    try {
        QueryEditorPart editor = (QueryEditorPart) window.getActivePage().openEditor(input, QueryEditorPart.ID);
        editor.connect(table.getDatabase());
        // FIXME move this logic to core module
        String escapedTableName = QuerySyntax.escapeKeyword(table.getName());
        String sql = "SELECT " + cols + " FROM " + escapedTableName + ";";
        editor.setQuery(sql, false, true, false);
    } catch (PartInitException e) {
        LOGGER.error(e.getMessage());
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) QueryUnit(com.cubrid.common.ui.query.editor.QueryUnit) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)158 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)104 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)55 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)30 ArrayList (java.util.ArrayList)28 TreeViewer (org.eclipse.jface.viewers.TreeViewer)27 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)23 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)23 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)22 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)22 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)21 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)21 Shell (org.eclipse.swt.widgets.Shell)16 ITask (com.cubrid.common.core.task.ITask)13 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)13 IEditorPart (org.eclipse.ui.IEditorPart)12 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)12 HashSet (java.util.HashSet)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 PartInitException (org.eclipse.ui.PartInitException)10