use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class GroupSettingDialog method copyForSetup.
/**
* Copy the information from source to this.
*
* @param source the source node.
* @param target the target node
*/
private void copyForSetup(CubridGroupNode source, CubridGroupNode target) {
target.setId(source.getId());
target.setLabel(source.getLabel());
target.removeAllChild();
for (ICubridNode node : source.getChildren()) {
//use reflect to clone a new group.
ICubridNode newNode = null;
if (node instanceof CubridServer) {
newNode = new CubridServer(node.getId(), node.getName(), ((CubridServer) node).getConnectedIconPath(), ((CubridServer) node).getDisConnectedIconPath());
} else if (node instanceof CubridDatabase) {
newNode = new CubridDatabase(node.getId(), node.getName());
} else {
throw new RuntimeException("Group item is not supported.");
}
target.addChild(newNode);
}
}
use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class ActionSupportUtil method hasAdminPermission.
/**
* Whether having cubrid manager's administrative permissions
*
* @param obj ISchemaNode or ISchemaNode[]
* @return boolean
*/
public static boolean hasAdminPermission(Object obj) {
if (!(obj instanceof ISchemaNode)) {
return false;
}
ISchemaNode node = (ISchemaNode) obj;
CubridServer server = node.getServer();
if (server == null) {
return false;
}
ServerInfo serverInfo = server.getServerInfo();
if (serverInfo == null) {
return false;
}
if (!serverInfo.isConnected()) {
return false;
}
ServerUserInfo serverUserInfo = serverInfo.getLoginedUserInfo();
if (serverUserInfo == null) {
return false;
}
if (serverUserInfo.getDbCreateAuthType() == DbCreateAuthType.AUTH_ADMIN) {
return true;
}
CubridDatabase database = node.getDatabase();
if (database == null) {
return false;
}
DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
if (dbUserInfo != null && dbUserInfo.isDbaAuthority() && database.isLogined()) {
return true;
}
return false;
}
use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class NavigatorTreeLabelProvider method getText.
public String getText(Object element) {
if (element instanceof ICubridNode) {
if (element instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) element;
StringBuffer sbLabel = new StringBuffer();
sbLabel.append(((ICubridNode) element).getLabel());
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
if (editorConfig != null && editorConfig.getDatabaseComment() != null && editorConfig.getDatabaseComment().length() > 0) {
sbLabel.append("(").append(editorConfig.getDatabaseComment()).append(")");
return sbLabel.toString();
}
} else if (element instanceof CubridBroker) {
CubridBroker broker = (CubridBroker) element;
BrokerInfo brokerInfo = broker.getBrokerInfo();
if (brokerInfo == null || brokerInfo.getAccess_mode() == null) {
return broker.getName();
}
return broker.getName() + " (" + brokerInfo.getPort() + "," + brokerInfo.getAccess_mode() + ")";
} else if (element instanceof CubridServer) {
CubridServer server = (CubridServer) element;
return decorateServerText(server.getLabel(), server);
}
return ((ICubridNode) element).getLabel();
} else if (element instanceof PendingUpdateAdapter) {
return com.cubrid.common.ui.common.Messages.msgLoading;
}
return element == null ? "" : element.toString();
}
use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class NavigatorTreeLabelProvider method decorateDatabaseImgae.
/**
* Decorate the database image
*
* @param label
* @param server
* @return
*/
private Image decorateDatabaseImgae(Image baseImage, CubridDatabase database) {
CubridServer server = database.getServer();
HAHostStatusInfo haHostStatusInfo = server.getServerInfo().getHaHostStatusInfo();
HADatabaseStatusInfo haDatabaseStatusInfo = HAUtil.getHADatabaseStatusInfo(database.getName(), haHostStatusInfo, server.getServerInfo());
List<String> haNodeList = HAUtil.getAllHaDBList(server.getServerInfo());
server.getLoader().setLoaded(true);
if (haNodeList.contains(database.getName())) {
DBStatusType statusType = haDatabaseStatusInfo.getStatusType();
if (DBStatusType.ACTIVE.equals(statusType)) {
DecoratedImage decoratedImage = decoratorManager.decorate(baseImage, "HADatabase", null, null, null, null, null, null, imgDecMaster, "Active");
return decoratedImage.getDecoratedImage();
}
if (DBStatusType.STANDBY.equals(statusType)) {
DecoratedImage decoratedImage = decoratorManager.decorate(baseImage, "HADatabase", null, null, null, null, null, null, imgDecSlave, "Standby");
return decoratedImage.getDecoratedImage();
}
}
return baseImage;
}
use of com.cubrid.common.ui.spi.model.CubridServer 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);
}
Aggregations