Search in sources :

Example 1 with CubridHostNavigatorView

use of com.cubrid.cubridmanager.ui.common.navigator.CubridHostNavigatorView in project cubrid-manager by CUBRID.

the class ImportHostsAction method run.

/**
	 * Import hosts and groups
	 */
public void run() {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN | SWT.APPLICATION_MODAL);
    String filePath = CommonUIPlugin.getSettingValue("IMPORT_HOSTS_WORKSPACE_KEY");
    if (null != filePath) {
        dialog.setFilterPath(filePath);
    }
    dialog.setMessage(Messages.msgSelectWorkspace);
    filePath = dialog.open();
    if (filePath == null) {
        return;
    }
    final String workspacePath = filePath;
    filePath = filePath + File.separator + ".metadata" + File.separator + ".plugins" + File.separator + "org.eclipse.core.runtime" + File.separator + ".settings" + File.separator + "com.cubrid.cubridmanager.ui.prefs";
    File file = new File(filePath);
    if (file == null || !file.exists()) {
        CommonUITool.openErrorBox(Messages.errInvalidWorkspace);
        return;
    } else {
        CommonUIPlugin.putSettingValue("IMPORT_HOSTS_WORKSPACE_KEY", workspacePath);
    }
    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

        public void run() {
            CMGroupNodePersistManager groupNodePersistManager = CMGroupNodePersistManager.getInstance();
            boolean isImportHost = CMHostNodePersistManager.getInstance().loadSevers(workspacePath);
            boolean isImportGroup = groupNodePersistManager.loadGroupNode(workspacePath);
            boolean isImportDb = CMDBNodePersistManager.getInstance().loadDatabases(workspacePath);
            if (isImportHost || isImportGroup || isImportDb) {
                CubridHostNavigatorView view = (CubridHostNavigatorView) CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
                if (view != null && view.getViewer() != null) {
                    view.getViewer().refresh(true);
                }
            }
        }
    });
}
Also used : Shell(org.eclipse.swt.widgets.Shell) CMGroupNodePersistManager(com.cubrid.cubridmanager.ui.spi.persist.CMGroupNodePersistManager) File(java.io.File) CubridHostNavigatorView(com.cubrid.cubridmanager.ui.common.navigator.CubridHostNavigatorView) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

CubridHostNavigatorView (com.cubrid.cubridmanager.ui.common.navigator.CubridHostNavigatorView)1 CMGroupNodePersistManager (com.cubrid.cubridmanager.ui.spi.persist.CMGroupNodePersistManager)1 File (java.io.File)1 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)1 Shell (org.eclipse.swt.widgets.Shell)1