use of org.eclipse.ui.IWorkbenchWindow in project azure-tools-for-java by Microsoft.
the class DeployToAzureHandler method onExecute.
@Override
public Object onExecute(ExecutionEvent ee) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(ee);
IProject project = PluginUtil.getSelectedProject();
if (project != null) {
if (!SignInCommandHandler.doSignIn(window.getShell()))
return null;
WebAppDeployDialog.go(window.getShell(), project);
} else {
MessageDialog.openInformation(window.getShell(), "Deploy to Azure App Service", "Can't detect an active project");
}
return null;
}
use of org.eclipse.ui.IWorkbenchWindow in project azure-tools-for-java by Microsoft.
the class SelectSubsriptionsCommandHandler method onExecute.
@Override
public Object onExecute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
onSelectSubscriptions(window.getShell());
return null;
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class DatabaseDashboardEditor method showLogView.
/**
* show sql log view at broker table
*
* @param type sql type
*/
public void showLogView(String type) {
try {
int i = brokerInfoTable.getSelectionIndex();
if (i < 0) {
return;
}
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
String brokerName = brokerInfoTable.getItem(i).getText(0);
String serverId = brokerInfoTable.getItem(i).getText(1);
//get all log infor
BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
final CommonQueryTask<BrokerLogInfos> task = new CommonQueryTask<BrokerLogInfos>(database.getDatabaseInfo().getServerInfo(), CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
task.setBroker(brokerName);
task.execute();
brokerLogInfos = task.getResultModel();
String logFileName = brokerName + "_" + serverId + "." + type + ".log";
sqlLogViewPartName = logFileName + "@" + database.getServer().getLabel() + ":" + database.getServer().getMonPort();
List<LogInfo> logInfoList = brokerLogInfos == null ? null : brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
task.finish();
//get the current log
LogInfo logInfo = null;
if (logInfoList != null && !logInfoList.isEmpty()) {
for (LogInfo logInfoInlist : logInfoList) {
if (logFileName.equals(logInfoInlist.getName())) {
logInfo = logInfoInlist;
break;
}
}
}
if (logInfo == null) {
String msg = Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.errLogFileNoExist, logFileName);
LOGGER.error(msg);
//CommonUITool.openErrorBox(msg);
return;
}
final String filePath = logInfo.getPath();
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask task : taskList) {
task.execute();
final String msg = task.getErrorMsg();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
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(com.cubrid.cubridmanager.ui.logs.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() {
try {
ICubridNode logInfoNode = new DefaultCubridNode("", "", "");
IEditorPart editor = window.getActivePage().openEditor(logInfoNode, LogEditorPart.ID);
((LogEditorPart) editor).setTableInfo(logContentInfo, true);
((LogEditorPart) editor).setShowLogPartName(sqlLogViewPartName);
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
}
});
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
task.finish();
}
return Status.OK_STATUS;
}
};
CheckFileTask checkFileTask = new CheckFileTask(cubridNode.getServer().getServerInfo());
checkFileTask.setFile(new String[] { filePath });
taskJobExecutor.addTask(checkFileTask);
GetLogListTask getLogListTask = new GetLogListTask(cubridNode.getServer().getServerInfo());
getLogListTask.setPath(filePath);
getLogListTask.setStart("1");
getLogListTask.setEnd("100");
taskJobExecutor.addTask(getLogListTask);
String jobName = com.cubrid.cubridmanager.ui.logs.Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
} catch (Exception e) {
LOGGER.error(Messages.exportDashboardOpenSQLLogErrMsg, e);
// CommonUITool.openErrorBox(Messages.exportDashboardOpenSQLLogErrMsg);
}
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class OpenJobAutomationInfoAction method run.
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
final Object[] obj = this.getSelectedObj();
if (!isSupported(obj) || obj.length == 0) {
setEnabled(false);
return;
}
ICubridNode node = (ICubridNode) obj[0];
if (node.getType().equals(CubridNodeType.JOB_FOLDER)) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView("com.cubrid.cubridmanager.host.navigator");
if (view == null) {
return;
}
//if not expand ,expand the node and wait until all children be added
TreeViewer treeViewer = view.getViewer();
if (!treeViewer.getExpandedState(node)) {
treeViewer.expandToLevel(node, 1);
while (node.getChildren().size() == 0) {
ThreadUtil.sleep(500);
}
}
openJobsDetailInfoEditor(NodeUtil.getCubridDatabase(node));
}
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class OpenJobAutomationInfoAction method openJobsDetailInfoEditor.
/**
* open job detail info part
* @param database
*/
public void openJobsDetailInfoEditor(CubridDatabase database) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == window) {
return;
}
if (database == null) {
return;
}
/*Check it open same editor*/
IEditorPart editorPart = getOpenedEditorPart(database, JobAutoDashboardEditorPart.ID);
if (editorPart == null) {
OpenJobAutomationInfoPartProgress progress = new OpenJobAutomationInfoPartProgress(database);
progress.loadJobAutomationInfoList();
if (progress.isSuccess()) {
JobAutoDashboardInput input = new JobAutoDashboardInput(database, progress.getBackupPlanInfoList(), progress.getQueryPlanInfoList());
try {
window.getActivePage().openEditor(input, JobAutoDashboardEditorPart.ID);
} catch (PartInitException e) {
LOGGER.error("Can not initialize the trigger view list UI.", e);
}
}
} else {
JobAutoDashboardEditorPart jobAutoDetailInfoPart = (JobAutoDashboardEditorPart) editorPart;
window.getActivePage().activate(jobAutoDetailInfoPart);
jobAutoDetailInfoPart.refreshAll();
}
}
Aggregations