Search in sources :

Example 61 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class CubridSystemTableFolderLoader 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) {
            database.getDatabaseInfo().setSysTableInfoList(null);
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        final GetAllClassListTask task = new GetAllClassListTask(databaseInfo);
        monitorCancel(monitor, new ITask[] { task });
        List<ClassInfo> allClassInfoList = task.getSchema(false, true);
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            openErrorBox(errorMsg);
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        parent.removeAllChild();
        if (allClassInfoList != null) {
            for (ClassInfo classInfo : allClassInfoList) {
                String id = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
                ICubridNode classNode = new DefaultSchemaNode(id, classInfo.getClassName(), "icons/navigator/schema_table_item.png");
                classNode.setType(NodeType.SYSTEM_TABLE);
                classNode.setEditorId(SchemaInfoEditorPart.ID);
                classNode.setContainer(false);
                classNode.setModelObj(classInfo);
                parent.addChild(classNode);
            }
        }
        database.getDatabaseInfo().setSysTableInfoList(allClassInfoList);
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : GetAllClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) 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)

Example 62 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class CubridProcedureFolderLoader method createProcedureNode.

/**
	 * 
	 * Create procedure node
	 * 
	 * @param id The node id
	 * @param spInfo The model object
	 * @return ICubridNode
	 */
public static ICubridNode createProcedureNode(String id, SPInfo spInfo) {
    ICubridNode spNode = new DefaultSchemaNode(id, spInfo.getSpName(), "icons/navigator/procedure_sp_item.png");
    spNode.setType(NodeType.STORED_PROCEDURE_PROCEDURE);
    spNode.setModelObj(spInfo);
    spNode.setContainer(false);
    return spNode;
}
Also used : ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 63 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class ExportConnectionUtil method createDialogArea.

/**
	 * Create dialog area content
	 *
	 * @param parent the parent composite
	 * @return the control
	 */
@SuppressWarnings("deprecation")
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    tableViewer = new CheckboxTreeViewer(composite, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
    tableViewer.getTree().setLinesVisible(true);
    tableViewer.getTree().setHeaderVisible(true);
    tableViewer.getTree().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    /* Name */
    final TreeColumn nameColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    nameColumn.setText(Messages.nameColumn);
    nameColumn.setWidth(120);
    nameColumn.setImage(CommonUIPlugin.getImage("icons/checked_green.png"));
    nameColumn.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            selectAll = !selectAll;
            tableViewer.setAllChecked(selectAll);
            Image image = selectAll ? CommonUIPlugin.getImage("icons/checked_green.png") : CommonUIPlugin.getImage("icons/unchecked.gif");
            nameColumn.setImage(image);
            tableViewer.refresh();
            updateWidgetStatus();
        }
    });
    /* IP */
    TreeColumn ipColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    ipColumn.setText(Messages.iPColumn);
    ipColumn.setWidth(100);
    /* Port */
    TreeColumn portColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    portColumn.setText(Messages.portColumn);
    portColumn.setWidth(80);
    /* DB user */
    TreeColumn userColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    userColumn.setText(Messages.userColumn);
    userColumn.setWidth(100);
    /* Comment */
    TreeColumn commentColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    commentColumn.setText(Messages.commentColumn);
    commentColumn.setWidth(120);
    /* Java Url */
    TreeColumn javaUrlColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    javaUrlColumn.setText(Messages.javaUrlColumn);
    javaUrlColumn.setWidth(300);
    TreeColumn phpUrlColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    phpUrlColumn.setText(Messages.phpUrlColumn);
    phpUrlColumn.setWidth(300);
    tableViewer.setContentProvider(new TreeViewerContentProvider());
    tableViewer.setLabelProvider(new TreeViewerLabelProvider());
    tableViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
                CheckboxTreeViewer viewer = (CheckboxTreeViewer) event.getSource();
                /* Select the sub node */
                if (event.getElement() instanceof CubridServer) {
                    viewer.setSubtreeChecked(event.getElement(), true);
                } else if (event.getElement() instanceof CubridDatabase) {
                    CubridDatabase database = (CubridDatabase) event.getElement();
                    viewer.setChecked(database.getServer(), true);
                }
            } else {
                CheckboxTreeViewer viewer = (CheckboxTreeViewer) event.getSource();
                ICubridNode element = (ICubridNode) event.getElement();
                viewer.setSubtreeChecked(element, false);
                if (element instanceof CubridDatabase) {
                    CubridDatabase database = (CubridDatabase) element;
                    /* Check the parent state */
                    ICubridNode parent = database.getParent();
                    if (parent != null) {
                        List<ICubridNode> children = parent.getChildren();
                        boolean isSelected = false;
                        for (ICubridNode child : children) {
                            DefaultSchemaNode childNode = (DefaultSchemaNode) child;
                            if (viewer.getChecked(childNode.getDatabase())) {
                                isSelected = true;
                                break;
                            }
                        }
                        viewer.setChecked(database.getServer(), isSelected);
                    }
                }
            }
            updateWidgetStatus();
        }
    });
    tableViewer.setInput(selections);
    tableViewer.expandAll();
    tableViewer.setAllChecked(true);
    setTitle(Messages.titleExportConnection);
    setMessage(Messages.msgExportConnection);
    return parentComp;
}
Also used : ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Image(org.eclipse.swt.graphics.Image) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Event(org.eclipse.swt.widgets.Event) List(java.util.List) ArrayList(java.util.ArrayList) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 64 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class ERSchemaTableNodesLoader method getAllTablesNode.

/**
	 * Get all the user tables node. If the table folder hasnot been expanded,
	 * it cannot get all nodes
	 * 
	 * @return List<DefaultSchemaNode>
	 */
public List<DefaultSchemaNode> getAllTablesNode() {
    List<DefaultSchemaNode> nodes = new ArrayList<DefaultSchemaNode>();
    if (!dbNode.isLogined()) {
        return nodes;
    }
    String tablesFolderId = dbNode.getId() + CubridTablesFolderLoader.TABLES_FULL_FOLDER_SUFFIX_ID;
    ICubridNode tablesFolder = dbNode.getChild(tablesFolderId);
    if (null == tablesFolder) {
        return nodes;
    }
    List<ICubridNode> children = tablesFolder.getChildren();
    for (ICubridNode node : children) {
        if (NodeType.USER_TABLE.equals(node.getType()) && node instanceof DefaultSchemaNode) {
            nodes.add((DefaultSchemaNode) node);
        }
    }
    return nodes;
}
Also used : ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 65 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class FileToTableMappingComposite method getSelectedTableNode.

public List<DefaultSchemaNode> getSelectedTableNode() {
    List<DefaultSchemaNode> result = new ArrayList<DefaultSchemaNode>();
    Object[] itemArray = treeViewer.getCheckedElements();
    for (Object object : itemArray) {
        DefaultSchemaNode node = (DefaultSchemaNode) object;
        result.add(node);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Aggregations

DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)88 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)33 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)22 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)21 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)18 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)17 ArrayList (java.util.ArrayList)15 TreeViewer (org.eclipse.jface.viewers.TreeViewer)10 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)9 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)9 Display (org.eclipse.swt.widgets.Display)9 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)8 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)7 File (java.io.File)5 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)4 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)4 GetAllClassListTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask)4 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)4