use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class CreateSerialAction method run.
/**
* Open the createSerial dialog and create serial
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (!isSupported(objArr)) {
setEnabled(false);
return;
}
ISchemaNode schemaNode = (ISchemaNode) objArr[0];
CubridDatabase database = schemaNode.getDatabase();
run(database);
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class EditSerialAction method run.
/**
* get edit serial node
*/
public void run() {
Object[] objArr = this.getSelectedObj();
final ISchemaNode schemaNode = (ISchemaNode) objArr[0];
CubridDatabase database = schemaNode.getDatabase();
run(database, schemaNode);
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class SerialDashboardEditorPart method dropSerial.
public void dropSerial() {
TableItem[] items = serialsDetailInfoTable.getTable().getSelection();
if (items.length > 0) {
List<ISchemaNode> selectNodeList = new ArrayList<ISchemaNode>();
for (TableItem item : items) {
SerialInfo serialInfo = (SerialInfo) item.getData();
Set<String> typeSet = new HashSet<String>();
typeSet.add(NodeType.SERIAL);
ICubridNode serialNode = CommonUITool.findNode(database, typeSet, serialInfo.getName());
selectNodeList.add((ISchemaNode) serialNode);
}
if (selectNodeList.size() > 0) {
DeleteSerialAction action = (DeleteSerialAction) ActionManager.getInstance().getAction(DeleteSerialAction.ID);
if (action == null) {
LOGGER.error("DeleteSerialAction is a null.");
return;
}
ISchemaNode[] nodeArr = new ISchemaNode[selectNodeList.size()];
action.run(selectNodeList.toArray(nodeArr));
refresh();
}
} else {
CommonUITool.openWarningBox(Messages.errSerialNoSelection);
}
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class ColumnSelectCountAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
public void run() {
Object[] obj = getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
ISchemaNode column = (ISchemaNode) obj[0];
ISchemaNode table = (ISchemaNode) column.getParent().getParent();
String columnName = column.getName().split(",")[0];
if ("".equals(columnName)) {
// FIXME
return;
}
CubridDatabase db = table.getDatabase();
DatabaseInfo dbInfo = db.getDatabaseInfo();
GetRecordCountTask task = new GetRecordCountTask(dbInfo);
int count = task.getRecordCount(table.getName(), columnName, null);
String[] bindings = new String[] { columnName, table.getName(), String.valueOf(count) };
if (count > 1) {
message = Messages.bind(Messages.columnSelectCountResult2, bindings);
} else {
message = Messages.bind(Messages.columnSelectCountResult1, bindings);
}
}
});
CommonUITool.openInformationBox(Messages.selectCountTitle, message);
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class ColumnSelectSqlAction method run.
public void run() {
Object[] objs = this.getSelectedObj();
if (!isSupported(objs)) {
setEnabled(false);
return;
}
ISchemaNode table = (ISchemaNode) ((ISchemaNode) objs[0]).getParent().getParent();
StringBuilder buf = new StringBuilder();
for (int i = 0; i < objs.length; i++) {
ISchemaNode columnNode = (ISchemaNode) objs[i];
String column = columnNode.getName().split(",")[0];
buf.append(QuerySyntax.escapeKeyword(column));
if (i != objs.length - 1) {
buf.append(',');
}
}
String cols = buf.toString();
if (StringUtil.isEmpty(cols)) {
return;
}
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
QueryUnit input = new QueryUnit();
input.setDatabase(table.getDatabase());
try {
QueryEditorPart editor = (QueryEditorPart) window.getActivePage().openEditor(input, QueryEditorPart.ID);
editor.connect(table.getDatabase());
// FIXME move this logic to core module
String escapedTableName = QuerySyntax.escapeKeyword(table.getName());
String sql = "SELECT " + cols + " FROM " + escapedTableName + ";";
editor.setQuery(sql, false, true, false);
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
}
Aggregations