Search in sources :

Example 21 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.

the class ExportSettingPage method initTableColumnInfo.

/**
	 * load tables and columns
	 */
public void initTableColumnInfo() {
    // FIXME move this logic to core module
    tableColumMap.clear();
    try {
        ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
        progress.setCancelable(true);
        progress.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException {
                monitor.beginTask(Messages.taskLoading, 2);
                tablesOrViewLst = new ArrayList<ICubridNode>();
                Connection conn = null;
                Statement stmt = null;
                ResultSet rs = null;
                StringBuilder sql = new StringBuilder();
                sql.append("SELECT c.class_name, c.class_type ");
                sql.append("FROM db_class c, db_attribute a ");
                sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' ");
                sql.append("AND a.from_class_name IS NULL ");
                sql.append("GROUP BY c.class_name, c.class_type ");
                sql.append("ORDER BY c.class_type, c.class_name");
                String query = sql.toString();
                // [TOOLS-2425]Support shard broker
                if (CubridDatabase.hasValidDatabaseInfo(getDatabase())) {
                    query = getDatabase().getDatabaseInfo().wrapShardQuery(query);
                }
                try {
                    monitor.subTask(Messages.taskLoadingTable);
                    conn = JDBCConnectionManager.getConnection(getDatabase().getDatabaseInfo(), true);
                    stmt = conn.createStatement();
                    rs = stmt.executeQuery(query);
                    while (rs.next()) {
                        //$NON-NLS-1$
                        String tableName = rs.getString(1);
                        //$NON-NLS-1$
                        String tableType = rs.getString(2);
                        if (ConstantsUtil.isExtensionalSystemTable(tableName)) {
                            continue;
                        }
                        String iconPath = "icons/navigator/schema_table_item.png";
                        if ("VCLASS".equalsIgnoreCase(tableType)) {
                            //export all view now so don't need select view node
                            continue;
                        }
                        ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, iconPath);
                        if ("VCLASS".equalsIgnoreCase(tableType)) {
                            classNode.setData(VIEWNODEFLAG, "true");
                        } else {
                            classNode.setData(VIEWNODEFLAG, "false");
                        }
                        classNode.setContainer(true);
                        classNode.setType(NodeType.TABLE_COLUMN_FOLDER);
                        tablesOrViewLst.add(classNode);
                    }
                    QueryUtil.freeQuery(rs);
                    monitor.worked(1);
                    monitor.subTask(Messages.taskLoadingColumn);
                } catch (SQLException e) {
                    String msg = e.getErrorCode() + StringUtil.NEWLINE + Messages.importErrorHead + e.getMessage();
                    CommonUITool.openErrorBox(getShell(), msg);
                    LOGGER.error("", e);
                } finally {
                    QueryUtil.freeQuery(conn, stmt, rs);
                }
            }
        });
    } catch (Exception e) {
        LOGGER.error("", e);
    }
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SQLException(java.sql.SQLException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ResultSet(java.sql.ResultSet)

Example 22 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.

the class FileToTableMappingComposite method loadClassInfo.

public List<ICubridNode> loadClassInfo() {
    // FIXME move this logic to core module
    allTableList = new ArrayList<ICubridNode>();
    try {
        ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
        progress.setCancelable(true);
        progress.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException {
                monitor.beginTask(Messages.taskLoading, 2);
                Connection conn = null;
                Statement stmt = null;
                ResultSet rsTable = null;
                try {
                    monitor.subTask(Messages.taskLoadingTable);
                    monitor.worked(1);
                    StringBuilder sql = new StringBuilder();
                    sql.append("SELECT c.class_name ");
                    sql.append("FROM db_class c, db_attribute a ");
                    sql.append("WHERE c.class_name = a.class_name AND c.is_system_class = 'NO' ");
                    sql.append("AND a.from_class_name IS NULL ");
                    sql.append("AND c.class_type = 'CLASS' ");
                    sql.append("GROUP BY c.class_name ");
                    sql.append("ORDER BY c.class_name");
                    conn = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true);
                    stmt = conn.createStatement();
                    rsTable = stmt.executeQuery(sql.toString());
                    while (rsTable.next()) {
                        //$NON-NLS-1$
                        String tableName = rsTable.getString(1);
                        if (ConstantsUtil.isExtensionalSystemTable(tableName)) {
                            continue;
                        }
                        String iconPath = "icons/navigator/schema_table_item.png";
                        ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, iconPath);
                        classNode.setContainer(true);
                        allTableList.add(classNode);
                    }
                    monitor.subTask(Messages.taskLoadingColumn);
                    monitor.worked(1);
                } catch (SQLException e) {
                    String msg = e.getErrorCode() + StringUtil.NEWLINE + Messages.importErrorHead + e.getMessage();
                    CommonUITool.openErrorBox(getShell(), msg);
                    LOGGER.error("", e);
                } finally {
                    QueryUtil.freeQuery(conn, stmt, rsTable);
                }
            }
        });
    } catch (Exception e) {
        LOGGER.error("", e);
    }
    return allTableList;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) Connection(java.sql.Connection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SQLException(java.sql.SQLException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ResultSet(java.sql.ResultSet)

Example 23 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.

the class ExportTableDefinitionProgress method export.

/**
	 * createDatabaseWithProgress return database name
	 *
	 * @return Catalog
	 */
public boolean export() {
    Display display = Display.getDefault();
    display.syncExec(new Runnable() {

        public void run() {
            try {
                new ProgressMonitorDialog(null).run(true, false, ExportTableDefinitionProgress.this);
            } catch (Exception e) {
                LOGGER.error("", e);
            }
        }
    });
    return success;
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) SQLException(java.sql.SQLException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Display(org.eclipse.swt.widgets.Display)

Example 24 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.

the class LoadTableRecordCountsProgress method getTableCounts.

/**
	 * loadTablesInfo
	 * 
	 * @return Catalog
	 */
public void getTableCounts() {
    Display display = Display.getDefault();
    display.syncExec(new Runnable() {

        public void run() {
            try {
                new ProgressMonitorDialog(null).run(true, true, LoadTableRecordCountsProgress.this);
            } catch (Exception e) {
                LOGGER.error("", e);
            }
        }
    });
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) SQLException(java.sql.SQLException) Display(org.eclipse.swt.widgets.Display)

Example 25 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.

the class OpenViewsDetailInfoPartProgress method loadViewsInfo.

/**
	 * loadViewsInfo
	 *
	 * @return Catalog
	 */
public void loadViewsInfo() {
    Display display = Display.getDefault();
    display.syncExec(new Runnable() {

        public void run() {
            try {
                new ProgressMonitorDialog(null).run(true, false, OpenViewsDetailInfoPartProgress.this);
            } catch (Exception e) {
                LOGGER.error(e.getMessage(), e);
            }
        }
    });
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) Display(org.eclipse.swt.widgets.Display)

Aggregations

ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)315 InvocationTargetException (java.lang.reflect.InvocationTargetException)250 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)241 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)207 CoreException (org.eclipse.core.runtime.CoreException)79 IOException (java.io.IOException)68 ArrayList (java.util.ArrayList)66 Shell (org.eclipse.swt.widgets.Shell)55 PartInitException (org.eclipse.ui.PartInitException)49 List (java.util.List)44 HashMap (java.util.HashMap)41 IResource (org.eclipse.core.resources.IResource)38 WorkspaceModifyOperation (org.eclipse.ui.actions.WorkspaceModifyOperation)37 LinkedHashMap (java.util.LinkedHashMap)34 Display (org.eclipse.swt.widgets.Display)32 EventObject (java.util.EventObject)30 BasicCommandStack (org.eclipse.emf.common.command.BasicCommandStack)30 Resource (org.eclipse.emf.ecore.resource.Resource)30 IFile (org.eclipse.core.resources.IFile)25 File (java.io.File)23