Java Code Examples for org.eclipse.jface.viewers.TableViewer#setLabelProvider()
The following examples show how to use
org.eclipse.jface.viewers.TableViewer#setLabelProvider() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Tables.java From olca-app with Mozilla Public License 2.0 | 6 votes |
/** * Creates a default table viewer with the given properties. The properties are * also used to create columns where each column label is the respective * property of this column. The viewer is configured in the following way: * <ul> * <li>content provider = {@link ArrayContentProvider} * <li>lines and header are visible * <li>grid data with horizontal and vertical fill * */ public static TableViewer createViewer(Composite parent, String[] properties, IBaseLabelProvider labelProvider) { TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.MULTI); viewer.setContentProvider(new ArrayContentProvider()); boolean hasColumns = properties != null && properties.length > 0; Table table = viewer.getTable(); table.setLinesVisible(hasColumns); table.setHeaderVisible(hasColumns); if (hasColumns) { createColumns(viewer, properties, labelProvider); } if (labelProvider != null) { viewer.setLabelProvider(labelProvider); } GridData data = UI.gridData(table, true, true); data.minimumHeight = 120; // workaround for this bug: // https://bugs.eclipse.org/bugs/show_bug.cgi?id=215997 Point p = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT); data.heightHint = p.y < 120 ? 120 : p.y; return viewer; }
Example 2
Source File: ContractPropertySectionTest.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Test public void should_bindAddChildButtonEnablement_convert_boolean_value() throws Exception { section.init(new WritableValue(aContract().build(), Contract.class)); final Button button = new Button(parent, SWT.PUSH); final TableViewer inputsTableViewer = new TableViewer(parent); inputsTableViewer.setLabelProvider(new LabelProvider()); inputsTableViewer.setContentProvider(ArrayContentProvider.getInstance()); final ContractInput textParentInput = ProcessFactory.eINSTANCE.createContractInput(); textParentInput.setType(ContractInputType.TEXT); final ContractInput complexParentInput = ProcessFactory.eINSTANCE.createContractInput(); complexParentInput.setType(ContractInputType.COMPLEX); inputsTableViewer.setInput(Arrays.asList(textParentInput, complexParentInput)); section.bindAddChildButtonEnablement(button, inputsTableViewer); assertThat(button.isEnabled()).isFalse(); assertThat(inputsTableViewer.getSelection().isEmpty()).isTrue(); inputsTableViewer.setSelection(new StructuredSelection(textParentInput)); assertThat(button.isEnabled()).isFalse(); assertThat(inputsTableViewer.getSelection().isEmpty()).isFalse(); inputsTableViewer.setSelection(new StructuredSelection(complexParentInput)); assertThat(button.isEnabled()).isTrue(); }
Example 3
Source File: CListTable.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private void createTable(Composite parent) { tableViewer = new TableViewer(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); tableViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); tableViewer.setContentProvider(ArrayContentProvider.getInstance()); tableViewer.setLabelProvider(new LabelProvider()); tableViewer.setComparator(new ViewerComparator()); tableViewer.setInput(items); tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateStates(); } }); updateStates(); }
Example 4
Source File: NLSSearchResultPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void configureTableViewer(TableViewer viewer) { viewer.setComparator(new ViewerComparator() { @Override public int category(Object element) { if (element instanceof FileEntry) { return 0; } else { return 1; } } }); viewer.setLabelProvider(new ColoringLabelProvider(new NLSSearchResultLabelProvider2(this))); fContentProvider= new TextSearchTableContentProvider(); viewer.setContentProvider(fContentProvider); }
Example 5
Source File: SvnRevPropertiesView.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private TableViewer createTable(Composite parent) { Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI); table.setHeaderVisible(true); table.setLinesVisible(true); GridData gridData = new GridData(GridData.FILL_BOTH); table.setLayoutData(gridData); TableLayout layout = new TableLayout(); table.setLayout(layout); tableViewer = new TableViewer(table); createColumns(table, layout); tableViewer.setContentProvider(new ArrayContentProvider()); tableViewer.setLabelProvider(new PropertiesLabelProvider()); return tableViewer; }
Example 6
Source File: ReportItemParametersDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Creates the TableViewer and set all kinds of processors. */ private void createTableViewer( ) { tableViewer = new TableViewer( table ); tableViewer.setUseHashlookup( true ); tableViewer.setColumnProperties( columnNames ); expressionCellEditor = new ExpressionDialogCellEditor( table ); tableViewer.setCellEditors( new CellEditor[]{ null, null, expressionCellEditor } ); tableViewer.setContentProvider( new BindingContentProvider( ) ); tableViewer.setLabelProvider( new BindingLabelProvider( ) ); tableViewer.setCellModifier( new BindingCellModifier( ) ); }
Example 7
Source File: JavaSearchResultPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void configureTableViewer(TableViewer viewer) { viewer.setUseHashlookup(true); fSortingLabelProvider= new SortingLabelProvider(this); viewer.setLabelProvider(new DecoratingJavaLabelProvider(fSortingLabelProvider, false)); fContentProvider=new JavaSearchTableContentProvider(this); viewer.setContentProvider(fContentProvider); viewer.setComparator(new DecoratorIgnoringViewerSorter(fSortingLabelProvider)); setSortOrder(fCurrentSortOrder); addDragAdapters(viewer); }
Example 8
Source File: ParameterPropertySection.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void createParameterComposite(final Composite parent) { final Composite parameterComposite = getWidgetFactory().createComposite(parent); parameterComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); parameterComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create()); final Composite buttonsComposite = getWidgetFactory().createComposite(parameterComposite, SWT.NONE); buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 3).create()); buttonsComposite.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).create()); createAddParameterButton(buttonsComposite); updateButton = createUpdateParameterButton(buttonsComposite); createRemoveParameterButton(buttonsComposite); parameterTableViewer = new TableViewer(widgetFactory.createTable(parameterComposite, GTKStyleHandler.removeBorderFlag(SWT.BORDER | SWT.MULTI | SWT.NO_FOCUS | SWT.H_SCROLL | SWT.V_SCROLL))); parameterTableViewer.getTable().setLayout(GridLayoutFactory.fillDefaults().create()); getWidgetFactory().adapt(parameterTableViewer.getTable(), false, false); parameterTableViewer.getTable() .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 100).create()); parameterTableViewer.setSorter(new ViewerSorter()); parameterTableViewer.addDoubleClickListener(this); parameterTableViewer.addSelectionChangedListener(this); parameterTableViewer.getTable().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { e.doit = false; remove(); } } }); parameterTableViewer.setContentProvider(new ArrayContentProvider()); parameterTableViewer.setLabelProvider(new ParameterStyledLabelProvider()); ColumnViewerToolTipSupport.enableFor(parameterTableViewer, ToolTip.RECREATE); }
Example 9
Source File: EdgeDisplayTableControl.java From depan with Apache License 2.0 | 5 votes |
public EdgeDisplayTableControl(Composite parent) { super(parent, SWT.NONE); setLayout(Widgets.buildContainerLayout(1)); propViewer = new TableViewer(this, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); // Layout embedded table Table propTable = propViewer.getTable(); propTable.setLayoutData(Widgets.buildGrabFillData()); // initialize the table propTable.setHeaderVisible(true); propTable.setToolTipText("Edge Display Properties"); EditColTableDef.setupTable(TABLE_DEF, propTable); // Configure cell editing CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length]; cellEditors[INDEX_NAME] = null; cellEditors[INDEX_HEAD] = null; cellEditors[INDEX_TAIL] = null; cellEditors[INDEX_COLOR] = new ColorCellEditor(propTable); cellEditors[INDEX_STYLE] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.LineStyle.values(), true)); cellEditors[INDEX_ARROWHEAD] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.ArrowheadStyle.values(), true)); propViewer.setCellEditors(cellEditors); propViewer.setLabelProvider(new EdgeDisplayLabelProvider()); propViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF)); propViewer.setCellModifier(new EdgeDisplayCellModifier()); propViewer.setContentProvider(ArrayContentProvider.getInstance()); configSorters(propTable); }
Example 10
Source File: RelationSetTableControl.java From depan with Apache License 2.0 | 5 votes |
public RelationSetTableControl(Composite parent) { super(parent, SWT.NONE); setLayout(Widgets.buildContainerLayout(1)); // Layout embedded table relSetViewer = new TableViewer(this, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); // Set up layout properties Table relSetTable = relSetViewer.getTable(); relSetTable.setLayoutData(Widgets.buildGrabFillData()); // initialize the table relSetTable.setHeaderVisible(true); relSetTable.setToolTipText("List of Relations"); EditColTableDef.setupTable(TABLE_DEF, relSetTable); // Configure cell editing CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length]; cellEditors[INDEX_NAME] = null; cellEditors[INDEX_SOURCE] = null; cellEditors[INDEX_VISIBLE] = new CheckboxCellEditor(relSetTable); // Configure table properties. relSetViewer.setCellEditors(cellEditors); relSetViewer.setLabelProvider(new ControlLabelProvider()); relSetViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF)); relSetViewer.setCellModifier(new ControlCellModifier()); relSetViewer.setContentProvider(ArrayContentProvider.getInstance()); configSorters(relSetTable); }
Example 11
Source File: TexTableView.java From texlipse with Eclipse Public License 1.0 | 4 votes |
/** * This is a callback that will allow us * to create the viewer and initialize it. */ public void createPartControl(Composite parent) { // Create a composite to hold the children GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_BOTH); parent.setLayoutData(gridData); //only one component... GridLayout layout = new GridLayout(1, false); layout.marginWidth = 4; parent.setLayout(layout); Table table = createTable(parent); viewer = new TableViewer(table); viewer.setUseHashlookup(true); viewer.setColumnProperties(columnNames); viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); viewer.setInput(rowList); CellEditor[] editors = new CellEditor[TexRow.COLUMNS]; //ICellEditorListeners for (int i = 0; i < TexRow.COLUMNS; i++) { editors[i] = new TextCellEditor(table); ((Text) editors[i].getControl()).setTextLimit(256); editors[i].getControl().addKeyListener( new TexCellListener(viewer, rowList, i)); } // Assign the cell editors to the viewer viewer.setCellEditors(editors); // Set the cell modifier for the viewer viewer.setCellModifier(new TexCellModifier(viewer, rowList)); // Set the default sorter for the viewer //viewer.setSorter(new LaTeXRowSorter(LaTeXRowSorter.COLUMN_1)); }
Example 12
Source File: CodesSystemsComposite.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
public void createContens(){ Label lblCodeSystem = new Label(this, SWT.NONE); lblCodeSystem.setText("Code System:"); Label lblCodeSystemText = new Label(this, SWT.NONE); lblCodeSystemText.setText(CodingSystem.ELEXIS_LOCAL_CODESYSTEM.getSystem()); Button btnAdd = new Button(this, SWT.PUSH); btnAdd.setImage(Images.IMG_NEW.getImage()); btnAdd.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false, 2, 1)); btnAdd.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e){ CodeCreateDialog codeDialog = new CodeCreateDialog(getShell()); if (codeDialog.open() == MessageDialog.OK) { loadTable(); } } }); tableViewer = new TableViewer(this, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); tableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); tableViewer.setContentProvider(new ArrayContentProvider()); tableViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element){ ILocalCoding iCoding = (ILocalCoding) element; StringBuilder stringBuilder = new StringBuilder(); for (ICoding mappedCoding : iCoding.getMappedCodes()) { if (stringBuilder.length() > 0) { stringBuilder.append(", "); } stringBuilder.append(mappedCoding.getSystem()); stringBuilder.append(": "); stringBuilder.append(mappedCoding.getCode()); } return iCoding != null ? iCoding.getDisplay() + " (" + iCoding.getCode() + ")" + (stringBuilder.length() > 0 ? (" [" + stringBuilder.toString() + "]") : "") : ""; } }); tableViewer.getTable().setLinesVisible(false); loadTable(); createContextMenu(tableViewer); }
Example 13
Source File: CodeElementStatisticsComposite.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
private void createContent(){ setLayout(new GridLayout(1, false)); title = new Label(this, SWT.NONE); title.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); viewer = new TableViewer(this, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); viewer.setContentProvider(ArrayContentProvider.getInstance()); viewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element){ if (element instanceof PersistentObject) { return ((PersistentObject) element).getLabel(); } else if (element instanceof Identifiable) { return ((Identifiable) element).getLabel(); } return super.getText(element); } }); MenuManager menu = new MenuManager(); menu.setRemoveAllWhenShown(true); menu.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager){ manager.add(new ClearStatisticAction()); } }); viewer.getControl().setMenu(menu.createContextMenu(viewer.getControl())); viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event){ IStructuredSelection selection = viewer.getStructuredSelection(); if (selection != null && !selection.isEmpty()) { ICodeSelectorTarget target = CodeSelectorHandler.getInstance().getCodeSelectorTarget(); if (target != null) { for (Object selected : selection.toList()) { target.codeSelected(selected); } } } } }); new GenericObjectDragSource(viewer); }
Example 14
Source File: UpdateTMWizardPage.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
public void createContent(Composite parent) { TableViewer tableViewer = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); final Table table = tableViewer.getTable(); GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH); tableData.heightHint = 160; table.setLayoutData(tableData); table.setLinesVisible(true); table.setHeaderVisible(true); TableColumn columnNumber = new TableColumn(table, SWT.LEFT); columnNumber.setText(Messages.getString("wizard.UpdateTMWizardPage.columnNumber")); columnNumber.setWidth(50); TableColumn columnPath = new TableColumn(table, SWT.LEFT); columnPath.setText(Messages.getString("wizard.UpdateTMWizardPage.columnPath")); columnPath.setWidth(400); tableViewer.setLabelProvider(new TableViewerLabelProvider()); tableViewer.setContentProvider(new ArrayContentProvider()); tableViewer.setInput(getTableInfo()); Group groupStatus = new Group(parent, SWT.None); groupStatus.setLayout(new GridLayout()); groupStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); groupStatus.setText(Messages.getString("dialog.UpdateTMDialog.lbl")); btnDraft = new Button(groupStatus, SWT.CHECK); btnDraft.setText(Messages.getString("dialog.UpdateTMDialog.btnDraft")); btnTranslated = new Button(groupStatus, SWT.CHECK); btnTranslated.setText(Messages.getString("dialog.UpdateTMDialog.btnTranslated")); btnTranslated.setSelection(true); btnApproved = new Button(groupStatus, SWT.CHECK); btnApproved.setText(Messages.getString("dialog.UpdateTMDialog.btnApproved")); btnApproved.setSelection(true); btnSignedOff = new Button(groupStatus, SWT.CHECK); btnSignedOff.setText(Messages.getString("dialog.UpdateTMDialog.btnSignedOff")); btnSignedOff.setSelection(true); btnLocked = new Button(groupStatus, SWT.CHECK); btnLocked.setText(Messages.getString("dialog.UpdateTMWizardPage.btnLocked")); }
Example 15
Source File: DBConnectorsPreferencePage.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
private void createDBConnectorsList(Composite parent) { final Composite connectorListComposite = new Composite(parent, SWT.NONE); connectorListComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create()); connectorListComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); final Text searchField = new Text(connectorListComposite, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); searchField.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); searchField.setMessage(Messages.search); viewer = new TableViewer(connectorListComposite, SWT.BORDER | SWT.FULL_SELECTION); viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(false, true).hint(200, SWT.DEFAULT).create()); viewer.setLabelProvider(new DabaBaseConnectorDefinitionLabelProvider()); viewer.setContentProvider(new DatabaseConnectorDefinitionContentProvider()); viewer.setInput(getCategory()); connectorFilter = new DbConnectorsPreferenceFilter(); viewer.addFilter(connectorFilter); searchField.addKeyListener(new KeyAdapter() { /* * (non-Javadoc) * @see org.eclipse.swt.events.KeyAdapter#keyReleased(org.eclipse.swt.events.KeyEvent) */ @Override public void keyReleased(KeyEvent e) { connectorFilter.setSearchText(searchField.getText()); viewer.refresh(); } }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { final ConnectorDefinition def = getSelectedConnector(); if (def != null) { final String defId = def.getId(); automaticallyAddDriver.setSelection(getAutoAddDriverProperty(defId)); driversLabelProvider.setDefaultDriver(getDefaultDriver(defId)); driverManagerViewer.setInput(defId); } } }); }
Example 16
Source File: CheckConfigurationWorkingSetEditor.java From eclipse-cs with GNU Lesser General Public License v2.1 | 4 votes |
/** * Creates the content regarding the management of check configurations. * * @param parent * the parent composite * @return the configuration area */ private Composite createCheckConfigContents(Composite parent) { Composite configComposite = new Composite(parent, SWT.NULL); configComposite.setLayout(new FormLayout()); final Control rightButtons = createButtonBar(configComposite); FormData fd = new FormData(); fd.top = new FormAttachment(0); fd.right = new FormAttachment(100); fd.bottom = new FormAttachment(100); rightButtons.setLayoutData(fd); Composite tableAndDesc = new Composite(configComposite, SWT.NULL); tableAndDesc.setLayout(new FormLayout()); fd = new FormData(); fd.left = new FormAttachment(0); fd.top = new FormAttachment(0); fd.right = new FormAttachment(rightButtons, -3, SWT.LEFT); fd.bottom = new FormAttachment(100, 0); tableAndDesc.setLayoutData(fd); final Control table = createConfigTable(tableAndDesc); fd = new FormData(); fd.left = new FormAttachment(0); fd.top = new FormAttachment(0); fd.right = new FormAttachment(100); fd.bottom = new FormAttachment(70); table.setLayoutData(fd); Composite descArea = new Composite(tableAndDesc, SWT.NULL); descArea.setLayout(new FormLayout()); fd = new FormData(); fd.left = new FormAttachment(0); fd.top = new FormAttachment(table, 0); fd.right = new FormAttachment(mIsShowUsage ? 60 : 100); fd.bottom = new FormAttachment(100); descArea.setLayoutData(fd); Label lblDescription = new Label(descArea, SWT.NULL); lblDescription.setText(Messages.CheckstylePreferencePage_lblDescription); fd = new FormData(); fd.left = new FormAttachment(0); fd.top = new FormAttachment(3); fd.right = new FormAttachment(100); lblDescription.setLayoutData(fd); mConfigurationDescription = new Text(descArea, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.VERTICAL); fd = new FormData(); fd.left = new FormAttachment(0); fd.top = new FormAttachment(lblDescription); fd.right = new FormAttachment(100); fd.bottom = new FormAttachment(100); mConfigurationDescription.setLayoutData(fd); if (mIsShowUsage) { Composite usageArea = new Composite(tableAndDesc, SWT.NULL); usageArea.setLayout(new FormLayout()); fd = new FormData(); fd.left = new FormAttachment(60, 0); fd.top = new FormAttachment(table, 3); fd.right = new FormAttachment(100); fd.bottom = new FormAttachment(100); usageArea.setLayoutData(fd); Label lblUsage = new Label(usageArea, SWT.NULL); lblUsage.setText(Messages.CheckstylePreferencePage_lblProjectUsage); fd = new FormData(); fd.left = new FormAttachment(0); fd.top = new FormAttachment(0); fd.right = new FormAttachment(100); lblUsage.setLayoutData(fd); mUsageView = new TableViewer(usageArea); mUsageView.getControl().setBackground(usageArea.getBackground()); mUsageView.setContentProvider(new ArrayContentProvider()); mUsageView.setLabelProvider(new WorkbenchLabelProvider()); fd = new FormData(); fd.left = new FormAttachment(0); fd.top = new FormAttachment(lblUsage); fd.right = new FormAttachment(100); fd.bottom = new FormAttachment(100); mUsageView.getControl().setLayoutData(fd); } // enforce update of button enabled state mController.selectionChanged(new SelectionChangedEvent(mViewer, new StructuredSelection())); return configComposite; }
Example 17
Source File: LockRepeatedSegmentResultDialog.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * Create contents of the dialog. * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); container.setLayout(new GridLayout(1, false)); Composite composite = new Composite(container, SWT.NONE); GridLayout gl_composite = new GridLayout(1, false); gl_composite.verticalSpacing = 0; gl_composite.marginWidth = 0; gl_composite.marginHeight = 0; composite.setLayout(gl_composite); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL); Table table = tableViewer.getTable(); GridData tableGd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); tableGd.heightHint = 220; table.setLayoutData(tableGd); table.setLinesVisible(true); table.setHeaderVisible(true); String[] clmnTitles = new String[] { Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles1"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles2"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles3"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles4"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles5"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles6") }; int[] clmnBounds = { 60, 200, 100, 110, 110, 110 }; for (int i = 0; i < clmnTitles.length; i++) { createTableViewerColumn(tableViewer, clmnTitles[i], clmnBounds[i], i); } tableViewer.setLabelProvider(new TableViewerLabelProvider()); tableViewer.setContentProvider(new ArrayContentProvider()); tableViewer.setInput(this.getTableViewerInput()); return container; }
Example 18
Source File: NewProjectWizardLanguagePage.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * 创建组件 * @param comp * ; */ public void createControl(Composite comp) { Composite canSelectComp = new Composite(comp, SWT.NONE); canSelectComp.setLayout(new GridLayout(1, false)); canSelectComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); canSelectTableViewer = new TableViewer(canSelectComp, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gridData.widthHint = 100; gridData.heightHint = 200; canSelectTableViewer.getTable().setLayoutData(gridData); canSelectTableViewer.setLabelProvider(new LanguageLabelProvider()); canSelectTableViewer.setContentProvider(new ArrayContentProvider()); canSelectTableViewer.setInput(canSelectInput); canSelectTableViewer.getTable().addListener(SWT.MouseDoubleClick, this); Composite selBtnComp = new Composite(comp, SWT.NONE); selBtnComp.setLayout(new GridLayout(1, false)); selBtnComp.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1)); addBtn = new Button(selBtnComp, SWT.NONE); addBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); addBtn.setText(Messages.getString("wizard.NewProjectWizardLanguagePage.addBtn")); addBtn.addListener(SWT.Selection, this); deleteBtn = new Button(selBtnComp, SWT.NONE); deleteBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); deleteBtn.setText(Messages.getString("wizard.NewProjectWizardLanguagePage.deleteBtn")); deleteBtn.addListener(SWT.Selection, this); deleteAllBtn = new Button(selBtnComp, SWT.NONE); deleteAllBtn.setText(Messages.getString("wizard.NewProjectWizardLanguagePage.deleteAllBtn")); deleteAllBtn.addListener(SWT.Selection, this); Composite hasSelComp = new Composite(comp, SWT.NONE); hasSelComp.setLayout(new GridLayout(1, false)); hasSelComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); hasSelTableViewer = new TableViewer(hasSelComp, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); hasSelTableViewer.getTable().setLayoutData(gridData); hasSelTableViewer.setLabelProvider(new LanguageLabelProvider()); hasSelTableViewer.setContentProvider(new ArrayContentProvider()); hasSelTableViewer.getTable().addListener(SWT.MouseDoubleClick, this); // initialization remember target language String strTargetLang = ps.getString(IPreferenceConstants.NEW_PROJECT_TGT_LANG); if (strTargetLang != null && !strTargetLang.equals("")) { String[] langCodes = strTargetLang.split(","); List<Language> targetLangList = new ArrayList<Language>(); for (String code : langCodes) { for (Language lang : languages) { if (code.equals(lang.getCode())) { targetLangList.add(lang); break; } } } execSelected(new StructuredSelection(targetLangList)); fireChangeEvent(); } }
Example 19
Source File: SdkEnvironmentControl.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
/** * Create the composite. * @param parent * @param style * @param editedSdk */ public SdkEnvironmentControl(Composite parent, int style, final Sdk editedSdk) { super(parent, style); this.editedSdk = editedSdk; selectedVar = null; setLayoutData(new GridData(GridData.FILL_BOTH)); setLayout(SwtUtils.removeMargins(new GridLayout(2, false))); Composite tableComposite = new Composite(this, SWT.NONE); tableComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); tableComposite.setLayout(new GridLayout(1, false)); tableComposite.setBackground(new Color(Display.getDefault(), 255,0,0)); tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); TableColumnLayout tableColumnLayout = new TableColumnLayout(); tableComposite.setLayout(tableColumnLayout); tableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION); table = tableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); columnName = new TableViewerColumn(tableViewer, SWT.NONE); tblclmnName = columnName.getColumn(); tableColumnLayout.setColumnData(tblclmnName, new ColumnPixelData(150, true, true)); tblclmnName.setText(Messages.SdkEnvironmentControl_Variable); columnLocation = new TableViewerColumn(tableViewer, SWT.NONE); tblclmnLocation = columnLocation.getColumn(); tableColumnLayout.setColumnData(tblclmnLocation, new ColumnPixelData(150, true, true)); tblclmnLocation.setText(Messages.SdkEnvironmentControl_Value); tableViewer.setContentProvider(new SdkEnvContentProvider()); tableViewer.setLabelProvider(new SdkEnvLabelProvider()); tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { TableItem[] selectedItems = table.getSelection(); boolean isEnabled = selectedItems.length > 0; btnEdit.setEnabled(isEnabled); btnDelete.setEnabled(isEnabled); selectedVar = isEnabled ? (String)selectedItems[0].getData() : null; } }); Composite buttonsComposite = new Composite(this, SWT.NONE); buttonsComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); buttonsComposite.setLayout(SwtUtils.removeMargins(new GridLayout(1, false))); btnNew = SWTFactory.createPushButton(buttonsComposite, Messages.SdkEnvironmentControl_New, null); btnNew.addSelectionListener(new AddVarButtonHandler()); btnEdit = SWTFactory.createPushButton(buttonsComposite, Messages.SdkEnvironmentControl_Edit, null); btnEdit.addSelectionListener(new EditValueButtonHandler()); btnEdit.setEnabled(false); btnDelete = SWTFactory.createPushButton(buttonsComposite, Messages.SdkEnvironmentControl_Delete, null); btnDelete.setEnabled(false); btnDelete.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (selectedVar != null) { editedSdk.removeEnvironmentVariable(selectedVar); tableViewer.setInput(editedSdk); } } }); tableViewer.setInput(editedSdk); }
Example 20
Source File: ImportFileWizardPage.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected Composite doCreateControls(Composite parent, DataBindingContext dbc) { final Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).margins(0, 0).extendedMargins(10, 10, 10, 0).create()); final Group transfoGroup = new Group(mainComposite, SWT.NONE); transfoGroup.setText(Messages.fileFormat); transfoGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 1).create()); transfoGroup.setLayout(new GridLayout(2, true)); final TableViewer importList = new TableViewer(transfoGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION); importList.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); importList.setContentProvider(ArrayContentProvider.getInstance()); importList.setComparator(new ImporterPriorityDisplayComparator()); importList.setLabelProvider(new LabelProvider() { @Override public String getText(Object item) { return ((ImporterFactory) item).getName(); } }); final List<ImporterFactory> allAvailableImports = ImporterRegistry.getInstance().getAllAvailableImports(); importList.setInput(allAvailableImports); final IObservableValue importerFactoryObservable = PojoObservables.observeValue(importFileData, "importerFactory"); importerFactoryObservable.setValue(importList.getElementAt(0)); dbc.bindValue(ViewersObservables.observeSingleSelection(importList), importerFactoryObservable, updateValueStrategy().withValidator(mandatoryValidator(Messages.fileFormat)).create(), updateValueStrategy().create()); final Composite descComposite = new Composite(transfoGroup, SWT.NONE); descComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).spacing(5, 3).create()); descComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create()); final Label importDescriptionLabel = new Label(descComposite, SWT.NONE); importDescriptionLabel.setText(Messages.importDescriptionLabel); final Label descriptionImage = new Label(descComposite, SWT.NONE); descriptionImage.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.FILL).create()); final Label separator = new Label(descComposite, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); final Label descriptionLabel = new Label(descComposite, SWT.WRAP); descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().hint(230, SWT.DEFAULT).grab(false, true).create()); updatePanel(importFileData.getImporterFactory(), descriptionImage, descriptionLabel); doCreateAdditionalControls(mainComposite, dbc); final Label fileLabel = new Label(mainComposite, SWT.NONE); fileLabel.setText(Messages.selectFileToImport); final Text text = new Text(mainComposite, SWT.BORDER); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final IObservableValue filePathObservable = PojoObservables.observeValue(importFileData, "filePath"); dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), filePathObservable, updateValueStrategy().withValidator(pathValidator(Messages.selectFileToImport).overrideMessage(Messages.invalidFilePath)).create(), updateValueStrategy().create()); final Button browseButton = new Button(mainComposite, SWT.PUSH); browseButton.setText(Messages.browseButton_label); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final String file = openFileDialog(); if (file != null) { text.setText(file); if (new File(file).exists()) { savePath(new File(file).getParentFile().getAbsolutePath()); } } } }); importList.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { updatePanel((ImporterFactory) importerFactoryObservable.getValue(), descriptionImage, descriptionLabel); } }); importList.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent arg0) { updatePanel((ImporterFactory) importerFactoryObservable.getValue(), descriptionImage, descriptionLabel); browseButton.notifyListeners(SWT.Selection, null); } }); return mainComposite; }