use of org.eclipse.core.runtime.NullProgressMonitor in project cubrid-manager by CUBRID.
the class TableEditorPart method completeAll.
public void completeAll() {
CommonUITool.openInformationBox(Messages.titleSuccess, Messages.bind(Messages.msgNull2DefComplete, jobName));
if (this.isNewTableFlag) {
ICubridNode node = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridTablesFolderLoader.TABLES_FOLDER_ID);
if (node == null || !node.getLoader().isLoaded()) {
return;
}
String id = node.getId() + ICubridNodeLoader.NODE_SEPARATOR + tableName;
boolean isPartition = newSchemaInfo.getPartitionList() != null && newSchemaInfo.getPartitionList().size() > 0;
ClassInfo newClassInfo = new ClassInfo(tableName, owner, ClassType.NORMAL, false, isPartition);
ICubridNode newNode = CubridTablesFolderLoader.createUserTableNode(node, id, newClassInfo, node.getLoader().getLevel(), new NullProgressMonitor());
if (CubridNavigatorView.findNavigationView() == null) {
getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
return;
}
TreeViewer treeViewer = CubridNavigatorView.findNavigationView().getViewer();
if (treeViewer == null || treeViewer.getTree() == null || treeViewer.getTree().isDisposed()) {
getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
return;
}
CommonUITool.addNodeToTree(treeViewer, node, newNode);
// refresh table folder count label
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, node);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
} else {
if (database == null) {
return;
}
database.getDatabaseInfo().removeSchema(tableName);
if (oldPartitionInfoList.isEmpty() && !partitionInfoList.isEmpty()) {
editedTableNode.setIconPath("icons/navigator/schema_table_partition.png");
editedTableNode.setType(NodeType.USER_PARTITIONED_TABLE_FOLDER);
editedTableNode.setLoader(new CubridPartitionedTableLoader());
} else if (!oldPartitionInfoList.isEmpty() && partitionInfoList.isEmpty()) {
editedTableNode.setIconPath("icons/navigator/schema_table_item.png");
editedTableNode.setType(NodeType.USER_TABLE);
editedTableNode.setLoader(new CubridUserTableLoader());
}
TreeViewer treeViewer = CubridNavigatorView.findNavigationView().getViewer();
if (treeViewer == null || treeViewer.getTree() == null || treeViewer.getTree().isDisposed()) {
getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
return;
}
CommonUITool.refreshNavigatorTree(treeViewer, editedTableNode);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(editedTableNode, CubridNodeChangedEventType.NODE_REFRESH));
/* Broadcast the view changed */
QueryEditorUtil.fireSchemaNodeChanged(editedTableNode);
}
getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
}
use of org.eclipse.core.runtime.NullProgressMonitor in project cubrid-manager by CUBRID.
the class LoginQueryEditDialog method initial.
/**
* initialize some values
*
*/
private void initial() {
//load the register CUBRID server and CUBRID database
List<CubridServer> servers = CMHostNodePersistManager.getInstance().getAllServers();
serverMap = new HashMap<String, CubridServer>();
databaseMap = new HashMap<String, List<CubridDatabase>>();
allHostCombo.removeAll();
for (CubridServer server : servers) {
serverMap.put(server.getName(), server);
allHostCombo.add(server.getName());
List<ICubridNode> children = server.getChildren();
for (ICubridNode child : children) {
if (!NodeType.DATABASE_FOLDER.equals(child.getType())) {
continue;
}
ICubridNode[] dbs = child.getChildren(new NullProgressMonitor());
if (dbs.length == 0) {
continue;
}
List<CubridDatabase> dbList = new ArrayList<CubridDatabase>();
for (ICubridNode database : dbs) {
if (NodeType.DATABASE.equals(database.getType())) {
CubridDatabase db = (CubridDatabase) database;
dbList.add(db);
}
}
databaseMap.put(server.getName(), dbList);
}
}
//load the self defined CUBRID server and CUBRID database
CubridServer selfDefinedServer = DatabaseNavigatorMenu.SELF_DATABASE.getServer();
if (selfDefinedServer == null) {
selfDefinedServer = new CubridServer(DatabaseNavigatorMenu.SELF_DATABASE_ID, DatabaseNavigatorMenu.SELF_DATABASE_SELECTED_LABEL, null, null);
DatabaseNavigatorMenu.SELF_DATABASE.setServer(selfDefinedServer);
}
serverMap.put(selfDefinedServer.getName(), selfDefinedServer);
allHostCombo.add(selfDefinedServer.getName());
List<CubridDatabase> dbList = new ArrayList<CubridDatabase>();
dbList.add(DatabaseNavigatorMenu.SELF_DATABASE);
databaseMap.put(selfDefinedServer.getName(), dbList);
connectionComp.init(null, this);
changeSelection();
}
use of org.eclipse.core.runtime.NullProgressMonitor in project dbeaver by serge-rider.
the class RenameHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
SQLEditor editor = RuntimeUtils.getObjectAdapter(HandlerUtil.getActivePart(event), SQLEditor.class);
if (editor == null) {
log.error("No active SQL editor");
return null;
}
Shell shell = HandlerUtil.getActiveShell(event);
IFile file = EditorUtils.getFileFromInput(editor.getEditorInput());
if (file == null) {
UIUtils.showErrorDialog(shell, "Rename", "Can't rename - no source file");
return null;
}
String newName = EnterNameDialog.chooseName(shell, "Rename SQL script [" + file.getName() + "]", file.getName());
if (newName == null) {
return null;
}
if (newName.indexOf('.') == -1) {
int divPos = file.getName().lastIndexOf('.');
if (divPos != -1) {
newName += file.getName().substring(divPos);
}
}
if (!newName.equals(file.getName())) {
NullProgressMonitor monitor = new NullProgressMonitor();
editor.doSave(monitor);
try {
file.move(file.getParent().getFullPath().append(newName), true, monitor);
} catch (CoreException e) {
UIUtils.showErrorDialog(shell, "Rename", "Error renaming file '" + file.getName() + "'", e);
}
}
//file.set
return null;
}
use of org.eclipse.core.runtime.NullProgressMonitor in project translationstudio8 by heartsome.
the class NewTermDbBaseInfoPage method executeCreateDB.
/**
* 创建数据库
* @return ;
*/
public String executeCreateDB(SystemDBOperator dbOp, IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask("", 3);
monitor.setTaskName(Messages.getString("wizard.NewTermDbBaseInfoPage.task2"));
String message = null;
try {
if (Constants.FAILURE == dbOp.createDB()) {
message = Messages.getString("wizard.NewTermDbBaseInfoPage.msg8");
} else {
if (!dbOp.getDBConfig().getDefaultType().equals(Constants.DBTYPE_SQLITE)) {
// 更新系统库
dbOp.updataSysDb(Constants.DB_TYPE_TB);
// 处理本地服务器列表
saveToServerConfigFile(dbOp);
}
}
monitor.worked(3);
} catch (SQLException e) {
logger.error("", e);
e.printStackTrace();
message = Messages.getString("wizard.NewTermDbBaseInfoPage.msg10") + e.getMessage();
return message;
} finally {
if (message != null) {
final String _message = message;
Display.getDefault().asyncExec(new Runnable() {
public void run() {
setErrorMessage(_message);
}
});
}
monitor.done();
}
return message;
}
use of org.eclipse.core.runtime.NullProgressMonitor in project translationstudio8 by heartsome.
the class NewTermDbImportPage method executeImport.
/**
* 执行导入
* @param tmxFile
* @param tbxFile
* @param dbMetaData
* @param monitor
* ;
*/
public void executeImport(String tbxFile, MetaData dbMetaData, IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.setTaskName(Messages.getString("wizard.NewTermDbImportPage.task2"));
monitor.beginTask("", 1);
int tbxResult = -10;
String message = "";
if (tbxFile != null) {
try {
tbxResult = DatabaseService.importTbxWithFile(tbxFile, new SubProgressMonitor(monitor, 100), dbMetaData, getTbxImportStrategy());
} catch (ImportException e) {
message = e.getMessage();
}
if (!message.equals("")) {
final String _message = message;
Display.getDefault().asyncExec(new Runnable() {
public void run() {
setErrorMessage(_message);
}
});
}
}
StringBuffer resultMessage = new StringBuffer();
if (tbxResult != DatabaseService.SUCCESS) {
if (tbxResult == DatabaseService.FAILURE_1) {
resultMessage.append(Messages.getString("wizard.NewTermDbImportPage.msg1"));
} else if (tbxResult == DatabaseService.FAILURE_2) {
resultMessage.append(Messages.getString("wizard.NewTermDbImportPage.msg2"));
} else if (tbxResult == DatabaseService.FAILURE_3) {
resultMessage.append(Messages.getString("wizard.NewTermDbImportPage.msg3"));
} else if (tbxResult == DatabaseService.FAILURE_4) {
resultMessage.append(Messages.getString("wizard.NewTermDbImportPage.msg4"));
} else if (tbxResult == DatabaseService.FAILURE) {
resultMessage.append(Messages.getString("wizard.NewTermDbImportPage.msg5"));
} else if (tbxResult == DatabaseService.CANCEL) {
resultMessage.append(Messages.getString("wizard.NewTermDbImportPage.msg6"));
}
if (!resultMessage.toString().equals("")) {
final String _message = resultMessage.toString();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
setErrorMessage(_message);
}
});
}
}
monitor.done();
}
Aggregations