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

The following examples show how to use org.eclipse.swt.events.FocusEvent. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
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 2
Source Project: nebula   Source File: InternalCompositeTable.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Handle focusGained events on any child control.
 * 
 * FIXME: Needs to automatically scroll horizontally if the newly-focused
 * control is fully or partially occluded.
 * 
 * @param sender
 *            The row containing the sending control.
 * @param e
 *            The SWT FocusEvent.
 */
public void focusGained(TableRow sender, FocusEvent e) {
	boolean rowChanged = false;
	int senderRowNumber = getRowNumber(sender);
	if (senderRowNumber != currentRow) {
		if (needToRequestRC) {
			if (!fireRequestRowChangeEvent()) {
				// Go back if we're not allowed to be here
				deferredSetFocus(getControl(currentColumn, currentRow),
						false);
			}
		} else {
			needToRequestRC = true;
		}
		rowChanged = true;
	}

	currentRow = senderRowNumber;
	currentColumn = sender.getColumnNumber((Control) e.widget);

	if (rowChanged)
		fireRowArriveEvent();
}
 
Example 3
Source Project: nebula   Source File: MonthCalendar.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public void focusGained(FocusEvent e) {
	Day day = (Day) e.widget;
	if (lastSelectedDay != null && lastSelectedDay != day) {
		lastSelectedDay.setFocusState(Day.NO_FOCUS);
		lastSelectedDay.redraw();
	}

	Point coordinates = day.getMonthPosition();
	selectedDay = new MonthCalendarSelectedDay(day.getDate(), coordinates);
	e.data = selectedDay;

	lastSelectedDay = day;

	for (Iterator<FocusListener> focusListenersIter = focusListeners.iterator(); focusListenersIter.hasNext();) {
		FocusListener listener = (FocusListener) focusListenersIter.next();
		listener.focusGained(e);
	}
}
 
Example 4
Source Project: nebula   Source File: BaseFocusControlListener.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
 */
@Override
public void focusGained(final FocusEvent e) {
	if (isFilled()) {
		// Widget not empty
		PromptSupport.setPromptDisplayed(control, false);
		return;
	}
	applyInitialLook();
	PromptSupport.setPromptDisplayed(control, true);
	if (PromptSupport.getFocusBehavior(control) == FocusBehavior.HIDE_PROMPT) {
		hidePrompt();
	} else {
		highLightPrompt();
	}
}
 
Example 5
Source Project: birt   Source File: AggregateEditorComposite.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void handleEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusOut :
			focusLost( new FocusEvent( event ) );
			break;

		case SWT.Traverse :
			switch ( event.detail )
			{
				case SWT.TRAVERSE_TAB_NEXT :
				case SWT.TRAVERSE_TAB_PREVIOUS :
					// Indicates getting focus control rather than
					// cursor control
					event.doit = true;
					isPressingKey = true;
			}
			break;

	}
}
 
Example 6
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
Source Project: ermaster-b   Source File: ErDiagramInformationControl.java    License: Apache License 2.0 6 votes vote down vote up
public ErDiagramInformationControl(ERDiagram diagram, Shell shell, Control composite) {
	super(shell, true);
	this.diagram = diagram;

	create();

	int width  = 300;
	int height = 300;

	Point loc  = composite.toDisplay(0, 0);
	Point size = composite.getSize();

	int x = (size.x - width)  / 2 + loc.x;
	int y = (size.y - height) / 2 + loc.y;

	setSize(width, height);
	setLocation(new Point(x, y));
	addFocusListener(new FocusAdapter() {
		@Override
		public void focusLost(FocusEvent e) {
			dispose();
		}
	});
}
 
Example 8
Source Project: ermasterr   Source File: ModelPropertiesDialog.java    License: Apache License 2.0 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 9
Source Project: SIMVA-SoS   Source File: SWTNumberAxisEditor.java    License: Apache License 2.0 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 10
Source Project: elexis-3-core   Source File: ETFTextPlugin.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public Composite createContainer(Composite parent, ICallback h){
	handler = h;
	etf = new EnhancedTextField(parent);
	etf.text.addFocusListener(new FocusAdapter() {
		@Override
		public void focusLost(FocusEvent e){
			if (bSaveOnFocusLost) {
				if (handler != null) {
					handler.save();
				}
			}
		}
		
	});
	ike = new ExternalLink();
	ike.connect(etf);
	etf.setText(StringTool.leer);
	return etf;
}
 
Example 11
@Override
public void focusLost(FocusEvent e) {
	if (SWT.getPlatform().equals("gtk")) {
		if (isIgnoreNextFocusLost()) {
			setIgnoreNextFocusLost(false);
			return;
		}
		if (text.getMenu().isVisible()) {
			setIgnoreNextFocusLost(true);
			return;
		}
	}

	if (this.selectionProviderOnFocusLost != null) {
		this.site.setSelectionProvider(this.selectionProviderOnFocusLost);
	}

	text.setSelection(text.getCaretOffset());

}
 
Example 12
Source Project: depan   Source File: RelationDisplayEditor.java    License: Apache License 2.0 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 13
Source Project: depan   Source File: EdgeMatcherEditor.java    License: Apache License 2.0 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 14
Source Project: depan   Source File: RelationSetDescriptorEditor.java    License: Apache License 2.0 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 15
Source Project: gama   Source File: SWTChartEditor.java    License: GNU General Public License v3.0 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 16
Source Project: tmxeditor8   Source File: EquivalentPage.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 验证用户输入的加权系数的正确性
 * @param equiTxt
 */
private void validEquiTxt(final Text equiTxt){
	final String defaultStr = "0.50";
	equiTxt.setText(defaultStr);
	equiTxt.addFocusListener(new FocusAdapter() {
		@Override
		public void focusLost(FocusEvent e) {
			String textStr = equiTxt.getText().trim();
			if (textStr == null || textStr.trim().length() == 0) {
				equiTxt.setText(defaultStr);
			}else {
				String regular = "1\\.(0){0,2}|0\\.\\d{0,2}";
				if (!textStr.matches(regular)) {
					MessageDialog.openInformation(getShell(), Messages.getString("preference.EquivalentPage.msgTitle"), 
						Messages.getString("preference.EquivalentPage.msg5"));
					equiTxt.setText(defaultStr);
				}
			}
		}
	});
}
 
Example 17
Source Project: gama   Source File: ExpressionControl.java    License: GNU General Public License v3.0 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 18
public void setProposalProvider(IContentProposalProvider proposalProvider) {
    final TextContentAdapter controlContentAdapter = new TextContentAdapter();
    proposalAdapter = new ContentProposalAdapter(getControl(), controlContentAdapter,
            proposalProvider, contentAssistKeyStroke, null);
    proposalAdapter.setPropagateKeys(true);
    proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    proposalAdapter.setAutoActivationDelay(0);
    proposalAdapter.getControl().addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            AutoCompleteTextCellEditor.this.focusLost();
        }
    });
    proposalAdapter.addContentProposalListener(new IContentProposalListener() {

        @Override
        public void proposalAccepted(IContentProposal proposal) {
            fireApplyEditorValue();
        }

    });
}
 
Example 19
Source Project: ermaster-b   Source File: ModelPropertiesDialog.java    License: Apache License 2.0 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 20
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 21
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 22
Source Project: pentaho-kettle   Source File: TeraFastDialog.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param factory
 *          factory to use.
 */
protected void buildTableLine( final PluginWidgetFactory factory ) {
  final Control topControl = this.wConnection;

  this.wlTable = factory.createRightLabel( BaseMessages.getString( PKG, "TeraFastDialog.TargetTable.Label" ) );
  this.props.setLook( this.wlTable );
  this.wlTable.setLayoutData( factory.createLabelLayoutData( topControl ) );

  this.wTable = factory.createSingleTextVarLeft();
  this.props.setLook( this.wTable );
  this.wTable.setLayoutData( factory.createControlLayoutData( topControl ) );

  this.wTable.addFocusListener( new FocusAdapter() {
    @Override
    public void focusLost( final FocusEvent event ) {
      setTableFieldCombo();
    }
  } );
}
 
Example 23
public void focusGained(FocusEvent e)
{
	if (listening)
	{
		return;
	}
	if (firstActivation)
	{
		firstActivation = false;
		// On the first activation we update the commands to bindings because we want its side-effect
		// which is updating the tooltips to match the command.
		updateCommandToBinding();
	}
	listening = true;
	display = PlatformUI.getWorkbench().getDisplay();
	display.addFilter(SWT.KeyDown, this);
	display.addFilter(SWT.Traverse, this);

	setFindBarContextActive(true);
}
 
Example 24
Source Project: erflute   Source File: ModelPropertiesDialog.java    License: Apache License 2.0 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
Source Project: birt   Source File: TextEditorComposite.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void focusLost( FocusEvent e )
{
	if ( bTextModified )
	{
		fireEvent( );
	}
}
 
Example 26
Source Project: nebula   Source File: DayEditor.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public void focusGained(FocusEvent e) {
	TimeSlice sendingRow = (TimeSlice) ((Composite) e.widget).getParent();
	int day = sendingRow.getControlColumn(e.widget);
	int row = compositeTable.getControlRow(sendingRow);
	if (selectCalendarableControlOnSetFocus) {
		setSelectionByDayAndRow(day, row, null);
	} else {
		selectCalendarableControlOnSetFocus = true;
	}
}
 
Example 27
Source Project: nebula   Source File: MonthCalendar.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public void focusLost(FocusEvent e) {
	Day day = (Day) e.widget;
	Point coordinates = day.getMonthPosition();
	e.data = new MonthCalendarSelectedDay(day.getDate(), coordinates);

	for (Iterator<FocusListener> focusListenersIter = focusListeners.iterator(); focusListenersIter.hasNext();) {
		FocusListener listener = (FocusListener) focusListenersIter.next();
		listener.focusLost(e);
	}
}
 
Example 28
Source Project: e4macs   Source File: MetaXMinibuffer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
 */
@Override
public void focusGained(FocusEvent e) {
	 if (!isInBegin() && !isExecuting()) {
		 leave();
	 }
}
 
Example 29
Source Project: CogniCrypt   Source File: CompositeForCodeTab.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public CompositeForCodeTab(final Composite parent, final int style, final Answer answer) {
	super(parent, style);

	// Non-editable text box containing answer value
	final Text txtBoxAnswers = new Text(this, SWT.BORDER);
	txtBoxAnswers.setBounds(5, 5, 210, 25);
	txtBoxAnswers.setEditable(false);
	txtBoxAnswers.setText(answer.getValue());

	// Code dependency text field
	final Text txtValue = new Text(this, SWT.BORDER);
	txtValue.setBounds(220, 5, 200, 25);
	txtValue.setVisible(true);

	final CodeDependency codeDependency = new CodeDependency();

	if (answer.getCodeDependencies() != null) {
		for (final CodeDependency cd : answer.getCodeDependencies()) {
			if (cd.getValue() != null) {
				txtValue.setText(cd.getValue());
				codeDependency.setValue(txtValue.getText());
			}
		}
	}

	txtValue.addFocusListener(new FocusAdapter() {

		@Override
		public void focusLost(final FocusEvent e) {
			codeDependency.setValue(txtValue.getText());
		}
	});

	final ArrayList<CodeDependency> codeDependencies = new ArrayList<CodeDependency>();
	codeDependencies.add(codeDependency);
	answer.setCodeDependencies(codeDependencies);

}
 
Example 30
/**
 * 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);
                }
            }
        }});
}