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);
}
}
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;
}
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;
}
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);
}
}
});
}
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);
}
}
});
}
Aggregations