List of usage examples for org.eclipse.jface.viewers TableViewer setContentProvider
@Override public void setContentProvider(IContentProvider provider)
AbstractTableViewer
. From source file:org.dita_op.dost.launcher.internal.ui.launchConfiguration.DOSTArgumentsGroup.java
License:Open Source License
/** * Creates and returns a configured table viewer in the given parent *//*from ww w . jav a 2 s. co m*/ private TableViewer createTableViewer(Composite parent) { Table table = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER); table.setLayoutData(new GridData(GridData.FILL_BOTH)); TableViewer tableViewer = new TableViewer(table); final EntryLabelProvider labelProvider = new EntryLabelProvider(); tableViewer.setLabelProvider(labelProvider); tableViewer.setContentProvider(new ArrayContentProvider()); tableViewer.addSelectionChangedListener(tableListener); tableViewer.setComparator(new ViewerComparator() { @Override public int compare(Viewer viewer, Object e1, Object e2) { return labelProvider.getColumnText(e1, 0).compareToIgnoreCase(labelProvider.getColumnText(e2, 0)); } }); TableLayout tableLayout = new TableLayout(); table.setLayout(tableLayout); table.setHeaderVisible(true); table.setLinesVisible(true); for (int i = 0; i < tableColumnHeaders.length; i++) { tableLayout.addColumnData(tableColumnLayouts[i]); TableColumn column = new TableColumn(table, SWT.NONE, i); column.setResizable(tableColumnLayouts[i].resizable); column.setText(tableColumnHeaders[i]); } return tableViewer; }
From source file:org.drools.eclipse.flow.common.editor.editpart.work.EmailCustomEditor.java
License:Apache License
public void createHeadersTab(TabFolder tabFolder) { final TabItem headersTabItem = new TabItem(tabFolder, SWT.NONE); headersTabItem.setText("Header"); final Composite container = new Composite(tabFolder, SWT.NONE); final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2;//from w ww .j ava 2s . c o m gridLayout.horizontalSpacing = 2; container.setLayout(gridLayout); headersTabItem.setControl(container); final Label recipientsLabel = new Label(container, SWT.NONE); final GridData gd_recipientsLabel = new GridData(); recipientsLabel.setLayoutData(gd_recipientsLabel); recipientsLabel.setText("Recipients"); new Label(container, SWT.NONE); // create main table final TableViewer tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION); // // Type column // TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE); // column.setLabelProvider(new TypeLabelProvider()); // column.setEditingSupport(new TypeEditing(tableViewer)); // column.getColumn().setWidth(70); // column.getColumn().setText("Type"); // column.getColumn().setMoveable(true); // // // Display Name column // column = new TableViewerColumn(tableViewer, SWT.NONE); // column.setLabelProvider(new DisplayNameLabelProvider()); // column.setEditingSupport(new DisplayNameEditing(tableViewer)); // column.getColumn().setWidth(200); // column.getColumn().setText("Display Name"); // column.getColumn().setMoveable(true); // Email column TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE); column.setLabelProvider(new EmailLabelProvider()); column.setEditingSupport(new EmailEditing(tableViewer)); column.getColumn().setText("Email Address"); column.getColumn().setWidth(200); column.getColumn().setMoveable(true); final Table table = tableViewer.getTable(); final GridData gd_table = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); gd_table.heightHint = 128; table.setLayoutData(gd_table); table.setLinesVisible(true); table.setHeaderVisible(true); tableViewer.setContentProvider(new RecipientsContentProvider()); tableViewer.setInput(recipients); // add/delete buttons final Composite composite = new Composite(container, SWT.NONE); composite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); composite.setLayout(new RowLayout()); final Button addButton = new Button(composite, SWT.NONE); addButton.setText("Add"); addButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { Recipient recipient = new Recipient(); recipients.add(recipient); tableViewer.add(recipient); tableViewer.refresh(); } public void widgetSelected(SelectionEvent e) { Recipient recipient = new Recipient(); recipients.add(recipient); tableViewer.add(recipient); tableViewer.refresh(); } }); final Button deleteButton = new Button(composite, SWT.NONE); deleteButton.setText("Remove"); deleteButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent event) { TableItem[] items = table.getSelection(); if (items != null && items.length > 0) { recipients.remove((Recipient) items[0].getData()); tableViewer.remove(items[0]); tableViewer.refresh(); } } public void widgetDefaultSelected(SelectionEvent event) { TableItem[] items = table.getSelection(); if (items != null && items.length > 0) { recipients.remove((Recipient) items[0].getData()); tableViewer.remove(items[0]); tableViewer.refresh(); } } }); // from label and text field final Label fromLabel = new Label(container, SWT.NONE); fromLabel.setLayoutData(new GridData()); fromLabel.setText("From"); fromText = new Text(container, SWT.BORDER); fromText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); }
From source file:org.drools.eclipse.flow.common.editor.editpart.work.HumanTaskCustomEditor.java
License:Apache License
private void createReassignmentTab(TabFolder tabFolder) { Work work = (Work) getValue();/* w w w. j a v a 2s.c o m*/ String notStartedReassign = (String) work.getParameter("NotStartedReassign"); String notCompletedReassign = (String) work.getParameter("NotCompletedReassign"); if (notStartedReassign != null) { String[] reassigns = notStartedReassign.split(COMPONENT_SEPARATOR_ESCAPED); for (String reassign : reassigns) { if (reassign != null && reassign.length() > 0) { reassignments.add(new Reassignment(reassign, "not-started")); } } } if (notCompletedReassign != null) { String[] reassigns = notCompletedReassign.split(COMPONENT_SEPARATOR_ESCAPED); for (String reassign : reassigns) { if (reassign != null && reassign.length() > 0) { reassignments.add(new Reassignment(reassign, "not-completed")); } } } final TabItem headersTabItem = new TabItem(tabFolder, SWT.NONE); headersTabItem.setText("Reassignment"); final Composite container = new Composite(tabFolder, SWT.NONE); final GridLayout gridLayout = new GridLayout(); gridLayout.horizontalSpacing = 2; container.setLayout(gridLayout); headersTabItem.setControl(container); final TableViewer tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION); TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE); column.setLabelProvider(new ReassignmentUsersLabelProvider()); column.setEditingSupport(new ReassignmentUsersEditing(tableViewer)); column.getColumn().setText("Users"); column.getColumn().setWidth(100); column.getColumn().setMoveable(true); TableViewerColumn column2 = new TableViewerColumn(tableViewer, SWT.NONE); column2.setLabelProvider(new ReassignmentGroupsLabelProvider()); column2.setEditingSupport(new ReassignmentGroupsEditing(tableViewer)); column2.getColumn().setText("Groups"); column2.getColumn().setWidth(100); column2.getColumn().setMoveable(true); TableViewerColumn column3 = new TableViewerColumn(tableViewer, SWT.NONE); column3.setLabelProvider(new ReassignmentExpiresAtLabelProvider()); column3.setEditingSupport(new ReassignmentExpiresAtEditing(tableViewer)); column3.getColumn().setText("Expires At"); column3.getColumn().setWidth(100); column3.getColumn().setMoveable(true); TableViewerColumn column4 = new TableViewerColumn(tableViewer, SWT.NONE); column4.setLabelProvider(new ReassignmentTypeLabelProvider()); column4.setEditingSupport(new ReassignmentTypeEditing(tableViewer)); column4.getColumn().setText("Type"); column4.getColumn().setWidth(100); column4.getColumn().setMoveable(true); final Table table = tableViewer.getTable(); final GridData gd_table = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); gd_table.heightHint = 128; table.setLayoutData(gd_table); table.setLinesVisible(true); table.setHeaderVisible(true); tableViewer.setContentProvider(new ReassignmentContentProvider()); tableViewer.setInput(reassignments); // add/delete buttons final Composite composite = new Composite(container, SWT.NONE); composite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); composite.setLayout(new RowLayout()); final Button addButton = new Button(composite, SWT.NONE); addButton.setText("Add"); addButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { Reassignment reassignment = new Reassignment(); reassignments.add(reassignment); tableViewer.add(reassignment); tableViewer.refresh(); } public void widgetSelected(SelectionEvent e) { Reassignment reassignment = new Reassignment(); reassignments.add(reassignment); tableViewer.add(reassignment); tableViewer.refresh(); } }); final Button deleteButton = new Button(composite, SWT.NONE); deleteButton.setText("Remove"); deleteButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent event) { TableItem[] items = table.getSelection(); if (items != null && items.length > 0) { reassignments.remove((Reassignment) items[0].getData()); tableViewer.remove(items[0]); tableViewer.refresh(); } } public void widgetDefaultSelected(SelectionEvent event) { TableItem[] items = table.getSelection(); if (items != null && items.length > 0) { reassignments.remove((Reassignment) items[0].getData()); tableViewer.remove(items[0]); tableViewer.refresh(); } } }); }
From source file:org.drools.eclipse.flow.common.editor.editpart.work.HumanTaskCustomEditor.java
License:Apache License
private void createNotificationTab(TabFolder tabFolder) { Work work = (Work) getValue();/* ww w . j av a2 s. c o m*/ String notStartedNotify = (String) work.getParameter("NotStartedNotify"); String notCompletedNotify = (String) work.getParameter("NotCompletedNotify"); if (notStartedNotify != null) { String[] notifies = notStartedNotify.split(COMPONENT_SEPARATOR_ESCAPED); for (String notification : notifies) { if (notification != null && notification.length() > 0) { notifications.add(new Notification(notification, "not-started")); } } } if (notCompletedNotify != null) { String[] notifies = notCompletedNotify.split(COMPONENT_SEPARATOR_ESCAPED); for (String notification : notifies) { if (notification != null && notification.length() > 0) { notifications.add(new Notification(notification, "not-completed")); } } } final TabItem headersTabItem = new TabItem(tabFolder, SWT.NONE); headersTabItem.setText("Notifications"); final Composite container = new Composite(tabFolder, SWT.NONE); final GridLayout gridLayout = new GridLayout(); gridLayout.horizontalSpacing = 2; container.setLayout(gridLayout); headersTabItem.setControl(container); final TableViewer tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION); TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE); column.setLabelProvider(new NotificationsLabelProvider()); column.setEditingSupport(new NotificationsEditing(tableViewer)); column.getColumn().setText("Notifications"); column.getColumn().setWidth(400); column.getColumn().setMoveable(true); final Label typeLabel = new Label(container, SWT.NONE); typeLabel.setLayoutData(new GridData()); typeLabel.setText("Type"); notifyTypeText = new Combo(container, SWT.NONE); notifyTypeText.add("not-started"); notifyTypeText.add("not-completed"); notifyTypeText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Label expiresAtLabel = new Label(container, SWT.NONE); expiresAtLabel.setLayoutData(new GridData()); expiresAtLabel.setText("ExpiresAt"); notifyExpiresAtText = new Text(container, SWT.NONE); notifyExpiresAtText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Label notifyFromLabel = new Label(container, SWT.NONE); notifyFromLabel.setLayoutData(new GridData()); notifyFromLabel.setText("From"); notifyFromText = new Text(container, SWT.NONE); notifyFromText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Label notifyToLabel = new Label(container, SWT.NONE); notifyToLabel.setText("To Users"); notifyToText = new Text(container, SWT.NONE); notifyToText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Label notifyToGroupsLabel = new Label(container, SWT.NONE); notifyToGroupsLabel.setText("To Groups"); notifyToGroupsText = new Text(container, SWT.NONE); notifyToGroupsText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Label notifyReplyToLabel = new Label(container, SWT.NONE); notifyReplyToLabel.setText("Reply To"); notifyReplyToText = new Text(container, SWT.NONE); notifyReplyToText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Label subjectLabel = new Label(container, SWT.NONE); subjectLabel.setLayoutData(new GridData()); subjectLabel.setText("Subject"); notifySubjectText = new Text(container, SWT.NONE); notifySubjectText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Label bodyLabel = new Label(container, SWT.NONE); bodyLabel.setText("Body"); notifyBodyText = new Text(container, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); final GridData gd_bodyText = new GridData(SWT.FILL, SWT.CENTER, true, false); gd_bodyText.heightHint = 100; notifyBodyText.setLayoutData(gd_bodyText); final Table table = tableViewer.getTable(); final GridData gd_table = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); gd_table.heightHint = 100; table.setLayoutData(gd_table); table.setLinesVisible(true); table.setHeaderVisible(true); table.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { TableItem[] items = table.getSelection(); if (items != null && items.length > 0) { int index = notifications.indexOf((Notification) items[0].getData()); Notification notification = notifications.get(index); notifyFromText.setText(notification.getFrom()); notifyToText.setText(notification.getTo()); notifyToGroupsText.setText(notification.getToGroups()); notifyReplyToText.setText(notification.getReplyTo()); notifySubjectText.setText(notification.getSubject()); notifyBodyText.setText(notification.getBody()); notifyTypeText.setText(notification.getType()); notifyExpiresAtText.setText(notification.getExpiresAt()); } else { notifyFromText.setText(""); notifyToText.setText(""); notifyToGroupsText.setText(""); notifyReplyToText.setText(""); notifySubjectText.setText(""); notifyBodyText.setText(""); notifyTypeText.setText(""); notifyExpiresAtText.setText(""); } } public void widgetDefaultSelected(SelectionEvent e) { TableItem[] items = table.getSelection(); if (items != null && items.length > 0) { int index = notifications.indexOf((Notification) items[0].getData()); Notification notification = notifications.get(index); notifyFromText.setText(notification.getFrom()); notifyToText.setText(notification.getTo()); notifyToGroupsText.setText(notification.getToGroups()); notifyReplyToText.setText(notification.getReplyTo()); notifySubjectText.setText(notification.getSubject()); notifyBodyText.setText(notification.getBody()); notifyTypeText.setText(notification.getType()); notifyExpiresAtText.setText(notification.getExpiresAt()); } else { notifyFromText.setText(""); notifyToText.setText(""); notifyToGroupsText.setText(""); notifyReplyToText.setText(""); notifySubjectText.setText(""); notifyBodyText.setText(""); notifyTypeText.setText(""); notifyExpiresAtText.setText(""); } } }); tableViewer.setContentProvider(new NotificationsContentProvider()); tableViewer.setInput(notifications); // add/delete buttons final Composite composite = new Composite(container, SWT.NONE); composite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); composite.setLayout(new RowLayout()); final Button addButton = new Button(composite, SWT.NONE); addButton.setText("Add"); addButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { Notification notification = new Notification(); notification.setFrom(notifyFromText.getText()); notification.setTo(notifyToText.getText()); notification.setToGroups(notifyToGroupsText.getText()); notification.setReplyTo(notifyReplyToText.getText()); notification.setSubject(notifySubjectText.getText()); notification.setBody(notifyBodyText.getText()); notification.setType(notifyTypeText.getText()); notification.setExpiresAt(notifyExpiresAtText.getText()); notifications.add(notification); tableViewer.add(notification); tableViewer.refresh(); // clear fields after add operation notifyFromText.setText(""); notifyToText.setText(""); notifyToGroupsText.setText(""); notifyReplyToText.setText(""); notifySubjectText.setText(""); notifyBodyText.setText(""); notifyTypeText.setText(""); notifyExpiresAtText.setText(""); } public void widgetSelected(SelectionEvent e) { Notification notification = new Notification(); notification.setFrom(notifyFromText.getText()); notification.setTo(notifyToText.getText()); notification.setToGroups(notifyToGroupsText.getText()); notification.setReplyTo(notifyReplyToText.getText()); notification.setSubject(notifySubjectText.getText()); notification.setBody(notifyBodyText.getText()); notification.setType(notifyTypeText.getText()); notification.setExpiresAt(notifyExpiresAtText.getText()); notifications.add(notification); tableViewer.add(notification); tableViewer.refresh(); // clear fields after add operation notifyFromText.setText(""); notifyToText.setText(""); notifyToGroupsText.setText(""); notifyReplyToText.setText(""); notifySubjectText.setText(""); notifyBodyText.setText(""); notifyTypeText.setText(""); notifyExpiresAtText.setText(""); } }); final Button deleteButton = new Button(composite, SWT.NONE); deleteButton.setText("Remove"); deleteButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent event) { TableItem[] items = table.getSelection(); if (items != null && items.length > 0) { notifications.remove((Notification) items[0].getData()); tableViewer.remove(items[0]); tableViewer.refresh(); } } public void widgetDefaultSelected(SelectionEvent event) { TableItem[] items = table.getSelection(); if (items != null && items.length > 0) { notifications.remove((Notification) items[0].getData()); tableViewer.remove(items[0]); tableViewer.refresh(); } } }); final Button updateButton = new Button(composite, SWT.NONE); updateButton.setText("Update"); updateButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent event) { TableItem[] items = table.getSelection(); if (items != null && items.length > 0) { int index = notifications.indexOf((Notification) items[0].getData()); Notification notification = notifications.get(index); notification.setFrom(notifyFromText.getText()); notification.setTo(notifyToText.getText()); notification.setToGroups(notifyToGroupsText.getText()); notification.setReplyTo(notifyReplyToText.getText()); notification.setSubject(notifySubjectText.getText()); notification.setBody(notifyBodyText.getText()); notification.setType(notifyTypeText.getText()); notification.setExpiresAt(notifyExpiresAtText.getText()); tableViewer.refresh(); // clear fields after add operation notifyFromText.setText(""); notifyToText.setText(""); notifyToGroupsText.setText(""); notifyReplyToText.setText(""); notifySubjectText.setText(""); notifyBodyText.setText(""); notifyTypeText.setText(""); notifyExpiresAtText.setText(""); } } public void widgetDefaultSelected(SelectionEvent event) { TableItem[] items = table.getSelection(); if (items != null && items.length > 0) { int index = notifications.indexOf((Notification) items[0].getData()); Notification notification = notifications.get(index); notification.setFrom(notifyFromText.getText()); notification.setTo(notifyToText.getText()); notification.setToGroups(notifyToGroupsText.getText()); notification.setReplyTo(notifyReplyToText.getText()); notification.setSubject(notifySubjectText.getText()); notification.setBody(notifyBodyText.getText()); notification.setType(notifyTypeText.getText()); notification.setExpiresAt(notifyExpiresAtText.getText()); tableViewer.refresh(); // clear fields after add operation notifyFromText.setText(""); notifyToText.setText(""); notifyToGroupsText.setText(""); notifyReplyToText.setText(""); notifySubjectText.setText(""); notifyBodyText.setText(""); notifyTypeText.setText(""); notifyExpiresAtText.setText(""); } } }); final Button clearButton = new Button(composite, SWT.NONE); clearButton.setText("Clear"); clearButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent event) { // clear fields after add operation notifyFromText.setText(""); notifyToText.setText(""); notifyToGroupsText.setText(""); notifyReplyToText.setText(""); notifySubjectText.setText(""); notifyBodyText.setText(""); notifyTypeText.setText(""); notifyExpiresAtText.setText(""); } public void widgetDefaultSelected(SelectionEvent event) { // clear fields after add operation notifyFromText.setText(""); notifyToText.setText(""); notifyToGroupsText.setText(""); notifyReplyToText.setText(""); notifySubjectText.setText(""); notifyBodyText.setText(""); notifyTypeText.setText(""); notifyExpiresAtText.setText(""); } }); }
From source file:org.dynami.dialogs.StrategyDescriptorDialog.java
License:Apache License
/** * Create contents of the dialog./*w ww . j a v a 2s . c o m*/ * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); container.setLayout(new FillLayout(SWT.HORIZONTAL)); ScrolledForm scrldfrmStrategy = formToolkit.createScrolledForm(container); scrldfrmStrategy.setImage(ResourceManager.getPluginImage(Activator.PLUGIN_ID, Constants.ICONS.INFO)); formToolkit.paintBordersFor(scrldfrmStrategy); scrldfrmStrategy.setText(descriptor.getName()); scrldfrmStrategy.getBody().setLayout(new FillLayout(SWT.HORIZONTAL)); CTabFolder tabFolder = new CTabFolder(scrldfrmStrategy.getBody(), SWT.BORDER | SWT.BOTTOM); formToolkit.adapt(tabFolder); formToolkit.paintBordersFor(tabFolder); tabFolder.setSelectionBackground( Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT)); CTabItem tbtmDefinition = new CTabItem(tabFolder, SWT.NONE); tbtmDefinition.setText("Definition"); Composite definitionTab = new Composite(tabFolder, SWT.NONE); TableWrapLayout definitionTabLayout = new TableWrapLayout(); definitionTabLayout.numColumns = 2; definitionTab.setLayout(definitionTabLayout); tbtmDefinition.setControl(definitionTab); formToolkit.adapt(definitionTab); formToolkit.paintBordersFor(definitionTab); Label lblOwner = new Label(definitionTab, SWT.NONE); lblOwner.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1)); formToolkit.adapt(lblOwner, true, true); lblOwner.setText("Owner:"); lblOwnerout = new Label(definitionTab, SWT.NONE); lblOwnerout.setForeground(SWTResourceManager.getColor(SWT.COLOR_LINK_FOREGROUND)); lblOwnerout.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); TableWrapData twd_lblOwnerout = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); twd_lblOwnerout.grabHorizontal = true; lblOwnerout.setLayoutData(twd_lblOwnerout); formToolkit.adapt(lblOwnerout, true, true); lblOwnerout.setText(descriptor.getOwner()); Label lblVendor = new Label(definitionTab, SWT.NONE); lblVendor.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1)); formToolkit.adapt(lblVendor, true, true); lblVendor.setText("Vendor:"); lblVendorout = new Label(definitionTab, SWT.NONE); lblVendorout.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); formToolkit.adapt(lblVendorout, true, true); lblVendorout.setText(descriptor.getVendor()); Label lblVersion = new Label(definitionTab, SWT.NONE); lblVersion.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1)); formToolkit.adapt(lblVersion, true, true); lblVersion.setText("Version:"); versionOut = new Label(definitionTab, SWT.NONE); versionOut.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); formToolkit.adapt(versionOut, true, true); versionOut.setText(String.valueOf(descriptor.getVersion())); Label lblReleased = new Label(definitionTab, SWT.NONE); lblReleased.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1)); formToolkit.adapt(lblReleased, true, true); lblReleased.setText("Released:"); lblReleasedout = formToolkit.createLabel(definitionTab, "", SWT.NONE); lblReleasedout.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); lblReleasedout.setText(DUtils.DATE_FORMAT.format(descriptor.getReleased())); Label lblClassName = new Label(definitionTab, SWT.NONE); lblClassName.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1)); formToolkit.adapt(lblClassName, true, true); lblClassName.setText("Class name:"); lblClassnameout = formToolkit.createLabel(definitionTab, "classnameOut", SWT.NONE); lblClassnameout.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); lblClassnameout.setText(descriptor.getClassName()); Label lblDescription = new Label(definitionTab, SWT.NONE); lblDescription.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1)); formToolkit.adapt(lblDescription, true, true); lblDescription.setText("Description:"); lblDescriptionout = formToolkit.createLabel(definitionTab, "descriptionOut", SWT.WRAP); lblDescriptionout.setForeground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BORDER)); TableWrapData twd_lblDescriptionout = new TableWrapData(TableWrapData.FILL, TableWrapData.FILL_GRAB, 1, 1); twd_lblDescriptionout.heightHint = 139; lblDescriptionout.setLayoutData(twd_lblDescriptionout); lblDescriptionout.setText(descriptor.getDescription()); CTabItem tbtmParameters = new CTabItem(tabFolder, SWT.NONE); tbtmParameters.setText("Parameters"); Composite parametersTab = new Composite(tabFolder, SWT.NONE); tbtmParameters.setControl(parametersTab); formToolkit.adapt(parametersTab); formToolkit.paintBordersFor(parametersTab); parametersTab.setLayout(new FillLayout(SWT.HORIZONTAL)); TableViewer paramsTableViewer = new TableViewer(parametersTab, SWT.BORDER | SWT.FULL_SELECTION); paramsTableViewer.setContentProvider(ArrayContentProvider.getInstance()); paramsTable = paramsTableViewer.getTable(); paramsTable.setLinesVisible(true); paramsTable.setHeaderVisible(true); formToolkit.paintBordersFor(paramsTable); TableViewerColumn tableViewerColumn = new TableViewerColumn(paramsTableViewer, SWT.NONE); TableColumn tblclmnName = tableViewerColumn.getColumn(); tblclmnName.setWidth(62); tblclmnName.setText("Name"); tableViewerColumn.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { Param p = (Param) cell.getElement(); cell.setText(p.getName()); } }); TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(paramsTableViewer, SWT.NONE); TableColumn tblclmnType = tableViewerColumn_1.getColumn(); tblclmnType.setWidth(58); tblclmnType.setText("Type"); tableViewerColumn_1.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { Param p = (Param) cell.getElement(); cell.setText(p.getType()); } }); TableViewerColumn tableViewerColumn_2 = new TableViewerColumn(paramsTableViewer, SWT.NONE); TableColumn tblclmnDefault = tableViewerColumn_2.getColumn(); tblclmnDefault.setWidth(100); tblclmnDefault.setText("Default"); tableViewerColumn_2.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { Param p = (Param) cell.getElement(); cell.setText(String.valueOf(p.get_default())); } }); TableViewerColumn tableViewerColumn_3 = new TableViewerColumn(paramsTableViewer, SWT.NONE); TableColumn tblclmnDescription = tableViewerColumn_3.getColumn(); tblclmnDescription.setWidth(202); tblclmnDescription.setText("Description"); tableViewerColumn_3.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { Param p = (Param) cell.getElement(); cell.setText(p.getDescription()); } }); CTabItem tbtmPhases = new CTabItem(tabFolder, SWT.NONE); tbtmPhases.setText("Phases"); Composite phasesTab = new Composite(tabFolder, SWT.NONE); tbtmPhases.setControl(phasesTab); formToolkit.adapt(phasesTab); formToolkit.paintBordersFor(phasesTab); phasesTab.setLayout(new FillLayout(SWT.HORIZONTAL)); TableViewer phasesTableViewer = new TableViewer(phasesTab, SWT.BORDER | SWT.FULL_SELECTION); phasesTableViewer.setContentProvider(ArrayContentProvider.getInstance()); phasesTable = phasesTableViewer.getTable(); phasesTable.setLinesVisible(true); phasesTable.setHeaderVisible(true); formToolkit.paintBordersFor(phasesTable); TableViewerColumn tableViewerColumn_4 = new TableViewerColumn(phasesTableViewer, SWT.NONE); TableColumn tblclmnName_1 = tableViewerColumn_4.getColumn(); tblclmnName_1.setWidth(109); tblclmnName_1.setText("Name"); tableViewerColumn_4.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { PhaseDescriptor p = (PhaseDescriptor) cell.getElement(); cell.setText(p.getName()); } }); TableViewerColumn tableViewerColumn_5 = new TableViewerColumn(phasesTableViewer, SWT.NONE); TableColumn tblclmnClassName = tableViewerColumn_5.getColumn(); tblclmnClassName.setWidth(204); tblclmnClassName.setText("Class Name"); tableViewerColumn_5.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { PhaseDescriptor p = (PhaseDescriptor) cell.getElement(); cell.setText(p.getClassName()); } }); TableViewerColumn tableViewerColumn_6 = new TableViewerColumn(phasesTableViewer, SWT.NONE); TableColumn tblclmnDescription_1 = tableViewerColumn_6.getColumn(); tblclmnDescription_1.setWidth(298); tblclmnDescription_1.setText("Description"); tableViewerColumn_6.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { PhaseDescriptor p = (PhaseDescriptor) cell.getElement(); cell.setText(p.getDescription()); } }); CTabItem tbtmPermissions = new CTabItem(tabFolder, SWT.NONE); tbtmPermissions.setText("Permissions"); Composite permissionsTab = new Composite(tabFolder, SWT.NONE); tbtmPermissions.setControl(permissionsTab); formToolkit.adapt(permissionsTab); formToolkit.paintBordersFor(permissionsTab); permissionsTab.setLayout(new FillLayout(SWT.HORIZONTAL)); TreeViewer permissionsTreeViewer = new TreeViewer(permissionsTab, SWT.BORDER); //permissionsTreeViewer.setContentProvider(ArrayContentProvider.getInstance()); Tree permissionsTree = permissionsTreeViewer.getTree(); permissionsTree.setLinesVisible(true); permissionsTree.setHeaderVisible(true); formToolkit.paintBordersFor(permissionsTree); TreeViewerColumn treeViewerColumn = new TreeViewerColumn(permissionsTreeViewer, SWT.NONE); TreeColumn trclmnPhase = treeViewerColumn.getColumn(); trclmnPhase.setWidth(100); trclmnPhase.setText("Phase"); treeViewerColumn.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { Phase p = (Phase) cell.getElement(); cell.setText(p.getName()); } }); TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(permissionsTreeViewer, SWT.NONE); TreeColumn trclmnPermission = treeViewerColumn_1.getColumn(); trclmnPermission.setWidth(185); trclmnPermission.setText("Permission"); TreeViewerColumn treeViewerColumn_2 = new TreeViewerColumn(permissionsTreeViewer, SWT.NONE); TreeColumn trclmnValue = treeViewerColumn_2.getColumn(); trclmnValue.setWidth(310); trclmnValue.setText("Value"); CTabItem tbtmDependencies = new CTabItem(tabFolder, SWT.NONE); tbtmDependencies.setText("Dependencies"); Composite dependenciesTab = new Composite(tabFolder, SWT.NONE); TableWrapLayout dependenciesTabLayout = new TableWrapLayout(); dependenciesTabLayout.numColumns = 2; dependenciesTab.setLayout(dependenciesTabLayout); tbtmDependencies.setControl(dependenciesTab); formToolkit.adapt(dependenciesTab); formToolkit.paintBordersFor(dependenciesTab); paramsTableViewer.setInput(descriptor.getSettings().getParams()); phasesTableViewer.setInput(descriptor.getPhases()); return container; }
From source file:org.ebayopensource.turmeric.eclipse.services.search.SOASearchResultPage.java
License:Open Source License
@Override protected void configureTableViewer(final TableViewer viewer) { viewer.setLabelProvider(new SOASearchTableLabelProvider()); fContentProvider = new SOASearchTableContentProvider(); viewer.setContentProvider(fContentProvider); final Table table = viewer.getTable(); table.setHeaderVisible(true);//w w w . j a v a2 s .c om table.setLinesVisible(true); //set the columns for the table and the sorter used for he table { final TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(35, 150, true)); layout.addColumnData(new ColumnWeightData(15, 100, true)); layout.addColumnData(new ColumnWeightData(15, 120, true)); table.setLayout(layout); viewer.setSorter(new SOASearchResultTableViewerSorter()); TableColumn svcNameColumn = new TableColumn(table, SWT.LEFT); svcNameColumn.setText("Service Name"); svcNameColumn.addSelectionListener(new TableSortSelectionAdatper(viewer, svcNameColumn, 0)); TableColumn svcLayerColumn = new TableColumn(table, SWT.LEFT); svcLayerColumn.setText("Service Layer"); svcLayerColumn.addSelectionListener(new TableSortSelectionAdatper(viewer, svcLayerColumn, 1)); TableColumn svcVersionColumn = new TableColumn(table, SWT.LEFT); svcVersionColumn.setText("Service Version"); svcVersionColumn.addSelectionListener(new TableSortSelectionAdatper(viewer, svcVersionColumn, 2)); } //add the viewer as the selection provider getSite().setSelectionProvider(viewer); }
From source file:org.eclipse.ajdt.internal.ui.refactoring.pullout.PullOutRefactoringInputPage.java
License:Open Source License
private TableLayoutComposite createTable(Composite parent) { GridData gridData;//from ww w. ja v a 2 s. c om initializeDialogUnits(parent); TableLayoutComposite layoutComposite = new TableLayoutComposite(parent, SWT.FILL); layoutComposite.addColumnData(new ColumnWeightData(20, convertWidthInCharsToPixels(20), true)); layoutComposite.addColumnData(new ColumnWeightData(20, convertWidthInCharsToPixels(20), true)); layoutComposite.addColumnData(new ColumnWeightData(40, convertWidthInCharsToPixels(40), true)); // use this instead if we want to implement check boxes // final CheckboxTableViewer tv = CheckboxTableViewer.newCheckList(layoutComposite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); final TableViewer tv = new TableViewer(layoutComposite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); tv.setContentProvider(new FieldContentProvider()); createColumns(tv); Table table = tv.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); gridData = new GridData(SWT.FILL, SWT.FILL, true, true); table.setLayoutData(gridData); tv.setInput(getRefactoring()); final Object[] fields = getRefactoring().getMembers(); // only if using checkbox viewer // for (int i= 0; i < fields.length; i++) { // IAspectJElement field= (IAspectJElement) fields[i]; // tv.setChecked(field, true); // } tv.refresh(true); gridData = new GridData(GridData.FILL_BOTH); gridData.widthHint = convertWidthInCharsToPixels(100); gridData.heightHint = SWTUtil.getTableHeightHint(table, Math.max(fields.length + 1, 2)); layoutComposite.setLayoutData(gridData); // sortListener = new SortListener(tv); // iconColumn.getColumn().addListener(SWT.Selection, sortListener); // aspectColumn.getColumn().addListener(SWT.Selection, sortListener); // targetColumn.getColumn().addListener(SWT.Selection, sortListener); // itdColumn.getColumn().addListener(SWT.Selection, sortListener); return layoutComposite; }
From source file:org.eclipse.ant.internal.ui.preferences.AntPropertiesBlock.java
License:Open Source License
/** * Creates and returns a configured table viewer in the given parent *//*from ww w . j ava 2 s . c om*/ private TableViewer createTableViewer(Composite parent, boolean setColumns, boolean defaultsorting, int sortcolumnidx, int sortdirection) { Table table = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER); GridData data = new GridData(GridData.FILL_BOTH); int availableRows = availableRows(parent); if (setColumns) { data.heightHint = table.getItemHeight() * (availableRows / 10); } data.widthHint = 425; table.setLayoutData(data); table.setFont(parent.getFont()); TableViewer tableViewer = new TableViewer(table); tableViewer.setContentProvider(new AntContentProvider(defaultsorting)); tableViewer.setLabelProvider(labelProvider); tableViewer.addSelectionChangedListener(tableListener); if (setColumns) { TableLayout tableLayout = new TableLayout(); table.setLayout(tableLayout); table.setHeaderVisible(true); table.setLinesVisible(true); ColumnSorter sorter = null; for (int i = 0; i < fTableColumnHeaders.length; i++) { tableLayout.addColumnData(fTableColumnLayouts[i]); TableColumn column = new TableColumn(table, SWT.NONE, i); column.setResizable(fTableColumnLayouts[i].resizable); column.setText(fTableColumnHeaders[i]); sorter = new ColumnSorter(tableViewer, column) { @Override public String getCompareText(Object obj, int columnindex) { return AntPropertiesBlock.this.labelProvider.getColumnText(obj, columnindex); } }; if (i == sortcolumnidx) { sorter.setDirection(sortdirection); } } } return tableViewer; }
From source file:org.eclipse.b3.aggregator.presentation.FixVersionsDialog.java
License:Open Source License
@Override public Control createDialogArea(Composite parent) { setTitle(B3Messages.FixVersionDialog_Title); setMessage(B3Messages.FixVersionDialog_UpdateMessage); Composite res = new Composite(parent, SWT.NONE); res.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); res.setLayout(new GridLayout(1, false)); Label summaryLabel = new Label(res, SWT.NONE); summaryLabel.setText(this.suggestedVersions.size() + " versions to update."); final TableViewer viewer = new TableViewer(res); viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); viewer.getTable().setHeaderVisible(true); viewer.getTable().setLinesVisible(true); TableViewerColumn nameColumn = new TableViewerColumn(viewer, SWT.DEFAULT); nameColumn.getColumn().setText("Feature"); nameColumn.getColumn().setResizable(true); nameColumn.getColumn().setWidth(200); nameColumn.setLabelProvider(new ColumnLabelProvider() { @Override/*from w w w. j a v a2s . c o m*/ public String getText(Object o) { return ((InstallableUnitRequest) o).getName(); } }); TableViewerColumn previousVersion = new TableViewerColumn(viewer, SWT.DEFAULT); previousVersion.getColumn().setResizable(true); previousVersion.getColumn().setWidth(200); previousVersion.getColumn().setText("Current Version"); previousVersion.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object o) { VersionRange range = ((InstallableUnitRequest) o).getVersionRange(); if (range != null) { return range.toString(); } return ""; //$NON-NLS-1$ } }); TableViewerColumn suggestedVersion = new TableViewerColumn(viewer, SWT.DEFAULT); suggestedVersion.getColumn().setText("Suggested Version"); suggestedVersion.getColumn().setResizable(true); suggestedVersion.getColumn().setWidth(200); suggestedVersion.setLabelProvider(new ColumnLabelProvider() { @Override public Color getForeground(Object o) { InstallableUnitRequest feature = (InstallableUnitRequest) o; VersionRange range = feature.getVersionRange(); if (range != null) { if (!range.isIncluded(suggestedVersions.get(feature))) { return viewer.getControl().getDisplay().getSystemColor(SWT.COLOR_RED); } } return viewer.getControl().getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN); } @Override public String getText(Object o) { InstallableUnitRequest feature = (InstallableUnitRequest) o; return suggestedVersions.get(feature).toString(); } }); suggestedVersion.setEditingSupport(new EditingSupport(viewer) { @Override protected boolean canEdit(Object element) { return ((InstallableUnitRequest) element).getAvailableVersions().size() > 1; } @Override protected CellEditor getCellEditor(Object element) { InstallableUnitRequest feature = (InstallableUnitRequest) element; ComboBoxViewerCellEditor comboCellEditor = new ComboBoxViewerCellEditor(viewer.getTable()); comboCellEditor.setContentProvider(new ArrayContentProvider()); List<Version> content = new ArrayList<Version>(); for (AvailableVersion version : feature.getAvailableVersions()) { content.add(version.getVersion()); } comboCellEditor.setInput(content); return comboCellEditor; } @Override protected Version getValue(Object element) { InstallableUnitRequest feature = (InstallableUnitRequest) element; return suggestedVersions.get(feature); } @Override protected void setValue(Object element, Object value) { suggestedVersions.put((InstallableUnitRequest) element, (Version) value); viewer.refresh(element); } }); viewer.setContentProvider(new ArrayContentProvider()); viewer.setInput(this.suggestedVersions.keySet()); return res; }
From source file:org.eclipse.babel.build.ui.wizard.FilteredListComponent.java
License:Open Source License
private TableViewer createTableViewer(Composite container, IContentProvider provider, Object[] input) { GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 200;/*from w ww .j ava 2s . c o m*/ gd.widthHint = 225; Table table = new Table(container, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); table.setLayoutData(gd); TableViewer viewer = new TableViewer(table); viewer.setLabelProvider(fLabelProvider); viewer.setContentProvider(provider); viewer.setInput(input); viewer.setComparator(new ViewerComparator()); return viewer; }