use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class UpdateStatisticsAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
// FIXME move this logic to core module
List<String> sqlList = new ArrayList<String>();
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < obj.length; i++) {
ISchemaNode schemaNode = (ISchemaNode) obj[i];
String tableName = schemaNode.getParent().getName();
int partitionNameLoc = schemaNode.getName().lastIndexOf("__p__");
if (partitionNameLoc == -1) {
continue;
}
partitionNameLoc += 5;
String partitionName = schemaNode.getName().substring(partitionNameLoc);
String sql = "ALTER TABLE " + QuerySyntax.escapeKeyword(tableName) + " ANALYZE PARTITION " + QuerySyntax.escapeKeyword(partitionName);
sqlList.add(sql);
buffer.append(",");
buffer.append(schemaNode.getName());
}
String str = buffer.toString().replaceFirst(",", "");
if (CommonUITool.openConfirmBox(Messages.bind(Messages.msgConfirmUpdateStatis, str))) {
DefaultSchemaNode node = (DefaultSchemaNode) obj[0];
String taskName = Messages.bind(Messages.updateStatisTaskName, node.getName());
TaskExecutor executor = new CommonTaskExec(taskName);
UpdateStatisticsTask task = new UpdateStatisticsTask(node.getDatabase().getDatabaseInfo());
task.setSqlList(sqlList);
executor.addTask(task);
new ExecTaskWithProgress(executor).exec();
if (executor.isSuccess()) {
CommonUITool.openInformationBox(Messages.titleSuccess, Messages.msgSuccessUpdateStatis);
}
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class MakeCloneQueryAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
final Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
final DefaultSchemaNode tableNode = (DefaultSchemaNode) obj[0];
CubridDatabase db = tableNode.getDatabase();
DatabaseInfo dbInfo = db.getDatabaseInfo();
GetTablesTask getTableTask = new GetTablesTask(dbInfo);
List<String> tableList = getTableTask.getAllTableAndViews();
String tableName = null;
if (NodeType.USER_TABLE.equals(tableNode.getType())) {
tableName = tableNode.getName();
}
final CloneTableDialog dialog = new CloneTableDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), tableList, tableName);
if (IDialogConstants.OK_ID == dialog.open()) {
targetName = dialog.getTargetName();
ICubridNode[] nodeArray = { tableNode };
super.doRun(nodeArray);
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class RenameTableAction method doRun.
/**
* Perform rename Table
*
* @param cubridDatabase
* @param table
*/
private void doRun(CubridDatabase cubridDatabase, ISchemaNode table) {
boolean isTable = false;
String type = table.getType();
if (NodeType.USER_TABLE.equals(type) || NodeType.USER_PARTITIONED_TABLE_FOLDER.equals(type)) {
isTable = true;
} else if (NodeType.USER_VIEW.equals(type)) {
isTable = false;
}
String tableName = table.getName();
CubridDatabase db = table.getDatabase();
DatabaseInfo dbInfo = db.getDatabaseInfo();
GetTablesTask getTableTask = new GetTablesTask(dbInfo);
List<String> tableList = getTableTask.getAllTableAndViews();
RenameTableDialog dlg = new RenameTableDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), tableName, isTable, tableList, true);
int ret = dlg.open();
if (ret == IDialogConstants.OK_ID) {
String newName = dlg.getNewName();
RenameTableOrViewTask task = new RenameTableOrViewTask(dbInfo);
task.setOldClassName(tableName);
task.setNewClassName(newName);
task.setTable(isTable);
String taskName = Messages.bind(com.cubrid.common.ui.cubrid.table.Messages.renameTableTaskName, new String[] { tableName, newName });
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
ISelectionProvider provider = this.getSelectionProvider();
final TreeViewer viewer = (TreeViewer) provider;
//remove the old table schema information
table.getDatabase().getDatabaseInfo().removeSchema(tableName);
DefaultSchemaNode cloneTable = null;
try {
cloneTable = ((DefaultSchemaNode) table).clone();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(cloneTable, CubridNodeChangedEventType.NODE_REMOVE));
} catch (CloneNotSupportedException ex) {
LOGGER.error(ex.getMessage());
}
ClassInfo classInfo = (ClassInfo) table.getAdapter(ClassInfo.class);
classInfo.setClassName(newName);
table.setId(table.getParent().getId() + ICubridNodeLoader.NODE_SEPARATOR + newName);
table.setLabel(newName);
viewer.refresh(table, true);
LayoutManager.getInstance().getWorkbenchContrItem().reopenEditorOrView(table);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(table, CubridNodeChangedEventType.NODE_ADD));
ActionManager.getInstance().fireSelectionChanged(getSelection());
/*Broadcast the view changed*/
QueryEditorUtil.fireSchemaNodeChanged(table);
/*For bug TOOLS-3118: close opened TableEditorPart about dropped table*/
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
for (IEditorReference editorRef : workbenchWindow.getActivePage().getEditorReferences()) {
IEditorPart editor = editorRef.getEditor(true);
if (editor.getEditorInput() instanceof TableEditorInput) {
TableEditorInput input = (TableEditorInput) editor.getEditorInput();
ISchemaNode tableOfEditor = input.getEditedTableNode();
if (tableOfEditor.equals(table)) {
workbenchWindow.getActivePage().closeEditor(editor, false);
break;
}
}
}
}
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class ImportSettingExcelPage method validate.
public boolean validate() {
setErrorMessage(null);
setPageComplete(false);
ImportConfig importConfig = getImportDataWizard().getImportConfig();
List<DefaultSchemaNode> result = mappingComposite.getSelectedTableNode();
if (result.size() == 0) {
setErrorMessage(Messages.errNoSelectedTable);
return false;
}
for (DefaultSchemaNode node : result) {
Object value = node.getData(ImportObjectLabelProvider.IS_MAPPED);
if (value == null || !Boolean.parseBoolean(value.toString())) {
setErrorMessage(Messages.bind(Messages.errTableSetting, node.getName()));
return false;
}
TableConfig tableConfig = importConfig.getTableConfig(node.getName());
if (tableConfig != null) {
String filePath = tableConfig.getFilePath();
if (!StringUtil.isEmpty(filePath)) {
File file = new File(filePath);
if (!file.exists()) {
setErrorMessage(Messages.bind(Messages.errFileNotExist, filePath));
return false;
}
}
}
}
setPageComplete(true);
return true;
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class ERSchemaTableNodesLoader method getAllUserTablesInfo.
/**
* Get all the user tables node infos
*
* @return List<SchemaInfo>
*/
public List<SchemaInfo> getAllUserTablesInfo() {
List<DefaultSchemaNode> tableNodes = getAllTablesNode();
List<SchemaInfo> tables = new ArrayList<SchemaInfo>();
for (DefaultSchemaNode node : tableNodes) {
SchemaInfo table = dbNode.getDatabaseInfo().getSchemaInfo(node.getName());
if (null != table) {
tables.add(table);
}
}
return tables;
}
Aggregations