use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class JobAutoDashboardEditorPart method editQueryPlan.
public void editQueryPlan() {
TableItem[] items = queryPlanInfoTable.getTable().getSelection();
if (items.length != 0) {
TableItem item = items[0];
QueryPlanInfo queryPlanInfo = (QueryPlanInfo) item.getData();
Set<String> typeSet = new HashSet<String>();
typeSet.add(CubridNodeType.QUERY_PLAN);
ICubridNode queryPlanNode = findAutoJobInfoNode(CubridNodeType.QUERY_PLAN, queryPlanInfo.getQuery_id());
if (queryPlanNode != null) {
EditQueryPlanAction action = (EditQueryPlanAction) ActionManager.getInstance().getAction(EditQueryPlanAction.ID);
if (action.run(database, (DefaultSchemaNode) queryPlanNode) == IDialogConstants.OK_ID) {
refreshQueryPlan();
}
}
} else {
CommonUITool.openWarningBox(Messages.errJobAutoNoSelection);
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class JobAutoDashboardEditorPart method findAutoJobInfoNode.
/**
* find queryPlanoNode or backupPlanNode from treeView
*
* @param nodeType String
* @param nodeType id
* @return
*/
public ICubridNode findAutoJobInfoNode(String nodeType, String id) {
Set<String> typeSet = new HashSet<String>();
typeSet.add(nodeType);
ICubridNode node = CommonUITool.findNode(database, typeSet, id);
//if backupPlanNode is null,expand the backupPlanNodeFolder then find again
if (node == null) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
ICubridNode jobAutoFolderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridDatabaseLoader.JOB_AUTO_FOLDER_ID);
String childNodeFolderID = nodeType.equals(CubridNodeType.BACKUP_PLAN) ? CubridJobAutoFolderLoader.BACKUP_PLAN_FOLDER_ID : CubridJobAutoFolderLoader.QUERY_PLAN_FOLDER_ID;
DefaultSchemaNode folderNode = (DefaultSchemaNode) jobAutoFolderNode.getChild(jobAutoFolderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + childNodeFolderID);
treeViewer.expandToLevel(folderNode, 1);
//wait 5 times expand the folder node
int time = 0;
while (folderNode.getChildren().size() == 0 && time++ < 5) {
try {
Thread.sleep(500);
} catch (Exception e) {
}
}
}
return CommonUITool.findNode(database, typeSet, id);
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class CopyToClipboardAction method doRun.
/**
* Do run
*
* @param objects
*/
protected void doRun(final Object[] objects) {
final int len = objects.length;
final Display display = PlatformUI.getWorkbench().getDisplay();
BusyIndicator.showWhile(display, new Runnable() {
public void run() {
IEditorPart ep = null;
if (isCopyToEditor) {
IWorkbenchPage activePage = LayoutUtil.getActivePage();
ep = activePage.getActiveEditor();
if (!(ep instanceof QueryEditorPart)) {
ep = openNewQueryEditor();
}
if (!(ep instanceof QueryEditorPart)) {
ep = null;
}
}
StringBuffer allTableSql = new StringBuffer();
for (int i = 0; i < len; i++) {
DefaultSchemaNode table = (DefaultSchemaNode) objects[i];
String sql = getStmtSQL(table, ep);
if (sql != null && sql.trim().length() > 0) {
allTableSql.append(sql);
allTableSql.append(StringUtil.NEWLINE);
allTableSql.append(StringUtil.NEWLINE);
}
}
if (allTableSql.length() > 0) {
if (isCopyToEditor) {
if (ep instanceof QueryEditorPart) {
((QueryEditorPart) ep).setQuery(allTableSql.toString(), true, false, false);
}
} else {
CommonUITool.copyContentToClipboard(allTableSql.toString());
}
}
}
});
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class DeleteTableAction method doRun.
/**
* Do run
*
* @param obj
*/
private void doRun(Object[] obj) {
StringBuilder sb = new StringBuilder();
final List<String> tableList = new ArrayList<String>();
CubridDatabase database = null;
for (int i = 0; i < obj.length; i++) {
DefaultSchemaNode table = (DefaultSchemaNode) obj[i];
database = table.getDatabase();
final String tableName = table.getName();
tableList.add(tableName);
if (i < 100) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(tableName);
}
}
if (obj.length > 100) {
sb.append("...");
}
String message = Messages.bind(Messages.confirmTableDeleteWarn, sb.toString());
if (!CommonUITool.openConfirmBox(message)) {
return;
}
final DelAllRecordsTask task = new DelAllRecordsTask(database.getDatabaseInfo());
TaskJobExecutor taskExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
int[] rowCount = task.getDeleteRecordsCount();
List<String> rowCountList = new ArrayList<String>();
for (int i = 0; i < rowCount.length; i++) {
rowCountList.add(String.valueOf(rowCount[i]));
}
String message = Messages.bind(Messages.resultTableDeleteInformantion, tableList, rowCountList);
CommonUITool.openInformationBox(Messages.msg_information, message);
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
String[] tableNames = new String[tableList.size()];
tableNames = tableList.toArray(tableNames);
task.setTableName(tableNames);
taskExec.addTask(task);
JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
String jobName = Messages.msgDeleteTableDataJobName + " - " + tableList.toString() + "@" + dbName + "@" + serverName;
taskExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode 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);
}
}
}
Aggregations