use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class DBSpaceLabelProvider method nodeChanged.
/**
* Perform node change event
*/
public void nodeChanged(CubridNodeChangedEvent event) {
ICubridNode cubridNode = event.getCubridNode();
CubridNodeChangedEventType eventType = event.getType();
if (cubridNode == null || eventType == null) {
return;
}
if (NodeType.SERVER.equals(cubridNode.getType())) {
if (CubridNodeChangedEventType.SERVER_DISCONNECTED.equals(eventType) || CubridNodeChangedEventType.NODE_REMOVE.equals(eventType)) {
if (serverInfo != null && StringUtil.isEqualNotIgnoreNull(cubridNode.getName(), serverInfo.getServerName())) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
window.getActivePage().closeEditor(this, true);
}
}
}
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class EditBrokerConfigAction method run.
public void run() {
final Object[] obj = this.getSelectedObj();
if (obj == null || obj.length <= 0) {
setEnabled(false);
return;
}
CubridServer server = null;
if (obj[0] instanceof CubridServer) {
server = (CubridServer) obj[0];
} else if (obj[0] instanceof CubridBrokerFolder) {
server = ((CubridBrokerFolder) obj[0]).getServer();
}
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null || server == null) {
return;
}
ConfEditInput editorInput = new ConfEditInput();
String id = ConfigType.CUBRID_BROKER.getValue() + "&" + server.getId();
editorInput.setId(id);
editorInput.setServerInfo(server.getServerInfo());
editorInput.setName(server.getName());
editorInput.setServerName(server.getServerName());
editorInput.setServerPort(server.getMonPort());
String[] tipMsg = new String[] { ConfigType.CUBRID_BROKER.getValue(), server.getName(), server.getServerName(), server.getMonPort() };
String toolTipText = Messages.bind(Messages.msgEditorTooltip, tipMsg);
editorInput.setToolTipText(toolTipText);
try {
window.getActivePage().openEditor(editorInput, EditCMCubridBrokerConfPart.ID);
} catch (Exception ex) {
LOGGER.error("", ex);
}
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class HostDashboardAction method getOpenedEditorPart.
/**
* Get all opened query editor
*
* @return
*/
private HostDashboardEditor getOpenedEditorPart(String serverName) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return null;
}
IEditorReference[] editorReferences = window.getActivePage().getEditorReferences();
for (IEditorReference reference : editorReferences) {
if (reference.getId().equals(HostDashboardEditor.ID)) {
HostDashboardEditor editor = (HostDashboardEditor) reference.getEditor(false);
if (editor != null && editor.getServerInfo() != null && editor.getServerInfo().getServerName().equals(serverName)) {
return editor;
}
}
}
return null;
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class HostDashboardAction method doRun.
public void doRun(ServerInfo serverInfo) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == window) {
return;
}
// Check it open same editor
HostDashboardEditor editorPart = getOpenedEditorPart(serverInfo.getServerName());
if (editorPart == null) {
HostDashboardEditorInput editorInput = new HostDashboardEditorInput(serverInfo);
editorInput.setName(serverInfo.getServerName());
editorInput.setToolTipText(serverInfo.getServerName());
try {
editorPart = (HostDashboardEditor) window.getActivePage().openEditor(editorInput, HostDashboardEditor.ID);
} catch (PartInitException ex) {
LOGGER.error(ex.getMessage());
}
} else {
window.getActivePage().activate(editorPart);
editorPart.loadAllData();
}
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class LogViewAction method run.
/**
* Open the log editor and show log content
*/
public void run() {
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
if (cubridNode == null) {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
cubridNode = (ICubridNode) obj[0];
}
LogInfo logInfo = (LogInfo) cubridNode.getAdapter(LogInfo.class);
final String filePath = logInfo.getPath();
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
cubridNode = null;
return Status.CANCEL_STATUS;
}
for (ITask task : taskList) {
task.execute();
final String msg = task.getErrorMsg();
if (monitor.isCanceled()) {
cubridNode = null;
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
cubridNode = null;
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
}
if (task instanceof CheckFileTask) {
CheckFileTask checkFileTask = (CheckFileTask) task;
final String[] files = checkFileTask.getExistFiles();
if (files == null || files.length == 0) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, Messages.bind(Messages.errLogFileNoExist, filePath));
}
} else if (task instanceof GetLogListTask) {
GetLogListTask getLogListTask = (GetLogListTask) task;
final LogContentInfo logContentInfo = (LogContentInfo) getLogListTask.getLogContent();
Display.getDefault().syncExec(new Runnable() {
public void run() {
IEditorPart editorPart = LayoutUtil.getEditorPart(cubridNode, LogEditorPart.ID);
if (editorPart != null) {
window.getActivePage().closeEditor(editorPart, false);
}
try {
IEditorPart editor = window.getActivePage().openEditor(cubridNode, LogEditorPart.ID);
((LogEditorPart) editor).setTableInfo(logContentInfo, true);
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
}
});
}
if (monitor.isCanceled()) {
cubridNode = null;
return Status.CANCEL_STATUS;
}
}
cubridNode = null;
return Status.OK_STATUS;
}
};
CheckFileTask checkFileTask = new CheckFileTask(cubridNode.getServer().getServerInfo());
checkFileTask.setFile(new String[] { filePath });
taskJobExecutor.addTask(checkFileTask);
GetLogListTask task = new GetLogListTask(cubridNode.getServer().getServerInfo());
task.setPath(filePath);
task.setStart("1");
task.setEnd("100");
taskJobExecutor.addTask(task);
String jobName = Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
}
Aggregations