use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class EditSerialAction method run.
/**
* Open the editSerial dialog and edit serial
*/
public int run(CubridDatabase database, final ISchemaNode node) {
final Shell shell = getShell();
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return false;
}
monitor.beginTask(Messages.loadSerialTaskName, IProgressMonitor.UNKNOWN);
for (ITask task : taskList) {
SerialInfo serialInfo = null;
if (task instanceof GetSerialInfoTask) {
GetSerialInfoTask getSerialInfoTask = (GetSerialInfoTask) task;
serialInfo = getSerialInfoTask.getSerialInfo(node.getLabel());
}
final String msg = task.getErrorMsg();
if (openErrorBox(shell, msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
if (serialInfo == null) {
openErrorBox(shell, Messages.errNameNotExist, monitor);
return false;
}
node.setModelObj(serialInfo);
}
return true;
}
};
DatabaseInfo databaseInfo = database.getDatabaseInfo();
GetSerialInfoTask task = new GetSerialInfoTask(databaseInfo);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return IDialogConstants.CANCEL_ID;
}
boolean isEditorAble = ActionSupportUtil.isSupportSinSelCheckDbUser(node, NodeType.SERIAL);
CreateOrEditSerialDialog dialog = new CreateOrEditSerialDialog(getShell(), isEditorAble);
dialog.setEditedNode(node);
dialog.setDatabase(database);
if (dialog.open() == IDialogConstants.OK_ID) {
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REFRESH));
ActionManager.getInstance().fireSelectionChanged(getSelection());
return IDialogConstants.OK_ID;
}
return IDialogConstants.CANCEL_ID;
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class AlterTriggerAction method run.
/**
* edit trigger
* @param database
* @param node
* @return
*/
public int run(final CubridDatabase database, final ISchemaNode node) {
// FIXME move this logic to core module
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return false;
}
for (ITask task : taskList) {
task.execute();
final String msg = task.getErrorMsg();
if (openErrorBox(shell, msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
Trigger trigger = null;
if (task instanceof GetTriggerListTask) {
GetTriggerListTask getTriggerListTask = (GetTriggerListTask) task;
List<Trigger> triggerList = getTriggerListTask.getTriggerInfoList();
for (int i = 0; triggerList != null && i < triggerList.size(); i++) {
Trigger trig = triggerList.get(i);
if (node.getName().equals(trig.getName())) {
trigger = trig;
break;
}
}
} else if (task instanceof JDBCGetTriggerInfoTask) {
JDBCGetTriggerInfoTask getTriggerInfoTask = (JDBCGetTriggerInfoTask) task;
trigger = getTriggerInfoTask.getTriggerInfo(node.getLabel());
}
if (trigger == null) {
openErrorBox(shell, Messages.errNameNoExist, monitor);
return false;
}
// getting comment for version after 10.0
if (CompatibleUtil.isCommentSupports(database.getDatabaseInfo())) {
try {
SchemaComment schemaComment = SchemaCommentHandler.loadObjectDescription(database.getDatabaseInfo(), JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true), trigger.getName(), CommentType.TRIGGER);
trigger.setDescription(schemaComment.getDescription());
} catch (SQLException e) {
CommonUITool.openErrorBox(e.getMessage());
}
}
node.setModelObj(trigger);
}
return true;
}
};
ITask task = null;
if (ApplicationType.CUBRID_MANAGER.equals(PerspectiveManager.getInstance().getCurrentMode())) {
task = new GetTriggerListTask(database.getServer().getServerInfo());
((GetTriggerListTask) task).setDbName(database.getName());
} else {
task = new JDBCGetTriggerInfoTask(database.getDatabaseInfo());
}
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return IDialogConstants.CANCEL_ID;
}
CreateTriggerDialog dialog = new CreateTriggerDialog(getShell(), node.getDatabase(), (Trigger) node.getAdapter(Trigger.class));
if (dialog.open() != IDialogConstants.CANCEL_ID) {
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REFRESH));
ActionManager.getInstance().fireSelectionChanged(getSelection());
return IDialogConstants.OK_ID;
}
return IDialogConstants.CANCEL_ID;
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class MultiDatabaseLoginFailedDialog method editHost.
public void editHost(MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo) {
if (multiDatabaseloginFailedInfo == null) {
return;
}
CubridDatabase database = multiDatabaseloginFailedInfo.getCubridDatabase();
//if login ,can't edit
if (database.isLogined()) {
return;
}
// CubridDatabase oldDatabase = null;
// try {
// oldDatabase = database.clone();
// } catch (CloneNotSupportedException e) {
// //Ignore
// }
LoginDatabaseDialog dialog = new LoginDatabaseDialog(getShell(), database);
int returnVal = dialog.open();
if (returnVal == IDialogConstants.OK_ID) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
database.removeAllChild();
if (database.getLoader() != null) {
database.getLoader().setLoaded(false);
}
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
/*Save the data*/
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
if (editorConfig == null) {
editorConfig = new DatabaseEditorConfig();
}
editorConfig.setBackGround(dialog.getSelectedColor());
CMDBNodePersistManager.getInstance().addDatabase(database, editorConfig);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
multiDatabaseloginFailedInfo.setErrMsg("");
}
databaseTable.refresh();
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class RenameHostAction method doRun.
private void doRun(CubridServer server) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
RenameHostDialog dlg = new RenameHostDialog(shell, server);
int ret = dlg.open();
if (ret == IDialogConstants.OK_ID) {
server.setLabel(dlg.getNewName());
server.getServerInfo().setServerName(dlg.getNewName());
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
LOGGER.error("Error: Can't find the navigator view:" + CubridHostNavigatorView.ID);
return;
}
// Fire all the databases which are in the server logout
List<ICubridNode> children = server.getChildren();
if (children != null) {
for (ICubridNode child : children) {
if (!NodeType.DATABASE_FOLDER.equals(child.getType())) {
continue;
}
List<ICubridNode> childList = child.getChildren();
if (childList == null) {
continue;
}
for (ICubridNode node : childList) {
if (!NodeType.DATABASE.equals(node.getType())) {
continue;
}
CubridDatabase database = (CubridDatabase) node;
database.setLogined(false);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
}
}
}
// Refresh the tree view
server.removeAllChild();
if (server.getLoader() != null) {
server.getLoader().setLoaded(false);
}
treeViewer.refresh(server, true);
treeViewer.expandToLevel(server, 1);
treeViewer.setSelection(null, true);
treeViewer.setSelection(new StructuredSelection(server), true);
setEnabled(false);
// Save the data
CMHostNodePersistManager.getInstance().addServer(server.getServerInfo().getHostAddress(), server.getServerInfo().getHostMonPort(), server.getServerInfo().getUserName(), server.getServerInfo());
QueryOptions.removePref(server.getServerInfo());
BrokerIntervalSettingManager.getInstance().removeAllBrokerIntervalSettingInServer(server.getLabel());
CMGroupNodePersistManager.getInstance().saveAllGroupNode();
CMHostNodePersistManager.getInstance().saveServers();
ActionManager.getInstance().fireSelectionChanged(getSelection());
LayoutManager.getInstance().fireSelectionChanged(getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_DISCONNECTED));
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class ChangeManagerPasswordAction method run.
/**
* Open change password dialog and change CUBRID Manager user password
*/
public void run() {
final Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
return;
}
ICubridNode node = (ICubridNode) obj[0];
CubridServer server = node.getServer();
ChangePasswordDialog changePasswordDialog = new ChangePasswordDialog(getShell(), false);
changePasswordDialog.setServerInfo(server.getServerInfo());
ISelectionProvider provider = this.getSelectionProvider();
if (IDialogConstants.OK_ID == changePasswordDialog.open() && provider instanceof TreeViewer) {
TreeViewer viewer = (TreeViewer) provider;
boolean isContinue = HostUtils.processHostDisconnected(server);
if (isContinue) {
viewer.refresh(server, true);
ActionManager.getInstance().fireSelectionChanged(getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_DISCONNECTED));
}
}
}
Aggregations