Search in sources :

Example 61 with ToolBar

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

the class ProjectSettingDialog method createHelpControl.

/**
	 * 添加帮助按钮
	 * robert	2012-09-06
	 */
@Override
protected Control createHelpControl(Composite parent) {
    // ROBERTHELP 项目设置
    String language = CommonFunction.getSystemLanguage();
    final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s03.html#project-setting", language);
    Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
    ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
    ((GridLayout) parent.getLayout()).numColumns++;
    toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    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 62 with ToolBar

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

the class TMXValidatorDialog method createToolBar.

private void createToolBar(Composite tparent) {
    Composite toolBarCmp = new Composite(tparent, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(toolBarCmp);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(toolBarCmp);
    ToolBar toolBar = new ToolBar(toolBarCmp, SWT.NO_FOCUS | SWT.FLAT);
    ToolItem openItem = new ToolItem(toolBar, SWT.PUSH);
    openItem.setToolTipText(Messages.getString("dialog.TMXValidatorDialog.openItem"));
    openItem.setImage(new Image(Display.getDefault(), openFilePath));
    openItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            openFile();
        }
    });
    ToolItem clearCharsItem = new ToolItem(toolBar, SWT.PUSH);
    clearCharsItem.setImage(new Image(Display.getDefault(), clearCharPath));
    clearCharsItem.setToolTipText(Messages.getString("dialog.TMXValidatorDialog.clearCharsItem"));
    clearCharsItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            cleanCharacters();
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Image(org.eclipse.swt.graphics.Image) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 63 with ToolBar

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

the class PluginHelpDialog method createToolBar.

/**
	 * 创建工具栏
	 * @param parent
	 *            ;
	 */
private void createToolBar(Composite parent) {
    Composite cmpToolBar = new Composite(parent, SWT.None);
    GridLayoutFactory.fillDefaults().spacing(0, 0).numColumns(1).applyTo(cmpToolBar);
    cmpToolBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    ToolBar toolBar = new ToolBar(cmpToolBar, SWT.NO_FOCUS | SWT.FLAT);
    ToolItem openItem = new ToolItem(toolBar, SWT.PUSH | SWT.FLAT);
    //$NON-NLS-1$
    openItem.setImage(Activator.getImageDescriptor(PluginConstants.HELP_OPEN_FILE).createImage());
    openItem.setToolTipText(Messages.getString("dialog.PluginHelpDialog.openFileItem"));
    openItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            openFile();
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem backItem = new ToolItem(toolBar, SWT.PUSH | SWT.FLAT);
    backItem.setImage(Activator.getImageDescriptor(PluginConstants.HELP_BACK).createImage());
    backItem.setToolTipText(Messages.getString("dialog.PluginHelpDialog.backItem"));
    backItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            goBack();
        }
    });
    ToolItem forwardItem = new ToolItem(toolBar, SWT.PUSH | SWT.FLAT);
    forwardItem.setImage(Activator.getImageDescriptor(PluginConstants.HELP_FORWARD).createImage());
    forwardItem.setToolTipText(Messages.getString("dialog.PluginHelpDialog.forwardItem"));
    forwardItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            goForward();
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem searchItem = new ToolItem(toolBar, SWT.PUSH | SWT.FLAT);
    searchItem.setImage(Activator.getImageDescriptor(PluginConstants.HELP_FIND).createImage());
    //$NON-NLS-1$
    searchItem.setToolTipText(Messages.getString("dialog.PluginHelpDialog.searchItem"));
    searchItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            searchText();
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 64 with ToolBar

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

the class TBXMakerDialog method createToolBar.

/**
	 * 创建工具栏
	 * @param parent
	 *            ;
	 */
private void createToolBar(Composite parent) {
    Composite cmpToolBar = new Composite(parent, SWT.None);
    GridLayoutFactory.fillDefaults().spacing(0, 0).numColumns(3).equalWidth(false).applyTo(cmpToolBar);
    cmpToolBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    ToolBar toolBar = new ToolBar(cmpToolBar, SWT.NO_FOCUS | SWT.FLAT);
    ToolItem openToolItem = new ToolItem(toolBar, SWT.PUSH);
    openToolItem.setToolTipText(Messages.getString("dialog.TBXMakerDialog.openToolItem"));
    openToolItem.setImage(Activator.getImageDescriptor(PluginConstants.PIC_OPEN_CSV_PATH).createImage());
    openToolItem.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    ToolItem exporToolItem = new ToolItem(toolBar, SWT.PUSH);
    exporToolItem.setToolTipText(Messages.getString("dialog.TBXMakerDialog.exporToolItem"));
    exporToolItem.setImage(Activator.getImageDescriptor(PluginConstants.PIC_EXPORT_TBX_PATH).createImage());
    exporToolItem.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    ToolItem deleteColToolItem = new ToolItem(toolBar, SWT.PUSH);
    deleteColToolItem.setToolTipText(Messages.getString("dialog.TBXMakerDialog.deleteColToolItem"));
    deleteColToolItem.setImage(Activator.getImageDescriptor(PluginConstants.PIC_DELETE_COLUMN_PATH).createImage());
    deleteColToolItem.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    ToolItem setColToolItem = new ToolItem(toolBar, SWT.PUSH);
    setColToolItem.setToolTipText(Messages.getString("dialog.TBXMakerDialog.setColToolItem"));
    setColToolItem.setImage(Activator.getImageDescriptor(PluginConstants.PIC_SET_COLUMN_PATH).createImage());
    setColToolItem.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    new Label(cmpToolBar, SWT.None).setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    ToolBar helpToolBar = new ToolBar(cmpToolBar, SWT.NO_FOCUS | SWT.FLAT);
    ToolItem helpToolItem = new ToolItem(helpToolBar, SWT.RIGHT);
    helpToolItem.setToolTipText(Messages.getString("dialog.TBXMakerDialog.helpToolItem"));
    helpToolItem.setImage(Activator.getImageDescriptor(PluginConstants.PIC_HELP_PATH).createImage());
    helpToolItem.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.eclipse.swt.widgets.Label) ToolItem(org.eclipse.swt.widgets.ToolItem) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 65 with ToolBar

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

the class NewProjectHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    NewProjectWizard wizard = new NewProjectWizard();
    TSWizardDialog dialog = new NewProjectWizardDialog(window.getShell(), wizard) {

        @Override
        protected void createButtonsForButtonBar(Composite parent) {
            super.createButtonsForButtonBar(parent);
            getButton(IDialogConstants.FINISH_ID).setText(Messages.getString("handlers.NewProjectHandler.finishLbl"));
        }

        // robert help 2012-09-06
        @Override
        protected Control createHelpControl(Composite parent) {
            Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
            ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
            ((GridLayout) parent.getLayout()).numColumns++;
            toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
            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) {
                    String language = CommonFunction.getSystemLanguage();
                    String helpUrl = "";
                    if (getCurrentPage() instanceof NewProjectWizardProjInfoPage) {
                        // ROBERTHELP 新建项目-项目信息
                        helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s02.html#create-project-wizard-project-info", language);
                        PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
                    } else if (getCurrentPage() instanceof NewProjectWizardLanguagePage) {
                        // ROBERTHELP 新建项目-语言信息
                        helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s02.html#create-project-wizard-languages", language);
                        PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
                    } else if (getCurrentPage() instanceof AbstractNewProjectWizardPage) {
                        if ("TM".equals(((AbstractNewProjectWizardPage) getCurrentPage()).getPageType())) {
                            // ROBERTHELP 新建项目-记忆库
                            helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s02.html#create-project-wizard-tm", language);
                            PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
                        } else {
                            // ROBERTHELP 新建项目-术语库
                            helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s02.html#create-project-wizard-tb", language);
                            PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
                        }
                    } else if (getCurrentPage() instanceof NewProjectWizardSourceFilePage) {
                        // ROBERTHELP 新建项目-源文件
                        helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s02.html#create-project-wizard-source-file", language);
                        PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
                    }
                }
            });
            return toolBar;
        }
    };
    dialog.setHelpAvailable(true);
    dialog.open();
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) NewProjectWizardSourceFilePage(net.heartsome.cat.ts.ui.wizards.NewProjectWizardSourceFilePage) NewProjectWizardProjInfoPage(net.heartsome.cat.ts.ui.wizards.NewProjectWizardProjInfoPage) Image(org.eclipse.swt.graphics.Image) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) AbstractNewProjectWizardPage(net.heartsome.cat.ts.ui.extensionpoint.AbstractNewProjectWizardPage) NewProjectWizardDialog(net.heartsome.cat.ts.ui.wizards.NewProjectWizardDialog) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NewProjectWizardLanguagePage(net.heartsome.cat.ts.ui.wizards.NewProjectWizardLanguagePage) NewProjectWizard(net.heartsome.cat.ts.ui.wizards.NewProjectWizard) TSWizardDialog(net.heartsome.cat.common.ui.wizard.TSWizardDialog) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

ToolBar (org.eclipse.swt.widgets.ToolBar)127 ToolItem (org.eclipse.swt.widgets.ToolItem)110 SelectionEvent (org.eclipse.swt.events.SelectionEvent)82 GridData (org.eclipse.swt.layout.GridData)81 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)74 GridLayout (org.eclipse.swt.layout.GridLayout)68 Composite (org.eclipse.swt.widgets.Composite)67 Image (org.eclipse.swt.graphics.Image)35 Label (org.eclipse.swt.widgets.Label)34 DisposeEvent (org.eclipse.swt.events.DisposeEvent)27 DisposeListener (org.eclipse.swt.events.DisposeListener)26 Point (org.eclipse.swt.graphics.Point)24 Cursor (org.eclipse.swt.graphics.Cursor)22 TableViewer (org.eclipse.jface.viewers.TableViewer)18 FillLayout (org.eclipse.swt.layout.FillLayout)18 Button (org.eclipse.swt.widgets.Button)17 Text (org.eclipse.swt.widgets.Text)17 ArrayList (java.util.ArrayList)14 SashForm (org.eclipse.swt.custom.SashForm)14 Combo (org.eclipse.swt.widgets.Combo)14