/** * Gets the text box value 1 listener. * * @param conditionsList * the conditions list * @param fieldsAndTypes * the fields and types * @param fieldNames * the field names * @param saveButton * the save button * @param displayButton * the display button * @return the text box value 1 listener */ public Listener getTextBoxValue1Listener(final List<Condition> conditionsList, final Map<String, String> fieldsAndTypes, final String[] fieldNames, final Button saveButton, final Button displayButton) { Listener listener = new Listener() { @Override public void handleEvent(Event event) { Text text = (Text)event.widget; int index = (int) text.getData(FilterConstants.ROW_INDEX); Condition filterConditions = conditionsList.get(index); filterConditions.setValue1(text.getText()); validateText(text, filterConditions.getFieldName(), fieldsAndTypes, filterConditions.getConditionalOperator()); toggleSaveDisplayButton(conditionsList, fieldsAndTypes, fieldNames, saveButton, displayButton); } }; return listener; }
@Override protected void configureShell(Shell newShell) { super.configureShell(newShell); this.currentShell = newShell; this.currentShell.setText(this.title); this.currentShell.getDisplay().addFilter(SWT.Traverse, new Listener() { @Override public void handleEvent(Event event) { switch (event.detail) { case SWT.TRAVERSE_ESCAPE: event.doit = false; cancelPressed(); break; default: break; } } }); }
public void open() { final Shell shell = new Shell(getParent(), getStyle()); shell.setText("Find/replace"); createContents(shell); shell.pack(); shell.open(); Listener researcherListener = new Listener() { public void handleEvent(Event event) { if (resultsIterator != null) resultsIterator = null; } }; text.addListener(SWT.Modify, researcherListener); Display display = getParent().getDisplay(); while (!shell.isDisposed()) if (!display.readAndDispatch()) display.sleep(); text.removeListener(SWT.Modify, researcherListener); clearSearchResults(); }
private void renderTransparency(final Shell shell) { Group group = new Group(shell, SWT.NONE); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 6, 1)); group.setLayout(new GridLayout(1, false)); group.setText("Transparency"); final Scale transparencySlider = new Scale(group, SWT.HORIZONTAL); transparencySlider.setMinimum(20); transparencySlider.setMaximum(100); transparencySlider.setPageIncrement(90); transparencySlider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); transparencySlider.setSelection(100); transparencySlider.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { shell.setAlpha(255 * transparencySlider.getSelection() / 100); } }); }
/** * Create contents of the dialog. * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); Link link = new Link(container, SWT.NONE); link.setText("Your project has been successfully deployed.\n\nYou can try it with this URL:\n<a href=\""+ projectURL + "\">" + projectURL + "</a>"); link.addListener (SWT.Selection, new Listener () { public void handleEvent(Event event) { org.eclipse.swt.program.Program.launch(event.text); } }); link.setSize(330, 150); return container; }
public GeneratorChoiceComposite(Composite parent, int style, IStructuredSelection selection, Listener listener) { super(parent, style); setLayout(new GridLayout(12, false)); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; setLayoutData(gridData); this.listener = listener; this.selection = selection; IFile file = (IFile) selection.getFirstElement(); loadAncestor(file); findStartElement () ; Label explanationLabel = new Label(this, SWT.NONE); explanationLabel.setLayoutData(new GridData(SWT.FILL)); explanationLabel.setText(MessageUtil.getString("three_modes_explanation")); skip(this); createAppendMode(); createExtendMode(); createNewMode(); }
private void buildLeftColumn() { final Composite composite = new Composite(this.shell, SWT.NONE); final GridData gd = new GridData(GridData.FILL, GridData.BEGINNING, false, true, 1, 1); composite.setLayoutData(gd); final FillLayout compositeLayout = new FillLayout(); compositeLayout.marginWidth = 2; composite.setLayout(compositeLayout); final Label label = new Label(composite, SWT.NONE); if (this.image == null) { this.image = new Image(display, this.getClass().getClassLoader() .getResourceAsStream("images/document_wrench_color.png")); shell.addListener(SWT.Close, new Listener() { @Override public void handleEvent(Event event) { image.dispose(); } }); } label.setImage(this.image); }
private void buildLeftColumn() { final Composite composite = new Composite(this.shell, SWT.NONE); final GridData gd = new GridData(GridData.FILL, GridData.BEGINNING, false, true, 1, 1); composite.setLayoutData(gd); final FillLayout compositeLayout = new FillLayout(); compositeLayout.marginWidth = 2; composite.setLayout(compositeLayout); final Label label = new Label(composite, SWT.NONE); if (this.image == null) { this.image = new Image(display, this.getClass().getClassLoader() .getResourceAsStream("images/light1.png")); shell.addListener(SWT.Close, new Listener() { @Override public void handleEvent(Event event) { image.dispose(); } }); } label.setImage(this.image); }
private void attachMouseScrollButtonListener(final ScrolledComposite scrolledComposite){ scrolledComposite.addListener(SWT.MouseWheel, new Listener() { @Override public void handleEvent(Event event) { int wheelCount = event.count; wheelCount = (int) Math.ceil(wheelCount / 3.0f); while (wheelCount < 0) { scrolledComposite.getVerticalBar().setIncrement(4); wheelCount++; } while (wheelCount > 0) { scrolledComposite.getVerticalBar().setIncrement(-4); wheelCount--; } } }); }
@Override public void created(final MainStatusBar.CLabelPadding label) { final Listener click_listener = new Listener() { @Override public void handleEvent(Event e) { onClick(); } }; Utils.execSWTThread(new AERunnable() { @Override public void runSupport() { label.addListener(SWT.MouseDoubleClick, click_listener); } }, true); }
@Override public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helper, Widget... widgets) { final Widget[] widgetList = widgets; if (helper != null){ txtDecorator = (ControlDecoration) helper.get(HelperType.CONTROL_DECORATION); } Listener listener = new Listener() { @Override public void handleEvent(Event event) { String charSet = ((Text) widgetList[0]).getText(); if(SWT.FocusIn == event.type) { if (StringUtils.isEmpty(charSet)) { txtDecorator.show(); ((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255)); ((Text) widgetList[0]).setToolTipText(txtDecorator.getDescriptionText()); } else { txtDecorator.hide(); } } } }; return listener; }
@Override public Listener getListener( PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helper, Widget... widgets) { final Widget[] widgetList = widgets; if (helper != null) { txtDecorator = (ControlDecoration) helper.get(HelperType.CONTROL_DECORATION); } Listener listener = new Listener() { @Override public void handleEvent(Event event) { String charSet = ((Text) widgetList[0]).getText().trim(); if (event.type == SWT.FocusIn) { ((Text) widgetList[0]).setText(charSet.replace("@{", "").replace("}", "")); } } }; return listener; }
@Override public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helper, Widget... widgets) { if (helper != null) { txtDecorator = (ControlDecoration) helper.get(HelperType.CONTROL_DECORATION); } Listener listener=new Listener() { @Override public void handleEvent(Event event) { String string=event.text; Matcher matchs=Pattern.compile("[\\d]*").matcher(string); if(!matchs.matches()){ txtDecorator.setDescriptionText(Messages.FIELDBATCH); txtDecorator.show(); event.doit=false; }else txtDecorator.hide(); } }; return listener; }
public IntListParameter(Composite composite, final String name, int defaultValue, final String labels[], final int values[]) { super(name); this.name = name; this.values = values; if(labels.length != values.length) return; int value = COConfigurationManager.getIntParameter(name,defaultValue); int index = findIndex(value,values); list = new Combo(composite,SWT.SINGLE | SWT.READ_ONLY); for(int i = 0 ; i < labels.length ;i++) { list.add(labels[i]); } setIndex(index); list.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { setIndex(list.getSelectionIndex()); } }); }
@Override public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Widget... widgets) { final Widget[] widgetList = widgets; Listener listener = new Listener() { @Override public void handleEvent(Event event) { if (StringUtils.equalsIgnoreCase(((Button) widgetList[0]).getText(), String.valueOf(FAST_LOAD)) && ((Button) widgetList[0]).getSelection() ) { MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_INFORMATION | SWT.OK); messageBox.setText(INFORMATION); messageBox.setMessage(Messages.FAST_LOAD_ERROR_MESSAGE); messageBox.open(); } } }; return listener; }
@Override public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar,ListenerHelper helpers, Widget... widgets) { final Widget[] widgetList = widgets; Listener listener=new Listener() { @Override public void handleEvent(Event event) { if (((Button)widgetList[0]).getSelection()) { ((Button)widgetList[1]).setEnabled(false); ((Button)widgetList[2]).setEnabled(false); ((Button)widgetList[3]).setEnabled(false); } else { ((Button)widgetList[1]).setEnabled(true); ((Button)widgetList[2]).setEnabled(true); ((Button)widgetList[3]).setEnabled(true); } } }; return listener; }
@Override public Listener getListener(final PropertyDialogButtonBar propertyDialogButtonBar,final ListenerHelper helpers, Widget... widgets) { final Widget[] widgetList = widgets; if (helpers != null) { file_extension=(String)helpers.get(HelperType.FILE_EXTENSION); } Listener listener=new Listener() { @Override public void handleEvent(Event event) { FilterOperationClassUtility.INSTANCE.browseFile(file_extension, (Text) widgetList[0]); propertyDialogButtonBar.enableApplyButton(true); } }; return listener; }
@Override public Listener getListener( final PropertyDialogButtonBar propertyDialogButtonBar, final ListenerHelper helpers, Widget... widgets) { final Widget[] wigetList = widgets; Listener listener = new Listener() { @Override public void handleEvent(Event event) { if (event.type == SWT.CHANGED) { propertyDialogButtonBar.enableApplyButton(true); } } }; return listener; }
@Override public Listener getListener(final PropertyDialogButtonBar propertyDialogButtonBar, final ListenerHelper helpers, Widget... widgets) { final Widget[] widgetList = widgets; if (helpers != null) { widgetConfig = (WidgetConfig) helpers.get(HelperType.WIDGET_CONFIG); } Listener listener=new Listener() { @Override public void handleEvent(Event event) { String comboValue = ((Combo) widgetList[0]).getText(); if (comboValue.equals(Messages.CUSTOM)) { FilterOperationClassUtility.INSTANCE.createNewClassWizard((Text) widgetList[1], widgetConfig); if(helpers.get(HelperType.OPERATION_CLASS_DIALOG_OK_CONTROL) instanceof OperationClassDialog) { OperationClassDialog operationClassDialog=(OperationClassDialog)helpers.get(HelperType.OPERATION_CLASS_DIALOG_OK_CONTROL); operationClassDialog.getShell().setFocus(); } propertyDialogButtonBar.enableApplyButton(true); } } }; return listener; }
@Override public Listener getListener(final PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helper, Widget... widgets) { final Widget[] widgetList = widgets; Listener listener = new Listener() { @Override public void handleEvent(Event event) { if (StringUtils.equalsIgnoreCase(((Combo) widgetList[0]).getText(), String.valueOf(Boolean.TRUE))) { MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_INFORMATION | SWT.OK); messageBox.setText(INFORMATION); messageBox.setMessage("All files at given location will be overwritten."); messageBox.open(); } } }; return listener; }
@Override public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helper, Widget... widgets) { final Widget[] widgetList = widgets; Listener listener=new Listener() { @Override public void handleEvent(Event event) { String string=((Text) widgetList[0]).getText().trim(); Matcher matcher=Pattern.compile("[\\d]*").matcher(string); if(!matcher.matches() && StringUtils.isNotBlank(string)){ ((Text) widgetList[0]).setText(string.replace("@{", "").replace("}", "")); ((Text) widgetList[0]).setText("@{"+((Text) widgetList[0]).getText()+"}"); ((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255)); } } }; return listener; }
/** * Notifies the WindowRemovedListener handlers * @param sender A SWT shell that "sends" the events */ protected final void notifyRemoveListeners(Shell sender) { Iterator iter = removeHandlers.iterator(); for(int i = 0; i < removeHandlers.size(); i++) { ((Listener)iter.next()).handleEvent(getSWTEvent(sender)); } }
private ToolItem addItemToToolBar(ToolBar bar, String text, String toolTip, int type, Listener listener, Image icon) { ToolItem item = addItemToToolBar(bar, text, toolTip, type); if (listener != null) item.addListener(SWT.Selection, listener); if (icon != null) item.setImage(icon); return item; }
@Override public void addListener( int eventType, Listener listener ) { boolean wasListening = isListening( SWT.Selection ); super.addListener( eventType, listener ); if( eventType == SWT.Selection && !wasListening ) { remoteObject.listen( "Selection", true ); } }
/** * * Mouse click listener to set focus on tooltip container * * @param container * @return */ private Listener getMouseClickListener(final Composite container) { return new Listener() { @Override public void handleEvent(Event event) { logger.debug("ComponentTooltip.getMouseClickListener() - setting foucs to container"); container.setFocus(); } }; }
public static Observable<Event> displayFilter(Display display, int eventType) { checkNotNull(display, "display == null"); return new DisplayObservable(display, eventType) { @Override protected void addlistener(Listener listener) { display.addFilter(eventType, listener); } }; }
public static Observable<Event> displayListener(Display display, int eventType) { checkNotNull(display, "display == null"); return new DisplayObservable(display, eventType) { @Override protected void addlistener(Listener listener) { display.addListener(eventType, listener); } }; }
@Override public Listener makeSelectionListener(MenuItem menu_item) { final MenuItemImpl mii = (MenuItemImpl) menu_item; return new Listener() { @Override public void handleEvent(Event e) { mii.invokeListenersMulti(objects); } }; }
/** * Create the keyboard handler for the directory pane. * These are keys that are <em>only</em> active in the directory * viewer. See createToolbarCommandHandler for the general application * keyboard handler. * @see #createToolbarCommandHandler */ private Listener createDirectoryKeyboardHandler() { return new Listener() { public void handleEvent(Event event) { if (event.type == SWT.KeyUp) { TreeItem[] treeItem = null; if ((event.stateMask & SWT.CTRL) != 0) { switch (event.character) { case '-': treeItem = getDirectoryTree().getSelection(); setDirectoryExpandedStates(treeItem[0], false); break; case '+': treeItem = getDirectoryTree().getSelection(); setDirectoryExpandedStates(treeItem[0], true); break; } } else { // assume no control and no alt switch (event.character) { case '-': treeItem = getDirectoryTree().getSelection(); treeItem[0].setExpanded(false); break; case '+': treeItem = getDirectoryTree().getSelection(); treeItem[0].setExpanded(true); break; } } } } }; }
private void createAppendMode() { btnAppendRadioButton = new Button(this, SWT.RADIO); btnAppendRadioButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 12, 1)); btnAppendRadioButton.setText(MessageUtil.getString("append_mode")); btnAppendRadioButton.setSelection(true); btnAppendRadioButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { switch (e.type) { case SWT.Selection: updateUI(); break; } } }); btnAppendRadioButton.setData(GW4E_CONVERSION_WIDGET_ID, GW4E_APPEND_CHECKBOX); Composite composite = new Composite(this, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 12, 1)); composite.setLayout(new GridLayout(12, false)); lblAppendClassNameLabel = new Label(composite, SWT.NONE); lblAppendClassNameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1)); lblAppendClassNameLabel.setText("Class name"); comboAppendClassnameViewer = new AncestorViewer(composite); comboAppendClassnameViewer.initialize(GW4E_CONVERSION_COMBO_ANCESTOR_EXTEND_TEST, false); comboAppendClassnameViewer.getCombo().setData(GW4E_CONVERSION_WIDGET_ID, GW4E_CONVERSION_COMBO_ANCESTOR_APPEND_TEST); Combo combo = comboAppendClassnameViewer.getCombo(); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 8, 1)); combo.setEnabled(true); }
private void createNewMode() { btnCreateNewRadioButton = new Button(this, SWT.RADIO); btnCreateNewRadioButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 12, 1)); btnCreateNewRadioButton.setText(MessageUtil.getString("standalone_mode")); btnCreateNewRadioButton.setSelection(false); btnCreateNewRadioButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { switch (e.type) { case SWT.Selection: updateUI(); break; } } }); btnCreateNewRadioButton.setData(GW4E_CONVERSION_WIDGET_ID, GW4E_NEWCLASS_CHECKBOX); Composite composite = new Composite(this, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 12, 1)); composite.setLayout(new GridLayout(12, false)); lblNewClassnameLabel = new Label(composite, SWT.NONE); lblNewClassnameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1)); lblNewClassnameLabel.setText("Class name"); lblNewClassnameLabel.setEnabled(false); newClassnameText = new Text(composite, SWT.BORDER); newClassnameText.setEnabled(false); newClassnameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { listener.handleEvent(null); } }); newClassnameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 8, 1)); newClassnameText.setEnabled(false); newClassnameText.setData(GW4E_CONVERSION_WIDGET_ID, GW4E_NEWCLASS_TEXT); }
public void init (Listener listener,GridData gd) { getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); getTable().setLayoutData(gd); setContentProvider(new IStructuredContentProvider() { @Override public Object[] getElements(Object inputElement) { BuildPolicy[] ret = (BuildPolicy[]) inputElement; return ret; } }); setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { BuildPolicy bp = (BuildPolicy) element; return bp.getPathGenerator(); } }); getTable().addListener(SWT.Resize, new Listener() { @Override public void handleEvent(Event event) { TableHelper.handleEvent(event); } }); TableColumn column = new TableColumn(getTable(), SWT.LEFT); column.setText(""); column.pack(); getTable().setHeaderVisible(true); getTable().setLinesVisible(true); getTable().addListener(SWT.Selection, listener); }
/** * The toolbar command handler contains the global toolbar * actions. The intent is that the listener is then added to * multiple visual components. */ public Listener createToolbarCommandHandler() { return new Listener() { public void handleEvent(Event event) { if (event.type == SWT.KeyUp) { if ((event.stateMask & SWT.CTRL) != 0) { // CTRL+key switch (event.character) { case CTRL_C: getContentTypeAdapter().copy(); break; case CTRL_A: getContentTypeAdapter().selectAll(); break; case CTRL_P: getContentTypeAdapter().print(); break; } } else if ((event.stateMask & SWT.ALT) == 0) { // key alone switch (event.keyCode) { case SWT.F2: // the "native" file format (image, text, etc) getNativeFilterAdapter().display(); setFilterToolItemSelection(true, false, false); break; case SWT.F3: // Hex format getHexFilterAdapter().display(); setFilterToolItemSelection(false, true, false); break; case SWT.F4: // "Raw" hex format getRawDumpFilterAdapter().display(); setFilterToolItemSelection(false, false, true); break; } } } } }; }
/** * Create the keyboard handler for the file pane. * These are keys that are <em>only</em> active in the file * viewer. See createToolbarCommandHandler for the general application * keyboard handler. * @see #createToolbarCommandHandler */ private Listener createFileKeyboardHandler() { return new Listener() { public void handleEvent(Event event) { FileEntry fileEntry = getSelectedFileEntry(); if (fileEntry != null && event.type == SWT.KeyUp && (event.stateMask & SWT.CTRL) != 0) { switch (event.character) { case CTRL_C: // Compile Wizard if (getCompileToolItem().isEnabled()) { compileFileWizard(); } break; case CTRL_D: // Delete file if (getDeleteToolItem().isEnabled()) { deleteFile(); } break; case CTRL_E: // Export Wizard exportFileWizard(); break; case CTRL_V: // View file viewFile(null); break; } } } }; }
@Override public void removeListener( int eventType, Listener listener ) { boolean wasListening = isListening( SWT.Selection ); super.removeListener( eventType, listener ); if( eventType == SWT.Selection && wasListening ) { if( !isListening( SWT.Selection ) ) { remoteObject.listen( "Selection", false ); } } }
protected void createButtonsForButtonBar(Composite parent) { // create OK and Cancel buttons by default okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); //do this here because setting the text will set enablement on the ok // button nameText.setFocus(); if (name != null) { nameText.setText(name); } if (value != null) { valueText.setText(value); } viewer.setInput(possibleParents); if (this.parent != null) { viewer.setSelection(new StructuredSelection(this.parent)); } viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged( SelectionChangedEvent event) { parentSelected(valueFromSelection(event.getSelection())); validateInput(); } }); viewer.getControl().addListener(SWT.Modify, new Listener() { @Override public void handleEvent(Event arg0) { validateInput(); } }); }
private void addMouseUpListener() { addListener(SWT.MouseUp, new Listener() { @Override public void handleEvent(final Event event) { for (final BreadcrumbItem item : Breadcrumb.this.items) { if (item.getBounds().contains(event.x, event.y)) { if (item.getData(IS_BUTTON_PRESSED) == null) { // The button was not pressed return; } item.setData(IS_BUTTON_PRESSED, null); if ((item.getStyle() & SWT.PUSH) != 0) { item.setSelection(false); } if ((item.getStyle() & (SWT.TOGGLE | SWT.PUSH)) != 0) { item.fireSelectionEvent(); redraw(); update(); } return; } } } }); }
private void addMouseHoverListener() { addListener(SWT.MouseHover, new Listener() { @Override public void handleEvent(final Event event) { for (final BreadcrumbItem item : Breadcrumb.this.items) { if (item.getBounds().contains(event.x, event.y)) { setToolTipText( item.getTooltipText() == null ? "" : item.getTooltipText()); return; } } } }); }
private Listener getMouseClickListener() { return new Listener() { @Override public void handleEvent(Event event) { for(AbstractWidget abstractWidget: eltWidgetList){ if(abstractWidget.getFirstTextWidget() != null){ abstractWidget.getFirstTextWidget().setFocus(); } } } }; }