Search in sources :

Example 36 with DisposeEvent

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

the class AutoResizeRowAction 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 row = CellEdgeDetectUtil.getRowPositionToResize(natTable, clickPoint);
    InitializeAutoResizeRowsCommand command = new InitializeAutoResizeRowsCommand(natTable, row, natTable.getConfigRegistry(), gc);
    natTable.doCommand(command);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) InitializeAutoResizeRowsCommand(net.sourceforge.nattable.resize.command.InitializeAutoResizeRowsCommand) Point(org.eclipse.swt.graphics.Point) GC(org.eclipse.swt.graphics.GC) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Point(org.eclipse.swt.graphics.Point)

Example 37 with DisposeEvent

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

the class ColumnResizeCursorAction method run.

public void run(NatTable natTable, MouseEvent event) {
    if (columnResizeCursor == null) {
        columnResizeCursor = new Cursor(Display.getDefault(), SWT.CURSOR_SIZEWE);
        natTable.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(DisposeEvent e) {
                columnResizeCursor.dispose();
            }
        });
    }
    natTable.setCursor(columnResizeCursor);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 38 with DisposeEvent

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

the class ImportProjectHandler method execute.

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

        /**
			 * 添加帮助按钮
			 * 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}/ch07s03.html#import-project", 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;
        }
    };
    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) ImportProjectWizard(net.heartsome.cat.ts.importproject.wizards.ImportProjectWizard) Image(org.eclipse.swt.graphics.Image) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TSWizardDialog(net.heartsome.cat.common.ui.wizard.TSWizardDialog) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 39 with DisposeEvent

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

the class PreMachineTranslationDialog method createHelpControl.

// TODO :帮助按钮URL需要修改
/**
	 * 添加帮助按钮 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?#prestore-mt", 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 40 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project archi by archimatetool.

the class SaveCanvasAsTemplateWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    GridData gd;
    Label label;
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout());
    setControl(container);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(container, HELP_ID);
    Group fileComposite = new Group(container, SWT.NULL);
    fileComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout = new GridLayout(3, false);
    fileComposite.setLayout(layout);
    label = new Label(fileComposite, SWT.NULL);
    label.setText(Messages.SaveCanvasAsTemplateWizardPage_2);
    fFileTextField = new Text(fileComposite, SWT.BORDER | SWT.SINGLE);
    fFileTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    File newFile = new File(CURRENT_FOLDER, Messages.SaveCanvasAsTemplateWizardPage_3 + CanvasTemplateManager.CANVAS_TEMPLATE_FILE_EXTENSION);
    fFileTextField.setText(newFile.getPath());
    // Single text control so strip CRLFs
    UIUtils.conformSingleTextControl(fFileTextField);
    fFileTextField.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateFields();
        }
    });
    Button fileButton = new Button(fileComposite, SWT.PUSH);
    fileButton.setText(Messages.SaveCanvasAsTemplateWizardPage_4);
    fileButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            File file = chooseFile();
            if (file != null) {
                fFileTextField.setText(file.getPath());
                CURRENT_FOLDER = file.getParentFile();
            }
        }
    });
    Group fieldGroup = new Group(container, SWT.NULL);
    fieldGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout(2, false);
    fieldGroup.setLayout(layout);
    label = new Label(fieldGroup, SWT.NULL);
    label.setText(Messages.SaveCanvasAsTemplateWizardPage_5);
    fNameTextField = new Text(fieldGroup, SWT.BORDER | SWT.SINGLE);
    fNameTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (StringUtils.isSet(fCanvasModel.getName())) {
        fNameTextField.setText(fCanvasModel.getName());
    }
    // Single text control so strip CRLFs
    UIUtils.conformSingleTextControl(fNameTextField);
    fNameTextField.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateFields();
        }
    });
    label = new Label(fieldGroup, SWT.NULL);
    label.setText(Messages.SaveCanvasAsTemplateWizardPage_6);
    gd = new GridData(SWT.NULL, SWT.TOP, false, false);
    label.setLayoutData(gd);
    fDescriptionTextField = new Text(fieldGroup, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 120;
    fDescriptionTextField.setLayoutData(gd);
    if (StringUtils.isSet(fCanvasModel.getDocumentation())) {
        fDescriptionTextField.setText(fCanvasModel.getDocumentation());
    }
    // Thumbnail
    Group thumbsGroup = new Group(container, SWT.NULL);
    thumbsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    layout = new GridLayout(2, false);
    thumbsGroup.setLayout(layout);
    fButtonIncludeThumbnail = new Button(thumbsGroup, SWT.CHECK);
    fButtonIncludeThumbnail.setText(Messages.SaveCanvasAsTemplateWizardPage_7);
    fButtonIncludeThumbnail.setSelection(true);
    fButtonIncludeThumbnail.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            fPreviewLabel.setEnabled(fButtonIncludeThumbnail.getSelection());
        }
    });
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    fButtonIncludeThumbnail.setLayoutData(gd);
    label = new Label(thumbsGroup, SWT.NULL);
    // $NON-NLS-1$
    label.setText(Messages.SaveCanvasAsTemplateWizardPage_8 + "  ");
    gd = new GridData(SWT.NULL, SWT.TOP, false, false);
    label.setLayoutData(gd);
    fPreviewLabel = new Label(thumbsGroup, SWT.BORDER);
    gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 120;
    gd.widthHint = 150;
    fPreviewLabel.setLayoutData(gd);
    // Dispose of the image here not in the main dispose() method because if the help system is showing then
    // the TrayDialog is resized and this label is asked to relayout.
    fPreviewLabel.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            disposePreviewImage();
        }
    });
    Display.getCurrent().asyncExec(new Runnable() {

        @Override
        public void run() {
            TemplateUtils.createThumbnailPreviewImage(fCanvasModel, fPreviewLabel);
        }
    });
    fPreviewLabel.addControlListener(new ControlAdapter() {

        int oldTime;

        @Override
        public void controlResized(ControlEvent e) {
            if (e.time - oldTime > 10) {
                disposePreviewImage();
                TemplateUtils.createThumbnailPreviewImage(fCanvasModel, fPreviewLabel);
            }
            oldTime = e.time;
        }
    });
    validateFields();
}
Also used : Group(org.eclipse.swt.widgets.Group) DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) DisposeEvent(org.eclipse.swt.events.DisposeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) File(java.io.File)

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