private CCombo addComboInTable(TableViewer tableViewer, TableItem tableItem, String comboName, String comboPaneName, String editorName, int columnIndex, String[] relationalOperators, SelectionListener dropDownSelectionListener, ModifyListener modifyListener,FocusListener focusListener) { final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE); buttonPane.setLayout(new FillLayout()); final CCombo combo = new CCombo(buttonPane, SWT.NONE); combo.setItems(relationalOperators); combo.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem)); tableItem.setData(comboName, combo); tableItem.setData(comboPaneName, buttonPane); combo.addSelectionListener(dropDownSelectionListener); combo.addModifyListener(modifyListener); combo.addFocusListener(focusListener); new AutoCompleteField(combo, new CComboContentAdapter(), combo.getItems()); final TableEditor editor = new TableEditor(tableViewer.getTable()); editor.grabHorizontal = true; editor.grabVertical = true; editor.setEditor(buttonPane, tableItem, columnIndex); editor.layout(); combo.setData(editorName, editor); return combo; }
private void addButtonInTable(TableViewer tableViewer, TableItem tableItem, String columnName, String buttonPaneName, String editorName, int columnIndex, SelectionListener buttonSelectionListener, ImagePathConstant imagePath) { final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE); buttonPane.setLayout(new FillLayout()); final Button button = new Button(buttonPane, SWT.NONE); //button.setText(columnName); button.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem)); tableItem.setData(columnName, button); tableItem.setData(buttonPaneName, buttonPane); button.addSelectionListener(buttonSelectionListener); button.setImage(imagePath.getImageFromRegistry()); final TableEditor editor = new TableEditor(tableViewer.getTable()); editor.grabHorizontal = true; editor.grabVertical = true; editor.setEditor(buttonPane, tableItem, columnIndex); editor.layout(); button.setData(editorName, editor); }
private void addCheckButtonInTable(TableViewer tableViewer, TableItem tableItem, String columnName, String groupPaneName, String editorName, int columnIndex, SelectionListener buttonSelectionListener) { final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE); buttonPane.setLayout(new FillLayout()); final Button button = new Button(buttonPane, SWT.CHECK); button.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem)); if(null != buttonSelectionListener){ button.addSelectionListener(buttonSelectionListener); } tableItem.setData(columnName, button); tableItem.setData(groupPaneName, buttonPane); final TableEditor editor = new TableEditor(tableViewer.getTable()); editor.grabHorizontal = true; editor.grabVertical = true; editor.setEditor(buttonPane, tableItem, columnIndex); editor.layout(); button.setData(editorName, editor); }
@Override protected SelectionListener getBrowseButtonSelectionListener(final Shell shell) { return new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { String initialPath = projectFileTabPage.getConfigFolderText(); if (initialPath.length() == 0) { initialPath = null; } final ServerItemSource serverItemSource = new VersionedItemSource(buildServer.getConnection()); final ServerItemTreeDialog dialog = new ServerItemTreeDialog( projectFileTabPage.getControl().getShell(), Messages.getString("BuildDefinitionDialog.BrowseDialogTitle"), //$NON-NLS-1$ initialPath, serverItemSource, ServerItemType.ALL_FOLDERS); if (IDialogConstants.OK_ID == dialog.open()) { projectFileTabPage.getControl().getConfigFolderText().setText(dialog.getSelectedServerPath()); validate(); } } }; }
@Override protected SelectionListener getCreateButtonSelectionListener(final Shell shell) { return new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final CreateBuildConfigurationWizard wizard = new CreateBuildConfigurationWizard(); // update the build definition to contain values as // currently defined, that way // information inside is available in the creation wizard. updateAndVerifyBuildDefinition(true); wizard.init(buildDefinition); final WizardDialog dialog = new WizardDialog(getShell(), wizard); final int rc = dialog.open(); if (rc == IDialogConstants.OK_ID) { checkForBuildFileExistence(true); validate(); } } }; }
private SelectionListener getSelectionListener() { SelectionListener selectionListener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (e.getSource() == selectFromRevisionButton) { showLog(fromRevisionText); } else if (e.getSource() == toHeadButton || e.getSource() == toRevisionButton) { toRevisionText.setEnabled(toRevisionButton.getSelection()); selectToRevisionButton.setEnabled(toRevisionButton.getSelection()); if (toRevisionButton.getSelection()) toRevisionText.setFocus(); } else if (e.getSource() == selectToRevisionButton) { showLog(toRevisionText); } setPageComplete(canFinish()); } }; return selectionListener; }
private SelectionListener showDefaultOrCustomValueListener(final String defaultValue) { return new SelectionAdapter() { private String customValue = ""; //$NON-NLS-1$ @Override public void widgetSelected(SelectionEvent event) { boolean customLocation = !useDefaultLocation.getSelection(); // Update the targetCreator targetCreator.setCustomLocation(customLocation); // Enable/disable the location inputs as appropriate locationBrowse.setEnabled(customLocation); locationInput.setEnabled(customLocation); // Capture the current customValue if we're disabling custom values. if (!customLocation) { customValue = locationInput.getText(); } // Update the locationInput box locationInput.setText(customLocation ? customValue : defaultValue); } }; }
/** * Creates a new MenuItem. */ public static MenuItem newMenuItem(final Menu parent, final int style, final String text, final SelectionListener selectionListener) { if (Thread.currentThread() != getDisplay().getThread()) { Resultable res = new Resultable() {public void run() {result = newMenuItem(parent, style, text, selectionListener);}}; getDisplay().syncExec(res); return (MenuItem) res.result; } else { MenuItem menuItem = new MenuItem(parent, style); if (text != null) { menuItem.setText(text); } if (selectionListener != null) { menuItem.addSelectionListener(selectionListener); } return menuItem; } }
public void removeMetadataListener(Listener listener) { if (listener == null) return; pageStyleCombo.removeSelectionListener((SelectionListener)listener); if (regionTypeCombo!=null) regionTypeCombo.removeSelectionListener((SelectionListener)listener); structureText.removeModifyListener((ModifyListener) listener); for (Button b : structureRadios) b.removeSelectionListener((SelectionListener) listener); applyStructBtn.removeSelectionListener((SelectionListener)listener); applyStructRecBtn.removeSelectionListener((SelectionListener) listener); linkList.removeSelectionListener((SelectionListener) listener); deleteLinkMenuItem.removeSelectionListener((SelectionListener) listener); linkBtn.removeSelectionListener((SelectionListener) listener); breakLinkBtn.removeSelectionListener((SelectionListener) listener); shapeTypeCombo.removeSelectionListener((SelectionListener) listener); }
public void removeTextStyleListener(Listener listener) { if (listener == null) return; bgColorCombo.removeSelectionListener((SelectionListener)listener); boldCheck.removeSelectionListener((SelectionListener)listener); fontFamilyText.removeModifyListener((ModifyListener)listener); fontSizeSpinner.removeSelectionListener((SelectionListener)listener); italicCheck.removeSelectionListener((SelectionListener)listener); kerningSpinner.removeSelectionListener((SelectionListener)listener); letterSpacedCheck.removeSelectionListener((SelectionListener)listener); monospaceCheck.removeSelectionListener((SelectionListener)listener); reverseVideoCheck.removeSelectionListener((SelectionListener)listener); serifCheck.removeSelectionListener((SelectionListener)listener); smallCapsCheck.removeSelectionListener((SelectionListener)listener); strikethroughCheck.removeSelectionListener((SelectionListener)listener); underlinedCheck.removeSelectionListener((SelectionListener)listener); subscriptCheck.removeSelectionListener((SelectionListener)listener); superscriptCheck.removeSelectionListener((SelectionListener)listener); textColorCombo.removeSelectionListener((SelectionListener)listener); applyBtn.removeSelectionListener((SelectionListener)listener); applyRecursiveBtn.removeSelectionListener((SelectionListener)listener); }
public void addTextStyleListener(Listener listener) { if (listener == null) return; this.listener = listener; bgColorCombo.addSelectionListener((SelectionListener)listener); boldCheck.addSelectionListener((SelectionListener)listener); fontFamilyText.addModifyListener((ModifyListener)listener); fontSizeSpinner.addSelectionListener((SelectionListener)listener); italicCheck.addSelectionListener((SelectionListener)listener); kerningSpinner.addSelectionListener((SelectionListener)listener); letterSpacedCheck.addSelectionListener((SelectionListener)listener); monospaceCheck.addSelectionListener((SelectionListener)listener); reverseVideoCheck.addSelectionListener((SelectionListener)listener); serifCheck.addSelectionListener((SelectionListener)listener); smallCapsCheck.addSelectionListener((SelectionListener)listener); strikethroughCheck.addSelectionListener((SelectionListener)listener); underlinedCheck.addSelectionListener((SelectionListener)listener); subscriptCheck.addSelectionListener((SelectionListener)listener); superscriptCheck.addSelectionListener((SelectionListener)listener); textColorCombo.addSelectionListener((SelectionListener)listener); applyBtn.addSelectionListener((SelectionListener)listener); applyRecursiveBtn.addSelectionListener((SelectionListener)listener); }
@Override public void widgetSelected(SelectionEvent e) { // e.doit = false; if (e.getSource() instanceof Button) { Button b = (Button) e.getSource(); String text = b.getText(); if (!text.isEmpty()) { Event e1 = new Event(); e1.widget = VirtualKeyboard.this; e1.detail = text.charAt(0); e1.text = b.getToolTipText(); for (SelectionListener l : selListener) { l.widgetSelected(new SelectionEvent(e1)); } } } }
public static void addSelectionListener(Widget w, SelectionListener l) { if (w instanceof MenuItem) addSelectionListener((MenuItem) w, l); else if (w instanceof ToolItem) addSelectionListener((ToolItem) w, l); else if (w instanceof Button) addSelectionListener((Button) w, l); else if (w instanceof DropDownToolItem) { addSelectionListener((DropDownToolItem) w, l); } else if (w instanceof CTabFolder) { addSelectionListener((CTabFolder) w, l); } else if (w instanceof Combo){ addSelectionListener((Combo) w, l); } else throw new RuntimeException("Widget type not supported for selection events: " + w); }
protected Button createButton(Composite parent, String label, SelectionListener listener) { Button button = new Button(parent, SWT.PUSH); button.setFont(parent.getFont()); button.setText(label); button.addSelectionListener(listener); GridData gd = new GridData(); gd.horizontalAlignment = GridData.FILL; gd.grabExcessHorizontalSpace = true; gd.verticalAlignment = GridData.BEGINNING; gd.widthHint = SWTUtil.getButtonWidthHint(button); button.setLayoutData(gd); return button; }
/** * Adds a {@link SelectionListener} to the {@link #spinner}. If the widget * has not yet been created, the listener will be added when the widget is * created. * * @param listener * The listener to add. */ public void addSelectionListener(final SelectionListener listener) { if (spinner != null) { spinner.getDisplay().asyncExec(new Runnable() { @Override public void run() { spinner.addSelectionListener(listener); } }); } else { if (selectionListeners == null) { selectionListeners = new ArrayList<SelectionListener>(); } selectionListeners.add(listener); } return; }
@Override protected Control createControl(Composite parent) { spinner = new Spinner(parent, style); spinner.setBackground(parent.getBackground()); spinner.setMinimum(minimum); spinner.setMaximum(maximum); spinner.setSelection(selection); spinner.setIncrement(increment); if (selectionListeners != null) { for (SelectionListener l : selectionListeners) { spinner.addSelectionListener(l); } } return spinner; }
public HyperlinkInfoPopupDialog(Shell parentShell, String title, String message, SelectionListener selectionListener) { super(parentShell, title, message); if (selectionListener == null) { selectionListener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String text = e.text; if (!StringUtil.isEmpty(text)) { WorkbenchBrowserUtil.openURL(text); } } }; } this.selectionListener = selectionListener; // Null out the click listener. This dialog only listens for the closing of the dialog and hyper-link navigation clickListener = null; }
/** * Creates the columns for the history table. */ private void createColumns(Table table, TableLayout layout) { SelectionListener headerListener = getColumnListener(); // action TableColumn col = new TableColumn(table, SWT.NONE); col.setResizable(true); col.setText(Policy.bind("ChangePathsTableProvider.action")); //$NON-NLS-1$ col.addSelectionListener(headerListener); layout.addColumnData(new ColumnWeightData(10, true)); // path col = new TableColumn(table, SWT.NONE); col.setResizable(true); col.setText(Policy.bind("ChangePathsTableProvider.path")); //$NON-NLS-1$ col.addSelectionListener(headerListener); layout.addColumnData(new ColumnWeightData(45, true)); table.setSortColumn(col); // description col = new TableColumn(table, SWT.NONE); col.setResizable(true); col.setText(Policy.bind("ChangePathsTableProvider.description")); //$NON-NLS-1$ col.addSelectionListener(headerListener); layout.addColumnData(new ColumnWeightData(50, true)); }
private void createGwtSdkGroup(Group sdkGroup, SelectionListener useSdkCheckboxSelectionListener, int widthIndent) { useGwtCheckbox = new Button(sdkGroup, SWT.CHECK); useGwtCheckbox.addSelectionListener(useSdkCheckboxSelectionListener); useGwtCheckbox.setText("Use GWT"); useGwtCheckbox.setSelection(true); gwtSelectionBlock = new GwtWorkspaceSdkSelectionBlock(sdkGroup, SWT.NONE); gwtSelectionBlock.addSdkSelectionListener(new SdkSelectionBlock.SdkSelectionListener() { @Override public void onSdkSelection(SdkSelectionEvent e) { updateControls(); } }); ((GridData) gwtSelectionBlock.getLayoutData()).horizontalIndent = widthIndent; }
private void createColumns(final Table table, final TableViewer viewer) { TableLayout layout = (TableLayout) table.getLayout(); final PackageSorter sorter = new PackageSorter(); viewer.setSorter(sorter); SelectionListener headerListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { int selectedCol = table.indexOf((TableColumn) e.widget); if (selectedCol == sorter.getPriority()) { sorter.reversePriority(); } else { sorter.setPriority(selectedCol); } viewer.refresh(); } }; for (int i = 0, lentgh = columnHeaders.length; i < lentgh; i++) { TableColumn column = new TableColumn(table, SWT.NONE); column.setResizable(true); column.setText(columnHeaders[i]); layout.addColumnData(columnLayouts[i]); column.addSelectionListener(headerListener); } }
/** * Creates button with {@link org.eclipse.swt.SWT#PUSH} style. Provided parameters control other aspects of the * button. * * @param parent * the parent used to create the button. * @param text * the text used to set text of the button. * @param listener * the listener added to the button. * @param enabled * flag controls if created button is enabled. * @return created button. */ public static Button createPushButton(final Composite parent, final String text, final SelectionListener listener, boolean enabled) { final Button button = new Button(parent, PUSH); button.setLayoutData(fillDefaults().align(FILL, CENTER).create()); button.setText(text); if (null != listener) { button.addSelectionListener(listener); button.addDisposeListener(e -> { button.removeSelectionListener(listener); }); } button.setEnabled(enabled); return button; }
private Button addButton(Composite parent, int style, String label, int indentation, SelectionListener listener) { Button button = new Button(parent, style); button.setText(label); GridData gd = new GridData(32); gd.horizontalIndent = indentation; gd.horizontalSpan = 2; button.setLayoutData(gd); button.addSelectionListener(listener); return button; }
/** * Initializes the {@link InfoBar} with "Yes" and "No" {@link Button buttons}. * * @param managedForm The {@link IManagedForm} instance. * @param yesListener The {@link SelectionListener} to handle the Yes button selection. */ protected void initYesNoInfoBar(IManagedForm managedForm, SelectionListener yesListener, SelectionListener noListener) { InfoBar infoBar = getInfoBar(); FormToolkit toolkit = managedForm.getToolkit(); Button yesButton = toolkit.createButton(infoBar, "Yes", SWT.PUSH); if (yesListener != null) { yesButton.addSelectionListener(yesListener); } Button noButton = toolkit.createButton(infoBar, "No", SWT.PUSH); if (noListener != null) { noButton.addSelectionListener(noListener); } FormData yesButtonFormData = new FormData(); yesButtonFormData.top = new FormAttachment(0, 0); yesButtonFormData.right = new FormAttachment(noButton); yesButton.setLayoutData(yesButtonFormData); FormData noButtonFormData = new FormData(); noButtonFormData.top = new FormAttachment(0, 0); noButtonFormData.right = new FormAttachment(100, 0); noButton.setLayoutData(noButtonFormData); FormData labelFormData = new FormData(); labelFormData.top = new FormAttachment(yesButton, 0, SWT.CENTER); labelFormData.left = new FormAttachment(0, 0); infoBar.getLabel().setLayoutData(labelFormData); }
private MenuItem addMenuItem(Menu menu, String text, int accelerator, Object data, SelectionListener listener) { MenuItem item = new MenuItem(menu, SWT.NONE); item.setText(text); item.addSelectionListener(listener); if (accelerator != SWT.NONE) item.setAccelerator(accelerator); item.setData(data); return item; }
private MenuItem addConfigurableMenuItem(Menu menu, final String orgText, final String acceleratorKey, SelectionListener listener) { char accelerator = Config.getInstance().getString(acceleratorKey) .toUpperCase().charAt(0); int acc = SWT.MOD1 + (accelerator == ' ' ? SWT.SPACE : accelerator); String text = orgText + " \t Ctrl+" + (accelerator == ' ' ? "[space]" : accelerator); final MenuItem item = addMenuItem(menu, text, acc, listener); Config.getInstance().addPropertyChangeListener( new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { if (arg0.getProperty().equals(acceleratorKey)) updateAccelerator(item, orgText, Config .getInstance().getString(acceleratorKey) .toUpperCase().charAt(0)); } }); return item; }
private MenuItem addMenuItem(Menu menu, String text, SelectionListener listener) { MenuItem item = new MenuItem(menu, SWT.NONE); item.setText(text); item.addSelectionListener(listener); return item; }
private MenuItem addMenuItem(Menu menu, String text, int accelerator, SelectionListener listener) { MenuItem item = addMenuItem(menu, text, listener); if (accelerator != SWT.NONE) item.setAccelerator(accelerator); return item; }
private MenuItem addMenuItem(Menu menu, String text, int accelerator, SelectionListener listener, Image icon) { MenuItem item = addMenuItem(menu, text, accelerator, listener); item.setImage(icon); return item; }
void fireSelectionEvent() { final Event event = new Event(); event.widget = this.parentBreadcrumb; event.display = getDisplay(); event.item = this; event.type = SWT.Selection; for (final SelectionListener selectionListener : this.selectionListeners) { selectionListener.widgetSelected(new SelectionEvent(event)); } }
@Override public void attachToPropertySubGroup(AbstractELTContainerWidget container) { ELTDefaultSubgroupComposite eltSuDefaultSubgroupComposite = new ELTDefaultSubgroupComposite(container.getContainerControl()); eltSuDefaultSubgroupComposite.createContainerWidget(); eltSuDefaultSubgroupComposite.numberOfBasicWidgets(4); AbstractELTWidget eltDefaultLable = new ELTDefaultLable("Retain"); eltSuDefaultSubgroupComposite.attachWidget(eltDefaultLable); setPropertyHelpWidget((Control) eltDefaultLable.getSWTWidgetControl()); SelectionListener selectionListener = new SelectionAdapter () { @Override public void widgetSelected(SelectionEvent event) { Button button = ((Button) event.widget); properties = button.getText(); propertyDialogButtonBar.enableApplyButton(true); logger.debug( "Radio Button Value",button.getText()); // button.getSelection(); }; }; First = new ELTRadioButton("First"); eltSuDefaultSubgroupComposite.attachWidget(First); ((Button) First.getSWTWidgetControl()).addSelectionListener(selectionListener); //button=(Button) First.getSWTWidgetControl(); Last = new ELTRadioButton("Last"); eltSuDefaultSubgroupComposite.attachWidget(Last); ((Button) Last.getSWTWidgetControl()).addSelectionListener(selectionListener); Unique = new ELTRadioButton("Unique"); eltSuDefaultSubgroupComposite.attachWidget(Unique); ((Button) Unique.getSWTWidgetControl()).addSelectionListener(selectionListener); populateWidget(); }
public GridComposite(Composite parent, int style) { super(parent, style); if (parent instanceof GridComposite) { GridComposite gcp = (GridComposite) parent; if (gcp.selectionListener != null) setSelectionListener(gcp.selectionListener); } else { if (this instanceof SelectionListener) { // System.err.println("Setting self selectionListener"); setSelectionListener((SelectionListener) this); } } }
public static Button newButton(Composite parent, String title, SelectionListener action) { Button button = new Button(parent, SWT.PUSH); button.setText(Translate.getInstance().buttonName(title)); button.setFont(FontShop.dialogFont()); /* Apply layoutdata to button */ setButtonLayoutData(button); button.addSelectionListener(action); return button; }
public void setSelectionListener(SelectionListener selectionListener) { if (this.selectionListener != null) { if (this.selectionListener != selectionListener) { System.err.println("Change setSelectionListener!"); assert (this.selectionListener == selectionListener); } else { System.err.println("Dup Call To setSelectionListener"); } } this.selectionListener = selectionListener; }
void initTemplateComponent(Composite parent) { if (templates.size() == 0) { return; } String[] items = new String[templates.size()]; for (int i = 0; i < items.length; i++) { items[i] = templates.get(i).getName(); } templateList.setFont(parent.getFont()); templateList.setItems(items); if (context.getSelectedTemplate() == null) { templateList.select(0); handleTemplateSelection(0); } SelectionListener listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { int index = templateList.getSelectionIndex(); handleTemplateSelection(index); } }; templateList.addSelectionListener(listener); }
protected Button createButton( final Composite parent, final String text, final SelectionListener selectionListener) { final Button button = new Button(parent, SWT.NONE); button.setText(text); button.addSelectionListener(selectionListener); final GridData gd = new GridData(); gd.horizontalAlignment = SWT.FILL; button.setLayoutData(gd); return button; }