Search in sources :

Example 1 with SchemaEditorInput

use of com.cubrid.common.ui.er.SchemaEditorInput in project cubrid-manager by CUBRID.

the class OpenSchemaEditorAction method run.

/**
	 * Open the selected database Schema Editor. If basing on none-database
	 * node, open the ERD by a virtual database
	 */
public void run() {
    // FIXME move this logic to core module
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    Object[] obj = this.getSelectedObj();
    CubridDatabase[] cubridDatabases = getDBNodes(obj);
    for (int i = 0; i < cubridDatabases.length; i++) {
        // multi db nodes
        if (cubridDatabases[i].getDatabaseInfo() == null || !cubridDatabases[i].isLogined()) {
            cubridDatabases[i] = ERVirtualDatabase.getInstance();
        }
    }
    if (cubridDatabases.length == 0) {
        // when right-click not database nodes
        cubridDatabases = new CubridDatabase[1];
        cubridDatabases[0] = ERVirtualDatabase.getInstance();
    }
    // Limit max number one time
    if (cubridDatabases.length > LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM) {
        CommonUITool.openConfirmBox(Messages.bind("SchemaDesigner max...", LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM));
        List<CubridDatabase> list = new ArrayList<CubridDatabase>(LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM);
        for (int i = 0; i < LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM; i++) {
            list.add(cubridDatabases[i]);
        }
        cubridDatabases = new CubridDatabase[LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM];
        list.toArray(cubridDatabases);
    }
    for (CubridDatabase database : cubridDatabases) {
        SchemaEditorInput schemaEditorInput = new SchemaEditorInput(database, (provider instanceof TreeViewer) ? (TreeViewer) provider : null);
        schemaEditorInput.setDatabase(database);
        DatabaseInfo dbInfo = database.getDatabaseInfo();
        if (dbInfo == null) {
            continue;
        }
        try {
            window.getActivePage().openEditor(schemaEditorInput, ERSchemaEditor.ID);
            if (Util.isMac()) {
                // refresh for low version mac
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setEditorAreaVisible(false);
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setEditorAreaVisible(true);
            }
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage());
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SchemaEditorInput(com.cubrid.common.ui.er.SchemaEditorInput) ArrayList(java.util.ArrayList) PartInitException(org.eclipse.ui.PartInitException) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 2 with SchemaEditorInput

use of com.cubrid.common.ui.er.SchemaEditorInput in project cubrid-manager by CUBRID.

the class ERDNDController method getNavigatorPaneWidth.

private int getNavigatorPaneWidth() {
    SchemaEditorInput sInput = editor.getERSchema().getInput();
    Control control = sInput.getTv().getControl();
    Composite comp = control.getParent();
    org.eclipse.swt.graphics.Rectangle rec = comp.getBounds();
    return rec.width;
}
Also used : Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) SchemaEditorInput(com.cubrid.common.ui.er.SchemaEditorInput)

Example 3 with SchemaEditorInput

use of com.cubrid.common.ui.er.SchemaEditorInput in project cubrid-manager by CUBRID.

the class ERSchemaEditor method setInput.

protected void setInput(IEditorInput input) {
    super.setInput(input);
    if (input instanceof SchemaEditorInput) {
        database = ((SchemaEditorInput) input).getDatabase();
    }
    tableNodesLoader = new ERSchemaTableNodesLoader(database);
    erSchema = new ERSchema(database.getName(), (SchemaEditorInput) input);
    erSchema.setLayoutManualDesiredAndFire(true);
    initCollections(database.getDatabaseInfo());
}
Also used : ERSchemaTableNodesLoader(com.cubrid.common.ui.er.loader.ERSchemaTableNodesLoader) SchemaEditorInput(com.cubrid.common.ui.er.SchemaEditorInput) ERSchema(com.cubrid.common.ui.er.model.ERSchema)

Example 4 with SchemaEditorInput

use of com.cubrid.common.ui.er.SchemaEditorInput in project cubrid-manager by CUBRID.

the class ERSchemaEditor method init.

public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    String name = input.getName();
    if (input instanceof SchemaEditorInput) {
        name += "@" + ((SchemaEditorInput) input).getDatabase().getName();
    }
    this.setPartName(name);
    // store site and input
    setSite(site);
    setInput(input);
    getEditDomain().setPaletteRoot(getPaletteRoot());
    setTitleImage(input.getImageDescriptor().createImage());
    getCommandStack().addCommandStackListener(this);
    getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
    createActions();
    this.getSite().getPage().addPartListener(new IPartListener() {

        public void partOpened(IWorkbenchPart part) {
            if (part == ERSchemaEditor.this) {
                CommonUITool.activeView(ERDThumbnailViewPart.ID);
            }
        }

        public void partDeactivated(IWorkbenchPart part) {
        }

        public void partClosed(IWorkbenchPart part) {
            if (part == ERSchemaEditor.this) {
                ERDThumbnailViewPart view = (ERDThumbnailViewPart) CommonUITool.findView(ERDThumbnailViewPart.ID);
                if (view != null) {
                    view.redraw(null);
                }
            }
        }

        public void partBroughtToTop(IWorkbenchPart part) {
        }

        public void partActivated(IWorkbenchPart part) {
            if (part == ERSchemaEditor.this) {
                ERDThumbnailViewPart view = (ERDThumbnailViewPart) CommonUITool.findView(ERDThumbnailViewPart.ID);
                if (view != null) {
                    view.redraw(getRootEditPart());
                }
            }
        }
    });
    if (database != null && !database.isVirtual()) {
        CubridNodeManager.getInstance().addCubridNodeChangeListener(this);
    }
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IPartListener(org.eclipse.ui.IPartListener) SchemaEditorInput(com.cubrid.common.ui.er.SchemaEditorInput)

Example 5 with SchemaEditorInput

use of com.cubrid.common.ui.er.SchemaEditorInput in project cubrid-manager by CUBRID.

the class ERSchemaEditor method setDatabase.

/**
	 * set database node
	 * 
	 * @return CubridDatabase
	 */
public void setDatabase(CubridDatabase db) {
    database = db;
    SchemaEditorInput input = (SchemaEditorInput) getEditorInput();
    input.setDatabase(database);
    setPartName(input.getName() + "@" + database.getName());
}
Also used : SchemaEditorInput(com.cubrid.common.ui.er.SchemaEditorInput)

Aggregations

SchemaEditorInput (com.cubrid.common.ui.er.SchemaEditorInput)5 ERSchemaTableNodesLoader (com.cubrid.common.ui.er.loader.ERSchemaTableNodesLoader)1 ERSchema (com.cubrid.common.ui.er.model.ERSchema)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 ArrayList (java.util.ArrayList)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 IPartListener (org.eclipse.ui.IPartListener)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 PartInitException (org.eclipse.ui.PartInitException)1