Search in sources :

Example 66 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project eclipse-integration-commons by spring-projects.

the class QuickSearchDialog method createDetailsArea.

private void createDetailsArea(Composite parent) {
    details = new StyledText(parent, SWT.MULTI + SWT.READ_ONLY + SWT.BORDER + SWT.H_SCROLL);
    details.setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
    // GridDataFactory.fillDefaults().grab(true, false).applyTo(details);
    // details = new SourceViewer(parent, null, SWT.READ_ONLY+SWT.MULTI+SWT.BORDER);
    // details.getTextWidget().setText("Line 1\nLine 2\nLine 3\nLine 4\nLine 5");
    // details.setEditable(false);
    // 
    // IPreferenceStore prefs = EditorsPlugin.getDefault().getPreferenceStore();
    // TextSourceViewerConfiguration sourceViewerConf = new TextSourceViewerConfiguration(prefs);
    // details.configure(sourceViewerConf);
    // 
    // GridDataFactory.fillDefaults().grab(true, false).applyTo(details);
    // Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
    // details.getTextWidget().setFont(font);
    list.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            refreshDetails();
        }
    });
    details.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            refreshDetails();
        }
    });
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 67 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project eclipse-integration-commons by spring-projects.

the class DashboardMainPage method createFeedsSection.

private void createFeedsSection(Composite parent, final String title, FeedType feedType, String feedName) {
    final Section section = new Section(parent, ExpandableComposite.TITLE_BAR) {

        @Override
        public void redraw() {
            GridData compositeData = (GridData) feedsScrolled.getLayoutData();
            compositeData.widthHint = getSize().x - 35;
            compositeData.heightHint = getSize().y - 40;
            compositeData.grabExcessHorizontalSpace = false;
            compositeData.grabExcessVerticalSpace = false;
            super.redraw();
        }
    };
    form.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            GridData data = (GridData) section.getLayoutData();
            data.heightHint = form.getSize().y - FEEDS_TEXT_WRAP_INDENT;
        }
    });
    toolkit.adapt(section);
    section.setTitleBarForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE));
    section.setTitleBarBackground(toolkit.getColors().getColor(IFormColors.TB_BG));
    section.setTitleBarBorderColor(toolkit.getColors().getColor(IFormColors.TB_BORDER));
    section.setFont(FormFonts.getInstance().getBoldFont(getSite().getShell().getDisplay(), section.getFont()));
    section.setText(title);
    section.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, true).hint(300, 300).applyTo(section);
    final Composite headerComposite = toolkit.createComposite(section, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginTop = 0;
    rowLayout.marginBottom = 0;
    headerComposite.setLayout(rowLayout);
    headerComposite.setBackground(null);
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    toolBarManager.createControl(headerComposite);
    final PageBook pagebook = new PageBook(section, SWT.NONE);
    toolkit.adapt(pagebook);
    pagebook.setLayoutData(new GridLayout());
    final Composite disclaimer = createDisclaimer(pagebook);
    feedsScrolled = new ScrolledComposite(pagebook, SWT.V_SCROLL);
    feedsScrolled.setExpandVertical(false);
    feedsScrolled.setLayout(new GridLayout());
    feedsScrolled.setAlwaysShowScrollBars(false);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(feedsScrolled);
    toolkit.adapt(feedsScrolled);
    feedsComposite = toolkit.createComposite(feedsScrolled);
    feedsComposite.setLayout(new TableWrapLayout());
    GridDataFactory.fillDefaults().grab(true, false).applyTo(feedsComposite);
    feedsScrolled.setContent(feedsComposite);
    feedsComposite.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            GridData data = (GridData) feedsComposite.getLayoutData();
            data.widthHint = section.getSize().x - FEEDS_TEXT_WRAP_INDENT;
            data.heightHint = form.getSize().y - 50;
        }
    });
    section.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            GridData data = (GridData) feedsScrolled.getLayoutData();
            data.heightHint = form.getSize().y - 50;
            data.grabExcessVerticalSpace = false;
            feedsScrolled.setSize(section.getSize().x - 40, form.getSize().y - 50);
            for (Control feedControl : feedControls) {
                if (!feedControl.isDisposed()) {
                    ((TableWrapData) feedControl.getLayoutData()).maxWidth = section.getSize().x - FEEDS_TEXT_WRAP_INDENT;
                // Point size = feedControl.computeSize(data.widthHint,
                // 400);
                // feedControl.setSize(size);
                // feedControl.pack(true);
                }
            }
            feedsComposite.pack();
        }
    });
    feedControls = new HashSet<Control>();
    final Map<String, String> springMap = new HashMap<String, String>();
    String[] urls = ResourceProvider.getUrls(RESOURCE_DASHBOARD_FEEDS_BLOGS);
    for (String url : urls) {
        springMap.put(url, null);
    }
    getEditorSite().getShell().getDisplay().asyncExec(new Runnable() {

        public void run() {
            FeedsReader reader = new FeedsReader();
            CachedFeedsManager manager = new CachedFeedsManager(title, springMap, reader);
            try {
                manager.readCachedFeeds(null);
                Set<SyndEntry> entries = new HashSet<SyndEntry>();
                for (SyndFeed entry : reader.getFeeds()) {
                    entries.addAll(entry.getEntries());
                }
                if (!getManagedForm().getForm().isDisposed()) {
                    displayFeeds(entries, feedsComposite, feedsScrolled, pagebook, disclaimer, section);
                }
            } catch (IllegalArgumentException e) {
                StatusHandler.log(new Status(IStatus.ERROR, IdeUiPlugin.PLUGIN_ID, "An unexpected error occurred while retrieving feed content from cache.", e));
            } catch (FeedException e) {
                StatusHandler.log(new Status(IStatus.ERROR, IdeUiPlugin.PLUGIN_ID, "An unexpected error occurred while retrieving feed content from cache.", e));
            }
        }
    });
    refreshFeedsAction = new Action("Refresh Feeds", CommonImages.REFRESH) {

        @Override
        public void run() {
            Map<String, String> springMap = getFeedsMap();
            displayFeeds(feedsComposite, feedsScrolled, pagebook, disclaimer, springMap, title, section);
        }
    };
    Action configureURLsAction = new Action("Configure URLs", StsUiImages.RSS_CONFIGURE) {

        @Override
        public void run() {
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getSite().getShell(), URL_CONFIGURATION_ID, new String[] { URL_CONFIGURATION_ID }, null);
            dialog.open();
        }
    };
    section.setClient(pagebook);
    section.setTextClient(headerComposite);
    toolBarManager.add(configureURLsAction);
    toolBarManager.add(refreshFeedsAction);
    toolBarManager.update(true);
    refreshFeedsAction.run();
}
Also used : NewWizardAction(org.eclipse.ui.actions.NewWizardAction) Action(org.eclipse.jface.action.Action) Set(java.util.Set) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) HashSet(java.util.HashSet) ControlAdapter(org.eclipse.swt.events.ControlAdapter) HashMap(java.util.HashMap) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) GridLayout(org.eclipse.swt.layout.GridLayout) TextSearchControl(org.eclipse.mylyn.commons.workbench.search.TextSearchControl) Control(org.eclipse.swt.widgets.Control) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) RowLayout(org.eclipse.swt.layout.RowLayout) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) PaintListener(org.eclipse.swt.events.PaintListener) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) FeedException(com.sun.syndication.io.FeedException) Section(org.eclipse.ui.forms.widgets.Section) PageBook(org.eclipse.ui.part.PageBook) TableWrapLayout(org.eclipse.ui.forms.widgets.TableWrapLayout) GridData(org.eclipse.swt.layout.GridData) ControlEvent(org.eclipse.swt.events.ControlEvent) Map(java.util.Map) HashMap(java.util.HashMap)

Example 68 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project eclipse-integration-commons by spring-projects.

the class DashboardMainPage method createUpdateSection.

private void createUpdateSection(final Composite parent) {
    updateSection = new Section(parent, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE) {

        @Override
        public void redraw() {
            if (getStoredExpandedState(IIdeUiConstants.PREF_UPDATE_SECTION_COLLAPSE, true)) {
                GridData compositeData = (GridData) updateScrolled.getLayoutData();
                compositeData.widthHint = getSize().x - 55;
                compositeData.heightHint = getSize().y - 40;
                compositeData.grabExcessHorizontalSpace = false;
                compositeData.grabExcessVerticalSpace = false;
            }
            super.redraw();
        }
    };
    // updateSection = toolkit.createSection(parent,
    // ExpandableComposite.TITLE_BAR);
    toolkit.adapt(updateSection);
    updateSection.setTitleBarForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE));
    updateSection.setTitleBarBackground(toolkit.getColors().getColor(IFormColors.TB_BG));
    updateSection.setTitleBarBorderColor(toolkit.getColors().getColor(IFormColors.TB_BORDER));
    updateSection.setFont(FormFonts.getInstance().getBoldFont(getSite().getShell().getDisplay(), updateSection.getFont()));
    updateSection.setText("Updates");
    updateSection.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, getStoredExpandedState(IIdeUiConstants.PREF_UPDATE_SECTION_COLLAPSE, true)).applyTo(updateSection);
    setUpExpandableSection(updateSection, IIdeUiConstants.PREF_UPDATE_SECTION_COLLAPSE, true);
    final Composite headerComposite = toolkit.createComposite(updateSection, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginTop = 0;
    rowLayout.marginBottom = 0;
    headerComposite.setLayout(rowLayout);
    headerComposite.setBackground(null);
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    toolBarManager.createControl(headerComposite);
    updateSection.setTextClient(headerComposite);
    final PageBook pagebook = new PageBook(updateSection, SWT.NONE);
    toolkit.adapt(pagebook);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(pagebook);
    final Composite disclaimer = createDisclaimer(pagebook);
    updateScrolled = new ScrolledComposite(pagebook, SWT.V_SCROLL);
    updateScrolled.setExpandVertical(false);
    updateScrolled.setLayout(new GridLayout());
    updateScrolled.setAlwaysShowScrollBars(false);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(updateScrolled);
    toolkit.adapt(updateScrolled);
    final Composite composite = toolkit.createComposite(updateScrolled);
    updateScrolled.setContent(composite);
    composite.setLayout(new TableWrapLayout());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
    displayUpdates(composite, pagebook, disclaimer);
    refreshUpdatesAction = new Action("Refresh Updates", CommonImages.REFRESH) {

        @Override
        public void run() {
            displayUpdates(composite, pagebook, disclaimer);
        }
    };
    toolBarManager.add(refreshUpdatesAction);
    toolBarManager.update(true);
    pagebook.showPage(composite);
    updateSection.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            if (updateSection.isExpanded()) {
                GridData data = (GridData) updateScrolled.getLayoutData();
                data.grabExcessVerticalSpace = false;
                updateScrolled.setSize(updateSection.getSize().x - 14, updateSection.getSize().y - 33);
                for (Control child : composite.getChildren()) {
                    ((TableWrapData) child.getLayoutData()).maxWidth = updateSection.getSize().x - UPDATE_TEXT_WRAP_INDENT;
                }
                composite.pack();
            }
        }
    });
    updateSection.setClient(pagebook);
}
Also used : NewWizardAction(org.eclipse.ui.actions.NewWizardAction) Action(org.eclipse.jface.action.Action) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) Section(org.eclipse.ui.forms.widgets.Section) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) TextSearchControl(org.eclipse.mylyn.commons.workbench.search.TextSearchControl) Control(org.eclipse.swt.widgets.Control) PageBook(org.eclipse.ui.part.PageBook) TableWrapLayout(org.eclipse.ui.forms.widgets.TableWrapLayout) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 69 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project eclipse-integration-commons by spring-projects.

the class TableResizeHelper method enableResizing.

public void enableResizing() {
    ControlListener resizeListener = new ControlListener() {

        public void controlResized(ControlEvent e) {
            resizeTable();
        }

        public void controlMoved(ControlEvent e) {
        }
    };
    tableViewer.getTable().addControlListener(resizeListener);
    TableColumn[] cols = tableViewer.getTable().getColumns();
    if (cols != null) {
        for (int i = 0; i < cols.length - 1; i++) {
            cols[i].addControlListener(resizeListener);
        }
    }
    // Initial resize of the columns
    resizeTable();
}
Also used : ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 70 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project webtools.sourceediting by eclipse.

the class XMLAnnotationsView method createStyledTextWidget.

private void createStyledTextWidget(Composite container) {
    styledtext = new StyledText(container, SWT.V_SCROLL | SWT.H_SCROLL);
    styledtext.setBackground(getColor(SWT.COLOR_INFO_BACKGROUND));
    styledtext.setEditable(false);
    styledtext.setBounds(container.getBounds());
    styledtext.addControlListener(new ControlAdapter() {

        /*
			 * @see
			 * org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse
			 * .swt.events.ControlEvent)
			 */
        public void controlResized(ControlEvent e) {
            doStyledTextInput();
        }
    });
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ControlEvent(org.eclipse.swt.events.ControlEvent)

Aggregations

ControlEvent (org.eclipse.swt.events.ControlEvent)187 ControlAdapter (org.eclipse.swt.events.ControlAdapter)135 Composite (org.eclipse.swt.widgets.Composite)76 GridData (org.eclipse.swt.layout.GridData)67 ControlListener (org.eclipse.swt.events.ControlListener)54 GridLayout (org.eclipse.swt.layout.GridLayout)50 SelectionEvent (org.eclipse.swt.events.SelectionEvent)49 TableColumn (org.eclipse.swt.widgets.TableColumn)42 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)41 Point (org.eclipse.swt.graphics.Point)38 Table (org.eclipse.swt.widgets.Table)37 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)36 FillLayout (org.eclipse.swt.layout.FillLayout)35 Tree (org.eclipse.swt.widgets.Tree)35 TreeViewer (org.eclipse.jface.viewers.TreeViewer)33 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)32 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)31 AdapterFactoryTreeEditor (org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor)30 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)30 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)30