/** This is a callback that will allow us to create the viewer and initialize it. */ public void createPartControl(Composite parent) { Table table = createTableWithColumns(parent); viewer = new TableViewer(table); GridData gd = new GridData(GridData.FILL_BOTH); viewer.getControl().setLayoutData(gd); // Create the help context id for the viewer's control PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "YetiPlugIn.viewer"); viewer.setContentProvider(new OverviewContentProvider()); // Get the content for the viewer, setInput will call getElements in the // contentProvider viewer.setLabelProvider(new OverviewLabelProvider()); viewer.setInput(YetiPlugIn.getOverviewArrayList()); /* viewer.setContentProvider( new ViewSummaryContentProvider()); // Get the content for the viewer, setInput will call getElements in the // contentProvider viewer.setLabelProvider(new ViewSummaryLabelProvider()); viewer.setInput(YetiPlugIn.getSummaryInfoArrayList()); // Share Viewer Selection with other workbench parts getViewSite().setSelectionProvider(viewer); viewer.addSelectionChangedListener(this); */ }
/** This is a callback that will allow us to create the viewer and initialize it. */ public void createPartControl(Composite parent) { viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); viewer.setSorter(new NameSorter()); viewer.setInput(getViewSite()); // Delegator // Create the help context id for the viewer's control PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "test.viewer"); makeActions(); hookContextMenu(); hookDoubleClickAction(); contributeToActionBars(); }
/* (non-Javadoc) * @see org.eclipse.pde.internal.ui.editor.PDESection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit) */ protected void createClient(Section section, FormToolkit toolkit) { section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); GridData sectionData = new GridData(GridData.FILL_BOTH); sectionData.verticalSpan = 2; section.setLayoutData(sectionData); Composite container = createClientContainer(section, 2, toolkit); createViewerPartControl(container, SWT.MULTI, 2, toolkit); container.setLayoutData(new GridData(GridData.FILL_BOTH)); createOptionalDependenciesButton(container); TablePart tablePart = getTablePart(); fPluginTable = tablePart.getTableViewer(); fPluginTable.setContentProvider(new ContentProvider()); fPluginTable.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); fPluginTable.setComparator( new ViewerComparator() { public int compare(Viewer viewer, Object e1, Object e2) { IProductPlugin p1 = (IProductPlugin) e1; IProductPlugin p2 = (IProductPlugin) e2; return super.compare(viewer, p1.getId(), p2.getId()); } }); GridData data = (GridData) tablePart.getControl().getLayoutData(); data.minimumWidth = 200; fPluginTable.setInput(getProduct()); tablePart.setButtonEnabled(0, isEditable()); tablePart.setButtonEnabled(1, isEditable()); tablePart.setButtonEnabled(2, isEditable()); // remove buttons will be updated on refresh tablePart.setButtonEnabled(5, isEditable()); toolkit.paintBordersFor(container); section.setClient(container); section.setText(PDEUIMessages.Product_PluginSection_title); section.setDescription(PDEUIMessages.Product_PluginSection_desc); getModel().addModelChangedListener(this); createSectionToolbar(section, toolkit); }
@Override protected void createClient(Section section, FormToolkit toolkit) { section.setText(PDEUIMessages.ExportPackageSection_title); if (isFragment()) section.setDescription(PDEUIMessages.ExportPackageSection_descFragment); else section.setDescription(PDEUIMessages.ExportPackageSection_desc); Composite container = createClientContainer(section, 2, toolkit); createViewerPartControl(container, SWT.MULTI, 2, toolkit); TablePart tablePart = getTablePart(); fPackageViewer = tablePart.getTableViewer(); fPackageViewer.setContentProvider(new ExportPackageContentProvider()); fPackageViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); fPackageViewer.setComparator( new ViewerComparator() { @Override public int compare(Viewer viewer, Object e1, Object e2) { String s1 = e1.toString(); String s2 = e2.toString(); if (s1.indexOf(" ") != -1) // $NON-NLS-1$ s1 = s1.substring(0, s1.indexOf(" ")); // $NON-NLS-1$ if (s2.indexOf(" ") != -1) // $NON-NLS-1$ s2 = s2.substring(0, s2.indexOf(" ")); // $NON-NLS-1$ return super.compare(viewer, s1, s2); } }); toolkit.paintBordersFor(container); section.setClient(container); GridData gd = new GridData(GridData.FILL_BOTH); if (((ManifestEditor) getPage().getEditor()).isEquinox()) { gd.verticalSpan = 2; gd.minimumWidth = 300; } section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); section.setLayoutData(gd); makeActions(); IBundleModel model = getBundleModel(); fPackageViewer.setInput(model); model.addModelChangedListener(this); updateButtons(); }
protected void createViewer(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 3; layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); fExportPart.createControl(composite); GridData gd = (GridData) fExportPart.getControl().getLayoutData(); gd.heightHint = 125; gd.widthHint = 150; gd.horizontalSpan = 2; TableViewer viewer = fExportPart.getTableViewer(); viewer.setContentProvider(new ExportListProvider()); viewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); viewer.setComparator(ListUtil.PLUGIN_COMPARATOR); viewer.addDoubleClickListener( new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (event.getSource() instanceof CheckboxTableViewer) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); ((CheckboxTableViewer) event.getSource()) .setChecked( selection.getFirstElement(), !((CheckboxTableViewer) event.getSource()) .getChecked(selection.getFirstElement())); fExportPart.updateCounter( ((CheckboxTableViewer) event.getSource()).getCheckedElements().length); } } }); fExportPart.getTableViewer().setInput(getInput()); }
@Override public void createPartControl(Composite parent) { final IActionBars actionBars = getViewSite().getActionBars(); IToolBarManager toolbar = actionBars.getToolBarManager(); mSymbolEntryText = new TextContributionItem(""); // $NON-NLS-1$ toolbar.add(mSymbolEntryText); toolbar.add(new AddSymbolAction(mSymbolEntryText, this)); final Table table = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.BORDER); table.setHeaderVisible(true); mViewer = new TableViewer(table); GridDataFactory.defaultsFor(table).applyTo(table); final MarketDataItemComparator comparator = new MarketDataItemComparator(); mViewer.setComparator(comparator); SelectionListener listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // determine new sort column and direction TableColumn sortColumn = table.getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; final int index = table.indexOf(currentColumn); int dir = table.getSortDirection(); if (sortColumn == currentColumn) { dir = dir == SWT.UP ? SWT.DOWN : SWT.UP; } else { table.setSortColumn(currentColumn); dir = SWT.UP; } table.setSortDirection(dir); comparator.setSort(dir == SWT.UP ? 1 : -1); comparator.setIndex(index); mViewer.refresh(); } }; // create columns, using FIXFieldLocalizer to preserve backwards // compatibility TableViewerColumn symbolColumn = new TableViewerColumn( mViewer, createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(Symbol.class.getSimpleName()), SWT.LEFT, listener)); symbolColumn.setEditingSupport(new SymbolEditingSupport()); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(LastPx.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(LastQty.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(BidSize.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(BidPx.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(OfferPx.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(OfferSize.class.getSimpleName()), SWT.RIGHT, listener); // restore table state if it exists if (mViewState != null) { ColumnState.restore(table, mViewState); for (TableColumn column : table.getColumns()) { if (column.getWidth() == 0) { column.setResizable(false); } } } registerContextMenu(); getSite().setSelectionProvider(mViewer); ObservableListContentProvider content = new ObservableListContentProvider(); mViewer.setContentProvider(content); IObservableSet domain = content.getKnownElements(); IObservableMap[] maps = new IObservableMap[] { BeansObservables.observeMap(domain, MarketDataViewItem.class, "symbol"), // $NON-NLS-1$ createCompositeMap( domain, "latestTick", MDPackage.Literals.MD_LATEST_TICK__PRICE), // $NON-NLS-1$ createCompositeMap( domain, "latestTick", MDPackage.Literals.MD_LATEST_TICK__SIZE), // $NON-NLS-1$ createCompositeMap( domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__BID_SIZE), // $NON-NLS-1$ createCompositeMap( domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__BID_PRICE), // $NON-NLS-1$ createCompositeMap( domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__ASK_PRICE), // $NON-NLS-1$ createCompositeMap( domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__ASK_SIZE) // $NON-NLS-1$ }; mViewer.setLabelProvider(new ObservableMapLabelProvider(maps)); mViewer.setUseHashlookup(true); mItems = WritableList.withElementType(MarketDataViewItem.class); mViewer.setInput(mItems); }