Search in sources :

Example 66 with SelectionListener

use of org.eclipse.swt.events.SelectionListener 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 67 with SelectionListener

use of org.eclipse.swt.events.SelectionListener 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 68 with SelectionListener

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

the class NonTranslationQAPage method initListener.

/**
	 * 一些事件的添加
	 */
public void initListener() {
    // 非译元素的添加事件
    addBtn.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            addNonTransElement();
        }
    });
    editBtn.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent arg0) {
            editNontransElement();
        }

        public void widgetDefaultSelected(SelectionEvent arg0) {
            editNontransElement();
        }
    });
    // 删除按钮的点击操作
    deleteBtn.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            deleteElement();
        }
    });
    // 给comboViewer添加事件,同时传入内置元素
    comboViewer.getCombo().addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            addInternalElement();
            comboViewer.getCombo().setText(Messages.getString("qa.preference.NonTranslationQAPage.addInterElement"));
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            addInternalElement();
            comboViewer.getCombo().setText(Messages.getString("qa.preference.NonTranslationQAPage.addInterElement"));
        }
    });
    // 非译元素列表的点击事件
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = tableViewer.getSelection();
            if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
                IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                if (structuredSelection.getFirstElement() instanceof NontransElementBean) {
                    if (structuredSelection.size() == 1 && !validIsInternalElementNonTip((NontransElementBean) structuredSelection.getFirstElement())) {
                        editBtn.setEnabled(true);
                    } else {
                        editBtn.setEnabled(false);
                    }
                    deleteBtn.setEnabled(true);
                } else {
                    setAddModel();
                }
            } else {
                setAddModel();
            }
        }
    });
    tableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent arg0) {
            editNontransElement();
        }
    });
}
Also used : NontransElementBean(net.heartsome.cat.ts.ui.qa.model.NontransElementBean) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 69 with SelectionListener

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

the class ColumnCategoriesDialog method createUpButton.

private Button createUpButton(Composite upDownbuttonComposite) {
    Button upButton = new Button(upDownbuttonComposite, SWT.PUSH);
    upButton.setImage(GUIHelper.getImage("arrow_up"));
    upButton.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create());
    upButton.addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent e) {
            moveSelectedUp();
        }
    });
    return upButton;
}
Also used : Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 70 with SelectionListener

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

the class ColumnCategoriesDialog method createAddButton.

private Button createAddButton(Composite buttonComposite) {
    Button addButton = new Button(buttonComposite, SWT.PUSH);
    addButton.setImage(GUIHelper.getImage("arrow_right"));
    addButton.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create());
    addButton.addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent e) {
            addSelected();
        }
    });
    return addButton;
}
Also used : Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

SelectionListener (org.eclipse.swt.events.SelectionListener)711 SelectionEvent (org.eclipse.swt.events.SelectionEvent)665 GridData (org.eclipse.swt.layout.GridData)411 Button (org.eclipse.swt.widgets.Button)409 Composite (org.eclipse.swt.widgets.Composite)381 GridLayout (org.eclipse.swt.layout.GridLayout)374 Label (org.eclipse.swt.widgets.Label)256 Text (org.eclipse.swt.widgets.Text)152 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)140 Group (org.eclipse.swt.widgets.Group)137 ModifyListener (org.eclipse.swt.events.ModifyListener)113 ModifyEvent (org.eclipse.swt.events.ModifyEvent)112 Combo (org.eclipse.swt.widgets.Combo)101 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)69 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)69 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)69 FormData (org.eclipse.swt.layout.FormData)69 Event (org.eclipse.swt.widgets.Event)69 FormAttachment (org.eclipse.swt.layout.FormAttachment)68 ArrayList (java.util.ArrayList)57