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();
}
});
}
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();
}
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);
}
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();
}
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();
}
});
}
Aggregations