Search in sources :

Example 26 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project translationstudio8 by heartsome.

the class ImportDocxHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    XLIFFEditorImplWithNatTable xliffEditor = null;
    Shell shell = HandlerUtil.getActiveShell(event);
    String partId = HandlerUtil.getActivePartId(event);
    IFile file = null;
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (editor instanceof XLIFFEditorImplWithNatTable) {
        xliffEditor = (XLIFFEditorImplWithNatTable) editor;
    }
    if (partId.equals("net.heartsome.cat.common.ui.navigator.view")) {
        // 导航视图处于激活状态
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IViewPart viewPart = page.findView("net.heartsome.cat.common.ui.navigator.view");
        StructuredSelection selection = (StructuredSelection) viewPart.getSite().getSelectionProvider().getSelection();
        if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
            List<?> lstObj = ((IStructuredSelection) selection).toList();
            ArrayList<IFile> lstXliff = new ArrayList<IFile>();
            for (Object obj : lstObj) {
                if (obj instanceof IFile) {
                    IFile tempFile = (IFile) obj;
                    // Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空
                    if (tempFile.getFileExtension() != null && CommonFunction.validXlfExtension(tempFile.getFileExtension())) {
                        lstXliff.add(tempFile);
                    }
                }
            }
            if (lstXliff.size() > 1) {
                MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg1"));
                return null;
            }
            if (lstXliff.size() == 1) {
                file = lstXliff.get(0);
            }
        }
    } else if (partId.equals("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor")) {
        // nattable 处于激活状态
        IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
        IEditorInput editorInput = ((IEditorPart) part).getEditorInput();
        IFile iFile = (IFile) editorInput.getAdapter(IFile.class);
        if (xliffEditor.isMultiFile()) {
            MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg2"));
            return null;
        } else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) {
            file = iFile;
        }
    }
    if (file != null) {
        XLFValidator.resetFlag();
        if (!XLFValidator.validateXliffFile(file)) {
            return null;
        }
        XLFValidator.resetFlag();
    }
    ImportDocxDialog dialog = new ImportDocxDialog(shell, xliffEditor, file == null ? "" : file.getFullPath().toOSString(), file == null ? "" : ResourceUtils.iFileToOSPath(file));
    dialog.open();
    return null;
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) IViewPart(org.eclipse.ui.IViewPart) IFile(org.eclipse.core.resources.IFile) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ArrayList(java.util.ArrayList) IEditorPart(org.eclipse.ui.IEditorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ImportDocxDialog(net.heartsome.cat.ts.ui.docx.dialog.ImportDocxDialog) Shell(org.eclipse.swt.widgets.Shell) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorInput(org.eclipse.ui.IEditorInput)

Example 27 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project translationstudio8 by heartsome.

the class ImportExternal method execute.

@SuppressWarnings("deprecation")
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    XLIFFEditorImplWithNatTable xliffEditor = null;
    final Shell shell = HandlerUtil.getActiveShell(event);
    String partId = HandlerUtil.getActivePartId(event);
    IFile file = null;
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (editor instanceof XLIFFEditorImplWithNatTable) {
        xliffEditor = (XLIFFEditorImplWithNatTable) editor;
    }
    if (partId.equals("net.heartsome.cat.common.ui.navigator.view")) {
        // 导航视图处于激活状态
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IViewPart viewPart = page.findView("net.heartsome.cat.common.ui.navigator.view");
        StructuredSelection selection = (StructuredSelection) viewPart.getSite().getSelectionProvider().getSelection();
        if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
            List<?> lstObj = ((IStructuredSelection) selection).toList();
            ArrayList<IFile> lstXliff = new ArrayList<IFile>();
            for (Object obj : lstObj) {
                if (obj instanceof IFile) {
                    IFile tempFile = (IFile) obj;
                    // Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空
                    if (tempFile.getFileExtension() != null && CommonFunction.validXlfExtension(tempFile.getFileExtension())) {
                        lstXliff.add(tempFile);
                    }
                }
            }
            if (lstXliff.size() > 1) {
                MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg1"));
                return null;
            }
            if (lstXliff.size() == 1) {
                file = lstXliff.get(0);
            }
        }
    } else if (partId.equals("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor")) {
        // nattable 处于激活状态
        IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
        IEditorInput editorInput = ((IEditorPart) part).getEditorInput();
        IFile iFile = (IFile) editorInput.getAdapter(IFile.class);
        if (xliffEditor.isMultiFile()) {
            MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg2"));
            return null;
        } else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) {
            file = iFile;
        }
    }
    if (file != null) {
        XLFValidator.resetFlag();
        if (!XLFValidator.validateXliffFile(file)) {
            return null;
        }
        XLFValidator.resetFlag();
    }
    final ImportConfig config = new ImportConfig();
    config.setShell(shell);
    config.set_xliff(file == null ? "" : file.getFullPath().toOSString());
    config.setXliffEditor(xliffEditor);
    config.setXliffFile(file == null ? "" : ResourceUtils.iFileToOSPath(file));
    HsMultiActiveCellEditor.commit(true);
    ImportExternalDialog dialog = new ImportExternalDialog(shell, xliffEditor, config);
    if (Dialog.OK == dialog.open()) {
        config.doImport();
        if (xliffEditor != null) {
            // reopen if need
            if (xliffEditor.getXLFHandler().getVnMap().get(config.getXliffFile()) != null) {
                Map<String, Object> resultMap = xliffEditor.getXLFHandler().openFile(config.getXliffFile());
                if (resultMap == null || Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap.get(Constant.RETURNVALUE_RESULT)) {
                    // 打开文件失败。
                    MessageDialog.openWarning(shell, Messages.getString("all.dialog.warning"), MessageFormat.format(Messages.getString("ImportDocxDialog.ok.parseError"), config.get_xliff()));
                    LOGGER.error(MessageFormat.format(Messages.getString("ImportDocxDialog.ok.parseError"), config.get_xliff()));
                    return null;
                }
                xliffEditor.reloadData();
                HsMultiCellEditorControl.activeSourceAndTargetCell(xliffEditor);
            }
        }
    }
    return null;
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) IViewPart(org.eclipse.ui.IViewPart) IFile(org.eclipse.core.resources.IFile) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ArrayList(java.util.ArrayList) IEditorPart(org.eclipse.ui.IEditorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Shell(org.eclipse.swt.widgets.Shell) ImportConfig(net.heartsome.cat.ts.ui.external.ImportConfig) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorInput(org.eclipse.ui.IEditorInput) ImportExternalDialog(net.heartsome.cat.ts.ui.docx.dialog.ImportExternalDialog)

Example 28 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project translationstudio8 by heartsome.

the class SetSplitPointByWordNumHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    final String navegatorID = "net.heartsome.cat.common.ui.navigator.view";
    final String XLIFF_EDITOR_ID = "net.heartsome.cat.ts.ui.xliffeditor.nattable.editor";
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    final Shell shell = window.getShell();
    IFile selectFile = null;
    XLIFFEditorImplWithNatTable xliffEditor = null;
    IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    // 如果是导航视图,那么就获取导航视图中选中的文件
    if (activePart instanceof IViewPart) {
        if (navegatorID.equals(activePart.getSite().getId())) {
            IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(navegatorID);
            ISelection currentSelection = (StructuredSelection) viewPart.getSite().getSelectionProvider().getSelection();
            if (currentSelection != null && !currentSelection.isEmpty() && currentSelection instanceof IStructuredSelection) {
                IStructuredSelection structuredSelection = (IStructuredSelection) currentSelection;
                Object object = structuredSelection.getFirstElement();
                if (object instanceof IFile) {
                    selectFile = (IFile) object;
                    String fileExtension = selectFile.getFileExtension();
                    // 如果后缀名不是xlf,那么就退出操作
                    if (fileExtension == null || !CommonFunction.validXlfExtension(fileExtension)) {
                        MessageDialog.openInformation(shell, Messages.getString("handler.SplitXliffHandler.msgTitle"), Messages.getString("handler.SplitXliffHandler.msg1"));
                        return null;
                    }
                    FileEditorInput fileInput = new FileEditorInput(selectFile);
                    IEditorReference[] editorRefer = window.getActivePage().findEditors(fileInput, XLIFF_EDITOR_ID, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
                    IEditorPart editorPart = null;
                    if (editorRefer.length >= 1) {
                        editorPart = editorRefer[0].getEditor(true);
                        xliffEditor = (XLIFFEditorImplWithNatTable) editorPart;
                        if (window.getActivePage().getActiveEditor() != editorPart) {
                            window.getActivePage().activate(editorPart);
                        }
                    } else {
                        try {
                            xliffEditor = (XLIFFEditorImplWithNatTable) window.getActivePage().openEditor(fileInput, XLIFF_EDITOR_ID, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
                        } catch (PartInitException e) {
                            LOGGER.error("", e);
                            e.printStackTrace();
                        }
                    }
                } else {
                    MessageDialog.openInformation(shell, Messages.getString("all.dialog.info"), Messages.getString("SetSplitPointHandler.cantSetPointToNotXlf"));
                    return null;
                }
            }
        }
    } else if (activePart instanceof IEditorPart) {
        if (XLIFF_EDITOR_ID.equals(activePart.getSite().getId())) {
            xliffEditor = (XLIFFEditorImplWithNatTable) activePart;
            if (xliffEditor.isMultiFile()) {
                MessageDialog.openInformation(shell, Messages.getString("all.dialog.info"), Messages.getString("SetSplitPointByWOrdNumHandler.cantSetForMulty"));
                return null;
            }
            selectFile = ((FileEditorInput) xliffEditor.getEditorInput()).getFile();
        }
    }
    if (selectFile == null) {
        return null;
    }
    XLIFFEditorImplWithNatTable nattable = XLIFFEditorImplWithNatTable.getCurrent();
    final XLFHandler xlfHander = nattable.getXLFHandler();
    Map<String, Integer> rowWordNumMap = xlfHander.getSplitFileInfoForPointSetting(selectFile.getLocation().toOSString());
    if (rowWordNumMap.size() <= 1) {
        MessageDialog.openInformation(shell, Messages.getString("all.dialog.info"), Messages.getString("SetSplitPointHandler.cantSetPointForTuNum"));
        return null;
    }
    List<String> splitPointList = nattable.getSplitXliffPoints();
    // 排序之前先过滤重复
    HashSet<String> set = new HashSet<String>(splitPointList);
    splitPointList.clear();
    splitPointList.addAll(set);
    // 先对 splitPointList 进行排序
    Collections.sort(splitPointList, new Comparator<String>() {

        public int compare(String rowId1, String rowId2) {
            int rowIndex1 = xlfHander.getRowIndex(rowId1);
            int rowIndex2 = xlfHander.getRowIndex(rowId2);
            return rowIndex1 > rowIndex2 ? 1 : -1;
        }
    });
    List<SegPointBean> segPointList = new ArrayList<SegPointBean>();
    if (splitPointList.size() > 0) {
        int segWordNum = 0;
        int i = 0;
        String pointRowId = splitPointList.get(i);
        for (Entry<String, Integer> entry : rowWordNumMap.entrySet()) {
            segWordNum += entry.getValue();
            if (pointRowId.equals(entry.getKey())) {
                segPointList.add(new SegPointBean(segWordNum));
                segWordNum = 0;
                i++;
                if (i < splitPointList.size()) {
                    pointRowId = splitPointList.get(i);
                }
            }
        }
        if (splitPointList.size() + 1 > segPointList.size()) {
            segPointList.add(new SegPointBean(segWordNum));
        }
    }
    SetSplitPointByWordNumDialog dialog = new SetSplitPointByWordNumDialog(shell, xlfHander, selectFile.getLocation().toOSString(), rowWordNumMap, segPointList);
    int openResult = dialog.open();
    if (openResult == IDialogConstants.OK_ID) {
        // 如果选择确定,那么在界面上生成分割点
        nattable.getSplitXliffPoints().clear();
        for (SegPointBean bean : segPointList) {
            if (bean.getRowId() != null && !bean.getRowId().isEmpty()) {
                nattable.getSplitXliffPoints().add(bean.getRowId());
            }
        }
        nattable.refresh();
    }
    return null;
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) IViewPart(org.eclipse.ui.IViewPart) IFile(org.eclipse.core.resources.IFile) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Shell(org.eclipse.swt.widgets.Shell) IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ISelection(org.eclipse.jface.viewers.ISelection) PartInitException(org.eclipse.ui.PartInitException) SetSplitPointByWordNumDialog(net.heartsome.cat.ts.handlexlf.dialog.SetSplitPointByWordNumDialog) HashSet(java.util.HashSet) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) SegPointBean(net.heartsome.cat.ts.core.bean.SegPointBean) IEditorPart(org.eclipse.ui.IEditorPart) FileEditorInput(org.eclipse.ui.part.FileEditorInput) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler)

Example 29 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project translationstudio8 by heartsome.

the class UpdateTMHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell shell = HandlerUtil.getActiveShell(event);
    String partId = HandlerUtil.getActivePartId(event);
    ArrayList<IFile> lstXliff = new ArrayList<IFile>();
    //		boolean isShowCurrentLangBtn = true;
    if (partId.equals("net.heartsome.cat.common.ui.navigator.view")) {
        // 导航视图处于激活状态
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IViewPart viewPart = page.findView("net.heartsome.cat.common.ui.navigator.view");
        StructuredSelection selection = (StructuredSelection) viewPart.getSite().getSelectionProvider().getSelection();
        // ISelection selection = HandlerUtil.getCurrentSelection(event);
        if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
            List<?> lstObj = ((IStructuredSelection) selection).toList();
            for (Object obj : lstObj) {
                if (obj instanceof IFile) {
                    IFile file = (IFile) obj;
                    // Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空
                    if (file.getFileExtension() != null && CommonFunction.validXlfExtension(file.getFileExtension())) {
                        lstXliff.add(file);
                    }
                } else if (obj instanceof IFolder) {
                    try {
                        ResourceUtils.getXliffs((IFolder) obj, lstXliff);
                    } catch (CoreException e) {
                        LOGGER.error(Messages.getString("handler.UpdateTMHandler.logger1"), e);
                        MessageDialog.openInformation(shell, Messages.getString("handler.UpdateTMHandler.msgTitle"), Messages.getString("handler.UpdateTMHandler.msg1"));
                    }
                } else if (obj instanceof IProject) {
                    try {
                        ResourceUtils.getXliffs((IProject) obj, lstXliff);
                    } catch (CoreException e) {
                        LOGGER.error(Messages.getString("handler.UpdateTMHandler.logger2"), e);
                        MessageDialog.openInformation(shell, Messages.getString("handler.UpdateTMHandler.msgTitle"), Messages.getString("handler.UpdateTMHandler.msg2"));
                    }
                }
            }
            CommonFunction.removeRepeateSelect(lstXliff);
            if (lstXliff.size() == 0) {
                MessageDialog.openInformation(shell, Messages.getString("handler.UpdateTMHandler.msgTitle"), Messages.getString("handler.UpdateTMHandler.msg3"));
                return null;
            }
            Iterator<IFile> iterator = lstXliff.iterator();
            while (iterator.hasNext()) {
                IFile file = iterator.next();
                FileEditorInput editorInput = new FileEditorInput(file);
                IEditorPart editorPart = page.findEditor(editorInput);
                if (editorPart == null || (editorPart != null && !(editorPart instanceof IXliffEditor))) {
                    //						isShowCurrentLangBtn = false;
                    break;
                }
            }
        } else {
            MessageDialog.openInformation(shell, Messages.getString("handler.UpdateTMHandler.msgTitle"), Messages.getString("handler.UpdateTMHandler.msg3"));
            return null;
        }
    } else if (partId.equals("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor")) {
        // nattable 处于激活状态
        IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
        IEditorInput editorInput = ((IEditorPart) part).getEditorInput();
        IFile iFile = (IFile) editorInput.getAdapter(IFile.class);
        IEditorPart editor = HandlerUtil.getActiveEditor(event);
        IXliffEditor xliffEditor = (IXliffEditor) editor;
        if (xliffEditor.isMultiFile()) {
            List<String> lstFile = new XLFHandler().getMultiFiles(iFile);
            if (lstFile.size() > 0) {
                for (String filePath : lstFile) {
                    lstXliff.add(ResourceUtils.fileToIFile(filePath));
                }
            }
        } else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) {
            lstXliff.add(iFile);
        }
    }
    if (lstXliff.size() > 0) {
        if (lstXliff.size() > 1) {
            String projectPath = lstXliff.get(0).getProject().getFullPath().toOSString();
            for (int i = 1; i < lstXliff.size(); i++) {
                String projectPath2 = lstXliff.get(i).getProject().getFullPath().toOSString();
                if (!projectPath.equals(projectPath2)) {
                    MessageDialog.openInformation(shell, Messages.getString("handler.UpdateTMHandler.msgTitle"), Messages.getString("handler.UpdateTMHandler.msg4"));
                    return null;
                }
            }
        }
        ArrayList<IFile> lstFiles = new ArrayList<IFile>();
        XLFValidator.resetFlag();
        for (IFile iFile : lstXliff) {
            if (!XLFValidator.validateXliffFile(iFile)) {
                lstFiles.add(iFile);
            }
        }
        XLFValidator.resetFlag();
        lstXliff.removeAll(lstFiles);
        if (lstXliff.size() == 0) {
            return null;
        }
        ProjectConfiger projectConfig = ProjectConfigerFactory.getProjectConfiger(lstXliff.get(0).getProject());
        if (projectConfig.getDefaultTMDb() == null) {
            MessageDialog.openInformation(shell, Messages.getString("handler.UpdateTMHandler.msgTitle"), Messages.getString("handler.UpdateTMHandler.msg5"));
            return null;
        }
        UpdateTMWizard wizard = new UpdateTMWizard(lstXliff);
        TSWizardDialog dialog = new UpdateTMWizardDialog(shell, wizard);
        //			UpdateTMDialog dialog = new UpdateTMDialog(shell, isShowCurrentLangBtn, lstXliff);
        dialog.open();
    }
    return null;
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IXliffEditor(net.heartsome.cat.ts.ui.editors.IXliffEditor) UpdateTMWizard(net.heartsome.cat.database.ui.tm.wizard.UpdateTMWizard) Shell(org.eclipse.swt.widgets.Shell) UpdateTMWizardDialog(net.heartsome.cat.database.ui.tm.wizard.UpdateTMWizardDialog) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ProjectConfiger(net.heartsome.cat.ts.core.file.ProjectConfiger) ArrayList(java.util.ArrayList) List(java.util.List) IEditorPart(org.eclipse.ui.IEditorPart) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) TSWizardDialog(net.heartsome.cat.common.ui.wizard.TSWizardDialog) IEditorInput(org.eclipse.ui.IEditorInput) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler) IFolder(org.eclipse.core.resources.IFolder)

Example 30 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project translationstudio8 by heartsome.

the class StyledTextCellEditor method close.

public void close() {
    if (close) {
        return;
    }
    for (Listener listener : closingListeners) {
        Event event = new Event();
        event.data = this;
        listener.handleEvent(event);
    }
    // 状态改为已经关闭
    close = true;
    xliffEditor.getTable().removeDisposeListener(this);
    StyledText text = viewer.getTextWidget();
    if (text != null && !text.isDisposed()) {
        actionHandler.removeTextViewer();
        // dispose前应去掉右键menu,因为右键menu是和nattable共享的
        text.setMenu(null);
        viewer.reset();
        text.dispose();
        text = null;
    }
    // 如果 XLIFF 编辑器仍处于激活状态,则把焦点交给编辑器
    try {
        IWorkbenchPart activepart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
        if (xliffEditor.equals(activepart)) {
            xliffEditor.setFocus();
        }
    } catch (NullPointerException e) {
    }
// NatTable table = xliffEditor.getTable();
// int[] rowPositions = new int[] { hsCellEditor.getRowPosition() };
// table.doCommand(new AutoResizeCurrentRowsCommand(table, rowPositions, table.getConfigRegistry()));
}
Also used : VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) DisposeListener(org.eclipse.swt.events.DisposeListener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseListener(org.eclipse.swt.events.MouseListener) FocusListener(org.eclipse.swt.events.FocusListener) IDocumentListener(org.eclipse.jface.text.IDocumentListener) Listener(org.eclipse.swt.widgets.Listener) KeyListener(org.eclipse.swt.events.KeyListener) StyledText(org.eclipse.swt.custom.StyledText) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) DocumentEvent(org.eclipse.jface.text.DocumentEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Event(org.eclipse.swt.widgets.Event) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Aggregations

IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)50 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)21 IEditorPart (org.eclipse.ui.IEditorPart)17 ISelection (org.eclipse.jface.viewers.ISelection)16 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)12 ArrayList (java.util.ArrayList)11 Shell (org.eclipse.swt.widgets.Shell)11 IFile (org.eclipse.core.resources.IFile)10 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)10 IViewPart (org.eclipse.ui.IViewPart)10 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)10 IEditorInput (org.eclipse.ui.IEditorInput)8 Command (org.eclipse.gef.commands.Command)6 CommandStack (org.eclipse.gef.commands.CommandStack)6 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)5 PartInitException (org.eclipse.ui.PartInitException)5 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)5 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)4 Iterator (java.util.Iterator)3 IPartListener (org.eclipse.ui.IPartListener)3