Search in sources :

Example 1 with Cursor

use of org.eclipse.swt.graphics.Cursor in project cogtool by cogtool.

the class UI method performAction.

/**
     * Wrapper method for invoking performAction; uses this as the
     * transmuter.  ContextMenuManager is currently the only place that
     * invokes performAction as "context".
     *
     * @param id the general semantic LID to lookup and perform action for
     * @param isContextSelection true if we should specialize based on the
     *                           current contextual selection;
     *                           false to use the standard selection
     * @return <code>true</code> if it is ok to continue with action processing
     *         and <code>false</code> if processing should stop.
     */
public boolean performAction(ListenerIdentifier id, boolean isContextSelection) {
    View view = getView();
    boolean wasPerforming = view.isPerformingAction();
    Shell s = getShell();
    Cursor oldCursor = s.getCursor();
    view.setStatusMessage("");
    view.setPerformingAction(true);
    s.setCursor(WindowUtil.BUSY_CURSOR_INSTANCE);
    // false means a normal action, not caused by a context menu selection
    try {
        return lIDMap.performAction(this, id, isContextSelection);
    } catch (RecoverableException ex) {
        RcvrExceptionHandler.recover(ex, getStandardInteraction());
    } finally {
        view.setPerformingAction(wasPerforming);
        if (!s.isDisposed()) {
            s.setCursor(oldCursor);
        }
    }
    return false;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Cursor(org.eclipse.swt.graphics.Cursor) AboutView(edu.cmu.cs.hcii.cogtool.view.AboutView) View(edu.cmu.cs.hcii.cogtool.view.View) RecoverableException(edu.cmu.cs.hcii.cogtool.util.RecoverableException)

Example 2 with Cursor

use of org.eclipse.swt.graphics.Cursor in project cogtool by cogtool.

the class WindowUtil method getOpenHandCursor.

/**
     * Returns a hand cursor.
     *
     * IMPORTANT: this cursor must be disposed when its creator is disposed,
     *            or we will have a memory link.
     *
     * @return a hew hand cursor
     */
public static Cursor getOpenHandCursor() {
    if (OPEN_HAND_CURSOR == null) {
        ImageData curData = GraphicsUtil.getImageDataFromResource("edu/cmu/cs/hcii/cogtool/resources/open_hand.gif");
        if (curData == null) {
            return null;
        }
        OPEN_HAND_CURSOR = new Cursor(GLOBAL_DISPLAY, curData, 8, 8);
    }
    return OPEN_HAND_CURSOR;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) Cursor(org.eclipse.swt.graphics.Cursor)

Example 3 with Cursor

use of org.eclipse.swt.graphics.Cursor in project translationstudio8 by heartsome.

the class TermBaseSearchDialog 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}/ch05s04.html#search-terminology", 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 4 with Cursor

use of org.eclipse.swt.graphics.Cursor in project translationstudio8 by heartsome.

the class TermDbManagerDialog 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}/ch06s04.html#tb-management", 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 5 with Cursor

use of org.eclipse.swt.graphics.Cursor in project translationstudio8 by heartsome.

the class ImportTbxHandler method execute.

/**
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
	 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    TermDbManagerImportWizard wizard = new TermDbManagerImportWizard();
    TermDbManagerImportWizardDialog dlg = new TermDbManagerImportWizardDialog(window.getShell(), wizard) {

        // robert help 2012-09-06
        @Override
        protected Control createHelpControl(Composite parent) {
            // ROBERTHELP 导入TBX
            String language = CommonFunction.getSystemLanguage();
            final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s03.html#create-tb-wizard-import-tbx", 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;
        }
    };
    dlg.setHelpAvailable(true);
    dlg.open();
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DisposeListener(org.eclipse.swt.events.DisposeListener) TermDbManagerImportWizardDialog(net.heartsome.cat.database.ui.tb.wizard.TermDbManagerImportWizardDialog) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Image(org.eclipse.swt.graphics.Image) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) TermDbManagerImportWizard(net.heartsome.cat.database.ui.tb.wizard.TermDbManagerImportWizard) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

Cursor (org.eclipse.swt.graphics.Cursor)38 DisposeEvent (org.eclipse.swt.events.DisposeEvent)26 DisposeListener (org.eclipse.swt.events.DisposeListener)26 SelectionEvent (org.eclipse.swt.events.SelectionEvent)22 Image (org.eclipse.swt.graphics.Image)22 ToolBar (org.eclipse.swt.widgets.ToolBar)22 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)21 GridData (org.eclipse.swt.layout.GridData)21 ToolItem (org.eclipse.swt.widgets.ToolItem)20 Composite (org.eclipse.swt.widgets.Composite)7 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 TSWizardDialog (net.heartsome.cat.common.ui.wizard.TSWizardDialog)3 Action (org.eclipse.jface.action.Action)2 ToolBarManager (org.eclipse.jface.action.ToolBarManager)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2 Display (org.eclipse.swt.widgets.Display)2 Label (org.eclipse.swt.widgets.Label)2 Shell (org.eclipse.swt.widgets.Shell)2 RecoverableException (edu.cmu.cs.hcii.cogtool.util.RecoverableException)1