List of usage examples for org.eclipse.jface.viewers ViewerCell setText
public void setText(String text)
From source file:de.walware.statet.nico.internal.ui.preferences.ResourceMappingPreferencePage.java
License:Open Source License
protected Composite createTable(final Composite parent) { final TableComposite composite = new ViewerUtil.TableComposite(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); fListViewer = composite.viewer;//from w w w .j a v a 2 s. c o m composite.table.setHeaderVisible(true); composite.table.setLinesVisible(true); { final TableViewerColumn column = new TableViewerColumn(composite.viewer, SWT.NONE); composite.layout.setColumnData(column.getColumn(), new ColumnWeightData(1)); column.getColumn().setText("Local"); column.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final IResourceMapping mapping = (IResourceMapping) cell.getElement(); final IFileStore fileStore = mapping.getFileStore(); cell.setText((fileStore != null) ? fileStore.toString() : "<invalid>"); } }); } { final TableViewerColumn column = new TableViewerColumn(composite.viewer, SWT.NONE); composite.layout.setColumnData(column.getColumn(), new ColumnWeightData(1)); column.getColumn().setText("Host"); column.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final IResourceMapping mapping = (IResourceMapping) cell.getElement(); cell.setText(mapping.getHost()); } }); } { final TableViewerColumn column = new TableViewerColumn(composite.viewer, SWT.NONE); composite.layout.setColumnData(column.getColumn(), new ColumnWeightData(1)); column.getColumn().setText("Remote"); column.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final IResourceMapping mapping = (IResourceMapping) cell.getElement(); final IPath path = mapping.getRemotePath(); cell.setText((path != null) ? path.toString() : "<invalid>"); } }); } composite.viewer.setContentProvider(new ArrayContentProvider()); composite.viewer.setComparator(new ComparatorViewerComparator(ResourceMappingManager.DEFAULT_COMPARATOR)); return composite; }
From source file:de.walware.statet.r.internal.console.ui.launching.RConsoleOptionsTab.java
License:Open Source License
private Composite createTrackingOptions(final Composite parent) { final Group group = new Group(parent, SWT.NONE); group.setText("History / Transcript / Tracking:"); group.setLayout(LayoutUtil.createGroupGrid(2)); final ViewerUtil.CheckboxTableComposite trackingTable; {//from ww w . jav a2 s. co m trackingTable = new ViewerUtil.CheckboxTableComposite(group, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = LayoutUtil.hintHeight(trackingTable.table, 5); trackingTable.setLayoutData(gd); fTrackingTable = trackingTable.viewer; } { final TableViewerColumn column = trackingTable.addColumn("Name", SWT.LEFT, new ColumnWeightData(100)); column.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final TrackingConfiguration config = (TrackingConfiguration) cell.getElement(); cell.setText(config.getName()); } }); } fTrackingButtons = new ButtonGroup<TrackingConfiguration>(group) { @Override protected TrackingConfiguration edit1(TrackingConfiguration item, final boolean newItem, final Object parent) { TrackingConfigurationDialog dialog; if (!newItem && item != null && item.getId().equals(HistoryTrackingConfiguration.HISTORY_TRACKING_ID)) { item = new HistoryTrackingConfiguration(item.getId(), (HistoryTrackingConfiguration) item); dialog = new TrackingConfigurationDialog(RConsoleOptionsTab.this.getShell(), item, false) { @Override protected TrackingConfigurationComposite createConfigComposite(final Composite parent) { return new RHistoryConfigurationComposite(parent); } }; } else { if (newItem) { final String id = CUSTOM_TRACKING_ID_PREFIX + (fTrackingMaxCustomId + 1); if (item == null) { item = new TrackingConfiguration(id); } else { item = new TrackingConfiguration(id, item); } } else { item = new TrackingConfiguration(item.getId(), item); } dialog = new TrackingConfigurationDialog(RConsoleOptionsTab.this.getShell(), item, newItem) { @Override protected TrackingConfigurationComposite createConfigComposite(final Composite parent) { return new RTrackingConfigurationComposite(parent); } }; } if (dialog.open() == Dialog.OK) { if (newItem) { fTrackingMaxCustomId++; } return item; } return null; } }; fTrackingButtons.addAddButton(null); fTrackingButtons.addDeleteButton(null); fTrackingButtons.addEditButton(null); fTrackingButtons.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); ViewerUtil.scheduleStandardSelection(fTrackingTable); return group; }
From source file:de.walware.statet.r.internal.console.ui.launching.RRemoteConsoleSelectionDialog.java
License:Open Source License
@Override protected Control createDialogArea(final Composite parent) { // page group final Composite area = (Composite) super.createDialogArea(parent); createMessageArea(area);/* w ww .j ava 2 s . c o m*/ final IDialogSettings dialogSettings = getDialogSettings(); { final Composite composite = new Composite(area, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); composite.setLayout(LayoutUtil.applyCompositeDefaults(new GridLayout(), 3)); final Label label = new Label(composite, SWT.NONE); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); label.setText(RConsoleMessages.RRemoteConsoleSelectionDialog_Hostname_label); fHostAddressControl = new Combo(composite, SWT.DROP_DOWN); final GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); gd.widthHint = LayoutUtil.hintWidth(fHostAddressControl, 50); fHostAddressControl.setLayoutData(gd); final String[] history = dialogSettings.getArray(SETTINGS_HOST_HISTORY_KEY); if (history != null) { fHistoryAddress.addAll(Arrays.asList(history)); } fHostAddressControl.addSelectionListener(new SelectionAdapter() { @Override public void widgetDefaultSelected(final SelectionEvent e) { update(); } }); final Button goButton = new Button(composite, SWT.PUSH); goButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); goButton.setText(RConsoleMessages.RRemoteConsoleSelectionDialog_Update_label); goButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { update(); } }); } { final TreeComposite composite = new TreeComposite(area, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = LayoutUtil.hintHeight(composite.tree, 10); composite.setLayoutData(gd); fRServerViewer = composite.viewer; composite.tree.setHeaderVisible(true); ColumnViewerToolTipSupport.enableFor(composite.viewer); { final TreeViewerColumn column = new TreeViewerColumn(fRServerViewer, SWT.NONE); column.getColumn().setText(RConsoleMessages.RRemoteConsoleSelectionDialog_Table_UserOrEngine_label); composite.layout.setColumnData(column.getColumn(), new ColumnWeightData(1)); column.setLabelProvider(new RemoteRLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); String text = null; Image image = null; if (element instanceof String) { text = (String) element; image = SharedUIResources.getImages().get(SharedUIResources.OBJ_USER_IMAGE_ID); } else if (element instanceof RemoteR) { text = getText((RemoteR) element); } cell.setText(text); cell.setImage(image); } @Override public String getText(final RemoteR r) { return r.info.getName(); } }); } { final TreeViewerColumn column = new TreeViewerColumn(fRServerViewer, SWT.NONE); column.getColumn().setText(RConsoleMessages.RRemoteConsoleSelectionDialog_Table_Host_label); composite.layout.setColumnData(column.getColumn(), new ColumnWeightData(1)); column.setLabelProvider(new RemoteRLabelProvider() { @Override public String getText(final RemoteR r) { return r.hostName; } }); } fRServerViewer.setContentProvider(new RemoteRContentProvider()); fRServerViewer.getTree().addSelectionListener(new SelectionListener() { @Override public void widgetSelected(final SelectionEvent e) { updateState(); } @Override public void widgetDefaultSelected(final SelectionEvent e) { updateState(); if (getOkButton().isEnabled()) { buttonPressed(IDialogConstants.OK_ID); } } }); } Dialog.applyDialogFont(area); updateInput(); if (fRServerList != null) { updateStatus(new Status(IStatus.OK, RConsoleUIPlugin.PLUGIN_ID, RConsoleMessages.RRemoteConsoleSelectionDialog_info_ListRestored_message)); } return area; }
From source file:de.walware.statet.r.internal.debug.ui.preferences.REnvLocalConfigDialog.java
License:Open Source License
@Override protected Control createDialogArea(final Composite parent) { final Composite area = new Composite(parent, SWT.NONE); area.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); area.setLayout(LayoutUtil.createDialogGrid(2)); { // Name:// w w w . j ava 2 s . co m final Label label = new Label(area, SWT.LEFT); label.setText(Messages.REnv_Detail_Name_label + ':'); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); fNameControl = new Text(area, SWT.BORDER); final GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); gd.widthHint = LayoutUtil.hintWidth(fNameControl, 60); fNameControl.setLayoutData(gd); fNameControl.setEditable(fConfigModel.isEditable()); } if (fConfigModel.isEditable()) { // Location: final Label label = new Label(area, SWT.LEFT); label.setText(Messages.REnv_Detail_Location_label + ':'); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); fRHomeControl = new RHomeComposite(area); fRHomeControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); } LayoutUtil.addSmallFiller(area, false); { // Architecture / Bits: final Label label = new Label(area, SWT.LEFT); label.setText(Messages.REnv_Detail_Arch_label + ':'); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); final Composite composite = new Composite(area, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); composite.setLayout(LayoutUtil.createCompositeGrid(3)); { fRArchControl = new Combo(composite, SWT.DROP_DOWN); final GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.widthHint = LayoutUtil.hintWidth(fRArchControl, 8); fRArchControl.setLayoutData(gd); fRArchControl.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final int selectionIdx; if (!fRArchControl.getListVisible() && (selectionIdx = fRArchControl.getSelectionIndex()) >= 0) { final String item = fRArchControl.getItem(selectionIdx); } } }); fRArchControl.setEnabled(fConfigModel.isEditable()); } if (fConfigModel.isEditable()) { fLoadButton = new Button(composite, SWT.PUSH); fLoadButton.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, false, 2, 1)); fLoadButton.setText(Messages.REnv_Detail_DetectSettings_label); fLoadButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { detectSettings(); } }); } else { LayoutUtil.addGDDummy(composite, true, 2); } } { // Libraries: final Label label = new Label(area, SWT.LEFT); label.setText(Messages.REnv_Detail_Libraries_label + ":"); //$NON-NLS-1$ label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); final Composite composite = new Composite(area, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); composite.setLayout(LayoutUtil.createCompositeGrid(2)); final TreeComposite treeComposite = new ViewerUtil.TreeComposite(composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); fRLibrariesViewer = treeComposite.viewer; final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.widthHint = LayoutUtil.hintWidth(fNameControl, 80); gd.heightHint = LayoutUtil.hintHeight(treeComposite.tree, 10); treeComposite.setLayoutData(gd); treeComposite.viewer.setContentProvider(new ITreeContentProvider() { @Override public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { } @Override public void dispose() { } @Override public Object[] getElements(final Object inputElement) { return fConfigModel.getRLibraryGroups().toArray(); } @Override public Object getParent(final Object element) { if (element instanceof RLibraryContainer) { return ((RLibraryContainer) element).parent; } return null; } @Override public boolean hasChildren(final Object element) { if (element instanceof IRLibraryGroup.WorkingCopy) { return !((IRLibraryGroup.WorkingCopy) element).getLibraries().isEmpty(); } return false; } @Override public Object[] getChildren(final Object parentElement) { if (parentElement instanceof IRLibraryGroup.WorkingCopy) { final IRLibraryGroup.WorkingCopy group = (IRLibraryGroup.WorkingCopy) parentElement; final List<? extends IRLibraryLocation.WorkingCopy> libs = group.getLibraries(); final RLibraryContainer[] array = new RLibraryContainer[libs.size()]; for (int i = 0; i < libs.size(); i++) { array[i] = new RLibraryContainer(group, libs.get(i)); } return array; } return null; } }); final TreeViewerColumn column = treeComposite.addColumn(SWT.LEFT, new ColumnWeightData(100)); column.setLabelProvider(new REnvLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof RLibraryContainer) { final IRLibraryLocation lib = ((RLibraryContainer) element).library; cell.setImage(RUI.getImage(RUI.IMG_OBJ_LIBRARY_LOCATION)); if (lib.getSource() != IRLibraryLocation.USER && lib.getLabel() != null) { cell.setText(lib.getLabel()); } else { cell.setText(lib.getDirectoryPath()); } finishUpdate(cell); return; } super.update(cell); } }); column.setEditingSupport(new EditingSupport(treeComposite.viewer) { @Override protected boolean canEdit(final Object element) { if (element instanceof RLibraryContainer) { final RLibraryContainer container = ((RLibraryContainer) element); return (container.library.getSource() == IRLibraryLocation.USER); } return false; } @Override protected void setValue(final Object element, final Object value) { final RLibraryContainer container = (RLibraryContainer) element; container.library.setDirectoryPath((String) value); getViewer().refresh(container, true); getDataBinding().updateStatus(); } @Override protected Object getValue(final Object element) { final RLibraryContainer container = (RLibraryContainer) element; return container.library.getDirectoryPath(); } @Override protected CellEditor getCellEditor(final Object element) { return new ExtensibleTextCellEditor(treeComposite.tree) { @Override protected Control createCustomControl(final Composite parent) { final ResourceInputComposite chooseResourceComposite = new ResourceInputComposite( parent, ResourceInputComposite.STYLE_TEXT, ResourceInputComposite.MODE_DIRECTORY | ResourceInputComposite.MODE_OPEN, Messages.REnv_Detail_LibraryLocation_label) { @Override protected void beforeMenuAction() { getFocusGroup().discontinueTracking(); } @Override protected void afterMenuAction() { getFocusGroup().continueTracking(); } }; chooseResourceComposite.setShowInsertVariable(true, DialogUtil.DEFAULT_NON_ITERACTIVE_FILTERS, null); fText = (Text) chooseResourceComposite.getTextControl(); return chooseResourceComposite; } }; } }); treeComposite.viewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS); treeComposite.viewer.setInput(fConfigModel); ViewerUtil.installDefaultEditBehaviour(treeComposite.viewer); ViewerUtil.scheduleStandardSelection(treeComposite.viewer); fRLibrariesButtons = new ButtonGroup<IRLibraryLocation.WorkingCopy>(composite) { @Override protected IRLibraryLocation.WorkingCopy edit1(final IRLibraryLocation.WorkingCopy item, final boolean newItem, final Object parent) { if (newItem) { return ((IRLibraryGroup.WorkingCopy) parent).newLibrary(""); //$NON-NLS-1$ } return item; } @Override public void updateState() { super.updateState(); if (getDataAdapter().isDirty()) { getDataBinding().updateStatus(); } } }; fRLibrariesButtons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true)); fRLibrariesButtons.addAddButton(null); fRLibrariesButtons.addDeleteButton(null); // fRLibrariesButtons.addSeparator(); // fRLibrariesButtons.addUpButton(); // fRLibrariesButtons.addDownButton(); final DataAdapter<IRLibraryLocation.WorkingCopy> adapter = new DataAdapter.ListAdapter<IRLibraryLocation.WorkingCopy>( (ITreeContentProvider) fRLibrariesViewer.getContentProvider(), null, null) { private IRLibraryGroup.WorkingCopy getGroup(final Object element) { if (element instanceof IRLibraryGroup.WorkingCopy) { return (IRLibraryGroup.WorkingCopy) element; } else { return ((RLibraryContainer) element).parent; } } @Override public IRLibraryLocation.WorkingCopy getModelItem(final Object element) { if (element instanceof RLibraryContainer) { return ((RLibraryContainer) element).library; } return (IRLibraryLocation.WorkingCopy) element; } @Override public Object getViewerElement(final IRLibraryLocation.WorkingCopy item, final Object parent) { return new RLibraryContainer((IRLibraryGroup.WorkingCopy.WorkingCopy) parent, item); } @Override public boolean isAddAllowed(final Object element) { return !getGroup(element).getId().equals(IRLibraryGroup.R_DEFAULT); } @Override public boolean isModifyAllowed(final Object element) { return (element instanceof RLibraryContainer && ((RLibraryContainer) element).library.getSource() == IRLibraryLocation.USER); } @Override public Object getAddParent(final Object element) { return getGroup(element); } @Override public List<? super IRLibraryLocation.WorkingCopy> getContainerFor(final Object element) { if (element instanceof IRLibraryGroup.WorkingCopy) { return ((IRLibraryGroup.WorkingCopy) element).getLibraries(); } else { return ((RLibraryContainer) element).parent.getLibraries(); } } }; fRLibrariesButtons.connectTo(fRLibrariesViewer, adapter); } if (fConfigModel.isEditable()) { final Composite group = createInstallDirGroup(area); if (group != null) { group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); } } LayoutUtil.addSmallFiller(area, true); applyDialogFont(area); return area; }
From source file:de.walware.statet.r.internal.ui.dataeditor.RDataLabelProvider.java
License:Open Source License
@Override public void update(final ViewerCell cell) { Image image;// w ww .j a v a 2 s . c o m final StyledString text = new StyledString(); final Object element = cell.getElement(); if (element instanceof RDataTableContentDescription) { final RDataTableContentDescription description = (RDataTableContentDescription) element; if (description.getRElementStruct() instanceof ICombinedRElement) { fRLabelProvider.update(cell, (IModelElement) description.getRElementStruct()); super.update(cell); return; } switch (description.getRElementStruct().getRObjectType()) { case RObject.TYPE_VECTOR: image = RUI.getImage(RUI.IMG_OBJ_VECTOR); break; case RObject.TYPE_ARRAY: image = RUI.getImage(RUI.IMG_OBJ_VECTOR); break; case RObject.TYPE_DATAFRAME: image = RUI.getImage(RUI.IMG_OBJ_VECTOR); break; default: image = null; break; } text.append(description.getElementName().toString()); } else if (element instanceof IRDataTableVariable) { final IRDataTableVariable variable = (IRDataTableVariable) element; image = getImage(variable); text.append(variable.getName()); if (element instanceof RDataTableColumn) { final RDataTableColumn column = (RDataTableColumn) variable; text.append(" : ", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$ final List<String> classNames = column.getClassNames(); text.append(classNames.get(0), StyledString.DECORATIONS_STYLER); for (int i = 1; i < classNames.size(); i++) { text.append(", ", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$ text.append(classNames.get(i), StyledString.DECORATIONS_STYLER); } if (!classNames.contains(RDataUtil.getStoreClass(column.getDataStore()))) { text.append(" (", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$ text.append(RDataUtil.getStoreAbbr(column.getDataStore()), StyledString.DECORATIONS_STYLER); text.append(")", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$ } } } else if (element instanceof VariablePropertyItem) { final VariablePropertyItem item = (VariablePropertyItem) element; image = null; text.append(item.getName()); final int count = item.getCount(); if (count >= 0) { text.append(" (", StyledString.COUNTER_STYLER); //$NON-NLS-1$ text.append(Integer.toString(count), StyledString.COUNTER_STYLER); text.append(")", StyledString.COUNTER_STYLER); //$NON-NLS-1$ } } else { image = null; text.append(element.toString()); } cell.setText(text.getString()); cell.setStyleRanges(text.getStyleRanges()); cell.setImage(image); super.update(cell); }
From source file:de.walware.statet.r.internal.ui.datafilterview.ColumnLabelProvider.java
License:Open Source License
@Override public void update(final ViewerCell cell) { final Object data = fColumn.getDefaultFormat().modelToDisplayValue(cell.getElement()); cell.setFont((data instanceof InfoString) ? getInfoFont() : null); cell.setText(data.toString()); }
From source file:de.walware.statet.r.internal.ui.pkgmanager.PkgTab.java
License:Open Source License
private Composite createTable(final Composite parent) { final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(LayoutUtil.createCompositeGrid(2)); {/*from w w w. j av a 2 s .c o m*/ final Label label = new Label(composite, SWT.NONE); label.setText("Packages:"); label.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false)); } { fToolBar = new ToolBarManager(SWT.HORIZONTAL | SWT.FLAT); final ToolBar toolBar = fToolBar.createControl(composite); toolBar.setLayoutData(new GridData(SWT.END, SWT.FILL, true, false)); } final TableComposite viewer = new TableComposite(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL); fPkgTable = viewer; viewer.viewer.setUseHashlookup(true); viewer.table.setHeaderVisible(true); { final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); gd.heightHint = LayoutUtil.hintHeight(viewer.table, 15); gd.widthHint = fDialog.hintWidthInChars(40); viewer.setLayoutData(gd); } ColumnViewerToolTipSupport.enableFor(viewer.viewer, ToolTip.NO_RECREATE); { final TableViewerColumn column = viewer.addColumn("Name", SWT.LEFT, new ColumnWeightData(50)); column.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final String name = (String) cell.getElement(); cell.setImage(RUI.getImage((fPkgSet.getInstalled().containsByName(name)) ? RUI.IMG_OBJ_R_PACKAGE : RUI.IMG_OBJ_R_PACKAGE_NOTA)); cell.setText(name); } @Override public String getToolTipText(final Object element) { final String name = (String) element; final IRPkgInfoAndData v = fPkgSet.getInstalled().getFirstByName(name); if (v != null) { return v.getTitle(); } return null; } }); } return composite; }
From source file:de.walware.statet.r.internal.ui.pkgmanager.PkgTab.java
License:Open Source License
private void createDetailTable(final Composite parent) { {/*from w w w . j av a2 s . c om*/ final Label label = new Label(parent, SWT.NONE); label.setText("&Versions:"); label.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false)); } { // for layout final Label label = new Label(parent, SWT.NONE); final GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.heightHint = fToolBar.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT).y; label.setLayoutData(gd); } final TreeComposite composite = new TreeComposite(parent, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); fDetailTable = composite; { final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1); gd.heightHint = LayoutUtil.hintHeight(composite.tree, 6); gd.widthHint = fDialog.hintWidthInChars(40); composite.setLayoutData(gd); } composite.viewer.setContentProvider(new DetailGroup.ContentProvider(2) { { fGroups[AVAIL] = new DetailGroup(AVAIL, "Available"); fGroups[INST] = new DetailGroup(INST, "Installed"); } @Override public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { if (newInput instanceof String) { final String name = (String) newInput; fGroups[AVAIL].setList(fPkgSet.getAvailable().getByName(name)); fGroups[INST].setList(fPkgSet.getInstalled().getByName(name)); } else { fGroups[AVAIL].clearList(); fGroups[INST].clearList(); } } }); composite.viewer.setComparer(new IElementComparer() { @Override public int hashCode(final Object element) { if (element instanceof IRPkgData) { return element.hashCode() + ((IRPkgData) element).getRepoId().hashCode(); } return element.hashCode(); } @Override public boolean equals(final Object a, final Object b) { if (a == b) { return true; } if (!a.equals(b)) { return false; } if (a instanceof IRPkgData) { return ((IRPkgData) a).getRepoId().equals(((IRPkgData) b).getRepoId()); } return false; } }); composite.viewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS); { final TreeViewerColumn column = composite.addColumn("Repository/Library", SWT.LEFT, new ColumnWeightData(50, fDialog.hintWidthInChars(20), true)); column.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof DetailGroup) { cell.setText(((DetailGroup) element).getLabel()); return; } else if (element instanceof IRPkgInfo) { final IRLibraryLocation location = ((IRPkgInfo) element).getLibraryLocation(); cell.setText(REnvLabelProvider.getSafeLabel(location)); return; } else if (element instanceof IRPkgData) { final IRPkgData pkg = (IRPkgData) element; if (pkg.getRepoId() != null) { final RRepo repo = RPkgUtil.getRepoById(fDialog.fRepoTab.getAvailableRepos(), pkg.getRepoId()); if (repo != null) { cell.setText(repo.getName()); return; } } cell.setText("-"); return; } throw new IllegalStateException(); } }); } { final TreeViewerColumn column = composite.addColumn("Version", SWT.LEFT, new ColumnPixelData(fDialog.hintWidthInChars(VERSION_CHARS), true, true)); column.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof IRPkgData) { cell.setText(((IRPkgData) element).getVersion().toString()); return; } cell.setText(""); //$NON-NLS-1$ } @Override public String getToolTipText(final Object element) { return (element instanceof IRPkgData) ? getDetailToolTipText((IRPkgData) element) : null; } }); } ColumnViewerToolTipSupport.enableFor(composite.viewer); composite.viewer.setInput(RPkgManagerDialog.NO_INPUT); }
From source file:de.walware.statet.r.internal.ui.pkgmanager.PkgTab.java
License:Open Source License
private void createDetailRef(final Composite parent, final int type) { {//from w w w. ja v a2 s . c o m final Label label = new Label(parent, SWT.NONE); label.setText((type == 0) ? "Dependencies:" : "Reverse:"); label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); } final TreeViewer viewer = new TreeViewer(parent, (SWT.BORDER | SWT.SINGLE)); if (type == 0) { fDetailDepTable = viewer; } else { fDetailRevTable = viewer; } { final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd.heightHint = LayoutUtil.hintHeight(viewer.getTree(), 12); gd.widthHint = fDialog.hintWidthInChars(20); viewer.getControl().setLayoutData(gd); } viewer.setContentProvider(new DetailGroup.ContentProvider(5) { private static final int DEPENDS = 0; private static final int IMPORTS = 1; private static final int LINKINGTO = 2; private static final int SUGGESTS = 3; private static final int ENHANCES = 4; { fGroups[DEPENDS] = new DetailGroup(0, "Depends"); fGroups[IMPORTS] = new DetailGroup(1, "Imports"); fGroups[LINKINGTO] = new DetailGroup(2, "Linking To"); fGroups[SUGGESTS] = new DetailGroup(3, "Suggests"); fGroups[ENHANCES] = new DetailGroup(4, "Enhances"); } @Override public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { if (newInput instanceof IRPkgData) { final IRPkgData pkg = (IRPkgData) newInput; fGroups[DEPENDS].setList(pkg.getDepends()); fGroups[IMPORTS].setList(pkg.getImports()); fGroups[LINKINGTO].setList(pkg.getLinkingTo()); fGroups[SUGGESTS].setList(pkg.getSuggests()); fGroups[ENHANCES].setList(pkg.getEnhances()); } else { fGroups[DEPENDS].clearList(); fGroups[IMPORTS].clearList(); fGroups[LINKINGTO].clearList(); fGroups[SUGGESTS].clearList(); fGroups[ENHANCES].clearList(); } } }); viewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS); viewer.setLabelProvider(new StyledCellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof DetailGroup) { cell.setText(((DetailGroup) element).getLabel()); cell.setStyleRanges(null); return; } else if (element instanceof IRPkg) { final IRPkg pkg = (IRPkg) element; final StyledString text = new StyledString(); text.append(pkg.getName()); final String version = pkg.getVersion().toString(); if (!version.isEmpty()) { text.append(" (", StyledString.QUALIFIER_STYLER); //$NON-NLS-1$ text.append(version, StyledString.QUALIFIER_STYLER); text.append(")", StyledString.QUALIFIER_STYLER); //$NON-NLS-1$ } cell.setText(text.getString()); cell.setStyleRanges(text.getStyleRanges()); return; } throw new IllegalStateException(); } }); viewer.setInput(NO_INPUT); viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(final DoubleClickEvent event) { final Object element = ((IStructuredSelection) event.getSelection()).getFirstElement(); if (element instanceof IRPkg) { showPkg(((IRPkg) element).getName()); } } }); }
From source file:de.walware.statet.r.internal.ui.pkgmanager.RRepoLabelProvider.java
License:Open Source License
protected void update(final ViewerCell cell, final RRepo repo) { final StyledString sb = new StyledString(repo.getName()); sb.append(" - ", StyledString.QUALIFIER_STYLER); //$NON-NLS-1$ sb.append(repo.getURL(), StyledString.QUALIFIER_STYLER); cell.setText(sb.getString()); cell.setStyleRanges(sb.getStyleRanges()); }