@Override public Object[] getCheckedElements() { Object[] checked = super.getCheckedElements(); // add all items that are children of a checked node but not created yet ArrayList<Object> result = new ArrayList<>(); for (int i = 0; i < checked.length; i++) { Object curr = checked[i]; result.add(curr); Widget item = findItem(curr); if (item != null) { Item[] children = getChildren(item); // check if contains the dummy node if (children.length == 1 && children[0].getData() == null) { // not yet created collectChildren(curr, result); } } } return result.toArray(); }
/** * The Function will call to disable the widgets * @param textbox1 * @param textbox2 * @param buttonWidgets * @return Selection Adapter */ private SelectionAdapter buttonSelectionListener( Text textbox2,Widget... buttonWidgets){ Supplier<Stream<Widget>> streamSupplier = () -> Stream.of(buttonWidgets); SelectionAdapter adapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { newTableRadioButton.setSelection(false); textbox2.setEnabled(false); streamSupplier.get().forEach((Widget widgets) ->{((Button)widgets).setEnabled(false);}); if(OSValidator.isMac()){ ((Button)event.getSource()).setFocus(); } propertyDialogButtonBar.enableApplyButton(true); } }; return adapter; }
@Override public Listener getListener(final PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, final Widget... widgets) { final Button button = ((Button)widgets[0]); button.getShell(); if(helpers != null){ txtDecorator = (ControlDecoration) helpers.get(HelperType.CONTROL_DECORATION); file_extension=(String)helpers.get(HelperType.FILE_EXTENSION); } Listener listener=new Listener() { @Override public void handleEvent(Event event) { if(event.type==SWT.Selection){ FilterOperationClassUtility.INSTANCE.browseFile(file_extension,((Text) widgets[0])); propertyDialogButtonBar.enableApplyButton(true); txtDecorator.hide(); } } }; 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(Constants.REGEX).matcher(string); LOGGER.debug("Verifying text format"); if (!matchs.matches()) { txtDecorator.setDescriptionText(Messages.CHARACTERSET); txtDecorator.show(); event.doit = false; } else txtDecorator.hide(); } }; return listener; }
@Override public void selectionListenerAction( PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Widget... widgets) { ELTGridDetails gridDetails = (ELTGridDetails) helpers.get(HelperType.SCHEMA_GRID); Table table =gridDetails.getTableViewer().getTable(); int temp = table.getSelectionIndex(); int[] indexs=table.getSelectionIndices(); if (temp == -1) { WidgetUtility.errorMessage("Please Select row to delete"); } else { table.remove(indexs); ArrayList tempList= new ArrayList(); for (int index :indexs) { // PropertyField test =(PropertyField) gridDetails.getGrids().get(index); // tempList.add(test); } gridDetails.getGrids().removeAll(tempList); } }
@Override public void selectionListenerAction(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Widget... widgets) { propertyDialogButtonBar.enableApplyButton(true); table=(Table)widgets[0]; table.getParent().getShell().setFocus(); ((Button) widgets[1]).setEnabled(true); ELTGridDetails eltGridDetails = (ELTGridDetails)helpers.get(HelperType.SCHEMA_GRID); if (eltGridDetails.getGrids().size() >= 1) { ((Button) widgets[2]).setEnabled(true); ((Button) widgets[3]).setEnabled(true); } GridWidgetCommonBuilder gridCommonBuilder = eltGridDetails.getGridWidgetCommonBuilder(); gridCommonBuilder.setRowSequence(rowSequence); gridCommonBuilder.createDefaultSchema(eltGridDetails.getGrids(), eltGridDetails.getTableViewer(), eltGridDetails.getLabel()); rowSequence++; ((Component)helpers.get(HelperType.COMPONENT)).setLatestChangesInSchema(true); }
@Override public void selectionListenerAction(final PropertyDialogButtonBar propertyDialogButtonBar, final ListenerHelper helpers, Widget... widget) { ELTGridDetails gridDetails = (ELTGridDetails) helpers.get(HelperType.SCHEMA_GRID); final TableViewer tableViewer = gridDetails.getTableViewer(); final int columns = tableViewer.getCellEditors().length; final Widget[] widgets = widget; table=(Table)widgets[0]; if (!isKeyListenerAttached){ for (int i =0; i < columns; i++){ attachShortcutKeyListener(tableViewer.getCellEditors()[i].getControl(), propertyDialogButtonBar, helpers, widgets); } attachShortcutKeyListener(table, propertyDialogButtonBar, helpers, widgets); } }
@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(final 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) { if (((Combo) widgetList[0]).getText().equals("Parameter") || ((Combo) widgetList[0]).getText().equals("Others")) { ((Text) widgetList[1]).setVisible(true); ((Text) widgetList[1]).setFocus(); txtDecorator.hide(); } else { ((Text) widgetList[1]).setVisible(false); txtDecorator.hide(); } propertyDialogButtonBar.enableApplyButton(true); } }; 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[1]).getSelection()){ ControlDecoration fieldNameMustJava = WidgetUtility.addDecorator((Text)widgetList[0],Messages.INVALID_FILE); if(!WidgetUtility.isFileExtention((((Text)widgetList[0]).getText()).trim(), ".java") && !(((Text)widgetList[0]).getText().trim().isEmpty())){ fieldNameMustJava.show(); ((Text)widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 204)); } else { ((Text)widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255)); fieldNameMustJava.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(SWT.FocusIn == event.type) { if (StringUtils.isBlank(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( 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; }
@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(regex).matcher(string); logger.debug(this+"::ELTVerifyTextListener is called"); if(!matchs.matches()){ txtDecorator.setDescriptionText(errorMessage); txtDecorator.show(); event.doit=false; logger.trace("Pattern does not matches !matchs.matches() with :" + string); }else{ txtDecorator.hide(); logger.trace("Pattern matches with :" + string); } } }; return listener; }
/** * Handle all events and enablements for widgets in this page * * @param e * Event */ @Override public void handleEvent(Event e) { Widget source = e.widget; if (source == destinationBrowseButton) { handleDestinationBrowseButtonPressed(); } updatePageCompletion(); }
@Override public void handleEvent(Event event) { Widget source = event.widget; if (source == destinationBrowseButton) { handleDestinationBrowseButtonPressed(); } updatePageCompletion(); }
/** * Returns the widget. * * @return The widget */ public final Widget getWidget() { Object delegate = getDelegate(); if (delegate instanceof IWidgetProvider) { return ((IWidgetProvider) delegate).getWidget(); } return (Widget) delegate; }
public static boolean checkWidget(Observer<?> observer, Widget widget) { if (null == widget) { observer.onError(new NullPointerException("The given widget was null")); return false; } else if (widget.isDisposed()) { observer.onError(new IllegalStateException("The given widget is diposed")); return false; } else if (!(Thread.currentThread().equals(widget.getDisplay().getThread()))) { observer.onError(new IllegalStateException( "Expected to be called on the main thread but was " + Thread.currentThread().getName())); return false; } return true; }
/** * */ @Override protected boolean accepts(Context context, Event event) { // final Widget widget = event.widget; if(calendar == null || calendar.isDisposed()) return false; // final Shell shell = calendar.getShell(); if(widget != calendar && widget != shell) return false; return isMouseEvent(event) || event.type == SWT.Deactivate; }
private SWTBotView waitForConsoleBeDisplayed () { getConsoleView(bot); Matcher<Widget> console = getConsoleMatcher () ; bot.waitUntil(Conditions.waitForWidget(console)); SWTBotView consoleView = getConsoleView(bot); consoleView.setFocus(); return consoleView; }
/** * Update element after a checkstate change. * @param element */ protected void doCheckStateChanged(Object element) { Widget item = findItem(element); if (item instanceof TreeItem) { TreeItem treeItem = (TreeItem) item; treeItem.setGrayed(false); updateChildrenItems(treeItem); updateParentItems(treeItem.getParentItem()); } }
public static void exec(Widget w, Runnable r) { try { exec(w.getDisplay(), r); } catch (SWTException ex) { if (ex.code != SWT.ERROR_WIDGET_DISPOSED) { throw ex; } // do nothing: UI is already dead } }
private void updateWidgetsValue(Widget... widgets){ if(optionList.length >1){ for(int i = 0; i <= widgets.length - 1; i++){ if(widgets[i] != null && !widgets[i].isDisposed()){ ((Text)widgets[i]).setText("");; } } } }
/** * Create Label Widget * @param control * @param widgetName * @return */ public Widget createLabel(Composite control, String widgetName){ Label label = new Label(control, SWT.NONE); GridData label_gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); label.setLayoutData(label_gridData); label.setText(widgetName); return label; }
/** * Create Text Widget * @param control * @param widgetName * @return */ public Widget createText(Composite control, String widgetName, int style){ Text text = new Text(control, style); GridData gd_text = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_text.horizontalIndent = 10; text.setLayoutData(gd_text); text.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 204)); return text; }
/** * Create Combo Widget * @param control * @param widgetName * @return */ public Widget CreateCombo(Composite control, String[] widgetName){ Combo combo = new Combo(control, SWT.READ_ONLY); combo.setItems(widgetName); combo.select(0); GridData gd_partitionKeyButton = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_partitionKeyButton.horizontalIndent = 10; combo.setLayoutData(gd_partitionKeyButton); return combo; }
private void updateWidgetsValue(Widget... widgets){ for(int i = 0; i <= widgets.length - 1; i++){ if(widgets[i] != null && !widgets[i].isDisposed()){ ((Text)widgets[i]).setText("");; } } }
private void addButtonListener(final MappingSheetRow mappingSheetRow, final TableViewer operationalInputFieldTableViewer,Widget addButton) { addButton.addListener(SWT.MouseUp, new Listener(){ @Override public void handleEvent(Event event) { operationInputTableAddButton(mappingSheetRow, operationalInputFieldTableViewer); } }); }
@Override public Listener getListener( final PropertyDialogButtonBar propertyDialogButtonBar, final ListenerHelper helper, final Widget... widgets) { Listener listener = new Listener() { @Override public void handleEvent(Event event) { selectionListenerAction(propertyDialogButtonBar,helper, widgets); } }; return listener; }
@Override public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Widget... widgets) { if (helpers != null) { txtDecorator = (ControlDecoration) helpers.get(HelperType.CONTROL_DECORATION); txtDecorator.hide(); } Listener listener = new Listener() { @Override public void handleEvent(Event event) { String charSet = ((Text) widgets[0]).getText().trim(); if (SWT.FocusOut == event.type) { Matcher matchs=Pattern.compile(Constants.PORT_VALIDATION_REGEX).matcher(charSet); if (StringUtils.isBlank(charSet)){ txtDecorator.show(); ((Text) widgets[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 204)); ((Text) widgets[0]).setToolTipText(txtDecorator.getDescriptionText()); } else if (matchs.matches()||ParameterUtil.isParameter(charSet)) { txtDecorator.hide(); }else{ txtDecorator.show(); } } } }; 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); txtDecorator.hide(); } Listener listener = new Listener() { @Override public void handleEvent(Event event) { String charSet = ((Text) widgetList[0]).getText(); if (SWT.FocusOut == event.type) { if (StringUtils.isEmpty(charSet)){ txtDecorator.show(); ((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 204)); ((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) { IPath path = new Path(((Text) widgetList[0]).getText().trim()); if (event.type == SWT.Modify ) { if (StringUtils.isNotBlank(path.segment(0))) { if (path.lastSegment().endsWith(".xml")) { txtDecorator.hide(); ((Text) widgetList[0]).setToolTipText(""); ((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255)); }else{ txtDecorator.show(); txtDecorator.setDescriptionText("Select valid XML file"); ((Text) widgetList[0]).setToolTipText(txtDecorator.getDescriptionText()); ((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 204)); } } } } }; return listener; }
@Override public Listener getListener( PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Widget... widgets) { final Widget[] widgetList = widgets; if (helpers != null) { txtDecorator = (ControlDecoration) helpers.get(HelperType.CONTROL_DECORATION); characterLimit = (int) helpers.get(HelperType.CHARACTER_LIMIT); } Listener listener=new Listener() { @Override public void handleEvent(Event event) { Text text = (Text)widgetList[0]; text.setTextLimit(characterLimit); 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; }
@Override public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helper, Widget... widgets) { final Widget[] widgetList = widgets; if (helper != null) { txtDecorator = (ControlDecoration) helper.get(HelperType.CONTROL_DECORATION); txtDecorator.hide(); } Listener listener = new Listener() { @Override public void handleEvent(Event event) { String charSet = ((Text) widgetList[0]).getText().trim(); if (SWT.FocusOut == event.type) { if (StringUtils.isBlank(charSet)){ txtDecorator.show(); ((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 204)); ((Text) widgetList[0]).setToolTipText(txtDecorator.getDescriptionText()); } else { txtDecorator.hide(); } } } }; return listener; }
@Override public Listener getListener(final PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Widget... widgets) { final Widget[] widgetList = widgets; Listener listener = new Listener() { @Override public void handleEvent(Event event) { String comboValue = ((Combo) widgetList[0]).getText(); propertyDialogButtonBar.enableApplyButton(true); if (Messages.CUSTOM.equalsIgnoreCase(comboValue) && !FilterOperationClassUtility.INSTANCE.isCheckBoxSelected()) { ((Text) widgetList[1]).setText(""); ((Text) widgetList[1]).setEnabled(true); FilterOperationClassUtility.INSTANCE.enableAndDisableButtons(true, false); } else { if(FilterOperationClassUtility.INSTANCE.isCheckBoxSelected()) { MessageBox messageBox = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK); messageBox.setText(Messages.ERROR); messageBox.setMessage(Messages.CHECKBOX_DISABLE_MESSAGE); if (messageBox.open() == SWT.OK) { ((Combo) widgetList[0]).setText(Messages.CUSTOM); } } else { FilterOperationClassUtility.INSTANCE.setOperationClassNameInTextBox(comboValue, (Text)widgetList[1]); ((Text) widgetList[1]).setEnabled(false); FilterOperationClassUtility.INSTANCE.enableAndDisableButtons(false, false); ((Button) widgetList[2]).setEnabled(false); } } } }; return listener; }
@Override public void mouseAction(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Event event, Widget... widgets) { Table table=(Table)event.widget; Shell tip=(Shell) table.getData("tip"); Label label=(Label) table.getData("label"); if(tip!=null) { tip.dispose(); tip = null; label = null; } }
@Override public void mouseAction(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Event event, Widget... widgets) { Label label=(Label )event.widget; label.getShell().dispose(); }
@Override public void selectionListenerAction(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Widget... widgets) { propertyDialogButtonBar.enableApplyButton(true); Table table = (Table) widgets[0]; boolean userAns = WidgetUtility.eltConfirmMessage("Do you really want to delete all properties?"); if (userAns) { ELTGridDetails gridDetails = (ELTGridDetails) helpers.get(HelperType.SCHEMA_GRID); gridDetails.getGrids().removeAll(gridDetails.getGrids()); gridDetails.getTableViewer().refresh(); } }