Search in sources :

Example 46 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project translationstudio8 by heartsome.

the class Martif2TBXConverterDialog method createMenu.

/**
	 * 创建菜单 ;
	 */
private void createMenu() {
    Menu menu = new Menu(getShell(), SWT.BAR);
    getShell().setMenuBar(menu);
    getShell().pack();
    Rectangle screenSize = Display.getDefault().getClientArea();
    Rectangle frameSize = getShell().getBounds();
    getShell().setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    Menu fileMenu = new Menu(menu);
    MenuItem fileItem = new MenuItem(menu, SWT.CASCADE);
    fileItem.setText(Messages.getString("dialog.Martif2TBXConverterDialog.fileMenu"));
    fileItem.setMenu(fileMenu);
    MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH);
    exitItem.setText(Messages.getString("dialog.Martif2TBXConverterDialog.exitItem"));
    exitItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            close();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    Menu helpMenu = new Menu(menu);
    MenuItem helpItem = new MenuItem(menu, SWT.CASCADE);
    helpItem.setText(Messages.getString("dialog.Martif2TBXConverterDialog.helpMenu"));
    helpItem.setMenu(helpMenu);
    MenuItem aboutItem = new MenuItem(helpMenu, SWT.PUSH);
    aboutItem.setText(Messages.getString("dialog.Martif2TBXConverterDialog.aboutItem"));
    String imgPath = PluginUtil.getAbsolutePath(PluginConstants.LOGO_MARTIF2TBX_MENU_PATH);
    aboutItem.setImage(new Image(Display.getDefault(), imgPath));
    aboutItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            AboutDialog dialog = new AboutDialog(getShell(), Messages.getString("dialog.Martif2TBXConverterDialog.dialogName"), imagePath, Messages.getString("dialog.Martif2TBXConverterDialog.dialogVersion"));
            dialog.open();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) Image(org.eclipse.swt.graphics.Image) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 47 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project translationstudio8 by heartsome.

the class TMX2TXTConverterDialog method createMenu.

private void createMenu(Composite tparent) {
    Menu menuBar = new Menu(getShell(), SWT.BAR);
    getShell().setMenuBar(menuBar);
    getShell().pack();
    Rectangle screenSize = Display.getDefault().getClientArea();
    Rectangle frameSize = getShell().getBounds();
    getShell().setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    // 文件菜单
    Menu fileMenu = new Menu(menuBar);
    MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE);
    fileItem.setText(Messages.getString("dialog.TMX2TXTConverterDialog.fileMenu"));
    fileItem.setMenu(fileMenu);
    MenuItem quitItem = new MenuItem(fileMenu, SWT.PUSH);
    quitItem.setText(Messages.getString("dialog.TMX2TXTConverterDialog.quitItem"));
    quitItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            close();
        }
    });
    // 帮助菜单
    Menu helpMenu = new Menu(menuBar);
    MenuItem helpItem = new MenuItem(menuBar, SWT.CASCADE);
    helpItem.setText(Messages.getString("dialog.TMX2TXTConverterDialog.helpMenu"));
    helpItem.setMenu(helpMenu);
    MenuItem aboutItem = new MenuItem(helpMenu, SWT.PUSH);
    aboutItem.setText(Messages.getString("dialog.TMX2TXTConverterDialog.aboutItem"));
    String aboutPath = PluginUtil.getAbsolutePath(PluginConstants.LOGO_TMX2TXTCONVERTER_MENU_PATH);
    aboutItem.setImage(new Image(Display.getDefault(), aboutPath));
    aboutItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            AboutDialog dialog = new AboutDialog(getShell(), Messages.getString("dialog.TMX2TXTConverterDialog.aboutItemName"), imagePath, Messages.getString("dialog.TMX2TXTConverterDialog.version"));
            dialog.open();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) Image(org.eclipse.swt.graphics.Image) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 48 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project translationstudio8 by heartsome.

the class TMXValidatorDialog method createMenu.

private void createMenu(Composite tparent) {
    Menu menuBar = new Menu(getShell(), SWT.BAR);
    getShell().setMenuBar(menuBar);
    getShell().pack();
    Rectangle screenSize = Display.getDefault().getClientArea();
    Rectangle frameSize = getShell().getBounds();
    getShell().setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    // 文件菜单
    Menu fileMenu = new Menu(menuBar);
    MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE);
    fileItem.setText(Messages.getString("dialog.TMXValidatorDialog.fileMenu"));
    fileItem.setMenu(fileMenu);
    MenuItem openFileItem = new MenuItem(fileMenu, SWT.PUSH);
    openFileItem.setText(Messages.getString("dialog.TMXValidatorDialog.openFileItem"));
    openFileItem.setImage(new Image(Display.getDefault(), openFilePath));
    openFileItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            openFile();
        }
    });
    MenuItem clearCharItem = new MenuItem(fileMenu, SWT.PUSH);
    clearCharItem.setText(Messages.getString("dialog.TMXValidatorDialog.clearCharItem"));
    clearCharItem.setImage(new Image(Display.getDefault(), clearCharPath));
    clearCharItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            cleanCharacters();
        }
    });
    new MenuItem(fileMenu, SWT.SEPARATOR);
    MenuItem quitItem = new MenuItem(fileMenu, SWT.PUSH);
    quitItem.setText(Messages.getString("dialog.TMXValidatorDialog.quitItem"));
    quitItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            close();
        }
    });
    // 帮助菜单
    Menu helpMenu = new Menu(menuBar);
    MenuItem helpItem = new MenuItem(menuBar, SWT.CASCADE);
    helpItem.setText(Messages.getString("dialog.TMXValidatorDialog.helpMenu"));
    helpItem.setMenu(helpMenu);
    MenuItem aboutItem = new MenuItem(helpMenu, SWT.PUSH);
    aboutItem.setText(Messages.getString("dialog.TMXValidatorDialog.aboutItem"));
    String aboutPath = PluginUtil.getAbsolutePath(PluginConstants.LOGO_TMXVALIDATOR_MENU_PATH);
    aboutItem.setImage(new Image(Display.getDefault(), aboutPath));
    aboutItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            AboutDialog dialog = new AboutDialog(getShell(), Messages.getString("dialog.TMXValidatorDialog.aboutItemName"), imagePath, Messages.getString("dialog.TMXValidatorDialog.version"));
            dialog.open();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) Image(org.eclipse.swt.graphics.Image) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 49 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project translationstudio8 by heartsome.

the class XSLTransformationDialog method createMenu.

/**
	 * 创建菜单 ;
	 */
private void createMenu() {
    Menu menu = new Menu(getShell(), SWT.BAR);
    getShell().setMenuBar(menu);
    getShell().pack();
    Rectangle screenSize = Display.getDefault().getClientArea();
    Rectangle frameSize = getShell().getBounds();
    getShell().setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    Menu fileMenu = new Menu(menu);
    MenuItem fileItem = new MenuItem(menu, SWT.CASCADE);
    fileItem.setText(Messages.getString("dialog.XSLTransformationDialog.fileItem"));
    fileItem.setMenu(fileMenu);
    MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH);
    exitItem.setText(Messages.getString("dialog.XSLTransformationDialog.exitItem"));
    exitItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            close();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    Menu helpMenu = new Menu(menu);
    MenuItem helpItem = new MenuItem(menu, SWT.CASCADE);
    helpItem.setText(Messages.getString("dialog.XSLTransformationDialog.helpMenu"));
    helpItem.setMenu(helpMenu);
    MenuItem aboutItem = new MenuItem(helpMenu, SWT.PUSH);
    aboutItem.setText(Messages.getString("dialog.XSLTransformationDialog.aboutItem"));
    String imgPath = PluginUtil.getAbsolutePath(PluginConstants.LOGO_XSL_MENU_PATH);
    aboutItem.setImage(new Image(Display.getDefault(), imgPath));
    aboutItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            AboutDialog dialog = new AboutDialog(getShell(), Messages.getString("dialog.XSLTransformationDialog.aboutItemName"), imagePath, Messages.getString("dialog.XSLTransformationDialog.aboutItemVersion"));
            dialog.open();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) Image(org.eclipse.swt.graphics.Image) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 50 with MenuItem

use of org.eclipse.swt.widgets.MenuItem 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)

Aggregations

MenuItem (org.eclipse.swt.widgets.MenuItem)386 Menu (org.eclipse.swt.widgets.Menu)259 SelectionEvent (org.eclipse.swt.events.SelectionEvent)247 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)208 Event (org.eclipse.swt.widgets.Event)58 ArrayList (java.util.ArrayList)55 Point (org.eclipse.swt.graphics.Point)52 GridData (org.eclipse.swt.layout.GridData)49 Listener (org.eclipse.swt.widgets.Listener)48 SelectionListener (org.eclipse.swt.events.SelectionListener)46 Composite (org.eclipse.swt.widgets.Composite)43 GridLayout (org.eclipse.swt.layout.GridLayout)42 Rectangle (org.eclipse.swt.graphics.Rectangle)35 Label (org.eclipse.swt.widgets.Label)34 Shell (org.eclipse.swt.widgets.Shell)34 Table (org.eclipse.swt.widgets.Table)33 MenuEvent (org.eclipse.swt.events.MenuEvent)32 Button (org.eclipse.swt.widgets.Button)32 List (java.util.List)31 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)29