Search in sources :

Example 31 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project translationstudio8 by heartsome.

the class SrxConfigurationDialog method createHelpToolItem.

/**
	 * 添加帮助按钮,备注,这里的配置与其他的不一样
	 * robert	2012-09-06
	 */
protected Control createHelpToolItem(Composite parent) {
    // ROBERTHELP 分段规则管理器
    String language = CommonFunction.getSystemLanguage();
    final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s03#segmentation-rule-manager", language);
    Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
    ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
    toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
    toolBar.setCursor(cursor);
    toolBar.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            cursor.dispose();
        }
    });
    ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
    helpItem.setImage(helpImage);
    //$NON-NLS-1$
    helpItem.setToolTipText(JFaceResources.getString("helpToolTip"));
    helpItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
        }
    });
    return toolBar;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Image(org.eclipse.swt.graphics.Image) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 32 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project translationstudio8 by heartsome.

the class XmlConverterConfigurationDialog method createHelpToolItem.

/**
	 * 添加帮助按钮,备注,这里的配置与其他的不一样
	 * robert	2012-09-06
	 */
protected Control createHelpToolItem(Composite parent) {
    // ROBERTHELP xml 转换器配置
    String language = CommonFunction.getSystemLanguage();
    final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch08.html#configure-xml-converter", language);
    Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
    ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
    toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
    toolBar.setCursor(cursor);
    toolBar.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            cursor.dispose();
        }
    });
    ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
    helpItem.setImage(helpImage);
    //$NON-NLS-1$
    helpItem.setToolTipText(JFaceResources.getString("helpToolTip"));
    helpItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
        }
    });
    return toolBar;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Image(org.eclipse.swt.graphics.Image) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 33 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project translationstudio8 by heartsome.

the class QAResultViewPart method createPropMenu.

/**
	 * 创建右键参数
	 */
private void createPropMenu() {
    Menu propMenu = new Menu(table);
    table.setMenu(propMenu);
    MenuItem deletWarnItem = new MenuItem(propMenu, SWT.NONE);
    deletWarnItem.setText(Messages.getString("views.QAResultViewPart.deletWarnItem"));
    deletWarnItem.setImage(deleteImage);
    deletWarnItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            QAResultBean bean;
            for (int i = 0; i < dataList.size(); i++) {
                bean = dataList.get(i);
                // 0为错误,1为警告
                if (1 == bean.getLevel()) {
                    dataList.remove(bean);
                    i--;
                }
            }
            tableModel.textRenderer.clearRowHeiMap();
            table.redraw();
        }
    });
    MenuItem deleteAllItem = new MenuItem(propMenu, SWT.NONE);
    deleteAllItem.setText(Messages.getString("views.QAResultViewPart.deleteAllItem"));
    deleteAllItem.setImage(deleteImage);
    deleteAllItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            dataList.clear();
            tableModel.textRenderer.clearRowHeiMap();
            table.redraw();
        }
    });
    // 导出品质检查报告
    exportItem = new MenuItem(propMenu, SWT.NONE);
    exportItem.setText(Messages.getString("qa.views.QAResultViewPart.exportPopMenu"));
    exportItem.setImage(exportImg);
    exportItem.setEnabled(false);
    exportItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ExportQAResultDialog dialog = new ExportQAResultDialog(getSite().getShell());
            int result = dialog.open();
            if (result == IDialogConstants.OK_ID) {
                final String exportFilePath = dialog.getExportFilePath();
                if (exportFilePath == null || exportFilePath.isEmpty()) {
                    MessageDialog.openInformation(getSite().getShell(), Messages.getString("qa.all.dialog.info"), Messages.getString("qa.views.QAResultViewPart.msg.nullFilePath"));
                    return;
                }
                IRunnableWithProgress runnable = new IRunnableWithProgress() {

                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        monitor.beginTask("", 1);
                        while (!isQAEnd) {
                            try {
                                Thread.sleep(500);
                            } catch (Exception e2) {
                                logger.error("", e2);
                            }
                            if (monitor.isCanceled()) {
                                return;
                            }
                        }
                        List<QAResultBean> exportDataList = new ArrayList<QAResultBean>();
                        exportDataList.addAll(dataList);
                        ExportQAResult export = new ExportQAResult(isMultiFile, exportFilePath);
                        export.beginExport(dataList, filePathList, monitor);
                        monitor.done();
                    }
                };
                try {
                    new ProgressMonitorDialog(getSite().getShell()).run(true, true, runnable);
                } catch (Exception e1) {
                    logger.error("", e1);
                }
            }
        }
    });
    propMenu.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            if (deleteImage != null && !deleteImage.isDisposed()) {
                deleteImage.dispose();
            }
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) QAResultBean(net.heartsome.cat.ts.ui.qa.model.QAResultBean) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) MenuItem(org.eclipse.swt.widgets.MenuItem) DisposeEvent(org.eclipse.swt.events.DisposeEvent) InvocationTargetException(java.lang.reflect.InvocationTargetException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ExportQAResult(net.heartsome.cat.ts.ui.qa.export.ExportQAResult) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ExportQAResultDialog(net.heartsome.cat.ts.ui.qa.export.ExportQAResultDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) ArrayList(java.util.ArrayList) Menu(org.eclipse.swt.widgets.Menu)

Example 34 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project translationstudio8 by heartsome.

the class Comparator method Compare.

/**
	 * 用于比较的参照文本(不含内部标记)
	 * @param referenceText
	 * @param text
	 *            ;
	 */
public static void Compare(String referenceText, StyledText text) {
    ColorConfigBean colorCfgBean = ColorConfigBean.getInstance();
    final Color differencefg = colorCfgBean.getSrcDiffFgColor();
    final Color differencebg = colorCfgBean.getSrcDiffBgColor();
    Position[] tagRanges = InnerTagUtil.getStyledTagRanges(text.getText());
    TokenComparator left = new TokenComparator(InnerTagUtil.getDisplayValueWithoutTags(text.getText()));
    TokenComparator right = new TokenComparator(referenceText);
    ArrayList<StyleRange> styleRanges = new ArrayList<StyleRange>();
    RangeDifference[] e = RangeDifferencer.findRanges(left, right);
    for (int i = 0; i < e.length; i++) {
        RangeDifference es = e[i];
        int leftStart = es.leftStart();
        int leftEnd = es.leftEnd();
        int lStart = left.getTokenStart(leftStart);
        int lEnd = left.getTokenStart(leftEnd);
        if (es.kind() == RangeDifference.CHANGE) {
            int start = lStart;
            int end = lEnd;
            if (tagRanges.length > 0) {
                for (Position tagRange : tagRanges) {
                    int tagStart = tagRange.getOffset();
                    int tagEnd = tagRange.getOffset() + tagRange.getLength();
                    if (tagStart <= start) {
                        start += tagRange.getLength();
                        end += tagRange.getLength();
                    } else if (start < tagStart && tagStart < end) {
                        StyleRange range = new StyleRange(start, tagStart - start, differencefg, differencebg);
                        styleRanges.add(range);
                        start = tagEnd;
                        end += tagRange.getLength();
                    } else {
                        break;
                    }
                }
            }
            StyleRange range = new StyleRange(start, end - start, differencefg, differencebg);
            styleRanges.add(range);
        }
    }
    for (int i = 0; i < styleRanges.size(); i++) {
        text.setStyleRange(styleRanges.get(i));
        text.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(DisposeEvent e) {
                differencefg.dispose();
                differencebg.dispose();
            }
        });
    }
}
Also used : ColorConfigBean(net.heartsome.cat.common.bean.ColorConfigBean) DisposeListener(org.eclipse.swt.events.DisposeListener) Position(org.eclipse.jface.text.Position) Color(org.eclipse.swt.graphics.Color) StyleRange(org.eclipse.swt.custom.StyleRange) ArrayList(java.util.ArrayList) DisposeEvent(org.eclipse.swt.events.DisposeEvent) RangeDifference(org.eclipse.compare.rangedifferencer.RangeDifference)

Example 35 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project translationstudio8 by heartsome.

the class AutoResizeColumnAction method run.

public void run(NatTable natTable, MouseEvent event) {
    if (gc == null) {
        gc = new GC(natTable);
        natTable.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(DisposeEvent e) {
                gc.dispose();
            }
        });
    }
    Point clickPoint = new Point(event.x, event.y);
    int column = CellEdgeDetectUtil.getColumnPositionToResize(natTable, clickPoint);
    InitializeAutoResizeColumnsCommand command = new InitializeAutoResizeColumnsCommand(natTable, column, natTable.getConfigRegistry(), gc);
    natTable.doCommand(command);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) InitializeAutoResizeColumnsCommand(net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand) Point(org.eclipse.swt.graphics.Point) GC(org.eclipse.swt.graphics.GC) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Point(org.eclipse.swt.graphics.Point)

Aggregations

DisposeEvent (org.eclipse.swt.events.DisposeEvent)365 DisposeListener (org.eclipse.swt.events.DisposeListener)362 GridData (org.eclipse.swt.layout.GridData)103 Composite (org.eclipse.swt.widgets.Composite)91 SelectionEvent (org.eclipse.swt.events.SelectionEvent)88 GridLayout (org.eclipse.swt.layout.GridLayout)76 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)71 Image (org.eclipse.swt.graphics.Image)53 Cursor (org.eclipse.swt.graphics.Cursor)49 Label (org.eclipse.swt.widgets.Label)42 ToolBar (org.eclipse.swt.widgets.ToolBar)42 Point (org.eclipse.swt.graphics.Point)38 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)37 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)36 Control (org.eclipse.swt.widgets.Control)36 Color (org.eclipse.swt.graphics.Color)35 FillLayout (org.eclipse.swt.layout.FillLayout)35 Event (org.eclipse.swt.widgets.Event)35 MouseEvent (org.eclipse.swt.events.MouseEvent)32 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)31