use of com.cubrid.cubridmanager.core.cubrid.table.task.GetPartitionedClassListTask 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 com.cubrid.cubridmanager.core.cubrid.table.task.GetPartitionedClassListTask in project cubrid-manager by CUBRID.
the class PartitionEditListPage method initValuesCombo.
/**
*
* Fill in the values into Combo
*
*/
private void initValuesCombo() {
if (isNewTable) {
return;
}
GetPartitionedClassListTask task = new GetPartitionedClassListTask(dbInfo);
String expr = partitionExprText.getText();
String[] distinctValues = task.getDistinctValuesInAttribute(schemaInfo.getClassname(), expr);
if (distinctValues == null || distinctValues.length <= 0) {
return;
}
partitionValueCombo.setItems(distinctValues);
if (distinctValues.length > 1024) {
setMessage(Messages.bind(Messages.errValueTooMany, distinctValues.length));
}
partitionValueCombo.select(0);
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetPartitionedClassListTask in project cubrid-manager by CUBRID.
the class PartitionTypePage method createAttrTable.
/**
* Create attribute table information
*
* @param parent Composite
*/
private void createAttrTable(Composite parent) {
useColumnButton = new Button(parent, SWT.RADIO | SWT.LEFT);
useColumnButton.setText(Messages.btnUseColumn);
useColumnButton.setLayoutData(CommonUITool.createGridData(2, 1, -1, -1));
useColumnButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (useColumnButton.getSelection()) {
useExprButton.setSelection(false);
partitionExprText.setText("");
partitionExprText.setEnabled(false);
setErrorMessage(Messages.errNoSelectColumn);
setPageComplete(false);
attributeTable.setEnabled(true);
}
}
});
List<DBAttributeStatistic> dbAttrStatList = null;
if (!isNewTable) {
GetPartitionedClassListTask task = new GetPartitionedClassListTask(dbInfo);
dbAttrStatList = task.getColumnStatistics(schemaInfo.getClassname());
}
attrList.addAll(schemaInfo.getAttributes());
for (int i = 0; dbAttrStatList != null && i < dbAttrStatList.size(); i++) {
DBAttributeStatistic dbAttributeStatics = dbAttrStatList.get(i);
for (int j = 0; j < attrList.size(); j++) {
DBAttribute dbAttribute = attrList.get(j);
if (dbAttribute.getName().equals(dbAttributeStatics.getName())) {
attrList.remove(j);
attrList.add(dbAttributeStatics);
break;
}
}
}
attrTableView = new TableViewer(parent, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
attributeTable = attrTableView.getTable();
attributeTable.setLayout(TableViewUtil.createTableViewLayout(new int[] { 20, 20, 20, 20, 20 }));
attributeTable.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 200));
attributeTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
validate();
}
});
attributeTable.setHeaderVisible(true);
attributeTable.setLinesVisible(true);
TableViewUtil.createTableColumn(attributeTable, SWT.CENTER, Messages.tblColColumnName);
TableViewUtil.createTableColumn(attributeTable, SWT.CENTER, Messages.tblColDataType);
TableViewUtil.createTableColumn(attributeTable, SWT.CENTER, Messages.tblColMiniValue);
TableViewUtil.createTableColumn(attributeTable, SWT.CENTER, Messages.tblColMaxValue);
TableViewUtil.createTableColumn(attributeTable, SWT.CENTER, Messages.tblColValueCount);
attrTableView.setContentProvider(new PartitionTypeContentProvider());
attrTableView.setLabelProvider(new PartitionTypeLabelProvider());
attrTableView.setInput(attrList);
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetPartitionedClassListTask in project cubrid-manager by CUBRID.
the class TableEditorPart method loadPartitionInfoList.
/**
* Load partition information list
*/
private void loadPartitionInfoList() {
boolean isPartitionTable = false;
if (!isNewTableFlag) {
isPartitionTable = "YES".equals(oldSchemaInfo.isPartitionGroup());
}
if (isPartitionTable) {
GetPartitionedClassListTask task = new GetPartitionedClassListTask(database.getDatabaseInfo());
List<PartitionInfo> list = task.getPartitionItemList(newSchemaInfo.getClassname());
partitionInfoList.clear();
if (!ArrayUtil.isEmpty(list)) {
PartitionInfo partitionInfo = list.get(0);
if (partitionInfo != null && partitionInfo.getPartitionType() == PartitionType.RANGE) {
RangePartitionComparator comparator = new RangePartitionComparator(partitionInfo.getPartitionExprType());
Collections.sort(list, comparator);
}
partitionInfoList.addAll(list);
}
}
oldPartitionInfoList = new ArrayList<PartitionInfo>();
for (int i = 0; i < partitionInfoList.size(); i++) {
PartitionInfo partitionInfo = partitionInfoList.get(i);
if (partitionInfo != null) {
oldPartitionInfoList.add(partitionInfo.clone());
}
}
if (oldSchemaInfo != null) {
oldSchemaInfo.setPartitionList(oldPartitionInfoList);
}
if (newSchemaInfo != null) {
newSchemaInfo.setPartitionList(partitionInfoList);
}
}
Aggregations