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

The following are Jave code examples for showing how to use setData() 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: gw4e.project   File: GW4ELaunchConfigurationTab.java   View Source Code Vote up 6 votes
/**
 * Create the element that allow to select a project See the GraphWalker
 * offline command for more information
 */
private void createProjectSection(Composite parent) {
	fProjLabel = new Label(parent, SWT.NONE);
	fProjLabel.setText(MessageUtil.getString("label_project"));
	GridData gd = new GridData();
	gd.horizontalIndent = 25;
	fProjLabel.setLayoutData(gd);

	fProjText = new Text(parent, SWT.SINGLE | SWT.BORDER);
	fProjText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	fProjText.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent evt) {
			validatePage();
			updateConfigState();

		}
	});
	fProjText.setData(GW4E_LAUNCH_CONFIGURATION_CONTROL_ID, GW4E_LAUNCH_CONFIGURATION_TEXT_ID_PROJECT);

}
 
Example 2
Project: gw4e.project   File: GW4ELaunchConfigurationTab.java   View Source Code Vote up 6 votes
/**
 * Create the element that allow to select a start element See the
 * GraphWalker offline command for more information
 */
private void createStartElementSection(Composite parent) {

	Label fGeneratorLabel = new Label(parent, SWT.NONE);
	fGeneratorLabel.setText("Start Element");
	gd = new GridData();
	gd.horizontalSpan = 1;
	gd.horizontalIndent = 25;
	fGeneratorLabel.setLayoutData(gd);

	fStartNodeText = new Text(parent, SWT.SINGLE | SWT.BORDER);
	fStartNodeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	fStartNodeText.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent evt) {
			validatePage();
			updateConfigState();
			fStartNodeText.setFocus();
		}
	});
	fStartNodeText.setData(GW4E_LAUNCH_CONFIGURATION_CONTROL_ID, GW4E_LAUNCH_CONFIGURATION_TEXT_ID_START_ELEMENT);
}
 
Example 3
Project: gw4e.project   File: GW4ELaunchConfigurationTab.java   View Source Code Vote up 6 votes
/**
 * Create the element that allow to select a project See the GraphWalker
 * offline command for more information
 */
private void createProjectSection(Composite parent) {
	fProjLabel = new Label(parent, SWT.NONE);
	fProjLabel.setText(MessageUtil.getString("label_project"));
	GridData gd = new GridData();
	gd.horizontalIndent = 25;
	fProjLabel.setLayoutData(gd);

	fProjText = new Text(parent, SWT.SINGLE | SWT.BORDER);
	fProjText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	fProjText.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent evt) {
			validatePage();
			updateConfigState();

		}
	});
	fProjText.setData(GW4E_LAUNCH_CONFIGURATION_CONTROL_ID, GW4E_LAUNCH_CONFIGURATION_TEXT_ID_PROJECT);

}
 
Example 4
Project: gw4e.project   File: GW4ELaunchConfigurationTab.java   View Source Code Vote up 6 votes
/**
 * Create the element that allow to select a start element See the
 * GraphWalker offline command for more information
 */
private void createStartElementSection(Composite parent) {

	Label fGeneratorLabel = new Label(parent, SWT.NONE);
	fGeneratorLabel.setText("Start Element");
	gd = new GridData();
	gd.horizontalSpan = 1;
	gd.horizontalIndent = 25;
	fGeneratorLabel.setLayoutData(gd);

	fStartNodeText = new Text(parent, SWT.SINGLE | SWT.BORDER);
	fStartNodeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	fStartNodeText.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent evt) {
			validatePage();
			updateConfigState();
			fStartNodeText.setFocus();
		}
	});
	fStartNodeText.setData(GW4E_LAUNCH_CONFIGURATION_CONTROL_ID, GW4E_LAUNCH_CONFIGURATION_TEXT_ID_START_ELEMENT);
}
 
Example 5
Project: Hydrograph   File: FilterConditionsDialog.java   View Source Code Vote up 6 votes
private Text addTextBoxInTable(TableViewer tableViewer, TableItem tableItem, String textBoxName, 
		String valueTextPane, String editorName, int columnIndex, Listener listener) {
	final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE);
	buttonPane.setLayout(new FillLayout());
	final Text text = new Text(buttonPane, SWT.NONE);
	text.addListener(SWT.Modify, listener);
	text.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem));
	tableItem.setData(textBoxName, text);
	tableItem.setData(valueTextPane, buttonPane);
	//text.addModifyListener(FilterHelper.INSTANCE.getTextModifyListener());
	
	final TableEditor editor = new TableEditor(tableViewer.getTable());
	editor.grabHorizontal = true;
	editor.grabVertical = true;
	editor.setEditor(buttonPane, tableItem, columnIndex);
	editor.layout();
	text.setData(editorName, editor);
	return text;
}
 
Example 6
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 7
Project: gw4e.project   File: GraphModelPropertyPage.java   View Source Code Vote up 5 votes
/**
 * Create the Text that will hold the Requirement coming from the graphml file
 * @param panel
 * @param file
 */
protected void createrequirementSection(Composite panel, IFile file) {
	Label label = createLabel(panel, MessageUtil.getString("Requirements")); //$NON-NLS-1$
	Text t = new Text(panel, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
	t.setData(GW4E_FILE_REQUIREMENT_TEXT_ID,GW4E_FILE_REQUIREMENT_TEXT_ID );
	Set<String> requirements = null;
	String reqMessage = "";
	try {
		requirements = GraphWalkerFacade.getRequirement(file);
		String newline = System.getProperty("line.separator");
		if (requirements == null || requirements.size() == 0) {
			reqMessage = MessageUtil.getString("NoRequirements");
		} else {
			StringBuffer sb = new StringBuffer();

			for (String req : requirements) {
				sb.append(req).append(newline);
			}
			t.setText(sb.toString());
			reqMessage = requirements.size() + " " + MessageUtil.getString("requirementsfound");
		}
	} catch (Exception e) {
		ResourceManager.logException(e);
		t.setText(e.getMessage());
	}
	t.setEditable(false);
	GridDataFactory.fillDefaults().grab(true, true).hint(150, 150).applyTo(t);

	createLabel(panel, MessageUtil.getString("requirementMessage")); //$NON-NLS-1$
	label = createLabel(panel, reqMessage);
	fillExcessHorizontalSpace(label);
}
 
Example 8
Project: gw4e.project   File: GraphModelPropertyPage.java   View Source Code Vote up 5 votes
/**
 * Create the Text that will hold the Methods coming from the graphml file
 * 
 * @param panel
 * @param file
 */
protected void createMethodSection(Composite panel, IFile file) {
	Label label = createLabel(panel, MessageUtil.getString("Methods")); //$NON-NLS-1$
	Text t = new Text(panel, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
	t.setData(GraphModelPropertyPage.GW4E_FILE_METHODS_TEXT_ID, GW4E_FILE_METHODS_TEXT_ID);
	Set<String> methods = null;
	String reqMessage = "";
	try {
		methods = GraphWalkerFacade.getMethods(file);
		String newline = System.getProperty("line.separator");
		if (methods == null || methods.size() == 0) {
			reqMessage = MessageUtil.getString("NoMethods");
		} else {
			StringBuffer sb = new StringBuffer();

			for (String meth : methods) {
				sb.append(meth).append(newline);
			}
			t.setText(sb.toString());
			reqMessage = methods.size() + " " + MessageUtil.getString("methodsfound");
		}
	} catch (Exception e) {
		ResourceManager.logException(e);
		t.setText(e.getMessage());
	}
	t.setEditable(false);
	GridDataFactory.fillDefaults().grab(true, true).hint(150, 150).applyTo(t);

	createLabel(panel, MessageUtil.getString("methodMessage")); //$NON-NLS-1$
	label = createLabel(panel, reqMessage);
	fillExcessHorizontalSpace(label);
}
 
Example 9
Project: gw4e.project   File: GeneratorChoiceComposite.java   View Source Code Vote up 5 votes
private void createNewMode() {
	btnCreateNewRadioButton = new Button(this, SWT.RADIO);
	btnCreateNewRadioButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 12, 1));
	btnCreateNewRadioButton.setText(MessageUtil.getString("standalone_mode"));
	btnCreateNewRadioButton.setSelection(false);
	btnCreateNewRadioButton.addListener(SWT.Selection, new Listener() {
		public void handleEvent(Event e) {
			switch (e.type) {
			case SWT.Selection:
				updateUI();
				break;
			}
		}
	});
	btnCreateNewRadioButton.setData(GW4E_CONVERSION_WIDGET_ID, GW4E_NEWCLASS_CHECKBOX);

	Composite composite = new Composite(this, SWT.NONE);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 12, 1));
	composite.setLayout(new GridLayout(12, false));

	lblNewClassnameLabel = new Label(composite, SWT.NONE);
	lblNewClassnameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
	lblNewClassnameLabel.setText("Class name");
	lblNewClassnameLabel.setEnabled(false);

	newClassnameText = new Text(composite, SWT.BORDER);
	newClassnameText.setEnabled(false);
	newClassnameText.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent event) {
			listener.handleEvent(null);
		}
	});
	newClassnameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 8, 1));
	newClassnameText.setEnabled(false);
	newClassnameText.setData(GW4E_CONVERSION_WIDGET_ID, GW4E_NEWCLASS_TEXT);
}
 
Example 10
Project: Hydrograph   File: FilterOperationClassUtility.java   View Source Code Vote up 5 votes
/**
 * Creates the new class wizard.
 * 
 * @param fileNameTextBox
 *            the file name
 * @param widgetConfig 
 */
public void createNewClassWizard(Text fileNameTextBox, WidgetConfig widgetConfig) {
	OpenNewClassWizardAction wizard = new OpenNewClassWizardAction();
	wizard.setOpenEditorOnFinish(false);
	final CustomizeNewClassWizardPage page = new CustomizeNewClassWizardPage();
	page.setSuperClass("java.lang.Object", true);
	page.setMethodStubSelection(false, false, true, true);
	List<String> interfaceList = new ArrayList<String>();
	OperationClassConfig operationClassConfig = (OperationClassConfig) widgetConfig;
	Operations operations = XMLConfigUtil.INSTANCE.getComponent(getComponentName()).getOperations();
	TypeInfo typeInfo=operations.getInterface();
	if (operationClassConfig!=null && operationClassConfig.getComponentName().equalsIgnoreCase(typeInfo.getName()))
	{
		interfaceList.add(typeInfo.getClazz());
	}
	page.setSuperInterfaces(interfaceList, true);  
	wizard.setConfiguredWizardPage(page);
	if(OSValidator.isMac()){
		Display.getDefault().timerExec(0, new Runnable() {

			@Override
			public void run() {
				page.getControl().forceFocus();					
			}
		});
	}
	wizard.run();
	if (page.isPageComplete()) {
		if(!page.getPackageText().equalsIgnoreCase("")){
			fileNameTextBox.setText(page.getPackageText()+"."
					+ page.getTypeName());
		}else{
			fileNameTextBox.setText(page.getTypeName());
		}
	}
	fileNameTextBox.setData("path", "/" + page.getPackageFragmentRootText() + "/"
			+ page.getPackageText().replace(".", "/") + "/"
			+ page.getTypeName() + ".java");
}
 
Example 11
Project: Hydrograph   File: FilterOperationClassUtility.java   View Source Code Vote up 5 votes
/**
	 * Open selection dialog for Java files, File selection restricted to ".java" extension.
	 * @param filterExtension
	 * @param fileName
	 */
	public static void browseJavaSelectionDialog(String filterExtension, Text fileName) {
		ResourceFileSelectionDialog dialog = new ResourceFileSelectionDialog(
				"Project", "Select Java Class (.java)", new String[] { filterExtension });
		if (dialog.open() == IDialogConstants.OK_ID) {
			IResource resource = (IResource) dialog.getFirstResult();
			String filePath = resource.getRawLocation().toOSString();
			java.nio.file.Path path =Paths.get(filePath); 
			String classFile=path.getFileName().toString();
			String name = "";
			try(BufferedReader reader= new BufferedReader(new FileReader(filePath))){ 
				String firstLine= reader.readLine();
				if(firstLine.contains(Constants.PACKAGE)){
					name= firstLine.replaceFirst(Constants.PACKAGE, "").replace(";", "");
					if(!name.equalsIgnoreCase("")){
						name=name+"."+classFile.substring(0, classFile.lastIndexOf('.'));
					}
					
				}else{
					name=classFile.substring(0, classFile.lastIndexOf('.'));
				}
				
			} catch (IOException e) { 
				logger.error("Unable to read file " + filePath,e );
			}
			fileName.setText(name.trim());
			filePath = resource.getRawLocation().toOSString();
			fileName.setData("path", resource.getFullPath().toString());
}
	}
 
Example 12
Project: Hydrograph   File: ExecutionTrackingPreferanceComposite.java   View Source Code Vote up 5 votes
/**
 * Check if text box contains any alphabets
 * @param textBox
 * @param value
 * @param message
 */
private void validatePortField(Text textBox, String value, String message) {
	if (StringUtils.isBlank(value) || !value.matches(Constants.PORT_VALIDATION_REGEX)) {
		textBox.setData(ERROR_KEY, message);
		executionTrackPreference.setValid(false);
	} else {
		textBox.setData(ERROR_KEY, null);
		executionTrackPreference.setValid(true);
	}
	checkState();
}
 
Example 13
Project: Hydrograph   File: ExecutionTrackingPreferanceComposite.java   View Source Code Vote up 5 votes
/**
 * Check if text box is blank
 * @param textBox
 * @param value
 * @param message
 */
protected void validationForTextField(Text textBox, String message) {
	if (StringUtils.isBlank(textBox.getText())) {
		textBox.setData(ERROR_KEY, message);
		executionTrackPreference.setValid(false);
	} else {
		textBox.setData(ERROR_KEY, null);
		executionTrackPreference.setValid(true);
	}
	checkState();
}
 
Example 14
Project: gw4e.project   File: GeneratorChoiceComposite.java   View Source Code Vote up 4 votes
private void createExtendMode() {
	btnExtendRadioButton = new Button(this, SWT.RADIO);
	btnExtendRadioButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 12, 1));
	btnExtendRadioButton.setText(MessageUtil.getString("extending_class"));
	btnExtendRadioButton.setSelection(false);
	btnExtendRadioButton.addListener(SWT.Selection, new Listener() {
		public void handleEvent(Event e) {
			switch (e.type) {
			case SWT.Selection:
				updateUI();
				break;
			}
		}
	});
	btnExtendRadioButton.setData(GW4E_CONVERSION_WIDGET_ID, GW4E_EXTEND_CHECKBOX);

	Composite composite = new Composite(this, SWT.NONE);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 12, 1));
	composite.setLayout(new GridLayout(12, false));

	lblExtendedLabel = new Label(composite, SWT.NONE);
	lblExtendedLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
	lblExtendedLabel.setText(MessageUtil.getString("class_extended"));
	lblExtendedLabel.setEnabled(false);

	comboExtendedClassnameViewer = new AncestorViewer(composite);
	comboExtendedClassnameViewer.initialize(GW4E_CONVERSION_COMBO_ANCESTOR_EXTEND_TEST, false);
	comboExtendedClassnameViewer.getCombo().setData(GW4E_CONVERSION_WIDGET_ID, GW4E_CONVERSION_COMBO_ANCESTOR_EXTEND_TEST);
	
	Combo combo = comboExtendedClassnameViewer.getCombo();
	combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 8, 1));
	combo.setEnabled(false);

	lblExtendingLabel = new Label(composite, SWT.NONE);
	lblExtendingLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
	lblExtendingLabel.setText(MessageUtil.getString("classname"));
	lblExtendingLabel.setEnabled(false);

	extendingClassnameText = new Text(composite, SWT.BORDER);
	extendingClassnameText.setEnabled(false);
	extendingClassnameText.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent event) {
			listener.handleEvent(null);
		}
	});
	extendingClassnameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 8, 1));
	extendingClassnameText.setEnabled(false);
	extendingClassnameText.setData(GW4E_CONVERSION_WIDGET_ID, GW4E_EXTEND_CLASS_TEXT);
}