use of com.cubrid.common.ui.cubrid.trigger.dialog.CreateTriggerDialog 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.cubrid.trigger.dialog.CreateTriggerDialog in project cubrid-manager by CUBRID.
the class NewTriggerAction method run.
/**
* Create trigger
* @param database CubridDatabase
*/
public void run(CubridDatabase database) {
CreateTriggerDialog dlg = new CreateTriggerDialog(getShell(), database);
ISelectionProvider provider = getSelectionProvider();
if (dlg.open() == IDialogConstants.OK_ID && (provider instanceof TreeViewer)) {
TreeViewer treeViewer = (TreeViewer) provider;
ICubridNode folderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridTriggerFolderLoader.TRIGGER_FOLDER_ID);
if (folderNode == null || !folderNode.getLoader().isLoaded()) {
return;
}
String triggerName = dlg.getTriggerName().toLowerCase(Locale.getDefault());
String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + triggerName;
Trigger trigger = new Trigger();
trigger.setName(triggerName);
ICubridNode newNode = CubridTriggerFolderLoader.createTriggerNode(id, trigger);
CommonUITool.addNodeToTree(treeViewer, folderNode, newNode);
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, folderNode);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
}
}
Aggregations