/** * Activates the editor at the given position. * * @param row * @param col * @param rect */ public void open(KTable table, int col, int row, Rectangle rect) { m_Table = table; m_Model = table.getModel(); m_Rect = rect; m_Row = row; m_Col = col; if (m_Control == null) { m_Control = createControl(); m_Control.setToolTipText(toolTip); m_Control.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent arg0) { close(true); } }); } setBounds(m_Rect); GC gc = new GC(m_Table); m_Table.drawCell(gc, m_Col, m_Row); gc.dispose(); }
protected SourceViewer createViewer (Composite composite) { SourceViewer viewer = ViewerHelper.createEditor(composite); viewer.getControl().setData(WIDGET_ID, WIDGET_ACTION_SCRIPT); FocusListener listener = new FocusListener() { @Override public void focusGained(FocusEvent e) { } @Override public void focusLost(FocusEvent event) { if (!notification) return; if (viewer.getDocument() == null) return; String content = viewer.getDocument().get(); getProperties().setPropertyValue(ModelProperties.PROPERTY_EDGE_ACTION, content); } }; viewer.getControl().addFocusListener(listener); return viewer; }
protected SourceViewer createViewer (Composite composite) { SourceViewer viewer = ViewerHelper.createEditor(composite); viewer.getControl().setData(WIDGET_ID, WIDGET_GUARD_SCRIPT); FocusListener listener = new FocusListener() { @Override public void focusGained(FocusEvent e) { } @Override public void focusLost(FocusEvent event) { if (!notification) return; if (viewer.getDocument() == null) return; String content = viewer.getDocument().get(); getProperties().setPropertyValue(ModelProperties.PROPERTY_EDGE_GUARD, content); } }; viewer.getControl().addFocusListener(listener); return viewer; }
@Override public void focusLost(FocusEvent e) { if (!notification) return; GW4EVertexEditPartProperties properties = (GW4EVertexEditPartProperties) sectionProvider .getAdapter(IPropertySource.class); txtSharedNameDecorator.hide(); String value = textSharedName.getText(); if (value == null || value.trim().length() == 0) { txtSharedNameDecorator.show(); return; } properties.setPropertyValue(ModelProperties.PROPERTY_VERTEX_SHAREDNAME,value); }
public void focusLost(FocusEvent e) { if (e.getSource() == this.minimumRangeValue) { // verify min value if (! validateMinimum( this.minimumRangeValue.getText())) this.minimumRangeValue.setText(String.valueOf( this.minimumValue)); else this.minimumValue = Double.parseDouble( this.minimumRangeValue.getText()); } else if (e.getSource() == this.maximumRangeValue) { // verify max value if (! validateMaximum(this.maximumRangeValue.getText())) this.maximumRangeValue.setText(String.valueOf( this.maximumValue)); else this.maximumValue = Double.parseDouble( this.maximumRangeValue.getText()); } }
public void focusLost(FocusEvent e) { if (e.getSource() == this.minimumRangeValue) { // verify min value if (!validateMinimum(this.minimumRangeValue.getText())) this.minimumRangeValue.setText(String.valueOf( this.minimumValue)); else this.minimumValue = Double.parseDouble( this.minimumRangeValue.getText()); } else if (e.getSource() == this.maximumRangeValue) { // verify max value if (!validateMaximum(this.maximumRangeValue.getText())) this.maximumRangeValue.setText(String.valueOf( this.maximumValue)); else this.maximumValue = Double.parseDouble( this.maximumRangeValue.getText()); } }
@Override public void focusGained(final FocusEvent e) { if (!(e.widget instanceof Text)) { return; } final Text text = (Text) e.widget; final Boolean b = (Boolean) text.getData(DECORATED_KEY); if (b != null) { if (b.booleanValue()) { final ModifyListener modifyListener = (ModifyListener) text.getData(MODIFY_LISTENER_KEY); if (modifyListener != null) { text.removeModifyListener(modifyListener); } text.setForeground(null); text.setText(""); //$NON-NLS-1$ if (modifyListener != null) { text.addModifyListener(modifyListener); } } text.setData(DECORATED_KEY, Boolean.FALSE); } }
@Override public void focusGained(final FocusEvent e) { final Text text = (Text) e.widget; final Boolean addedDecoration = (Boolean) e.widget.getData(HISTORY_TEXT_DECORATION_KEY); if (addedDecoration == null || !addedDecoration.booleanValue()) { return; } final ModifyListener modifyListener = (ModifyListener) text.getData(UPDATE_WORK_ITEM_LISTENER_KEY); text.removeModifyListener(modifyListener); text.setText(""); //$NON-NLS-1$ text.addModifyListener(modifyListener); // Mac hack: grow to at least 60px so that the scroll bar displays // properly if (WindowSystem.isCurrentWindowSystem(WindowSystem.AQUA)) { ((GridData) text.getLayoutData()).heightHint = 70; text.getParent().layout(true); } e.widget.setData(HISTORY_TEXT_DECORATION_KEY, null); }
@Override public void focusLost(final FocusEvent e) { final Text text = (Text) e.widget; if (text.getText().trim().length() != 0) { return; } final Boolean addedDecoration = (Boolean) e.widget.getData(HISTORY_TEXT_DECORATION_KEY); if (addedDecoration != null && addedDecoration.booleanValue()) { return; } final ModifyListener modifyListener = (ModifyListener) text.getData(UPDATE_WORK_ITEM_LISTENER_KEY); text.removeModifyListener(modifyListener); text.setText(DECORATION_TEXT); text.addModifyListener(modifyListener); e.widget.setData(HISTORY_TEXT_DECORATION_KEY, Boolean.valueOf(true)); }
private void edit(final TableItem item, final TableEditor tableEditor) { final Text text = new Text(table, SWT.NONE); text.setText(item.getText(targetColumn)); text.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { item.setText(targetColumn, text.getText()); text.dispose(); } }); tableEditor.setEditor(text, item, targetColumn); text.setFocus(); text.selectAll(); }
private void edit(final TableItem item, final TableEditor tableEditor) { final Text text = new Text(table, SWT.NONE); text.setText(item.getText(targetColumn)); text.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { item.setText(targetColumn, text.getText()); text.dispose(); } }); tableEditor.setEditor(text, item, targetColumn); text.setFocus(); text.selectAll(); }
@Override public void focusGained(FocusEvent e) { Control c = (Control) e.getSource(); ServiceInstance service = (ServiceInstance) c.getData(); Rectangle bounds = service.getAppxLocation(); // child.getBounds(); Rectangle area = scrollComp.getClientArea(); Point origin = scrollComp.getOrigin(); // Our view is lower than the item if (origin.y > bounds.y) { origin.y = Math.max(0, bounds.y); } // Our view is above the item if (origin.y + area.height < bounds.y + bounds.height) { origin.y = Math.max(0, bounds.y + bounds.height - area.height); } scrollComp.setOrigin(origin); }
private void focusChanged(FocusEvent e) { Control control = fControl; if (Helper.okToUse(control)) { Display d = control.getDisplay(); if (d != null) { d.asyncExec(new Runnable() { public void run() { if (!fProposalPopup.hasFocus() && (fContextInfoPopup == null || !fContextInfoPopup.hasFocus())) { hide(); } } }); } } }
/** * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent) */ public void focusLost(FocusEvent e) { if (association.getName().equals(labelTextName.getText())) { return; } DomainUtil.run(new TransactionalAction() { /** * @see nexcore.tool.uml.manager.transaction.TransactionalAction#doExecute() */ @Override public void doExecute() { association.setName(labelTextName.getText()); } }); }
/** * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent) */ public void focusLost(FocusEvent e) { String text = multiplicityCombo.getText(); try { final int value = new Integer(text).intValue(); final Property property = this.getData(); if (value > 0) { DomainUtil.run(new TransactionalAction() { @Override public void doExecute() { property.setLower(value); property.setUpper(value); } }); } } catch (Exception e2) { // TODO: handle exception } }
/** * In a future world, this might provide access to a complete set * of {@code ResourceDocument} properties. */ @SuppressWarnings("unused") private Composite setupProperties(Composite parent) { Composite result = Widgets.buildGridContainer(parent, 2); Label label = Widgets.buildCompactLabel(result, "&Name:"); relSetName = new Text(result, SWT.BORDER | SWT.SINGLE); relSetName.setLayoutData(Widgets.buildHorzFillData()); relSetName.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { if (propInfo.getName().equals(relSetName.getText())) { return; } setDirtyState(true); handleDocumentChange(); } }); return result; }
/** * In a future world, this might provide access to a complete set * of {@code ResourceDocument} properties. */ @SuppressWarnings("unused") private Composite setupProperties(Composite parent) { Composite result = Widgets.buildGridContainer(parent, 2); Label label = Widgets.buildCompactLabel(result, "&Name:"); matcherName = new Text(result, SWT.BORDER | SWT.SINGLE); matcherName.setLayoutData(Widgets.buildHorzFillData()); if (null != matcherInfo) { matcherName.setText(matcherInfo.getName()); } matcherName.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { if (matcherInfo.getName().equals(matcherName.getText())) { return; } setDirtyState(true); handleDocumentChange(); } }); return result; }
/** * In a future world, this might provide access to a complete set * of {@code ResourceDocument} properties. * @return */ @SuppressWarnings("unused") private Composite setupProperties(Composite parent) { Composite result = Widgets.buildGridContainer(parent, 2); Label label = Widgets.buildCompactLabel(result, "&Name:"); relSetName = new Text(result, SWT.BORDER | SWT.SINGLE); relSetName.setLayoutData(Widgets.buildHorzFillData()); relSetName.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { if (relSetInfo.getName().equals(relSetName.getText())) { return; } setDirtyState(true); handleDocumentChange(); } }); return result; }
public AutoComplete(final ComboViewer comboViewer) { _comboViewer = comboViewer; final Combo combo = comboViewer.getCombo(); combo.addKeyListener(new KeyAdapter() { @Override public void keyReleased(final KeyEvent e) { if (e.keyCode == SWT.DEL) setSelection(null); autoCompleteKeyUp(e); } }); combo.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent arg0) { autoCompleteLeave(); } }); }
@Override public void focusLost(final FocusEvent fe) { if (getValidateStrategy() == VALIDATE_ON_KEY_STROKE) { final Text text = (Text) fe.widget; final String oldText = text.getText(); try { final DateFormat df = dateFormat.get(); final String newText = df.format(df.parse(getTextControl().getText())); if (!oldText.equals(newText)) { text.setText(newText); } valueChanged(); } catch (final ParseException pe) {/* Ignore */} } }
private void createDescription(String text, Composite comp, StyleRange[] styles) { final StyledText descLabel = new StyledText(comp, SWT.MULTI | SWT.WRAP); descLabel.setRightMargin(10); descLabel.setEditable(false); descLabel.setText(text); descLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); descLabel.addMouseListener(compositeMouseAction); if (styles != null && styles.length > 0) descLabel.setStyleRanges(styles); descLabel.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { setScrolledFocus(); descLabel.setSelection(0, 0); } }); }
@Override public void focusLost(final FocusEvent e) { if (e.getSource() == this.minimumRangeValue) { // verify min value if (!validateMinimum(this.minimumRangeValue.getText())) { this.minimumRangeValue.setText(String.valueOf(this.minimumValue)); } else { this.minimumValue = Double.parseDouble(this.minimumRangeValue.getText()); } } else if (e.getSource() == this.maximumRangeValue) { // verify max value if (!validateMaximum(this.maximumRangeValue.getText())) { this.maximumRangeValue.setText(String.valueOf(this.maximumValue)); } else { this.maximumValue = Double.parseDouble(this.maximumRangeValue.getText()); } } }
@Override public void focusLost(final FocusEvent e) { if (e.widget == null || !e.widget.equals(text)) { return; } widgetDefaultSelected(null); /* async is needed to wait until focus reaches its new Control */ removeTooltip(); // SwtGui.getDisplay().timerExec(100, new Runnable() { // // @Override // public void run() { // if ( SwtGui.getDisplay().isDisposed() ) { return; } // final Control control = SwtGui.getDisplay().getFocusControl(); // if ( control != text ) { // widgetDefaultSelected(null); // } // } // }); }
@Override public void focusLost(final FocusEvent fe) { try { int textValue = Integer.parseInt(text.getText()); if (textValue > getMaximum()) { textValue = getMaximum(); } if (textValue < getMinimum()) { textValue = getMinimum(); } setText(textValue); scale.setSelection(textValue); } catch (final RuntimeException e) { logger.log(Level.FINE, e.toString(), e); setText(scale.getSelection()); } }
protected Composite createValueTextarea(Composite parent) { Label valueLabel = createDescription(parent, MetamodelViewsRepository.Query.Properties.value, MetamodelMessages.QueryPropertiesEditionPart_ValueLabel); GridData valueLabelData = new GridData(GridData.FILL_HORIZONTAL); valueLabelData.horizontalSpan = 3; valueLabel.setLayoutData(valueLabelData); value = SWTUtils.createScrollableText(parent, SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL); GridData valueData = new GridData(GridData.FILL_HORIZONTAL); valueData.horizontalSpan = 2; valueData.heightHint = 80; valueData.widthHint = 200; value.setLayoutData(valueData); value.addFocusListener(new FocusAdapter() { /** * {@inheritDoc} * * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent) * */ public void focusLost(FocusEvent e) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(QueryPropertiesEditionPartImpl.this, MetamodelViewsRepository.Query.Properties.value, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, value.getText())); } }); EditingUtils.setID(value, MetamodelViewsRepository.Query.Properties.value); EditingUtils.setEEFtype(value, "eef::Textarea"); //$NON-NLS-1$ SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(MetamodelViewsRepository.Query.Properties.value, MetamodelViewsRepository.SWT_KIND), null); //$NON-NLS-1$ // Start of user code for createValueTextArea // End of user code return parent; }
@Override protected AbstractFocusListener getFocusListener(Control control, Observer<? super FocusEvent> observer) { return new AbstractFocusListener(control) { @Override public void focusLost(FocusEvent e) { if (!isDisposed()) { observer.onNext(e); } } }; }
@Override protected AbstractFocusListener getFocusListener(Control control, Observer<? super FocusEvent> observer) { return new AbstractFocusListener(control) { @Override public void focusGained(FocusEvent e) { if (!isDisposed()) { observer.onNext(e); } } }; }
@Override protected void subscribeActual(Observer<? super FocusEvent> observer) { if (!Preconditions.checkWidget(observer, control)) { return; } AbstractFocusListener listener = getFocusListener(control, observer); observer.onSubscribe(listener); control.addDisposeListener(e -> listener.dispose()); control.addFocusListener(listener); }
private void sendFocusEventToFX(FocusEvent fe, boolean focused) { if ((stage == null) || (stagePeer == null)) { return; } int focusCause = (focused ? AbstractEvents.FOCUSEVENT_ACTIVATED : AbstractEvents.FOCUSEVENT_DEACTIVATED); stagePeer.setFocused(focused, focusCause); }
protected void fillComposite (Composite composite) { composite.setLayout(new FormLayout()); viewer = ViewerHelper.createEditor(composite); viewer.getControl().setData(WIDGET_ID, WIDGET_SCRIPT); FocusListener listener = new FocusListener() { @Override public void focusGained(FocusEvent e) { } @Override public void focusLost(FocusEvent event) { if (!notification) return; GW4EVertexEditPartProperties properties = (GW4EVertexEditPartProperties) node.getAdapter(IPropertySource.class); if (viewer.getDocument() == null) return; String content = viewer.getDocument().get(); properties.setPropertyValue(ModelProperties.PROPERTY_VERTEX_INIT, content); } }; viewer.getControl().addFocusListener(listener); Control control = viewer.getControl(); control.setEnabled(false); FormData fd_javaScript = new FormData(); fd_javaScript.left = new FormAttachment(0, 10); fd_javaScript.right = new FormAttachment(100, -5); fd_javaScript.top = new FormAttachment(0, 10); setHeight (fd_javaScript, control, 10); control.setLayoutData(fd_javaScript); }
@Override public void focusLost(FocusEvent e) { if (!notification) return; GW4EVertexEditPartProperties properties = (GW4EVertexEditPartProperties) sectionProvider .getAdapter(IPropertySource.class); txtNameDecorator.hide(); String value = textName.getText(); if (value == null || value.trim().length() == 0 || (!Character.isJavaIdentifierStart(value.charAt(0)))) { txtNameDecorator.show(); return; } if (Constant.START_VERTEX_NAME.equalsIgnoreCase(value.trim())) { txtNameDecorator.show(); return; } int max = value.length(); for (int i = 1; i < max; i++) { if ((!Character.isJavaIdentifierPart(value.charAt(i)))) { txtNameDecorator.show(); return; } } if (!JDTManager.validateClassName(value)) { txtNameDecorator.show(); return; } properties.setPropertyValue(ModelProperties.PROPERTY_NAME, value); }
@Override public void focusLost(FocusEvent e) { if (!notification) return; GW4EVertexEditPartProperties properties = (GW4EVertexEditPartProperties) sectionProvider .getAdapter(IPropertySource.class); properties.setPropertyValue(ModelProperties.PROPERTY_DESCRIPTION, textDescription.getText()); }
@Override public void focusLost(FocusEvent e) { if (!notification) return; GW4EVertexEditPartProperties properties = (GW4EVertexEditPartProperties) sectionProvider .getAdapter(IPropertySource.class); properties.setPropertyValue(ModelProperties.PROPERTY_VERTEX_REQUIREMENTS, textRequirements.getText()); }
@Override public void focusLost(FocusEvent e) { if (!notification) return; GW4EGraphEditPartProperties properties = (GW4EGraphEditPartProperties) node .getAdapter(IPropertySource.class); properties.setPropertyValue(ModelProperties.PROPERTY_DESCRIPTION, textDescription.getText()); }
@Override public void focusLost(FocusEvent e) { if (!notification) return; GW4EGraphEditPartProperties properties = (GW4EGraphEditPartProperties) node .getAdapter(IPropertySource.class); properties.setPropertyValue(ModelProperties.PROPERTY_COMPONENT, textComponent.getText()); }
public void viewerFocusLost(FocusEvent event) { final IHandlerService handlerService = getHandlerService(); if (copyHandlerActivation != null) { handlerService.deactivateHandler(copyHandlerActivation); } if (refreshHandlerActivation != null) { handlerService.deactivateHandler(refreshHandlerActivation); } if (removeHandlerActivation != null) { handlerService.deactivateHandler(removeHandlerActivation); } }
public void viewerFocusGained(FocusEvent event) { final IHandlerService handlerService = getHandlerService(); copyHandlerActivation = handlerService .activateHandler(IWorkbenchCommandConstants.EDIT_COPY, new ActionHandler(copyAction)); refreshHandlerActivation = handlerService .activateHandler(IWorkbenchCommandConstants.FILE_REFRESH, new ActionHandler(reloadAction)); removeHandlerActivation = handlerService .activateHandler(IWorkbenchCommandConstants.EDIT_DELETE, new ActionHandler(removeAction)); }
@Override public void focusLost(final FocusEvent e) { if (!(e.widget instanceof Text)) { return; } final Text text = (Text) e.widget; addDecorationIfNeeded(text); }