Search in sources :

Example 31 with PartInitException

use of org.eclipse.ui.PartInitException in project cubrid-manager by CUBRID.

the class OpenTargetAction method openTriggersDetailInfoEditor.

/**
	 * open trigger detail info part
	 * @param database
	 */
public void openTriggersDetailInfoEditor(CubridDatabase database) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (null == window) {
        return;
    }
    if (database == null) {
        return;
    }
    /*Check it open same editor*/
    IEditorPart editorPart = getOpenedEditorPart(database, TriggerDashboardEditorPart.ID);
    if (editorPart == null) {
        OpenTriggerDetailInfoPartProgress progress = new OpenTriggerDetailInfoPartProgress(database);
        progress.loadTriggerInfoList();
        if (progress.isSuccess()) {
            TriggerDashboardInput input = new TriggerDashboardInput(database, progress.getTriggerList());
            try {
                window.getActivePage().openEditor(input, TriggerDashboardEditorPart.ID);
            } catch (PartInitException e) {
                LOGGER.error("Can not initialize the trigger view list UI.", e);
            }
        }
    } else {
        TriggerDashboardEditorPart triggerDetailInfoPart = (TriggerDashboardEditorPart) editorPart;
        window.getActivePage().activate(triggerDetailInfoPart);
        triggerDetailInfoPart.refresh();
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) OpenTriggerDetailInfoPartProgress(com.cubrid.common.ui.spi.progress.OpenTriggerDetailInfoPartProgress) TriggerDashboardInput(com.cubrid.common.ui.cubrid.trigger.editor.TriggerDashboardInput) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) TriggerDashboardEditorPart(com.cubrid.common.ui.cubrid.trigger.editor.TriggerDashboardEditorPart)

Example 32 with PartInitException

use of org.eclipse.ui.PartInitException in project cubrid-manager by CUBRID.

the class SearchContributionComposite method processSearch.

public void processSearch() {
    if (text.getText().length() == 0) {
        return;
    }
    String key = StringUtil.urlencode(text.getText(), "UTF-8");
    if (key == null) {
        LOGGER.error("Encode key word error");
        return;
    }
    String url = getUrl(key);
    BrowserEditorPart browserViewPart = null;
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IEditorReference[] editorReferences = window.getActivePage().getEditorReferences();
    for (IEditorReference reference : editorReferences) {
        if (reference.getId().equals(BrowserEditorPart.ID)) {
            browserViewPart = (BrowserEditorPart) reference.getEditor(true);
        }
    }
    if (browserViewPart == null) {
        try {
            browserViewPart = (BrowserEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(new BrowserEditorPartInput(), BrowserEditorPart.ID);
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
    if (browserViewPart != null) {
        browserViewPart.go(url);
        // For bug TOOLS-1014
        window.getActivePage().activate(browserViewPart);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) PartInitException(org.eclipse.ui.PartInitException)

Example 33 with PartInitException

use of org.eclipse.ui.PartInitException 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);
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITask(com.cubrid.common.core.task.ITask) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) BrokerLogInfos(com.cubrid.cubridmanager.core.logs.model.BrokerLogInfos) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask) PartInitException(org.eclipse.ui.PartInitException) CheckFileTask(com.cubrid.cubridmanager.core.cubrid.database.task.CheckFileTask) LogEditorPart(com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)

Example 34 with PartInitException

use of org.eclipse.ui.PartInitException 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();
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) OpenJobAutomationInfoPartProgress(com.cubrid.cubridmanager.ui.cubrid.jobauto.progress.OpenJobAutomationInfoPartProgress) JobAutoDashboardInput(com.cubrid.cubridmanager.ui.cubrid.jobauto.editor.JobAutoDashboardInput) JobAutoDashboardEditorPart(com.cubrid.cubridmanager.ui.cubrid.jobauto.editor.JobAutoDashboardEditorPart) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException)

Example 35 with PartInitException

use of org.eclipse.ui.PartInitException in project cubrid-manager by CUBRID.

the class EditConfigEditor method createPropEditor.

/**
	 *
	 * Create the property editor
	 *
	 * @param parent the Composite
	 */
private void createPropEditor(Composite parent) {
    final Composite editorComp = new Composite(parent, SWT.NONE);
    {
        editorComp.setLayoutData(new GridData(GridData.FILL_BOTH));
        GridLayout gridLayout = new GridLayout();
        gridLayout.marginHeight = 0;
        gridLayout.horizontalSpacing = 0;
        gridLayout.marginWidth = 0;
        editorComp.setLayout(gridLayout);
    }
    propEditor = new PropEditor();
    try {
        propEditor.init(this.getEditorSite(), this.getEditorInput());
    } catch (PartInitException ex) {
        LOGGER.error(ex.getMessage());
    }
    propEditor.createPartControl(editorComp);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) PropEditor(com.cubrid.tool.editor.property.PropEditor) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

PartInitException (org.eclipse.ui.PartInitException)720 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)300 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)177 IFile (org.eclipse.core.resources.IFile)146 IEditorPart (org.eclipse.ui.IEditorPart)141 CoreException (org.eclipse.core.runtime.CoreException)94 FileEditorInput (org.eclipse.ui.part.FileEditorInput)88 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)82 IEditorInput (org.eclipse.ui.IEditorInput)74 ISelection (org.eclipse.jface.viewers.ISelection)62 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)60 IResource (org.eclipse.core.resources.IResource)59 IEditorReference (org.eclipse.ui.IEditorReference)53 IViewPart (org.eclipse.ui.IViewPart)53 IOException (java.io.IOException)42 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)41 Point (org.eclipse.swt.graphics.Point)40 IWorkbench (org.eclipse.ui.IWorkbench)40 Path (org.eclipse.core.runtime.Path)39 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)39