Search in sources :

Example 71 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project liferay-ide by liferay.

the class TaglibVariableItemHelper method getInsertString.

public static String getInsertString(Shell host, IEditorPart editor, ISnippetItem item, boolean clearModality) {
    if (item == null) {
        return "";
    }
    String insertString = null;
    if (ListUtil.isNotEmpty(item.getVariables())) {
        VariableInsertionDialog dialog = new TaglibVariableInsertionDialog(host, editor, clearModality);
        dialog.setItem(item);
        // The editor itself influences the insertion's actions, so we
        // can't
        // allow the active editor to be changed.
        // Disabling the parent shell achieves psuedo-modal behavior
        // without
        // locking the UI under Linux
        int result = Window.CANCEL;
        try {
            if (clearModality) {
                host.setEnabled(false);
                dialog.addDisposeListener(new DisposeListener() {

                    public void widgetDisposed(DisposeEvent arg0) {
                        /*
								 * The parent shell must be reenabled when the
								 * dialog disposes, otherwise it won't automatically
								 * receive focus.
								 */
                        host.setEnabled(true);
                    }
                });
            }
            result = dialog.open();
        } catch (Exception t) {
            SnippetsUIPlugin.logError(t);
        } finally {
            if (clearModality) {
                host.setEnabled(true);
            }
        }
        if (result == Window.OK) {
            insertString = dialog.getPreparedText();
        }
    } else {
        insertString = item.getContentString();
    }
    return insertString;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) VariableInsertionDialog(org.eclipse.wst.common.snippets.internal.VariableInsertionDialog) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 72 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project liferay-ide by liferay.

the class PossibleValuesRadioPropertyEditorPresentation method createContents.

@Override
protected void createContents(final Composite parent) {
    final PropertyEditorPart part = part();
    final boolean showLabel = part.label() != null;
    final int leftMargin = part.getMarginLeft();
    PropertyEditorAssistDecorator decorator = null;
    final Composite composite = createMainComposite(parent, new CreateMainCompositeDelegate(part) {

        @Override
        public boolean getShowLabel() {
            return false;
        }

        @Override
        public boolean getSpanBothColumns() {
            return true;
        }
    });
    composite.setLayout(glspacing(glayout(2, 0, 0), 2, 5));
    decorator = createDecorator(composite);
    decorator.addEditorControl(composite);
    if (showLabel) {
        decorator.control().setLayoutData(gdvalign(gd(), SWT.CENTER));
        final Label label = new Label(composite, SWT.WRAP);
        label.setLayoutData(gd());
        final Runnable updateLabelOp = new Runnable() {

            public void run() {
                label.setText(part.label(CapitalizationType.FIRST_WORD_ONLY, true));
            }
        };
        final org.eclipse.sapphire.Listener listener = new org.eclipse.sapphire.Listener() {

            @Override
            public void handle(final org.eclipse.sapphire.Event event) {
                if (event instanceof LabelChangedEvent) {
                    updateLabelOp.run();
                    PossibleValuesRadioPropertyEditorPresentation.this.layout();
                }
            }
        };
        part.attach(listener);
        updateLabelOp.run();
        label.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(final DisposeEvent event) {
                part.detach(listener);
            }
        });
        decorator.addEditorControl(label);
    } else {
        decorator.control().setLayoutData(gdvindent(gdvalign(gd(), SWT.TOP), 4));
    }
    _control = new RadioButtonsGroup(composite, true);
    if (showLabel) {
        _control.setLayoutData(gdhindent(gdhspan(gdhfill(), 2), leftMargin + 20));
    } else {
        _control.setLayoutData(gdhfill());
    }
    binding = new PossibleValuesRadioButtonsGroupBinding<>(this, (RadioButtonsGroup) _control);
    _control.setData(DATA_BINDING, binding);
    decorator.addEditorControl(_control, true);
    addControl(_control);
}
Also used : PropertyEditorPart(org.eclipse.sapphire.ui.forms.PropertyEditorPart) DisposeListener(org.eclipse.swt.events.DisposeListener) DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) LabelChangedEvent(org.eclipse.sapphire.ui.SapphirePart.LabelChangedEvent) RadioButtonsGroup(org.eclipse.sapphire.ui.forms.swt.RadioButtonsGroup) DisposeEvent(org.eclipse.swt.events.DisposeEvent) PropertyEditorAssistDecorator(org.eclipse.sapphire.ui.assist.internal.PropertyEditorAssistDecorator) DisposeEvent(org.eclipse.swt.events.DisposeEvent) LabelChangedEvent(org.eclipse.sapphire.ui.SapphirePart.LabelChangedEvent)

Example 73 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project liferay-ide by liferay.

the class UpgradeView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.DOUBLE_BUFFERED | SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    Composite container = SWTUtil.createComposite(scrolledComposite, 1, 0, GridData.FILL_BOTH);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginWidth = 0;
    gridLayout.marginTop = 0;
    gridLayout.marginHeight = 0;
    container.setLayout(gridLayout);
    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayout(new GridLayout(1, true));
    GridData grData = new GridData(GridData.FILL_BOTH);
    grData.grabExcessVerticalSpace = true;
    grData.grabExcessHorizontalSpace = true;
    composite.setLayoutData(grData);
    final GearControl gear = new GearControl(composite, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.widthHint = 400;
    gridData.heightHint = 150;
    gear.setLayoutData(gridData);
    gear.setBackground(parent.getBackground());
    StackLayout stackLayout = new StackLayout();
    _pagesSwitchControler = new Composite(composite, SWT.BORDER);
    _pagesSwitchControler.setLayout(stackLayout);
    GridData containerData = new GridData(GridData.FILL_BOTH);
    containerData.grabExcessHorizontalSpace = true;
    containerData.grabExcessVerticalSpace = true;
    containerData.grabExcessHorizontalSpace = true;
    _pagesSwitchControler.setLayoutData(containerData);
    int pageIndex = 0;
    Page welcomePage = new WelcomePage(_pagesSwitchControler, SWT.NONE, _dataModel);
    welcomePage.setIndex(pageIndex++);
    welcomePage.setTitle("Welcome");
    welcomePage.setBackPage(false);
    welcomePage.addPageNavigateListener(gear);
    Page initConfigureProjectPage = new InitConfigureProjectPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    initConfigureProjectPage.setIndex(pageIndex++);
    initConfigureProjectPage.setTitle("Select project(s) to upgrade");
    initConfigureProjectPage.addPageNavigateListener(gear);
    initConfigureProjectPage.addPageValidationListener(gear);
    initConfigureProjectPage.setNextPage(false);
    Page upgradePomPage = new UpgradePomPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    upgradePomPage.setIndex(pageIndex++);
    upgradePomPage.setTitle("Upgrade POM Files");
    upgradePomPage.addPageValidationListener(gear);
    Page findBreakingChangesPage = new FindBreakingChangesPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    findBreakingChangesPage.setIndex(pageIndex++);
    findBreakingChangesPage.setTitle("Find Breaking Changes");
    Page descriptorsPage = new DescriptorsPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    descriptorsPage.setIndex(pageIndex++);
    descriptorsPage.setTitle("Update Descriptor Files");
    descriptorsPage.addPageValidationListener(gear);
    Page buildServicePage = new BuildServicePage(_pagesSwitchControler, SWT.NONE, _dataModel);
    buildServicePage.setIndex(pageIndex++);
    buildServicePage.setTitle("Build Services");
    Page layoutTemplatePage = new LayoutTemplatePage(_pagesSwitchControler, SWT.NONE, _dataModel);
    layoutTemplatePage.setIndex(pageIndex++);
    layoutTemplatePage.setTitle("Layout Templates");
    layoutTemplatePage.addPageValidationListener(gear);
    Page customJspPage = new CustomJspPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    customJspPage.setIndex(pageIndex++);
    customJspPage.setTitle("Custom Jsp");
    customJspPage.addPageValidationListener(gear);
    // Page extAndThemePage = new ExtAndThemePage( pagesSwitchControler, SWT.NONE,
    // dataModel );
    // extAndThemePage.setIndex( 7 );
    // extAndThemePage.setTitle( "Ext and Theme" );
    Page buildPage = new BuildPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    buildPage.setIndex(pageIndex++);
    buildPage.setTitle("Build");
    Page summaryPage = new SummaryPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    summaryPage.setIndex(pageIndex++);
    summaryPage.setTitle("Summary");
    summaryPage.setNextPage(false);
    summaryPage.addPageNavigateListener(gear);
    _staticPageList.clear();
    _staticPageList.add(welcomePage);
    _staticPageList.add(initConfigureProjectPage);
    _staticPageList.add(upgradePomPage);
    _staticPageList.add(findBreakingChangesPage);
    _staticPageList.add(descriptorsPage);
    _staticPageList.add(buildServicePage);
    _staticPageList.add(layoutTemplatePage);
    _staticPageList.add(customJspPage);
    // staticPageList.add( extAndThemePage );
    _staticPageList.add(buildPage);
    _staticPageList.add(summaryPage);
    resetPages();
    final NavigatorControl navigator = new NavigatorControl(composite, SWT.NONE);
    navigator.addPageNavigateListener(gear);
    navigator.addPageActionListener(gear);
    navigator.setBackground(parent.getBackground());
    _staticPageList.stream().forEach(navigator::addPageActionListener);
    gear.addSelectionChangedListener(navigator);
    gear.addSelectionChangedListener(this);
    gear.addSelectionChangedListener(initConfigureProjectPage);
    gear.addSelectionChangedListener(descriptorsPage);
    gear.addSelectionChangedListener(upgradePomPage);
    gear.addSelectionChangedListener(layoutTemplatePage);
    gear.addSelectionChangedListener(summaryPage);
    GridData navData = new GridData(GridData.FILL_HORIZONTAL);
    navData.grabExcessHorizontalSpace = true;
    navigator.setLayoutData(navData);
    scrolledComposite.setContent(container);
    // scrolledComposite.setMinSize(container.computeSize(SWT.DEFAULT, 670));
    setSelectPage(0);
    parent.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            int pageNum = getPageNumber();
            for (int i = 0; i < pageNum; i++) {
                Page page = UpgradeView.getPage(i);
                String pageId = page.getPageId();
                PageAction pageAction = page.getSelectedAction();
                if (pageAction != null) {
                    UpgradeSettingsUtil.storeProperty(pageId, pageAction.getPageActionName());
                }
            }
        }
    });
    IActionBars actionBars = getViewSite().getActionBars();
    final IToolBarManager mgr = actionBars.getToolBarManager();
    final IAction restart = new Action("Restart Upgrade", ImageDescriptor.createFromURL(bundle.getEntry("icons/e16/restart.gif"))) {

        @Override
        public void run() {
            _restartUpgradeTool();
        }
    };
    final IAction showAllPages = new Action("Show All Pages", ImageDescriptor.createFromURL(bundle.getEntry("icons/e16/showall.gif"))) {

        @Override
        public void run() {
            StringBuilder desriptors = new StringBuilder("If you fail to import projects, you can skip step 2 by ");
            desriptors.append("doing the following steps:\n");
            desriptors.append("   1.upgrade SDK 6.2 to SDK 7.0 manually\n");
            desriptors.append("      or use blade cli to create a Liferay workspace for your SDK\n");
            desriptors.append("   2.import projects you want to upgrade into Eclipse workspace\n");
            desriptors.append("   3.click \"yes\" to show all the steps");
            Boolean openNewLiferayProjectWizard = MessageDialog.openQuestion(UIUtil.getActiveShell(), "Show All Pages", desriptors.toString());
            if (openNewLiferayProjectWizard) {
                showAllPages();
            }
        }
    };
    mgr.add(restart);
    mgr.add(showAllPages);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DisposeEvent(org.eclipse.swt.events.DisposeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) StackLayout(org.eclipse.swt.custom.StackLayout) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IActionBars(org.eclipse.ui.IActionBars) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IAction(org.eclipse.jface.action.IAction) IToolBarManager(org.eclipse.jface.action.IToolBarManager) GridData(org.eclipse.swt.layout.GridData)

Example 74 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project nebula.widgets.nattable by eclipse.

the class NatTable method handleLayerEvent.

// Events /////////////////////////////////////////////////////////////////
@Override
public void handleLayerEvent(ILayerEvent event) {
    List<ILayerListener> currentListeners;
    this.eventListenerLock.readLock().lock();
    try {
        currentListeners = this.listeners;
    } finally {
        this.eventListenerLock.readLock().unlock();
    }
    for (ILayerListener layerListener : currentListeners) {
        layerListener.handleLayerEvent(event);
    }
    if (event instanceof CellVisualUpdateEvent) {
        CellVisualUpdateEvent update = (CellVisualUpdateEvent) event;
        repaintCell(update.getColumnPosition(), update.getRowPosition());
        return;
    }
    if (event instanceof ColumnVisualUpdateEvent) {
        ColumnVisualUpdateEvent update = (ColumnVisualUpdateEvent) event;
        // if more than one column has changed repaint the whole table
        Collection<Range> ranges = update.getColumnPositionRanges();
        if (ranges.size() == 1) {
            Range range = ranges.iterator().next();
            if (range.end - range.start == 1) {
                repaintColumn(range.start);
                return;
            }
        }
    }
    if (event instanceof RowVisualUpdateEvent) {
        RowVisualUpdateEvent update = (RowVisualUpdateEvent) event;
        // if more than one row has changed repaint the whole table
        Collection<Range> ranges = update.getRowPositionRanges();
        if (ranges.size() == 1) {
            Range range = ranges.iterator().next();
            if (range.end - range.start == 1) {
                repaintRow(range.start);
                return;
            }
        }
    }
    if (event instanceof ISelectionEvent) {
        if (event instanceof CellSelectionEvent || event instanceof RowSelectionEvent) {
            Event e = new Event();
            e.widget = this;
            try {
                notifyListeners(SWT.Selection, e);
            } catch (RuntimeException re) {
                // $NON-NLS-1$
                log.error("Error on SWT selection processing", re);
            }
        }
        // in case of selections we redraw immediately
        // this is because with Bug 440037 it was reported that
        // NatTable is too lazy in handling selections which
        // was caused by the EventConflaterChain that only performs
        // updates every 100ms to avoid flickering when handling too
        // many refresh operations in a short period
        redraw();
    } else if (event instanceof IVisualChangeEvent) {
        this.conflaterChain.addEvent(event);
    }
    if (event instanceof CellEditorCreatedEvent) {
        CellEditorCreatedEvent editorEvent = (CellEditorCreatedEvent) event;
        this.activeCellEditor = editorEvent.getEditor();
        Control editorControl = this.activeCellEditor.getEditorControl();
        if (editorControl != null && !editorControl.isDisposed()) {
            editorControl.addDisposeListener(new DisposeListener() {

                @Override
                public void widgetDisposed(DisposeEvent e) {
                    NatTable.this.activeCellEditor = null;
                    ActiveCellEditorRegistry.unregisterActiveCellEditor();
                }
            });
        } else {
            this.activeCellEditor = null;
            ActiveCellEditorRegistry.unregisterActiveCellEditor();
        }
        ActiveCellEditorRegistry.registerActiveCellEditor(this.activeCellEditor);
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) IVisualChangeEvent(org.eclipse.nebula.widgets.nattable.layer.event.IVisualChangeEvent) CellVisualUpdateEvent(org.eclipse.nebula.widgets.nattable.layer.event.CellVisualUpdateEvent) RowVisualUpdateEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowVisualUpdateEvent) ILayerListener(org.eclipse.nebula.widgets.nattable.layer.ILayerListener) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) DisposeEvent(org.eclipse.swt.events.DisposeEvent) CellEditorCreatedEvent(org.eclipse.nebula.widgets.nattable.edit.CellEditorCreatedEvent) Control(org.eclipse.swt.widgets.Control) ColumnVisualUpdateEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnVisualUpdateEvent) CellSelectionEvent(org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent) RowSelectionEvent(org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) CellVisualUpdateEvent(org.eclipse.nebula.widgets.nattable.layer.event.CellVisualUpdateEvent) CellEditorCreatedEvent(org.eclipse.nebula.widgets.nattable.edit.CellEditorCreatedEvent) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) CellSelectionEvent(org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent) ColumnVisualUpdateEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnVisualUpdateEvent) IVisualChangeEvent(org.eclipse.nebula.widgets.nattable.layer.event.IVisualChangeEvent) Event(org.eclipse.swt.widgets.Event) RowVisualUpdateEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowVisualUpdateEvent) RowSelectionEvent(org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent) ISelectionEvent(org.eclipse.nebula.widgets.nattable.selection.event.ISelectionEvent) ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) ISelectionEvent(org.eclipse.nebula.widgets.nattable.selection.event.ISelectionEvent)

Example 75 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project nebula.widgets.nattable by eclipse.

the class FillHandleDragMode method openMenu.

/**
 * Opens a menu that enables a user to select whether values should simply
 * be copied or if a series should be filled.
 *
 * @param natTable
 *            The NatTable instance on which the operation is performed.
 */
protected void openMenu(final NatTable natTable) {
    // lazily create the menu
    if (this.menu == null || this.menu.isDisposed()) {
        this.menu = new Menu(natTable);
        MenuItem copyItem = new MenuItem(this.menu, SWT.PUSH);
        // $NON-NLS-1$
        copyItem.setText(Messages.getLocalizedMessage("%FillHandleDragMode.menu.item.copy"));
        copyItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.COPY, FillHandleDragMode.this.direction, natTable.getConfigRegistry()));
            }
        });
        MenuItem seriesItem = new MenuItem(this.menu, SWT.PUSH);
        // $NON-NLS-1$
        seriesItem.setText(Messages.getLocalizedMessage("%FillHandleDragMode.menu.item.series"));
        seriesItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.SERIES, FillHandleDragMode.this.direction, natTable.getConfigRegistry()));
            }
        });
        // add a menu listener to reset the fill state when the menu is
        // closed
        this.menu.addMenuListener(new MenuAdapter() {

            @Override
            public void menuHidden(MenuEvent e) {
                // perform the reset operation asynchronously because on
                // several OS the hide event is processed BEFORE the
                // selection event
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        reset(natTable);
                    }
                });
            }
        });
        // add the dispose listener for disposing the menu
        natTable.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                FillHandleDragMode.this.menu.dispose();
            }
        });
    }
    this.menu.setVisible(true);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) FillHandlePasteCommand(org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuAdapter(org.eclipse.swt.events.MenuAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) DisposeEvent(org.eclipse.swt.events.DisposeEvent) MenuEvent(org.eclipse.swt.events.MenuEvent)

Aggregations

DisposeEvent (org.eclipse.swt.events.DisposeEvent)366 DisposeListener (org.eclipse.swt.events.DisposeListener)363 GridData (org.eclipse.swt.layout.GridData)103 Composite (org.eclipse.swt.widgets.Composite)91 SelectionEvent (org.eclipse.swt.events.SelectionEvent)87 GridLayout (org.eclipse.swt.layout.GridLayout)75 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)70 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 Control (org.eclipse.swt.widgets.Control)38 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)37 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)36 FillLayout (org.eclipse.swt.layout.FillLayout)35 Event (org.eclipse.swt.widgets.Event)35 Color (org.eclipse.swt.graphics.Color)34 MouseEvent (org.eclipse.swt.events.MouseEvent)32 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)31