Search in sources :

Example 1 with GetPartitionedClassListTask

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));
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) GetPartitionedClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetPartitionedClassListTask) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo) Display(org.eclipse.swt.widgets.Display)

Example 2 with GetPartitionedClassListTask

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);
}
Also used : GetPartitionedClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetPartitionedClassListTask)

Example 3 with GetPartitionedClassListTask

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);
}
Also used : Button(org.eclipse.swt.widgets.Button) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DBAttributeStatistic(com.cubrid.cubridmanager.core.cubrid.table.model.DBAttributeStatistic) GetPartitionedClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetPartitionedClassListTask) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 4 with GetPartitionedClassListTask

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);
    }
}
Also used : GetPartitionedClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetPartitionedClassListTask) PartitionInfo(com.cubrid.common.core.common.model.PartitionInfo) RangePartitionComparator(com.cubrid.common.ui.cubrid.table.control.RangePartitionComparator) Constraint(com.cubrid.common.core.common.model.Constraint)

Aggregations

GetPartitionedClassListTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetPartitionedClassListTask)4 Constraint (com.cubrid.common.core.common.model.Constraint)1 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)1 PartitionInfo (com.cubrid.common.core.common.model.PartitionInfo)1 RangePartitionComparator (com.cubrid.common.ui.cubrid.table.control.RangePartitionComparator)1 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)1 DBAttributeStatistic (com.cubrid.cubridmanager.core.cubrid.table.model.DBAttributeStatistic)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Button (org.eclipse.swt.widgets.Button)1 Display (org.eclipse.swt.widgets.Display)1