Search in sources :

Example 1 with CubridServerLoader

use of com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader in project cubrid-manager by CUBRID.

the class AddHostAction method getServerNode.

/**
	 * Create a new server node.
	 * 
	 * @param dialog the add server dialog.
	 * @return CubridServer.
	 */
private CubridServer getServerNode(HostDialog dialog) {
    ServerInfo serverInfo = dialog.getServerInfo();
    CubridServer server = new CubridServer(serverInfo.getServerName(), serverInfo.getServerName(), "icons/navigator/host.png", "icons/navigator/host_connected.png");
    server.setServerInfo(serverInfo);
    server.setLoader(new CubridServerLoader());
    server.setAutoSavePassword(dialog.isSavePassword());
    return server;
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridServerLoader(com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader)

Example 2 with CubridServerLoader

use of com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader in project cubrid-manager by CUBRID.

the class CMHostNodePersistManager method addServer.

/**
	 * Add CUBRID Manager server information
	 * 
	 * @param hostAddress String host address
	 * @param port int host port
	 * @param value ServerInfo given serverInfo
	 * @param userName the String
	 * @return ServerInfo
	 */
public void addServer(String hostAddress, int port, String userName, ServerInfo value) {
    synchronized (this) {
        CubridServer server = getServer(hostAddress, port, userName);
        if (server == null) {
            CubridServer newServer = new CubridServer(value.getServerName(), value.getServerName(), "com.cubrid.cubridmananger.ui/icons/navigator/host.png", "com.cubrid.cubridmananger.ui/icons/navigator/host_connected.png");
            newServer.setServerInfo(value);
            newServer.setLoader(new CubridServerLoader());
            addServer(newServer);
        } else {
            server.setServerInfo(value);
        }
        ServerManager.getInstance().addServer(hostAddress, port, userName, value);
    }
}
Also used : CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridServerLoader(com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader)

Example 3 with CubridServerLoader

use of com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader in project cubrid-manager by CUBRID.

the class CMHostNodePersistManager method loadSevers.

/**
	 *
	 * Load added host from plugin preference
	 *
	 */
protected void loadSevers() {
    synchronized (this) {
        //			serverList.clear();
        boolean isHasLocalHost = false;
        boolean alreadyAddedLocalhostDefault = false;
        IXMLMemento memento = PersistUtils.getXMLMemento(ApplicationUtil.CM_UI_PLUGIN_ID, SERVER_XML_CONTENT);
        // For compatible for the version before 8.4.0
        URL url = Platform.getInstanceLocation().getURL();
        File file = new File(url.getFile());
        String optionsPath = file.getAbsolutePath() + File.separator + ".metadata" + File.separator + ".plugins" + File.separator + "org.eclipse.core.runtime" + File.separator + ".settings" + File.separator;
        //Load global preference setting
        QueryOptions.load(optionsPath, null);
        if (memento != null) {
            alreadyAddedLocalhostDefault = memento.getBoolean("alreadyAddedLocalhostDefault");
        }
        isHasLocalHost = loadServers(memento, true, optionsPath);
        if (!isHasLocalHost && !alreadyAddedLocalhostDefault) {
            String id = "localhost";
            String name = "localhost";
            int port = 8001;
            String userName = "admin";
            ServerInfo serverInfo = new ServerInfo();
            serverInfo.setServerName(name);
            serverInfo.setHostAddress(name);
            serverInfo.setHostMonPort(port);
            serverInfo.setHostJSPort(port + 1);
            serverInfo.setUserName(userName);
            serverInfo.setUserPassword("");
            CubridServer server = new CubridServer(id, name, "icons/navigator/host.png", "icons/navigator/host_connected.png");
            server.setServerInfo(serverInfo);
            server.setType(NodeType.SERVER);
            server.setLoader(new CubridServerLoader());
            serverList.add(0, server);
            ServerManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
            /*Save the server list*/
            saveServers();
        }
    }
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) File(java.io.File) URL(java.net.URL) CubridServerLoader(com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader)

Example 4 with CubridServerLoader

use of com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader in project cubrid-manager by CUBRID.

the class CMHostNodePersistManager method loadServers.

private boolean loadServers(List<CubridServer> servers, IXMLMemento memento, boolean isLoadOptions, String optionPath, boolean allowDuplicate) {
    boolean isHasLocalHost = false;
    IXMLMemento[] children = memento == null ? null : memento.getChildren("host");
    for (int i = 0; children != null && i < children.length; i++) {
        String id = children[i].getString("id");
        String name = children[i].getString("name");
        if ("localhost".equals(name)) {
            isHasLocalHost = true;
        }
        String address = children[i].getString("address");
        String port = children[i].getString("port");
        String user = children[i].getString("user");
        String userPasword = children[i].getString("password");
        String jdbcDriver = children[i].getString("jdbcDriver");
        boolean savePassword = children[i].getBoolean("savePassword");
        String strSoTimeOut = children[i].getString("soTimeOut");
        int soTimeOut = StringUtil.intValue(strSoTimeOut, SocketTask.SOCKET_IO_TIMEOUT_MSEC);
        // duplicate entry check: memento -- current workspace
        if (!allowDuplicate) {
            if (getServer(id) != null && isContainedByHostAddress(address, port, null)) {
                continue;
            }
        }
        String strCheckCert = children[i].getString("isCheckCert");
        ServerInfo serverInfo = new ServerInfo();
        serverInfo.setServerName(name);
        serverInfo.setHostAddress(address);
        serverInfo.setHostMonPort(Integer.parseInt(port));
        serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
        serverInfo.setUserName(user);
        serverInfo.setUserPassword(CipherUtils.decrypt(userPasword));
        serverInfo.setJdbcDriverVersion(jdbcDriver);
        serverInfo.setSoTimeOut(soTimeOut);
        if (!StringUtil.isEmpty(strCheckCert)) {
            serverInfo.setCheckCertStatus(StringUtil.booleanValue(strCheckCert));
        }
        CubridServer server = new CubridServer(id, name, "icons/navigator/host.png", "icons/navigator/host_connected.png");
        server.setServerInfo(serverInfo);
        server.setType(NodeType.SERVER);
        server.setLoader(new CubridServerLoader());
        server.setAutoSavePassword(savePassword);
        if (isLoadOptions) {
            QueryOptions.load(optionPath, serverInfo);
        }
        servers.add(server);
        ServerManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
    }
    return isHasLocalHost;
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridServerLoader(com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader)

Example 5 with CubridServerLoader

use of com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader in project cubrid-manager by CUBRID.

the class GroupNodeDnDHandler method handle.

/**
	 * Handle the node to be DND.
	 * 
	 * @param dragNode the drag node
	 * @param dropNode the drop node
	 * @param insertBefore insert into the drop node before or after
	 * @param dropOperation the drop operation type <code>DND.DROP_COPY</code>
	 *        <code>DND.DROP_MOVE</code>
	 * @return boolean whether to handle with the drop
	 */
public boolean handle(ICubridNode dragNode, ICubridNode dropNode, boolean insertBefore, int dropOperation) {
    ICubridNode newDragNode = dragNode;
    if (DND.DROP_COPY == dropOperation && dragNode instanceof CubridServer) {
        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        HostDialog dialog = new HostDialog(shell, true, false);
        dialog.setServer((CubridServer) dragNode);
        int returnCode = dialog.open();
        if (returnCode == HostDialog.ADD_ID || returnCode == HostDialog.CONNECT_ID) {
            ServerInfo serverInfo = dialog.getServerInfo();
            CubridServer server = new CubridServer(serverInfo.getServerName(), serverInfo.getServerName(), "icons/navigator/host.png", "icons/navigator/host_connected.png");
            server.setServerInfo(serverInfo);
            server.setLoader(new CubridServerLoader());
            server.setAutoSavePassword(dialog.isSavePassword());
            CMHostNodePersistManager.getInstance().addServer(server);
            newDragNode = server;
        } else {
            return false;
        }
    }
    return super.handle(newDragNode, dropNode, insertBefore, dropOperation);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) HostDialog(com.cubrid.cubridmanager.ui.host.dialog.HostDialog) CubridServerLoader(com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader)

Aggregations

CubridServer (com.cubrid.common.ui.spi.model.CubridServer)7 CubridServerLoader (com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader)7 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)6 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)2 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)2 HostDialog (com.cubrid.cubridmanager.ui.host.dialog.HostDialog)2 Shell (org.eclipse.swt.widgets.Shell)2 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)1 File (java.io.File)1 URL (java.net.URL)1