Search in sources :

Example 1 with ClassItem

use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassItem in project cubrid-manager by CUBRID.

the class OptimizeDialog method initial.

/**
	 *
	 * Initial the data
	 *
	 */
private void initial() {
    databaseName.setText(database.getName());
    className.add(Messages.msgAllClass, 0);
    int i = 0;
    for (ClassItem item : userClassList) {
        className.add(item.getClassname(), ++i);
    }
    className.select(0);
}
Also used : ClassItem(com.cubrid.cubridmanager.core.cubrid.table.model.ClassItem)

Example 2 with ClassItem

use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassItem in project cubrid-manager by CUBRID.

the class UnloadDatabaseAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    final CubridDatabase database = node.getDatabase();
    final UnloadDatabaseDialog dialog = new UnloadDatabaseDialog(getShell());
    dialog.setDatabase(database);
    final Shell shell = getShell();
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            monitor.beginTask(Messages.loadAllClassTaskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
                if (task instanceof GetClassListTask) {
                    GetClassListTask getClassListTask = (GetClassListTask) task;
                    List<String> allUserClassList = new ArrayList<String>();
                    DBClasses dbClasses = getClassListTask.getDbClassInfo();
                    List<ClassItem> userClassList = dbClasses == null ? null : dbClasses.getUserClassList().getClassList();
                    if (userClassList != null && !userClassList.isEmpty()) {
                        for (ClassItem userClass : userClassList) {
                            allUserClassList.add(userClass.getClassname());
                        }
                    }
                    Collections.sort(allUserClassList);
                    dialog.setUserClassList(allUserClassList);
                }
            }
            return true;
        }
    };
    ServerInfo serverInfo = database.getServer().getServerInfo();
    GetClassListTask task = new GetClassListTask(serverInfo, database.getDatabaseInfo().getCharSet());
    task.setDbName(database.getLabel());
    task.setDbStatus(OnOffType.OFF);
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (taskExcutor.isSuccess()) {
        dialog.open();
    }
}
Also used : ITask(com.cubrid.common.core.task.ITask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ClassItem(com.cubrid.cubridmanager.core.cubrid.table.model.ClassItem) GetClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetClassListTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) UnloadDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.UnloadDatabaseDialog) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DBClasses(com.cubrid.cubridmanager.core.cubrid.table.model.DBClasses)

Example 3 with ClassItem

use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassItem in project cubrid-manager by CUBRID.

the class SelectTableComp method fillTableViewer.

/**
	 * 
	 * Fill the data for table viewer
	 * 
	 * @param dbClasses DBClasses
	 */
public void fillTableViewer(DBClasses dbClasses) {
    List<Map<String, String>> classList = new ArrayList<Map<String, String>>();
    if (dbClasses != null) {
        ClassList userClassList = dbClasses.getUserClassList();
        if (userClassList != null) {
            List<ClassItem> classItemList = userClassList.getClassList();
            for (int i = 0; classItemList != null && i < classItemList.size(); i++) {
                Map<String, String> map = new HashMap<String, String>();
                ClassItem item = classItemList.get(i);
                if (item != null && !item.isVirtual()) {
                    map.put("0", item.getClassname());
                    classList.add(map);
                }
            }
        }
    }
    if (tableViewer != null && selectClassesTable != null && !selectClassesTable.isDisposed()) {
        tableViewer.setInput(classList);
        for (int i = 0; i < selectClassesTable.getColumnCount(); i++) {
            selectClassesTable.getColumn(i).pack();
        }
    }
}
Also used : ClassItem(com.cubrid.cubridmanager.core.cubrid.table.model.ClassItem) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ClassList(com.cubrid.cubridmanager.core.cubrid.table.model.ClassList) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with ClassItem

use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassItem in project cubrid-manager by CUBRID.

the class GetClassListTaskTest method testClassInfo.

public void testClassInfo() {
    if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
        return;
    System.out.println("<table.classinfo.001.req.txt>");
    GetClassListTask task = new GetClassListTask(serverInfo);
    task.setDbName("demodb");
    task.setDbStatus(OnOffType.OFF);
    task.execute();
    assertTrue(task.isSuccess());
    DBClasses classes = task.getDbClassInfo();
    ClassList classList = classes.getSystemClassList();
    List<ClassItem> list = classList.getClassList();
    assertEquals("db_root", list.get(0).getClassname());
}
Also used : ClassItem(com.cubrid.cubridmanager.core.cubrid.table.model.ClassItem) DBClasses(com.cubrid.cubridmanager.core.cubrid.table.model.DBClasses) ClassList(com.cubrid.cubridmanager.core.cubrid.table.model.ClassList)

Aggregations

ClassItem (com.cubrid.cubridmanager.core.cubrid.table.model.ClassItem)4 ClassList (com.cubrid.cubridmanager.core.cubrid.table.model.ClassList)2 DBClasses (com.cubrid.cubridmanager.core.cubrid.table.model.DBClasses)2 ArrayList (java.util.ArrayList)2 ITask (com.cubrid.common.core.task.ITask)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1 GetClassListTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetClassListTask)1 UnloadDatabaseDialog (com.cubrid.cubridmanager.ui.cubrid.database.dialog.UnloadDatabaseDialog)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Shell (org.eclipse.swt.widgets.Shell)1