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());
}
}
}
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;
}
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());
}
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);
}
}
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());
}
Aggregations