Java Code Examples for org.eclipse.swt.events.FocusEvent

The following are top voted examples for showing how to use org.eclipse.swt.events.FocusEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: convertigo-eclipse   File: KTableCellEditor.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
}
 
Example 2
Project: gw4e.project   File: EdgeActionSection.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 3
Project: gw4e.project   File: EdgeGuardSection.java   Source Code and License 6 votes vote down vote up
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;		
}
 
Example 4
Project: gw4e.project   File: VertexDefaultSection.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 5
Project: parabuild-ci   File: SWTNumberAxisEditor.java   Source Code and License 6 votes vote down vote up
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());
    }
}
 
Example 6
Project: ccu-historian   File: SWTNumberAxisEditor.java   Source Code and License 6 votes vote down vote up
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());
    }
}
 
Example 7
Project: team-explorer-everywhere   File: WITSearchDialog.java   Source Code and License 6 votes vote down vote up
@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);
    }
}
 
Example 8
Project: team-explorer-everywhere   File: WorkItemHistoryControl.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 9
Project: team-explorer-everywhere   File: WorkItemHistoryControl.java   Source Code and License 6 votes vote down vote up
@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));
}
 
Example 10
Project: aya-lang   File: SWTNumberAxisEditor.java   Source Code and License 6 votes vote down vote up
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());
    }
}
 
Example 11
Project: ermasterr   File: ModelPropertiesDialog.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 12
Project: ermaster-k   File: ModelPropertiesDialog.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 13
Project: cft   File: CloudFoundryServiceWizardPageRightPanel.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 14
Project: APICloud-Studio   File: ContentAssistant.java   Source Code and License 6 votes vote down vote up
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();
					}
				}
			});
		}
	}
}
 
Example 15
Project: NEXCORE-UML-Modeler   File: AssociationGeneralSection.java   Source Code and License 6 votes vote down vote up
/**
 * @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());
        }
    });
}
 
Example 16
Project: NEXCORE-UML-Modeler   File: MultiplicityGeneralSection.java   Source Code and License 6 votes vote down vote up
/**
 * @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
    }

}
 
Example 17
Project: depan   File: RelationDisplayEditor.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 18
Project: depan   File: EdgeMatcherEditor.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 19
Project: depan   File: RelationSetDescriptorEditor.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 20
Project: mytourbook   File: AutoComplete.java   Source Code and License 6 votes vote down vote up
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();
			}
		});

	}
 
Example 21
Project: JFaceUtils   File: DateFieldEditor.java   Source Code and License 6 votes vote down vote up
@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 */}
	}
}
 
Example 22
Project: PDFReporter-Studio   File: SelectableComposite.java   Source Code and License 6 votes vote down vote up
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);
		}

	});
}
 
Example 23
Project: gama   File: SWTChartEditor.java   Source Code and License 6 votes vote down vote up
@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());
		}
	}
}
 
Example 24
Project: erflute   File: ModelPropertiesDialog.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 25
Project: gama   File: ExpressionControl.java   Source Code and License 6 votes vote down vote up
@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);
	// }
	// }
	// });

}
 
Example 26
Project: JFaceUtils   File: ScaleIntegerFieldEditor.java   Source Code and License 6 votes vote down vote up
@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());
	}
}
 
Example 27
Project: SimQRI   File: QueryPropertiesEditionPartImpl.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 28
Project: RxSWT   File: FocusLostObservable.java   Source Code and License 5 votes vote down vote up
@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);
			}
		}
	};
}
 
Example 29
Project: RxSWT   File: FocusGainedObservable.java   Source Code and License 5 votes vote down vote up
@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);
			}
		}
	};
}
 
Example 30
Project: RxSWT   File: FocusObservable.java   Source Code and License 5 votes vote down vote up
@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);

}
 
Example 31
Project: JavaFX-FrameRateMeter   File: OldFXCanvas.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 32
Project: gw4e.project   File: VertexInitSection.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 33
Project: gw4e.project   File: VertexDefaultSection.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 34
Project: gw4e.project   File: VertexDefaultSection.java   Source Code and License 5 votes vote down vote up
@Override
public void focusLost(FocusEvent e) {
	if (!notification)
		return;
	GW4EVertexEditPartProperties properties = (GW4EVertexEditPartProperties) sectionProvider
			.getAdapter(IPropertySource.class);
	properties.setPropertyValue(ModelProperties.PROPERTY_DESCRIPTION, textDescription.getText());
}
 
Example 35
Project: gw4e.project   File: VertexDefaultSection.java   Source Code and License 5 votes vote down vote up
@Override
public void focusLost(FocusEvent e) {
	if (!notification)
		return;
	GW4EVertexEditPartProperties properties = (GW4EVertexEditPartProperties) sectionProvider
			.getAdapter(IPropertySource.class);
	properties.setPropertyValue(ModelProperties.PROPERTY_VERTEX_REQUIREMENTS, textRequirements.getText());
}
 
Example 36
Project: gw4e.project   File: GraphDefaultSection.java   Source Code and License 5 votes vote down vote up
@Override
public void focusLost(FocusEvent e) {
	if (!notification)
		return;
	GW4EGraphEditPartProperties properties = (GW4EGraphEditPartProperties) node
			.getAdapter(IPropertySource.class);
	properties.setPropertyValue(ModelProperties.PROPERTY_DESCRIPTION, textDescription.getText());
}
 
Example 37
Project: gw4e.project   File: GraphDefaultSection.java   Source Code and License 5 votes vote down vote up
@Override
public void focusLost(FocusEvent e) {
	if (!notification)
		return;
	GW4EGraphEditPartProperties properties = (GW4EGraphEditPartProperties) node
			.getAdapter(IPropertySource.class);
	properties.setPropertyValue(ModelProperties.PROPERTY_COMPONENT, textComponent.getText());
}
 
Example 38
Project: com.onpositive.prefeditor   File: PreferenceView.java   Source Code and License 5 votes vote down vote up
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);
	}
}
 
Example 39
Project: com.onpositive.prefeditor   File: PreferenceView.java   Source Code and License 5 votes vote down vote up
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));

}
 
Example 40
Project: team-explorer-everywhere   File: WITSearchDialog.java   Source Code and License 5 votes vote down vote up
@Override
public void focusLost(final FocusEvent e) {
    if (!(e.widget instanceof Text)) {
        return;
    }

    final Text text = (Text) e.widget;
    addDecorationIfNeeded(text);
}
 
Example 41
Project: team-explorer-everywhere   File: AutocompleteCombo.java   Source Code and License 5 votes vote down vote up
@Override
public void focusGained(final FocusEvent e) {
    /*
     * Select all text initially so the user can start typing.
     */
    final int textlength = getText().length();
    setSelection(new Point(0, textlength));
}
 
Example 42
Project: subclipse   File: CommitCommentArea.java   Source Code and License 5 votes vote down vote up
public void focusGained(FocusEvent e) {

            if (fText.length() > 0) 
                return;
            
            fTextField.removeModifyListener(this);
            try {
                fTextField.setText(fText);
            } finally {
                fTextField.addModifyListener(this);
            }
        }
 
Example 43
Project: subclipse   File: CommitCommentArea.java   Source Code and License 5 votes vote down vote up
public void focusLost(FocusEvent e) {
    
    if (fText.length() > 0) 
        return;
    
    fTextField.removeModifyListener(this);
    try {
        fTextField.setText(fMessage);
        fTextField.selectAll();
    } finally {
        fTextField.addModifyListener(this);
    }
}
 
Example 44
Project: subclipse   File: CommitCommentArea.java   Source Code and License 5 votes vote down vote up
public void focusLost(FocusEvent e) {
    fCombo.removeSelectionListener(this);
    try {
        fCombo.setText(fMessage);
    } finally {
        fCombo.addSelectionListener(this);
    }
}
 
Example 45
Project: texlipse   File: TexlipseProjectFilesWizardPage.java   Source Code and License 5 votes vote down vote up
/**
 * Create the output file name field.
 * @param composite the parent container
 */
private void createOutputDirControl(Composite composite) {
    
    // add label
    Label mainLabel = new Label(composite, SWT.LEFT);
    mainLabel.setText(TexlipsePlugin.getResourceString("projectWizardOutputDirLabel"));
    mainLabel.setToolTipText(TexlipsePlugin.getResourceString("projectWizardOutputDirTooltip"));
    mainLabel.setLayoutData(new GridData());
    
    // add text field
    outputDirNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    outputDirNameField.setText(attributes.getOutputDir());
    outputDirNameField.setToolTipText(TexlipsePlugin.getResourceString("projectWizardOutputDirTooltip"));
    outputDirNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    outputDirNameField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) {
            if (outputDirItem != null) {
                dirTree.setSelection(new TreeItem[] { outputDirItem });
            }
        }});
    outputDirNameField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (!outputDirNameField.isDisposed()) {
                String t = outputDirNameField.getText();
                attributes.setOutputDir(t);
                validateDirName(outputDirNameField, t);
                if (t == null || t.length() == 0) {
                    recreateSubTree();
                } else if (outputDirItem == null) {
                    recreateSubTree();
                }
                if (outputDirItem != null) {
                    outputDirItem.setText(t);
                }
            }
        }});
}
 
Example 46
Project: texlipse   File: TexlipseProjectFilesWizardPage.java   Source Code and License 5 votes vote down vote up
/**
 * Create the output file name field.
 * @param composite the parent container
 */
private void createOutputFileControl(Composite composite) {
    
    // add label
    Label mainLabel = new Label(composite, SWT.LEFT);
    mainLabel.setText(TexlipsePlugin.getResourceString("projectWizardOutputFileLabel"));
    mainLabel.setToolTipText(TexlipsePlugin.getResourceString("projectWizardOutputFileTooltip"));
    mainLabel.setLayoutData(new GridData());
    
    // add text field
    outputFileNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    outputFileNameField.setText(attributes.getOutputFile());
    outputFileNameField.setToolTipText(TexlipsePlugin.getResourceString("projectWizardOutputFileTooltip"));
    outputFileNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    outputFileNameField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) {
            dirTree.setSelection(new TreeItem[] { outputFileItem });
        }});
    outputFileNameField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (!outputFileNameField.isDisposed()) {
                String t = outputFileNameField.getText();
                outputFileItem.setText(t);
                validateOutputFileName(t);
            }
        }});
}
 
Example 47
Project: texlipse   File: TexlipseProjectFilesWizardPage.java   Source Code and License 5 votes vote down vote up
/**
 * Create the output file name field.
 * @param composite the parent container
 */
private void createMainDirControl(Composite composite) {
    
    // add label
    Label mainLabel = new Label(composite, SWT.LEFT);
    mainLabel.setText(TexlipsePlugin.getResourceString("projectWizardMainDirLabel"));
    mainLabel.setToolTipText(TexlipsePlugin.getResourceString("projectWizardMainDirTooltip"));
    mainLabel.setLayoutData(new GridData());
    
    // add text field
    sourceDirNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    sourceDirNameField.setText(attributes.getSourceDir());
    sourceDirNameField.setToolTipText(TexlipsePlugin.getResourceString("projectWizardMainDirTooltip"));
    sourceDirNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    sourceDirNameField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) {
        	   if (sourceDirItem != null) {
        	       dirTree.setSelection(new TreeItem[] { sourceDirItem });
        	   }
        }});
    sourceDirNameField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (!sourceDirNameField.isDisposed()) {
                String t = sourceDirNameField.getText();
                attributes.setSourceDir(t);
                validateDirName(sourceDirNameField, t);
                if (t == null || t.length() == 0) {
                    recreateSubTree();
                } else if (sourceDirItem == null) {
                    recreateSubTree();
                }
                if (sourceDirItem != null) {
                    sourceDirItem.setText(t);
                }
            }
        }});
}
 
Example 48
Project: texlipse   File: TexlipseProjectFilesWizardPage.java   Source Code and License 5 votes vote down vote up
/**
 * Create main file settings box.
 * @param composite the parent container
 */
private void createMainFileControl(Composite composite) {
    
    // add label
    Label mainLabel = new Label(composite, SWT.LEFT);
    mainLabel.setText(TexlipsePlugin.getResourceString("projectWizardMainFileLabel"));
    mainLabel.setToolTipText(TexlipsePlugin.getResourceString("projectWizardMainFileTooltip"));
    mainLabel.setLayoutData(new GridData());
    
    // add text field
    sourceFileNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    sourceFileNameField.setText(attributes.getSourceFile());
    sourceFileNameField.setToolTipText(TexlipsePlugin.getResourceString("projectWizardMainFileTooltip"));
    sourceFileNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    sourceFileNameField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) {
            dirTree.setSelection(new TreeItem[] { sourceFileItem });
        }});
    sourceFileNameField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (!sourceFileNameField.isDisposed()) {
                String t = sourceFileNameField.getText();
                sourceFileItem.setText(t);
                tempFileItem.setText(t.substring(0, t.lastIndexOf('.')+1) + "aux");
                validateMainFileName(t);
            }
        }});
}
 
Example 49
Project: texlipse   File: TexlipseProjectFilesWizardPage.java   Source Code and License 5 votes vote down vote up
/**
 * Create the output file name field.
 * @param composite the parent container
 */
private void createTempDirControl(Composite composite) {
    
    // add label
    Label mainLabel = new Label(composite, SWT.LEFT);
    mainLabel.setText(TexlipsePlugin.getResourceString("projectWizardTempDirLabel"));
    mainLabel.setToolTipText(TexlipsePlugin.getResourceString("projectWizardTempDirTooltip"));
    mainLabel.setLayoutData(new GridData());
    
    // add text field
    tempDirNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    tempDirNameField.setText(attributes.getTempDir());
    tempDirNameField.setToolTipText(TexlipsePlugin.getResourceString("projectWizardTempDirTooltip"));
    tempDirNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tempDirNameField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) {
        	   if (tempDirItem != null) {
                dirTree.setSelection(new TreeItem[] { tempDirItem });
        	   }
        }});
    tempDirNameField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (!tempDirNameField.isDisposed()) {
                String t = tempDirNameField.getText();
                attributes.setTempDir(t);
                validateDirName(tempDirNameField, t);
                if (t == null || t.length() == 0) {
                    recreateSubTree();
                } else if (tempDirItem == null) {
                    recreateSubTree();
                }
                if (tempDirItem != null) {
                    tempDirItem.setText(t);
                }
            }
        }});
}
 
Example 50
Project: arduino_sct_tools   File: ArduinoFeatureConfigurationSection.java   Source Code and License 5 votes vote down vote up
/**
 * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
 */
@Override
public void focusLost(final FocusEvent event) {
	if (!this.mutex) {
		this.mutex = true;

		final Text text = (Text) event.getSource();
		getFormPage().updateModel((FeatureParameter) text.getData(), text.getText());

		this.mutex = false;
	}
}
 
Example 51
Project: arduino_sct_tools   File: GenericFeatureConfigurationSection.java   Source Code and License 5 votes vote down vote up
/**
 * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
 */
@Override
public void focusLost(final FocusEvent event) {
	if (!this.mutex) {
		final Text text = (Text) event.getSource();
		final FeatureParameter parameter = (FeatureParameter) text.getData();

		getFormPage().updateModel(parameter, text.getText());
	}
}
 
Example 52
Project: arduino_sct_tools   File: LicenseHeaderFeatureConfigurationSection.java   Source Code and License 5 votes vote down vote up
/**
 * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
 */
@Override
public void focusLost(final FocusEvent event) {
	if (!this.mutex) {
		this.mutex = true;

		final Text text = (Text) event.getSource();
		final FeatureParameter parameter = (FeatureParameter) text.getData();
		getFormPage().updateModel(parameter, text.getText());

		this.mutex = false;
	}
}
 
Example 53
Project: TranskribusSwtGui   File: MyContentProposalAdapter.java   Source Code and License 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	text = new Text(parent, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP
			| SWT.NO_FOCUS);

	// Use the compact margins employed by PopupDialog.
	GridData gd = new GridData(GridData.BEGINNING
			| GridData.FILL_BOTH);
	gd.horizontalIndent = PopupDialog.POPUP_HORIZONTALSPACING;
	gd.verticalIndent = PopupDialog.POPUP_VERTICALSPACING;
	text.setLayoutData(gd);
	text.setText(contents);

	// since SWT.NO_FOCUS is only a hint...
	text.addFocusListener(new FocusAdapter() {
		@Override
		public void focusGained(FocusEvent event) {
			ContentProposalPopup.this.close();
		}
	});
	return text;
}
 
Example 54
Project: APICloud-Studio   File: FindBarActions.java   Source Code and License 5 votes vote down vote up
public void focusLost(FocusEvent e)
{
	if (!listening)
	{
		return;
	}
	listening = false;
	setFindBarContextActive(false);
	display.removeFilter(SWT.KeyDown, this);
	display.removeFilter(SWT.Traverse, this);
}
 
Example 55
Project: mytourbook   File: SmoothingUI.java   Source Code and License 5 votes vote down vote up
@Override
public void focusLost(final FocusEvent e) {

	if (_slideout != null) {
		_slideout.setIsAnotherDialogOpened(false);
	}

}
 
Example 56
Project: JFaceUtils   File: LongFieldEditor.java   Source Code and License 5 votes vote down vote up
@Override
public void focusLost(final FocusEvent fe) {
	final Text text = (Text) fe.widget;
	final String oldText = text.getText();
	try {
		final String newText = Long.toString(Long.parseLong(oldText));
		if (!oldText.equals(newText)) {
			text.setText(newText);
		}
		valueChanged();
	}
	catch (final Exception e) {
		logger.log(Level.FINE, e.toString(), e);
	}
}
 
Example 57
Project: JFaceUtils   File: EditableComboFieldEditor.java   Source Code and License 5 votes vote down vote up
@Override
protected Combo getComboBoxControl(final Composite parent) {
	Combo combo = getComboBoxControl();
	if (combo == null) {
		combo = new Combo(parent, SWT.NONE);
		setComboBoxControl(combo);
		combo.setFont(parent.getFont());
		final String[][] entryNamesAndValues = getEntryNamesAndValues();
		for (int i = 0; i < entryNamesAndValues.length; i++) {
			combo.add(entryNamesAndValues[i][0], i);
		}
		combo.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(final SelectionEvent se) {
				updateValue();
			}
		});
		combo.addFocusListener(new FocusAdapter() {
			@Override
			public void focusLost(final FocusEvent fe) {
				updateValue();
			}
		});
		if (textLimit > 0) {
			combo.setTextLimit(textLimit);
		}
	}
	return combo;
}
 
Example 58
Project: afbb-bibo   File: LoginDialog.java   Source Code and License 5 votes vote down vote up
@Override
public void focusGained(FocusEvent e) {
	Text widget = (Text) e.widget;
	if (!widget.isDisposed()) {
		int length = widget.getText().length();
		widget.setSelection(0, length);
	}
}
 
Example 59
Project: mytourbook   File: DialogEasyImportConfig.java   Source Code and License 5 votes vote down vote up
private void onIC_Folder_FocusLost(final FocusEvent event) {

		final Combo combo = (Combo) event.widget;
		final HistoryItems historyItems = (HistoryItems) combo.getData();

		// keep manually entered folders in the history
		historyItems.updateHistory();
	}
 
Example 60
Project: velocity-edit   File: VelocityEditor.java   Source Code and License 5 votes vote down vote up
public void focusGained(FocusEvent e)
{
  IFile file = ((IFileEditorInput) getEditorInput()).getFile();
  try
  {
    // Automatically update the file in the editor if it has changed in the 
    // filesystem
    file.refreshLocal(IResource.DEPTH_ZERO, null);
  } 
  catch (CoreException e1)
  {
    // Just skip it.
  }
}