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

The following are Jave code examples for showing how to use getText() 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: ZnodeNewWizardComposite1.java   View Source Code Vote up 6 votes
@Override
public byte[] getZnodeData() throws Exception {
    Text filePathText = (Text) getControl(CONTROL_NAME_DATA_FILE_TEXT);
    String filePath = filePathText.getText();
    File file = new File(filePath);
    String fileName = file.getName();
    if (!file.exists()) {
        throw new IOException("File '" + fileName + "' does not exist.");
    }

    if (!file.isFile()) {
        throw new IOException("Path '" + filePath + "' is not a valid file.");
    }

    long length = file.length();

    if (length > Znode.MAX_DATA_SIZE) {
        throw new Exception("File '" + fileName
                + "' size is greater than the maximum allowed Znode data size (" + Znode.MAX_DATA_SIZE
                + " bytes).");
    }

    FileEditor fileEditor = new FileEditor(file);
    return fileEditor.read();
}
 
Example 2
Project: Hydrograph   File: SchemaRowValidation.java   View Source Code Vote up 6 votes
private void checkIfXPathIsDuplicate( ) {
	Text loopXpathQueryTextBox=(Text)table.getData();
	String loopXPathQuery=loopXpathQueryTextBox.getText();
	Set<Path> setToCheckDuplicates= new HashSet<Path>();
	Set<String> uniqueName=new HashSet<>();
	for(TableItem tableItem:table.getItems()){
		Path xPathColumn=makeXPathAbsoluteIfNot(tableItem.getText(2), loopXPathQuery);
		if(!uniqueName.add(tableItem.getText(0))){
			tableItem.setData(Constants.ERROR_MESSAGE,FIELD_IS_DUPLICATE);
			setRedColor(tableItem);
		}
		else if(!setToCheckDuplicates.add(xPathColumn)){
			tableItem.setData(Constants.ERROR_MESSAGE,Messages.X_PATH_IS_DUPLICATE);
			setRedColor(tableItem);
		}
		else{
			tableItem.setData(Constants.ERROR_MESSAGE,"");
			setBlackColor(tableItem);
		}
	}	
}
 
Example 3
Project: Hydrograph   File: SelectionDatabaseWidget.java   View Source Code Vote up 6 votes
private SelectionAdapter buttonWidgetSelectionListener(Text textWidget){
	SelectionAdapter adapter = new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			String text = textWidget.getText();
			SQLQueryStatementDialog sqlQueryStatementDialog = new SQLQueryStatementDialog(
					Display.getCurrent().getActiveShell(), text);
			sqlQueryStatementDialog.open();
			if(sqlQueryStatementDialog.getStyleTextSqlQuery() != null){
				textWidget.setText(sqlQueryStatementDialog.getStyleTextSqlQuery());
			}
			if(sqlQueryStatementDialog.isTextValueChanged()){
				propertyDialogButtonBar.enableApplyButton(true);
			}
		}
	};
	return adapter;
}
 
Example 4
Project: Hydrograph   File: DataViewerListeners.java   View Source Code Vote up 6 votes
private void jumpPageListener() {
	final Text jumpPageTextBox = ((Text) windowControls.get(ControlConstants.JUMP_TEXT));

	if (((Text) windowControls.get(ControlConstants.JUMP_TEXT)).getText().isEmpty()) {
		statusManager.setStatus(new StatusMessage(StatusConstants.ERROR, Messages.JUMP_PAGE_TEXTBOX_CAN_NOTE_BE_EMPTY));
		return;
	}

	String statusMessage=Messages.FETCHING_PAGE + " " + jumpPageTextBox.getText();
	statusManager.setStatus(new StatusMessage(StatusConstants.PROGRESS, statusMessage));
	statusManager.setAllWindowControlsEnabled(false);
	
	Long pageNumberToJump = Long.valueOf(jumpPageTextBox.getText());
	
	executeJumpPageJob(statusMessage, pageNumberToJump);
}
 
Example 5
Project: eZooKeeper   File: GridComposite.java   View Source Code Vote up 5 votes
private GridCompositeStatus updateStatusFromGridTextInput(GridTextInput source) {
    Text textControl = source.getText();
    String name = source.getName();
    GridTextInput.Type inputType = source.getType();

    String message;
    GridCompositeStatus.Type statusType;

    String text = textControl.getText();
    String defaultValue = source.getDefaultTextValue();

    if (inputType.isValueRequired() && text.trim().length() == 0) {

        if (defaultValue != null) {
            message = name + " value must be specified.  Default value is " + defaultValue;
        }
        else {
            message = name + " value must be specified.";
        }

        statusType = GridCompositeStatus.Type.ERROR_REQUIRED;
        return new GridCompositeStatus(name, message, statusType);
    }

    if (inputType.isInteger() && !GridTextInput.isValidIntegerText(text)) {

        if (defaultValue != null) {
            message = name + " value must be a positive integer.  Default value is " + defaultValue;
        }
        else {
            message = name + " value must be a positive integer.";
        }

        statusType = GridCompositeStatus.Type.ERROR_INVALID;
        return new GridCompositeStatus(name, message, statusType);
    }

    return GridCompositeStatus.OK_STATUS;
}
 
Example 6
Project: eZooKeeper   File: AddAuthInfoDialog.java   View Source Code Vote up 5 votes
@Override
protected void okPressed() {
    GridComposite gridComposite = getGridComposite();
    CCombo typeCombo = (CCombo) gridComposite.getControl(CONTROL_NAME_TYPE_COMBO);
    Text schemeText = (Text) gridComposite.getControl(CONTROL_NAME_SCHEME_TEXT);
    Text authStringText = (Text) gridComposite.getControl(CONTROL_NAME_AUTH_STRING_TEXT);

    AuthInfo.Type type = AuthInfo.Type.valueOf(typeCombo.getText());
    String scheme = schemeText.getText();
    String authString = authStringText.getText();

    _AuthInfo = new AuthInfo(type, scheme, authString);
    super.okPressed();
}
 
Example 7
Project: eZooKeeper   File: ZnodeAclComposite.java   View Source Code Vote up 5 votes
@Override
protected void okPressed() {
    GridComposite gridComposite = getGridComposite();

    Text userNameText = (Text) gridComposite.getControl(CONTROL_NAME_USER_NAME_TEXT);
    Text passwordText = (Text) gridComposite.getControl(CONTROL_NAME_PASSWORD_TEXT);

    String userName = userNameText.getText();
    String password = passwordText.getText();

    _DigestId = generateDigest(userName + ":" + password);

    super.okPressed();
}
 
Example 8
Project: eZooKeeper   File: ZooKeeperServerNewWizardPage2.java   View Source Code Vote up 5 votes
public String getPassword() {
    Text passwordText = (Text) getGridComposite().getControl(CONTROL_NAME_PASSWORD_TEXT);
    String password = passwordText.getText();
    if (password.isEmpty()) {
        return null;
    }
    return password;
}
 
Example 9
Project: eZooKeeper   File: ZooKeeperConnectionComposite1.java   View Source Code Vote up 5 votes
public ZooKeeperConnectionDescriptor getConnectionDescriptor() {

        Text nameText = (Text) getControl(CONTROL_NAME_NAME_TEXT);
        Text sessionTimeoutText = (Text) getControl(CONTROL_NAME_SESSION_TIMEOUT_TEXT);

        String name = nameText.getText();
        int sessionTimeout = Integer.parseInt(sessionTimeoutText.getText());

        ZooKeeperConnectionDescriptor connection = new ZooKeeperConnectionDescriptor(name, sessionTimeout);

        connection.getServers().addAll(_ServerComposite.getElementList());
        connection.setRootPath(getRootPath());
        return connection;
    }
 
Example 10
Project: avro-schema-editor   File: TextValidator.java   View Source Code Vote up 5 votes
protected void validate() {
    Text text = (Text) deco.getControl();
    String value = text.getText();
    String errorMsg = validator.isValid(value);
    if (errorMsg == null) {
    	deco.hide();            
    }
    else {
    	deco.show();
        deco.setImage(errorImg);
        deco.setDescriptionText(errorMsg);
    }
}
 
Example 11
Project: eZooKeeper   File: ZnodeNewWizardComposite1.java   View Source Code Vote up 5 votes
/**
 * TODO: Comment.
 * 
 * @param text
 * @return
 */
protected byte[] getZnodeData(Text text) throws Exception {
    String stringValue = text.getText();

    if (stringValue.isEmpty()) {
        return null;
    }

    // TODO: Need to support other Charsets?
    byte[] data = stringValue.getBytes();
    return data;
}
 
Example 12
Project: eZooKeeper   File: JmxConnectionNewWizardPage1.java   View Source Code Vote up 5 votes
public JMXServiceURL getServiceUrl() {
    Text jmxUrlText = (Text) getGridComposite().getControl(CONTROL_NAME_JMX_URL_TEXT);
    String jmxServiceUrlString = jmxUrlText.getText();

    try {
        return new JMXServiceURL(jmxServiceUrlString);
    }
    catch (MalformedURLException e) {
        // Validation should ensure that this should never happen
        return null;
    }
}
 
Example 13
Project: Hydrograph   File: EmptyTextListener.java   View Source Code Vote up 5 votes
@Override
public void modifyText(ModifyEvent event) {
	Text textBox = (Text)event.getSource();
	Button btnRemoteMode = (Button)textBox.getData(RunConfigDialog.SELECTION_BUTTON_KEY);
	String txt= textBox.getText();

	if (StringUtils.isBlank(txt)) {
		if(errorDecorator==null){
		errorDecorator = WidgetUtility.addDecorator(textBox,Messages.bind(Messages.EMPTY_FIELD, fieldName));
		}
		if(btnRemoteMode!=null){
			if(btnRemoteMode.getSelection()){
				errorDecorator.show();
			}else
				errorDecorator.hide();
		}else{
			errorDecorator.show();
		}
		errorDecorator.setMarginWidth(3);

	} else {
		if(errorDecorator!=null)
			errorDecorator.hide();

	}

}
 
Example 14
Project: bdf2   File: TransitionLabelDirectEditPolicy.java   View Source Code Vote up 4 votes
@Override
protected Command getDirectEditCommand(DirectEditRequest request) {
	Text text=(Text)request.getCellEditor().getControl();
	TransitionLabel transitionLabel=(TransitionLabel)(this.getHost().getModel());
	return new TransitionLabelDirectEditCommand(transitionLabel,text.getText());
}
 
Example 15
Project: eZooKeeper   File: ZooKeeperServerNewWizardPage1.java   View Source Code Vote up 4 votes
public String getHost() {
    Text hostText = (Text) getGridComposite().getControl(CONTROL_NAME_HOST_TEXT);
    String host = hostText.getText();
    return host.trim();
}
 
Example 16
Project: avro-schema-editor   File: TextValidator.java   View Source Code Vote up 4 votes
protected String getCurrentValue() {
	Text text = (Text) deco.getControl();
	return text.getText();
}
 
Example 17
Project: eZooKeeper   File: ZooKeeperConnectionComposite1.java   View Source Code Vote up 4 votes
@Override
protected GridCompositeStatus updateStatus(Object source) {
    GridCompositeStatus status = super.updateStatus(source);
    if (status.getType().isError()) {
        return status;
    }

    String message;

    if (source instanceof GridTextInput) {
        GridTextInput gridTextInput = (GridTextInput) source;
        if (gridTextInput.getName().equals(CONTROL_NAME_NAME_TEXT)) {

            Text nameText = gridTextInput.getText();
            String name = nameText.getText();
            if (_ZooKeeperConnectionNames.contains(name)) {
                message = "Name must be unique.";
                return new GridCompositeStatus(CONTROL_NAME_NAME_TEXT, message,
                        GridCompositeStatus.Type.ERROR_INVALID);
            }
        }
        else if (gridTextInput.getName().equals(CONTROL_NAME_ROOT_PATH_TEXT)) {

            String rootPath = getRootPath();
            if (rootPath != null) {
                try {
                    Znode.validatePath(rootPath, false);
                }
                catch (IllegalArgumentException e) {
                    message = e.getMessage();
                    return new GridCompositeStatus(CONTROL_NAME_ROOT_PATH_TEXT, message,
                            GridCompositeStatus.Type.ERROR_INVALID);
                }
            }
        }
    }
    else if (source instanceof Table) {
        Table serversTable = (Table) source;
        if (serversTable.getItemCount() == 0) {
            message = "At least one server must be added.";
            return new GridCompositeStatus(CONTROL_NAME_SERVERS_TABLE, message,
                    GridCompositeStatus.Type.ERROR_REQUIRED);
        }
    }

    return GridCompositeStatus.OK_STATUS;
}
 
Example 18
Project: eZooKeeper   File: ZnodeNewWizardComposite1.java   View Source Code Vote up 4 votes
@Override
protected GridCompositeStatus updateStatus(Object source) {

    GridCompositeStatus status = super.updateStatus(source);
    if (status.getType().isError()) {
        return status;
    }

    String message;

    if (source instanceof GridTextInput) {
        GridTextInput gridTextInput = (GridTextInput) source;
        if (gridTextInput.getName().equals(CONTROL_NAME_PATH_TEXT)) {

            Text pathText = gridTextInput.getText();

            String relativePath = pathText.getText();
            if (relativePath.indexOf(Znode.PATH_SEPARATOR_CHAR) >= 0) {
                message = CONTROL_NAME_PATH_TEXT + " should not contain the '" + Znode.PATH_SEPARATOR_CHAR
                        + "' character.";
                return new GridCompositeStatus(CONTROL_NAME_PATH_TEXT, message,
                        GridCompositeStatus.Type.ERROR_INVALID);
            }

            // TODO: Validate characters in the text (spaces etc)?

            ZnodeModel parentZnodeModel = getParentZnodeModel();
            Znode parentZnode = parentZnodeModel.getData();
            String parentPath = parentZnode.getPath();

            String absolutePath = Znode.getAbsolutePath(parentPath, relativePath);

            Button sequentialCheckbox = (Button) getControl(CONTROL_NAME_CREATE_MODE_SEQUENTIAL_BUTTON);
            boolean isSequential = sequentialCheckbox.getSelection();

            if (!isSequential) {
                // Use the DataModelManager for a hash look-up (avoid possibly long child string list scan).
                if (parentZnodeModel.getManager().findKeys(parentZnode).contains(absolutePath)) {

                    // TODO: Should this take the sequential flag into account (i think yes).

                    message = "Znode '" + absolutePath + "' already exists.";
                    return new GridCompositeStatus(CONTROL_NAME_PATH_TEXT, message,
                            GridCompositeStatus.Type.ERROR_INVALID);
                }
            }

            try {
                Znode.validatePath(absolutePath, isSequential);
            }
            catch (IllegalArgumentException e) {
                message = e.getMessage();
                return new GridCompositeStatus(CONTROL_NAME_PATH_TEXT, message,
                        GridCompositeStatus.Type.ERROR_INVALID);
            }
        }
    }

    return GridCompositeStatus.OK_STATUS;
}
 
Example 19
Project: avro-schema-editor   File: TextValidator.java   View Source Code Vote up 4 votes
protected boolean isValid() {
	Text text = (Text) deco.getControl();
    String value = text.getText();
    return validator.isValid(value) == null;
}
 
Example 20
Project: bdf2   File: NodeDirectEditPolicy.java   View Source Code Vote up 4 votes
@Override
protected Command getDirectEditCommand(DirectEditRequest request) {
	Text text=(Text)request.getCellEditor().getControl();
	return new NodeDirectEditCommand(((AbstractNodeElement)this.getHost().getModel()),text.getText());
}