Java Code Examples for org.eclipse.swt.widgets.Text.setTextLimit()

The following are Jave code examples for showing how to use setTextLimit() of the org.eclipse.swt.widgets.Text class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: eZooKeeper   File: ZooKeeperServerNewWizardPage1.java   View Source Code Vote up 6 votes
@Override
protected GridComposite createGridComposite(Composite parent) {

    GridComposite gridComposite = new GridComposite(parent) {

        @Override
        protected void createContents() {

            GridTextInput hostGridTextInput = new GridTextInput(this, GridTextInput.Type.VALUE_REQUIRED,
                    CONTROL_NAME_HOST_TEXT, "&Host:", ZooKeeperServerDescriptor.DEFAULT_HOST);
            addGridTextInput(hostGridTextInput);
            Text hostText = hostGridTextInput.getText();
            hostText.selectAll();
            hostText.setTextLimit(500);

            GridTextInput portGridTextInput = new GridTextInput(this, GridTextInput.Type.INTEGER_VALUE_REQUIRED,
                    CONTROL_NAME_PORT_TEXT, "&Port:", String.valueOf(ZooKeeperServerDescriptor.DEFAULT_PORT));
            addGridTextInput(portGridTextInput);
            Text portText = portGridTextInput.getText();
            portText.selectAll();

        }
    };

    return gridComposite;
}
 
Example 2
Project: eZooKeeper   File: GridTextInput.java   View Source Code Vote up 5 votes
/**
 * Constructor.
 *
 * @param parent The parent {@link Composite}.
 * @param type The {@link Type}.
 * @param name The {@link GridTextInput} name.
 * @param labelText The {@link Label} text.
 * @param labelStyle The {@link Label} style.
 * @param labelLayoutData The {@link Label} {@link GridData layout data}.
 * @param textText The {@link Text} text.
 * @param textStyle The {@link Text} style.
 * @param textLayoutData The {@link Text} {@link GridData layout data}.
 */
public GridTextInput(Composite parent, Type type, String name, String labelText, int labelStyle,
        GridData labelLayoutData, String textText, int textStyle, GridData textLayoutData) {

    _Type = type;

    _DefaultTextValue = textText;

    if (_DefaultTextValue != null && _Type.isInteger()) {
        if (!isValidIntegerText(_DefaultTextValue)) {
            throw new IllegalArgumentException("Invalid integer value: " + _DefaultTextValue);
        }
    }

    _Name = name;

    if (labelText != null) {
        _Label = new Label(parent, labelStyle);
        _Label.setText(labelText);
        _Label.setLayoutData(labelLayoutData);
        _Label.pack();
    }

    _Text = new Text(parent, textStyle);
    if (textText != null) {
        _Text.setText(textText);
    }
    _Text.setLayoutData(textLayoutData);

    if (_Type.isInteger()) {
        _Text.setTextLimit(10);
    }

    _Text.setData(this);

}
 
Example 3
Project: CharmMylynConnector   File: CharmQueryPage.java   View Source Code Vote up 5 votes
@Override
protected void createPageContent(@NonNull SectionComposite sectionComposite) {

	Composite parent = sectionComposite.getContent();

	Composite composite = new Composite(parent, SWT.BORDER);
	composite.setLayout(new GridLayout(2, false));

	Label lblDev = new Label(composite, SWT.NONE);
	lblDev.setText("Developer");
	developer = new Text(composite, SWT.BORDER);

	Label lblObjectId = new Label(composite, SWT.NONE);
	lblObjectId.setText("Process ID");
	objectId = new Text(composite, SWT.BORDER);
	objectId.setTextLimit(10);

	Label lblprocType = new Label(composite, SWT.NONE);
	lblprocType.setText("Process Type");
	procType = new Text(composite, SWT.BORDER);
	procType.setTextLimit(4);

	Label lblstatus = new Label(composite, SWT.NONE);
	lblstatus.setText("Status");
	status = new Text(composite, SWT.BORDER);

	Label lblPrio = new Label(composite, SWT.NONE);
	lblPrio.setText("Priority");
	priority = new Text(composite, SWT.BORDER);
	priority.setTextLimit(1);

}
 
Example 4
Project: Hydrograph   File: VerifyDigitLimitNumericListener.java   View Source Code Vote up 5 votes
@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;
}
 
Example 5
Project: Hydrograph   File: VerifyCharacterLimitListener.java   View Source Code Vote up 5 votes
@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 value = ((Text) widgets[0]).getText().trim();
				Matcher matchs = Pattern.compile(Constants.PARAMETER_REGEX).matcher(value);
				if ((!matchs.matches())) {
					txtDecorator.setDescriptionText(Messages.FIELDCHARACTER);
					txtDecorator.show();
					event.doit = false;
				} else if (matchs.matches()) {
					txtDecorator.hide();
				}
			}
		};
	return listener;

}
 
Example 6
Project: Hydrograph   File: JobRunPreferenceComposite.java   View Source Code Vote up 5 votes
/**
 * Create console buffer widget
 * @param bufferSize
 */
private void createConsoleBufferWidget(String bufferSize){
	HydroGroup hydroGroup = new HydroGroup(this, SWT.NONE);
	
	hydroGroup.setHydroGroupText(Messages.HYDROGRAPH_CONSOLE_PREFERANCE_PAGE_GROUP_NAME);
	hydroGroup.setLayout(new GridLayout(1, false));
	hydroGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
	hydroGroup.getHydroGroupClientArea().setLayout(new GridLayout(2, false));
	
	Label label = new Label(hydroGroup.getHydroGroupClientArea(), SWT.NONE);
	
	label.setText(Messages.PREFERANCE_CONSOLE_BUFFER_SIZE);
	
	textWidget = new Text(hydroGroup.getHydroGroupClientArea(), SWT.BORDER);
	textWidget.setText(bufferSize);
	textWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
	textWidget.setTextLimit(6);
	
	attachConsoleBufferValidator();
	
	Composite purgeComposite = new Composite(hydroGroup.getHydroGroupClientArea(), SWT.NONE);
	purgeComposite.setLayout(new GridLayout(2, false));
	purgeComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
	
	Label lblNote = new Label(purgeComposite, SWT.TOP | SWT.WRAP);
	lblNote.setText(Messages.PREFERANCE_PAGE_NOTE);
	FontData fontData = lblNote.getFont().getFontData()[0];
	Font font = new Font(purgeComposite.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
	lblNote.setFont(font);
	Label lblmsg = new Label(purgeComposite, SWT.TOP | SWT.WRAP);
	lblmsg.setText(Messages.UI_PERFORMANCE_NOTE_IN_CASE_OF_CHANGE_IN_BUFFER_SIZE);
	
}
 
Example 7
Project: Hydrograph   File: ComponentSearchUtility.java   View Source Code Vote up 5 votes
private void createAssitTextBox(Point cursorRelativePosition) {
	assistText = new Text((Composite) graphicControl, SWT.BORDER);
	assistText.setLocation(cursorRelativePosition.x, cursorRelativePosition.y - assistText.getLineHeight());
	assistText.setSize(200, assistText.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
	assistText.setTextLimit(51);
	assistText.setFocus();
}
 
Example 8
Project: Hydrograph   File: ELTComponentNameWidget.java   View Source Code Vote up 4 votes
@Override
public void attachToPropertySubGroup(AbstractELTContainerWidget container) {

	ELTDefaultSubgroupComposite eltDefaultSubgroupComposite = new ELTDefaultSubgroupComposite(
			container.getContainerControl());
	eltDefaultSubgroupComposite.createContainerWidget();

	AbstractELTWidget eltDefaultLable = new ELTDefaultLable(NAME);
	eltDefaultSubgroupComposite.attachWidget(eltDefaultLable);
	setPropertyHelpWidget((Control) eltDefaultLable.getSWTWidgetControl());

	AbstractELTWidget eltDefaultTextBox = new ELTDefaultTextBox().defaultText("Hello")
			.grabExcessHorizontalSpace(true);
	eltDefaultSubgroupComposite.attachWidget(eltDefaultTextBox);

	text = (Text) eltDefaultTextBox.getSWTWidgetControl();
	text.setFocus();
	text.setTextLimit(256);
	firstTextWidget = text;
	txtDecorator = WidgetUtility.addDecorator(text, Messages.FIELD_LABEL_ERROR);
	txtDecorator.setMarginWidth(3);
	ListenerHelper listenerHelper = new ListenerHelper();
	listenerHelper.put(HelperType.CONTROL_DECORATION, txtDecorator);
	listenerHelper.put(HelperType.CURRENT_COMPONENT, getComponent());
	try {
		listener = (ELTVerifyComponentNameListener) ListenerFactory.Listners.VERIFY_COMPONENT_NAME.getListener();
		listener.setNames((ArrayList<String>) super.componentMiscellaneousProperties
				.getComponentMiscellaneousProperty(COMPONENT_NAMES));
		eltDefaultTextBox.attachListener(listener, propertyDialogButtonBar, listenerHelper,
				eltDefaultTextBox.getSWTWidgetControl());

		focusOutListener = (ELTNormalFocusOutListener) ListenerFactory.Listners.NORMAL_FOCUS_OUT.getListener();
		listener.setNames((ArrayList<String>) super.componentMiscellaneousProperties
				.getComponentMiscellaneousProperty(COMPONENT_NAMES));
		eltDefaultTextBox.attachListener(focusOutListener, propertyDialogButtonBar, listenerHelper,
				eltDefaultTextBox.getSWTWidgetControl());

	} catch (Exception exception) {
		logger.error("Exception occured", exception);
	}

	populateWidget();

}
 
Example 9
Project: Hydrograph   File: GridWidgetCommonBuilder.java   View Source Code Vote up 3 votes
/**
 * Adds the text editor.
 * 
 * @param table
 *            the table
 * @param cellEditor
 *            the cell editor
 * @param position
 *            the position
 */
protected void addTextEditor(Table table, CellEditor[] cellEditor, Map<String, Integer> columns, String columnsName){
	
	cellEditor[columns.get(columnsName)]=new TextCellEditor(table);
	if(columnsName.equals(Messages.PRECISION) || columnsName.equals(Messages.SCALE)){
			TextCellEditor editor = (TextCellEditor) cellEditor[columns.get(columnsName)];
			Text txt = (Text) editor.getControl();
			txt.setTextLimit(2);
		}
}