本文整理匯總了Java中org.eclipse.swt.widgets.Text.setBackground方法的典型用法代碼示例。如果您正苦於以下問題:Java Text.setBackground方法的具體用法?Java Text.setBackground怎麽用?Java Text.setBackground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.Text
的用法示例。
在下文中一共展示了Text.setBackground方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createDialogArea
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
@Override
protected Control createDialogArea(Composite parent) {
Composite comp = (Composite) super.createDialogArea(parent);
Text filed = new Text(comp, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
| SWT.READ_ONLY | SWT.MULTI);
filed.setText(text);
filed.setBackground(getShell().getDisplay().getSystemColor(
SWT.COLOR_LIST_BACKGROUND));
filed.setFont(JFaceResources.getTextFont());
PixelConverter pc = new PixelConverter(filed);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = pc.convertWidthInCharsToPixels(80);
gd.heightHint = pc.convertHeightInCharsToPixels(30);
filed.setLayoutData(gd);
return comp;
}
示例2: validate
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
private void validate(Text text1, Text text2,
ControlDecoration text1Decorator, ControlDecoration text2Decorator, String lowerValue, String upperValue) {
if(validateNumericField(text1.getText())){
text1Decorator.hide();
if(StringUtils.isNotBlank(text2.getText()) && validateNumericField(text2.getText())){
if(compareBigIntegerValue(upperValue, lowerValue) == -1){
text1Decorator.show();
text1Decorator.setDescriptionText(Messages.UPPER_LOWER_BOUND_ERROR);
}else{
text1Decorator.hide();
text2Decorator.hide();
}
}
}
else{
text1Decorator.show();
text1.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255));
text1Decorator.setDescriptionText(Messages.DB_NUMERIC_PARAMETERZIATION_ERROR);
validateFieldWithParameter(text1.getText(), text1Decorator);
validateFieldWithParameter(text2.getText(), text2Decorator);
}
}
示例3: initialize
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
protected void initialize() {
GridData gridData = new org.eclipse.swt.layout.GridData();
gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
cicsData = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
cicsData.setEditable(false);
cicsData.setBackground(new Color(null,253,253,244));
cicsData.setFont(new Font(null,"Courier New",10,1));
cicsData.setLayoutData(gridData);
cicsData.setText("");
this.setLayout(new GridLayout());
setSize(new Point(300, 200));
}
示例4: addHeader
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
public Composite addHeader(){
Composite composite = new Composite(container, SWT.NONE);
GridLayout gl_composite = new GridLayout(textGridRow.getNumberOfColumn() + 1, false);
gl_composite.horizontalSpacing = 7;
gl_composite.marginWidth = 1;
gl_composite.marginHeight = 0;
gl_composite.verticalSpacing = 1;
composite.setLayout(gl_composite);
Button rowSelection = new Button(composite, SWT.CHECK);
Map<Integer, TextGridColumnLayout> columns = textGridRow.getTextGridColumns();
for(int columnNumber:columns.keySet()){
Text text = new Text(composite, SWT.BORDER);
if(!columns.get(columnNumber).grabHorizantalAccessSpace()){
GridData gd_text = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_text.widthHint = columns.get(columnNumber).getColumnWidth();
text.setLayoutData(gd_text);
text.setEditable(false);
text.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
text.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION));
}else{
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
text.setBounds(0, 0, 76, 21);
text.setFocus();
text.setEditable(false);
text.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
text.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION));
}
if(rowData!=null)
text.setText(rowData.get(columnNumber));
}
return composite;
}
示例5: validateTextWidget
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
private void validateTextWidget(Text text, boolean isEnable, ControlDecoration controlDecoration, Color color){
text.setText("");
text.setEnabled(isEnable);
if(!isEnable){
controlDecoration.hide();
}
text.setBackground(color);
}
示例6: createText
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
/**
* Create Text Widget
* @param control
* @param widgetName
* @return
*/
public Widget createText(Composite control, String widgetName, int style){
Text text = new Text(control, style);
GridData gd_text = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gd_text.horizontalIndent = 10;
text.setLayoutData(gd_text);
text.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 204));
return text;
}
示例7: removeModifyListener
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
/**
*
*/
public void removeModifyListener(Text text, PropertyDialogButtonBar propertyDialogButtonBar, Cursor cursor,
ControlDecoration controlDecoration){
controlDecoration.hide();
ELTModifyListener eltModifyListener = new ELTModifyListener();
ListenerHelper helper = new ListenerHelper();
helper.put(HelperType.CONTROL_DECORATION, controlDecoration);
text.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255));
text.removeListener(SWT.Modify, eltModifyListener.getListener(propertyDialogButtonBar, helper, text));
}
示例8: validateText
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
private boolean validateText(Text text, String fieldName, Map<String, String> fieldsAndTypes, String conditionalOperator) {
String type = FilterValidator.INSTANCE.getType(fieldName, fieldsAndTypes);
if((StringUtils.isNotBlank(text.getText()) && FilterValidator.INSTANCE.validateDataBasedOnTypes(type, text.getText(), conditionalOperator,debugDataViewer,fieldName)) ||
FilterValidator.INSTANCE.validateField(fieldsAndTypes,text.getText(),fieldName)){
text.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255));
return true;
}else {
text.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 244, 113));
return false;
}
}
示例9: createDialogArea
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
private Control createDialogArea(Composite shell) {
GridLayout layout = new GridLayout();
layout.numColumns = 1;
shell.setLayout(layout);
lblStep = new Label(shell, SWT.NONE);
lblStep.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
lblStep.setText("Step 1 / 999");
lblMessage = new Label(shell, SWT.NONE);
lblMessage.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
lblMessage.setText("Idle");
pbProg = new ProgressBar(shell, SWT.SMOOTH | SWT.INDETERMINATE);
pbProg.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
pbProg.setMaximum(1000);
pbProg.setSelection(0);
pbProg.setSelection(256);
final Label lblSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
lblSeparator.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
txtLog = new Text(shell, SWT.MULTI
| SWT.BORDER
| SWT.H_SCROLL
| SWT.V_SCROLL);
txtLog.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
txtLog.setEditable(false);
txtLog.setBackground(new Color(shell.getDisplay(), 10,10,10));
txtLog.setForeground(new Color(shell.getDisplay(), 200,200,200));
shell.layout();
return shell;
}
示例10: open
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
/**
* Create and display the wizard pane.
* @see com.webcodepro.applecommander.ui.swt.wizard.WizardPane#open()
*/
public void open() {
control = new Composite(parent, SWT.NULL);
control.setLayoutData(layoutData);
wizard.enableNextButton(false);
wizard.enableFinishButton(true);
RowLayout layout = new RowLayout(SWT.VERTICAL);
layout.justify = true;
layout.marginBottom = 5;
layout.marginLeft = 5;
layout.marginRight = 5;
layout.marginTop = 5;
layout.spacing = 3;
control.setLayout(layout);
Label label = new Label(control, SWT.WRAP);
label.setText(textBundle.get("ExportFilePrompt")); //$NON-NLS-1$
directoryText = new Text(control, SWT.WRAP | SWT.BORDER);
if (wizard.getDirectory() != null) directoryText.setText(wizard.getDirectory());
directoryText.setLayoutData(new RowData(parent.getSize().x - 30, -1));
directoryText.setBackground(new Color(control.getDisplay(), 255,255,255));
directoryText.setFocus();
directoryText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
Text text = (Text) event.getSource();
getWizard().setDirectory(text.getText());
}
});
Button button = new Button(control, SWT.PUSH);
button.setText(textBundle.get("BrowseButton")); //$NON-NLS-1$
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog directoryDialog = new DirectoryDialog(getShell());
directoryDialog.setFilterPath(getDirectoryText().getText());
directoryDialog.setMessage(
UiBundle.getInstance().get("ExportFileDirectoryPrompt")); //$NON-NLS-1$
String directory = directoryDialog.open();
if (directory != null) {
getDirectoryText().setText(directory);
}
}
});
}
示例11: createDialogArea
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
protected Control createDialogArea(Composite parent) {
// create composite
Composite composite = (Composite) super.createDialogArea(parent);
// create message
if (message != null) {
Label label = new Label(composite, SWT.WRAP);
label.setText(message);
GridData data = new GridData(GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL
| GridData.VERTICAL_ALIGN_CENTER);
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
label.setLayoutData(data);
label.setFont(parent.getFont());
}
viewer = new ComboViewer(composite);
viewer.setContentProvider(new ArrayContentProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(
SelectionChangedEvent event) {
valueSelected(valueFromSelection(event.getSelection()));
}
});
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof String) {
return PrefUIUtil.getFolderLabel((String) element, MAX_FOLDER_PATH_LEN);
}
return super.getText(element);
}
});
viewer.getControl().setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
| GridData.HORIZONTAL_ALIGN_FILL));
createLink(composite, "From folder", ()->addFolder());
createLink(composite, "From workspace prefs", ()->addWorkspace());
createLink(composite, "From installation", ()->addInstallation());
createLink(composite, "From launch config", ()->addLaunchCfg());
errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.WRAP);
errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
| GridData.HORIZONTAL_ALIGN_FILL));
errorMessageText.setBackground(errorMessageText.getDisplay()
.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
// Set the error message text
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292
setErrorMessage(errorMessage);
applyDialogFont(composite);
return composite;
}
示例12: getListener
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
@Override
public Listener getListener(final PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Widget... widgets) {
Widget[] widgetList = widgets;
final Text text = (Text) widgetList[0];
if(helpers != null){
if (helpers != null) {
currentComponent=(Component) helpers.get(HelperType.CURRENT_COMPONENT);
txtDecorator = (ControlDecoration) helpers.get(HelperType.CONTROL_DECORATION);
txtDecorator.hide();
}
}
Listener listener = new Listener() {
@Override
public void handleEvent(Event e) {
if (e.type == SWT.Verify) {
logger.debug("<<<<<<<<<<"+e.text.toString()+">>>>>>>>>>>");
String currentText = ((Text) e.widget).getText();
String newName = (currentText.substring(0, e.start) + e.text + currentText.substring(e.end)).trim();
Matcher matchName = Pattern.compile("[\\w+]*").matcher(newName.replaceAll("[\\W&&[\\ \\.\\-]]*", ""));
logger.debug("new text: {}", newName);
if (newName == null || newName.equals("")) {
// e.doit=false;
text.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 204));
text.setToolTipText(Messages.FIELD_LABEL_ERROR);
propertyDialogButtonBar.enableOKButton(false);
propertyDialogButtonBar.enableApplyButton(false);
txtDecorator.setDescriptionText(Messages.FIELD_LABEL_ERROR);
txtDecorator.show();
}else if(!matchName.matches()){
text.setToolTipText(Messages.INVALID_CHARACTERS);
txtDecorator.setDescriptionText(Messages.INVALID_CHARACTERS);
txtDecorator.show();
e.doit=false;
} else if(!newName.equalsIgnoreCase(oldName) && !isUniqueCompName(newName)) {
text.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry(255,255,204));
text.setToolTipText(Messages.FIELD_LABEL_ERROR);
propertyDialogButtonBar.enableOKButton(false);
propertyDialogButtonBar.enableApplyButton(false);
txtDecorator.setDescriptionText(Messages.FIELD_LABEL_ERROR);
txtDecorator.show();
}
else{
text.setBackground(null);
text.setToolTipText("");
text.setMessage("");
propertyDialogButtonBar.enableOKButton(true);
propertyDialogButtonBar.enableApplyButton(true);
txtDecorator.hide();
}
}
}
};
return listener;
}
示例13: launchXMLTextContainerWindow
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
/**
* Launches the component property editor window for Unknown components. It is used to display XML content of Unknown
* components on property window.
*
* @return XML content of component.
*/
public String launchXMLTextContainerWindow() {
try{
String xmlText = this.xmlText;
Shell shell = new Shell(Display.getDefault().getActiveShell(), SWT.WRAP | SWT.MAX | SWT.APPLICATION_MODAL);
shell.setLayout(new GridLayout(1, false));
shell.setText("XML Content");
shell.setSize(439, 432);
text = new Text(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
text.setEditable(false);
text.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 250, 250, 250));
if (this.xmlText != null) {
xmlText = xmlText.substring(xmlText.indexOf('\n') + 1);
xmlText = xmlText.substring(xmlText.indexOf('\n') + 1, xmlText.lastIndexOf('\n') - 13);
text.setText(xmlText);
} else
text.setText(Messages.EMPTY_XML_CONTENT);
GridData gd_text = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gd_text.widthHint = 360;
gd_text.heightHint = 360;
text.setLayoutData(gd_text);
Monitor primary = shell.getDisplay().getPrimaryMonitor();
Rectangle bounds = primary.getBounds();
Rectangle rect = shell.getBounds();
int x = bounds.x + (bounds.width - rect.width) / 2;
int y = bounds.y + (bounds.height - rect.height) / 2;
shell.setLocation(x, y);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!shell.getDisplay().readAndDispatch()) {
shell.getDisplay().sleep();
}
}
}catch(Exception e)
{
LOGGER.error("Error occurred while creating XML text container widget", e);
}
return getXmlText();
}
示例14: createTextContents
import org.eclipse.swt.widgets.Text; //導入方法依賴的package包/類
/**
* Creates the controls used to show the value of this cell area.
* <p>
* The default implementation of this framework method creates
* a label widget, using the same font and background color as the parent control.
* </p>
* <p>
* Subclasses may reimplement. If you reimplement this method, you
* should also reimplement <code>updateContents</code>.
* </p>
*
* @param cell the control for this cell area
* @return the underlying control
*/
protected Control createTextContents(Composite cell) {
Text txt = new Text(cell, SWT.LEFT);
txt.setFont(cell.getFont());
txt.setBackground(cell.getBackground());
txt.setEditable(false);
GridData gData = new GridData(SWT.FILL, SWT.FILL, true, true);
gData.widthHint = 100;
txt.setLayoutData(gData);
defaultLabel = txt;
return txt;
}