List of usage examples for org.eclipse.jface.bindings.keys IKeyLookup ENTER_NAME
String ENTER_NAME
To view the source code for org.eclipse.jface.bindings.keys IKeyLookup ENTER_NAME.
Click Source Link
From source file:de.unistuttgart.ipvs.pmp.editor.ui.editors.internals.localetable.LocaleTable.java
License:Apache License
/** * Creates a new locale table. This table shows all available names, * descriptions or change descriptions and their locale. * //from w w w. ja v a 2s . c o m * @param parent * Parent widget, to which this table should be added * @param data * Data, from which the information will be loaded and written * into * @param type * Type of data, that should be shown.<br /> * <b>Warning:</b> If type is set to {@code CHANGE_DESCRIPTION}, {@code data} has to of type * {@code RGISPrivacySetting}. * Otherwise this table will throw {@code ClassCastException}s * while user interaction! * @param tableAction * Action, that will be initated when the data in this table was * changed by the user * @param toolkit * SWT-Toolkit */ public LocaleTable(Composite parent, IBasicIS data, Type type, ILocaleTableAction tableAction, FormToolkit toolkit) { this.data = data; this.type = type; this.tableAction = tableAction; // Create grid for storing the table and buttons this.outerCompo = toolkit.createComposite(parent); this.outerCompo.setLayout(new GridLayout(2, false)); // Set layout so that the table uses the whole width GridData tableLayout = new GridData(); tableLayout.horizontalAlignment = GridData.FILL; tableLayout.verticalAlignment = GridData.FILL; tableLayout.grabExcessHorizontalSpace = true; tableLayout.grabExcessVerticalSpace = true; // Workaround for SWT-Bug // (https://bugs.eclipse.org/bugs/show_bug.cgi?id=215997) tableLayout.widthHint = 1; Composite tableCompo = toolkit.createComposite(this.outerCompo); tableCompo.setLayoutData(tableLayout); TableColumnLayout columnLayout = new TableColumnLayout(); tableCompo.setLayout(columnLayout); this.tableViewer = new TableViewer(tableCompo, SWT.BORDER | SWT.FULL_SELECTION); Table table = this.tableViewer.getTable(); table.setLayoutData(tableLayout); table.setHeaderVisible(true); table.setLinesVisible(true); createColumns(columnLayout); // Add decoration this.tableDec = new ControlDecoration(this.tableViewer.getControl(), SWT.TOP | SWT.LEFT); this.tableDec.setImage(Images.IMG_DEC_FIELD_ERROR); if (data != null) { validate(); } // Add keyboard navigation ColumnViewerEditorActivationStrategy activationStrategy = new ColumnViewerEditorActivationStrategy( this.tableViewer) { @Override protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) { // Editing is enabled as before but also by pressing enter boolean activateByKey = event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == KeyLookupFactory.getDefault().formalKeyLookup(IKeyLookup.ENTER_NAME); return super.isEditorActivationEvent(event) || activateByKey; } }; activationStrategy.setEnableEditorActivationWithKeyboard(true); FocusCellHighlighter highlighter = new FocusCellOwnerDrawHighlighter(this.tableViewer); TableViewerFocusCellManager focusManager = new TableViewerFocusCellManager(this.tableViewer, highlighter); TableViewerEditor.create(this.tableViewer, focusManager, activationStrategy, ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.KEYBOARD_ACTIVATION); // Add table sorter this.tableViewer.setSorter(new ViewerSorter()); // But data into table if set this.tableViewer.setContentProvider(new ListContentProvider()); setData(data); // Add tooltip listener TooltipTableListener tooltipListener = new TooltipTableListener(this.tableViewer, parent.getShell()); this.tableViewer.getTable().addListener(SWT.Dispose, tooltipListener); this.tableViewer.getTable().addListener(SWT.KeyDown, tooltipListener); this.tableViewer.getTable().addListener(SWT.MouseMove, tooltipListener); this.tableViewer.getTable().addListener(SWT.MouseHover, tooltipListener); // Add buttons createButtons(toolkit); }
From source file:org.dawnsci.common.widgets.gda.function.FunctionTreeViewer.java
License:Open Source License
public FunctionTreeViewer(final Composite parent, IFunctionDescriptorProvider functionDescriptorProvider) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new FillLayout()); treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.FULL_SELECTION); treeViewer.getTree().setLinesVisible(true); treeViewer.getTree().setHeaderVisible(true); TreeViewerFocusCellManager focusCellManager = new TreeViewerFocusCellManager(treeViewer, new FocusCellOwnerDrawHighlighter(treeViewer)); ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(treeViewer) { @Override//from w w w . java 2s . co m protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) { // TODO see AbstractComboBoxCellEditor for how list is made visible return super.isEditorActivationEvent(event) || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && (event.keyCode == KeyLookupFactory.getDefault() .formalKeyLookup(IKeyLookup.ENTER_NAME))); } }; TreeViewerEditor.create(treeViewer, focusCellManager, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION); createFunctionNameColumn(); createParameterValueColumn("Value", COLUMN.VALUE, false, new IGetSetValueOnParameterModel() { @Override public void setValue(ParameterModel param, String value) { param.setParameterValue(value); } @Override public double getValue(ParameterModel param) { return param.getParameterValue(); } @Override public String getErrorValue(ParameterModel param) { return param.getParameterValueError(); } }); createParameterValueColumn("Lower Limit", COLUMN.LOWERLIMIT, true, new IGetSetValueOnParameterModel() { @Override public void setValue(ParameterModel param, String value) { param.setParameterLowerLimit(value); } @Override public double getValue(ParameterModel param) { return param.getParameterLowerLimit(); } @Override public String getErrorValue(ParameterModel param) { return param.getParameterLowerLimitError(); } }); createParameterValueColumn("Upper Limit", COLUMN.UPPERLIMIT, true, new IGetSetValueOnParameterModel() { @Override public void setValue(ParameterModel param, String value) { param.setParameterUpperLimit(value); } @Override public double getValue(ParameterModel param) { return param.getParameterUpperLimit(); } @Override public String getErrorValue(ParameterModel param) { return param.getParameterUpperLimitError(); } }); createFittedParamsColumn(); treeViewer.setContentProvider(new FunctionTreeViewerContentProvider()); treeViewer.expandToLevel(2); // IFunctions are not safely hashable for this use (despite their having // a custom hashCode) treeViewer.setUseHashlookup(false); setInput(null); this.functionDescriptorProvider = functionDescriptorProvider; functionSelectionEditingSupport.setFunctionDesciptorProvider(functionDescriptorProvider); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); ISelection realSelection = convertSelection(selection); fireSelectionChanged(new SelectionChangedEvent(FunctionTreeViewer.this, realSelection)); } } }); }
From source file:org.dawnsci.common.widgets.table.SeriesTable.java
License:Open Source License
/** * Create the control for the table. The icon provider is checked for label and * icon for the first, name column in the table. It must provide at least an * icon for a given SeriesItem implementation. If it does not provide a label * then the 'getName()' method of SeriesItem is used. * // w w w . j a va 2 s . c o m * @param parent - the SWT composite to add the table to. * @param iconProvider - a provider which must at least give the icon for a given SeriesItem */ public void createControl(Composite parent, SeriesItemLabelProvider iconProvider) { tableViewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE) { protected void inputChanged(Object input, Object oldInput) { super.inputChanged(input, oldInput); checkValid((List<ISeriesItemDescriptor>) input); } }; tableViewer.getTable().setLinesVisible(true); tableViewer.getTable().setHeaderVisible(true); tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(tableViewer, new FocusCellOwnerDrawHighlighter(tableViewer)); ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(tableViewer) { @Override protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) { // TODO see AbstractComboBoxCellEditor for how list is made visible return super.isEditorActivationEvent(event) || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && (event.keyCode == KeyLookupFactory.getDefault() .formalKeyLookup(IKeyLookup.ENTER_NAME))); } }; TableViewerEditor.create(tableViewer, focusCellManager, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION); tableViewer.setContentProvider(new SeriesContentProvider()); this.error = new Composite(parent, SWT.NONE); error.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); error.setLayout(new GridLayout(2, false)); error.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); Label errorIcon = new Label(error, SWT.NONE); errorIcon.setImage(Activator.getImageDescriptor("icons/error.png").createImage()); errorIcon.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); errorIcon.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); this.errorLabel = new Label(error, SWT.WRAP); errorLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); GridUtils.setVisible(error, false); createColumns(iconProvider); //hook up delete key to remove from list tableViewer.getTable().addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { delete(); } } }); }
From source file:org.eclipse.jface.snippets.viewers.Snippet060TextCellEditorWithContentProposal.java
License:Open Source License
public Snippet060TextCellEditorWithContentProposal(Shell shell) { final TableViewer viewer = new TableViewer(shell, SWT.BORDER | SWT.FULL_SELECTION); final Table table = viewer.getTable(); table.setLinesVisible(true);// ww w. j a va2 s . c om table.setHeaderVisible(true); final TableViewerColumn colorColumn = new TableViewerColumn(viewer, SWT.LEFT); colorColumn.getColumn().setText("Color name"); colorColumn.getColumn().setWidth(200); colorColumn.setLabelProvider(new ColumnLabelProvider()); colorColumn.setEditingSupport(new ColorNameEditingSupport(viewer)); viewer.setContentProvider(new ArrayContentProvider()); ColumnViewerEditorActivationStrategy activationSupport = new ColumnViewerEditorActivationStrategy(viewer) { @Override protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) { return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == KeyLookupFactory.getDefault() .formalKeyLookup(IKeyLookup.ENTER_NAME)); } }; activationSupport.setEnableEditorActivationWithKeyboard(true); /* * Without focus highlighter, keyboard events will not be delivered to * ColumnViewerEditorActivationStragety#isEditorActivationEvent(...) (see above) */ FocusCellHighlighter focusCellHighlighter = new FocusCellOwnerDrawHighlighter(viewer); TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer, focusCellHighlighter); TableViewerEditor.create(viewer, focusCellManager, activationSupport, ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION); viewer.setInput(createModel()); }
From source file:org.eclipse.richbeans.widgets.table.SeriesTable.java
License:Open Source License
/** * Create the control for the table. The icon provider is checked for label and * icon for the first, name column in the table. It must provide at least an * icon for a given SeriesItem implementation. If it does not provide a label * then the 'getName()' method of SeriesItem is used. * /*from w w w .j av a2 s .co m*/ * @param parent - the SWT composite to add the table to. * @param iconProvider - a provider which must at least give the icon for a given SeriesItem * @param switches by defualt these are SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE */ public void createControl(Composite parent, SeriesItemLabelProvider iconProvider, int switches) { tableViewer = new TableViewer(parent, switches) { protected void inputChanged(Object input, Object oldInput) { super.inputChanged(input, oldInput); checkValid((List<ISeriesItemDescriptor>) input); } }; tableViewer.getTable().setLinesVisible(true); tableViewer.getTable().setHeaderVisible(true); tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(tableViewer, new FocusCellOwnerDrawHighlighter(tableViewer)); ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(tableViewer) { @Override protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) { // TODO see AbstractComboBoxCellEditor for how list is made visible return super.isEditorActivationEvent(event) || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && (event.keyCode == KeyLookupFactory.getDefault() .formalKeyLookup(IKeyLookup.ENTER_NAME))); } }; TableViewerEditor.create(tableViewer, focusCellManager, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION); tableViewer.setContentProvider(new SeriesContentProvider()); this.error = new Composite(parent, SWT.NONE); error.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); error.setLayout(new GridLayout(2, false)); error.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); Label errorIcon = new Label(error, SWT.NONE); errorIcon.setImage(Activator.getImageDesciptor("icons/error.png").createImage()); errorIcon.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); errorIcon.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); this.errorLabel = new Label(error, SWT.WRAP); errorLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); GridUtils.setVisible(error, false); createColumns(iconProvider); //hook up delete key to remove from list tableViewer.getTable().addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { delete(); } } }); }
From source file:org.eclipse.scanning.device.ui.model.ModelViewer.java
License:Open Source License
private TableViewer createTableViewer(Composite content2) { TableViewer viewer = new TableViewer(content, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); viewer.setContentProvider(createContentProvider()); viewer.getTable().setLinesVisible(true); viewer.getTable().setHeaderVisible(true); viewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); // resize the row height using a MeasureItem listener viewer.getTable().addListener(SWT.MeasureItem, new Listener() { public void handleEvent(Event event) { event.height = 24;//from w w w . j av a 2s. c om } }); //added 'event.height=rowHeight' here just to check if it will draw as I want viewer.getTable().addListener(SWT.EraseItem, new Listener() { public void handleEvent(Event event) { event.height = 24; } }); TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer, new FocusCellOwnerDrawHighlighter(viewer)); ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(viewer) { @Override protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) { // TODO see AbstractComboBoxCellEditor for how list is made visible return super.isEditorActivationEvent(event) || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && (event.keyCode == KeyLookupFactory.getDefault() .formalKeyLookup(IKeyLookup.ENTER_NAME))); } }; TableViewerEditor.create(viewer, focusCellManager, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION); createColumns(viewer); createDropTarget(viewer); viewer.getTable().addKeyListener(new KeyListener() { public void keyReleased(KeyEvent e) { } public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.F1) { // TODO Help! } if (e.character == SWT.DEL) { try { Object ob = ((IStructuredSelection) viewer.getSelection()).getFirstElement(); ((FieldValue) ob).set(null); viewer.setSelection(new StructuredSelection(ob)); refresh(); // Must do global refresh because might effect units of other parameters. } catch (Exception ne) { logger.error("Cannot delete item " + (IStructuredSelection) viewer.getSelection(), ne); } } } }); return viewer; }