use of org.eclipse.ui.forms.widgets.TableWrapData in project netxms by netxms.
the class ExportFileBuilder method createActionsSection.
/**
* Create "Actions" section
*/
private void createActionsSection() {
Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
section.setText("Actions");
TableWrapData td = new TableWrapData();
td.align = TableWrapData.FILL;
td.grabHorizontal = true;
section.setLayoutData(td);
Composite clientArea = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
clientArea.setLayout(layout);
section.setClient(clientArea);
actionViewer = new TableViewer(clientArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
toolkit.adapt(ruleViewer.getTable());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 200;
gd.verticalSpan = 2;
actionViewer.getTable().setLayoutData(gd);
actionViewer.setContentProvider(new ArrayContentProvider());
actionViewer.setLabelProvider(new ActionLabelProvider());
actionViewer.setComparator(new ActionComparator());
actionViewer.getTable().setSortDirection(SWT.UP);
final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkAdd.setText(Messages.get().ExportFileBuilder_Add);
linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkAdd.setLayoutData(gd);
linkAdd.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
addActions();
}
});
final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkRemove.setText(Messages.get().ExportFileBuilder_Remove);
linkRemove.setImage(SharedIcons.IMG_DELETE_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkRemove.setLayoutData(gd);
linkRemove.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
removeObjects(actionViewer, actions);
}
});
}
use of org.eclipse.ui.forms.widgets.TableWrapData in project netxms by netxms.
the class ExportFileBuilder method createTrapSection.
/**
* Create "SNMP Traps" section
*/
private void createTrapSection() {
Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
section.setText(Messages.get().ExportFileBuilder_SectionTraps);
TableWrapData td = new TableWrapData();
td.align = TableWrapData.FILL;
td.grabHorizontal = true;
section.setLayoutData(td);
Composite clientArea = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
clientArea.setLayout(layout);
section.setClient(clientArea);
trapViewer = new TableViewer(clientArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
toolkit.adapt(trapViewer.getTable());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 200;
gd.verticalSpan = 2;
trapViewer.getTable().setLayoutData(gd);
trapViewer.setContentProvider(new ArrayContentProvider());
trapViewer.setLabelProvider(new TrapListLabelProvider());
trapViewer.setComparator(new ObjectLabelComparator((ILabelProvider) eventViewer.getLabelProvider()));
trapViewer.getTable().setSortDirection(SWT.UP);
final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkAdd.setText(Messages.get().ExportFileBuilder_Add);
linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkAdd.setLayoutData(gd);
linkAdd.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
if (snmpTrapCache == null) {
new ConsoleJob(Messages.get().ExportFileBuilder_TrapsLoadJobName, ExportFileBuilder.this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
snmpTrapCache = session.getSnmpTrapsConfigurationSummary();
runInUIThread(new Runnable() {
@Override
public void run() {
addTraps();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ExportFileBuilder_TrapsLoadJobError;
}
}.start();
} else {
addTraps();
}
}
});
final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkRemove.setText(Messages.get().ExportFileBuilder_Remove);
linkRemove.setImage(SharedIcons.IMG_DELETE_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkRemove.setLayoutData(gd);
linkRemove.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
removeObjects(trapViewer, traps);
}
});
}
use of org.eclipse.ui.forms.widgets.TableWrapData 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.ui.forms.widgets.TableWrapData 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.ui.forms.widgets.TableWrapData in project cubrid-manager by CUBRID.
the class NoticeDashboardPage method createFormContent.
protected void createFormContent(IManagedForm managedForm) {
super.createFormContent(managedForm);
toolkit = managedForm.getToolkit();
form = managedForm.getForm();
toolkit.decorateFormHeading(form.getForm());
String title = client.equals("CMT") ? Messages.titleCUBRIDMigration : client.equals("CQB") ? Messages.titleCUBRIDQuery : Messages.titleCUBRIDManager;
form.setText(title);
form.setFont(new Font(Display.getCurrent(), "Arial", 13, SWT.BOLD));
Composite composite = form.getBody();
TableWrapLayout layout2 = new TableWrapLayout();
layout2.numColumns = 2;
layout2.makeColumnsEqualWidth = true;
composite.setLayout(layout2);
TableWrapLayout layout1 = new TableWrapLayout();
layout1.numColumns = 1;
TableWrapData twd;
left = toolkit.createComposite(composite, SWT.None);
left.setLayout(layout1);
twd = new TableWrapData(TableWrapData.FILL_GRAB);
left.setLayoutData(twd);
layout1 = new TableWrapLayout();
layout1.numColumns = 1;
right = toolkit.createComposite(composite, SWT.None);
right.setLayout(layout1);
twd = new TableWrapData(TableWrapData.FILL_GRAB);
right.setLayoutData(twd);
createContentSections(left, right);
ScheduledExecutorService pool = Executors.newSingleThreadScheduledExecutor();
pool.schedule(new Runnable() {
public void run() {
initData();
Display.getDefault().syncExec(new Runnable() {
public void run() {
setContent();
}
});
}
}, 10, TimeUnit.MILLISECONDS);
pool.shutdown();
}
Aggregations