use of org.eclipse.swt.widgets.Display in project cubrid-manager by CUBRID.
the class TableToPhpCodeAction method doRun.
/**
* Perform all tables
*
* @param obj
*/
private void doRun(final Object[] obj) {
final File filepath = TableUtil.getSavedDirForCreateCodes(getShell(), null);
if (filepath == null) {
return;
}
if (!CommonUITool.openConfirmBox(Messages.msgConfirmTableToCode)) {
return;
}
final Map<CubridDatabase, Connection> connections = new HashMap<CubridDatabase, Connection>();
try {
final Display display = PlatformUI.getWorkbench().getDisplay();
BusyIndicator.showWhile(display, new Runnable() {
public void run() {
// FIXME move this logic to core module
StringBuilder notExportedList = new StringBuilder();
for (int i = 0; i < obj.length; i++) {
DefaultSchemaNode table = (DefaultSchemaNode) obj[i];
Connection connection = connections.get(table.getDatabase());
if (connection == null) {
try {
connection = JDBCConnectionManager.getConnection(table.getDatabase().getDatabaseInfo(), true);
connections.put(table.getDatabase(), connection);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
if (connection == null) {
if (notExportedList.length() > 0) {
notExportedList.append(", ");
}
notExportedList.append(table.getName());
continue;
}
String pojoClassFileName = getPojoFileName(table);
String pojoClassData = getPojoString(connection, table);
String pojoClassPath = filepath.getAbsolutePath() + File.separator + pojoClassFileName;
//TODO: error handling
boolean result = FileUtil.writeToFile(pojoClassPath, pojoClassData, "utf-8");
if (!result) {
if (notExportedList.length() > 0) {
notExportedList.append(", ");
}
notExportedList.append(table.getName());
}
}
finishNotice(notExportedList.toString());
}
});
} finally {
Collection<Connection> items = connections.values();
for (Connection conn : items) {
QueryUtil.freeQuery(conn);
}
}
}
use of org.eclipse.swt.widgets.Display in project cubrid-manager by CUBRID.
the class ReformatColumnsAliasDialog method open.
public String open() {
createContents();
CommonUITool.centerShell(shell);
shell.open();
shell.layout();
Display display = getParent().getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return resultAliasText;
}
use of org.eclipse.swt.widgets.Display in project cubrid-manager by CUBRID.
the class CubridUserTableIndexLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
CubridDatabase database = ((ISchemaNode) parent).getDatabase();
if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetUserClassIndexesTask task = new GetUserClassIndexesTask(databaseInfo);
monitorCancel(monitor, new ITask[] { task });
String tableName = parent.getParent().getLabel();
List<TableIndex> indexes = task.getIndexesNames(tableName);
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
parent.removeAllChild();
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(errorMsg);
}
});
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
parent.removeAllChild();
String parentId = parent.getId();
if (indexes != null && !indexes.isEmpty()) {
for (TableIndex index : indexes) {
String indexName = index.getIndexName();
String nodeId = parentId + NODE_SEPARATOR + indexName;
String label = indexName;
List<String> dependColumns = index.getColumns();
if (dependColumns != null && !dependColumns.isEmpty()) {
String keyAttrName = index.getColumns().toString();
label += keyAttrName.replace('[', '(').replace(']', ')');
}
ICubridNode node = new DefaultSchemaNode(nodeId, label, "icons/navigator/table_index_item.png");
if (index.isPrimaryKey()) {
node.setIconPath("icons/primary_key.png");
}
node.setType(NodeType.TABLE_INDEX);
node.setModelObj(index);
node.setContainer(false);
parent.addChild(node);
}
}
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of org.eclipse.swt.widgets.Display in project cubrid-manager by CUBRID.
the class CubridPartitionedTableLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
CubridDatabase database = ((ISchemaNode) parent).getDatabase();
if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetPartitionedClassListTask task = new GetPartitionedClassListTask(databaseInfo);
monitorCancel(monitor, new ITask[] { task });
List<ClassInfo> classInfoList = task.getAllPartitionedClassInfoList(parent.getLabel());
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
parent.removeAllChild();
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(errorMsg);
}
});
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
parent.removeAllChild();
if (classInfoList != null && !classInfoList.isEmpty()) {
for (ClassInfo clasInfo : classInfoList) {
String id = parent.getId() + NODE_SEPARATOR + clasInfo.getClassName();
ICubridNode partitionedClassNode = new DefaultSchemaNode(id, clasInfo.getClassName(), "icons/navigator/schema_table_item.png");
partitionedClassNode.setType(NodeType.USER_PARTITIONED_TABLE);
partitionedClassNode.setModelObj(clasInfo);
partitionedClassNode.setContainer(false);
partitionedClassNode.setEditorId(SchemaInfoEditorPart.ID);
parent.addChild(partitionedClassNode);
}
}
database.getDatabaseInfo().addPartitionedTableList(parent.getLabel(), classInfoList);
Collections.sort(parent.getChildren());
loadColumns(parent, getLevel(), monitor);
loadIndexes(parent, getLevel(), monitor);
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of org.eclipse.swt.widgets.Display in project cubrid-manager by CUBRID.
the class CubridNodeLoader method openErrorBox.
/**
*
* Open the error box
*
* @param msg the error message
*/
protected void openErrorBox(final String msg) {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
if (msg != null && msg.trim().length() > 0) {
CommonUITool.openErrorBox(msg);
}
}
});
}
Aggregations