packagedev.equo.internal;importorg.eclipse.swt.SWT;importorg.eclipse.swt.graphics.Point;importorg.eclipse.swt.graphics.Rectangle;importorg.eclipse.swt.layout.FillLayout;importorg.eclipse.swt.layout.RowLayout;importorg.eclipse.swt.widgets.*;/** * A row of single-line controls in a RowLayout, each top-aligned at its preferred height: two fields * made of a borderless Text with an ARROW button beside it, two check boxes and a read-only Combo. * The field is as tall as the taller of its Text and its arrow. */publicclassTextArrowRowSnippet{staticclassArrowFieldextendsComposite{finalTexttext;finalButtonarrow;ArrowField(Compositeparent,intstyle){super(parent,style);text=newText(this,SWT.SINGLE);text.setText("2026-01-01");arrow=newButton(this,SWT.ARROW|SWT.DOWN);addListener(SWT.Resize,e->{Rectanglearea=getClientArea();PointarrowSize=arrow.computeSize(SWT.DEFAULT,area.height);text.setBounds(0,0,area.width-arrowSize.x,area.height);arrow.setBounds(area.width-arrowSize.x,0,arrowSize.x,arrowSize.y);});}@OverridepublicPointcomputeSize(intwHint,inthHint,booleanchanged){PointtextSize=text.computeSize(wHint,SWT.DEFAULT,changed);PointarrowSize=arrow.computeSize(SWT.DEFAULT,SWT.DEFAULT,changed);intborder=getBorderWidth();intheight=Math.max(hHint,Math.max(textSize.y,arrowSize.y)+2*border);intwidth=Math.max(wHint,textSize.x+arrowSize.x+2*border);returnnewPoint(width,height);}}publicstaticvoidmain(String[]args){Displaydisplay=newDisplay();Shellshell=newShell(display);shell.setText("Text and ARROW row");shell.setLayout(newFillLayout(SWT.VERTICAL));Compositerow=newComposite(shell,SWT.BORDER);row.setLayout(newRowLayout());ArrowFieldfrom=newArrowField(row,SWT.BORDER);ArrowFieldto=newArrowField(row,SWT.BORDER);Buttonfirst=newButton(row,SWT.CHECK);first.setText("first");Buttonsecond=newButton(row,SWT.CHECK);second.setText("second");Combochoice=newCombo(row,SWT.READ_ONLY);choice.setItems("All","A","B");choice.select(0);shell.setSize(700,120);shell.open();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}display.dispose();}}
packagedev.equo;importdev.equo.swt.Config;importorg.eclipse.swt.SWT;importorg.eclipse.swt.layout.GridData;importorg.eclipse.swt.layout.GridLayout;importorg.eclipse.swt.widgets.*;/** * Demonstrates Text character limit * This example showcases: * - Text field with character limit using setTextLimit() * - Visual feedback of remaining characters */publicclassTextLimitSnippet{publicstaticvoidmain(String[]args){Config.useEquo(Text.class);Displaydisplay=newDisplay();Shellshell=newShell(display);shell.setText("TextLimitSnippet");shell.setLayout(newGridLayout(1,false));// Text with 10 character limitLabellabel1=newLabel(shell,SWT.NONE);label1.setText("Username (max 10 characters):");TextlimitedText=newText(shell,SWT.BORDER);limitedText.setLayoutData(newGridData(SWT.FILL,SWT.CENTER,true,false));limitedText.setTextLimit(10);limitedText.setMessage("Enter username");limitedText.addListener(SWT.Modify,e->{intlength=limitedText.getText().length();intremaining=10-length;System.out.println("Characters used: "+length+"/10 (remaining: "+remaining+")");});// Add some spacingLabelspacer=newLabel(shell,SWT.NONE);spacer.setLayoutData(newGridData(SWT.FILL,SWT.CENTER,true,false));// Text with 50 character limitLabellabel2=newLabel(shell,SWT.NONE);label2.setText("Description (max 50 characters):");TextlimitedText2=newText(shell,SWT.BORDER);limitedText2.setLayoutData(newGridData(SWT.FILL,SWT.CENTER,true,false));limitedText2.setTextLimit(50);limitedText2.setMessage("Enter description");shell.pack();shell.setSize(400,250);shell.open();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}display.dispose();}}
packagedev.equo;importdev.equo.swt.Config;importorg.eclipse.swt.SWT;importorg.eclipse.swt.layout.GridData;importorg.eclipse.swt.layout.GridLayout;importorg.eclipse.swt.widgets.*;/** * Demonstrates Multi-line Text widget * This example showcases: * - Multi-line text area with SWT.MULTI * - Vertical scrolling * - Text modification events */publicclassTextMultiLineSnippet{publicstaticvoidmain(String[]args){Config.useEquo(Text.class);Displaydisplay=newDisplay();Shellshell=newShell(display);shell.setText("TextMultiLineSnippet");shell.setLayout(newGridLayout(1,false));// Multi-line text areaLabellabel=newLabel(shell,SWT.NONE);label.setText("Multi-line text area:");TextmultiText=newText(shell,SWT.BORDER|SWT.MULTI|SWT.V_SCROLL);multiText.setLayoutData(newGridData(SWT.FILL,SWT.FILL,true,true));multiText.setMessage("Enter multiple lines of text...");multiText.setText("Line 1\nLine 2\nLine 3");multiText.addListener(SWT.Modify,e->System.out.println("Text modified: "+multiText.getText()));shell.pack();shell.setSize(400,300);shell.open();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}display.dispose();}}
packagedev.equo;importdev.equo.swt.Config;importorg.eclipse.swt.SWT;importorg.eclipse.swt.layout.GridData;importorg.eclipse.swt.layout.GridLayout;importorg.eclipse.swt.widgets.*;/** * Demonstrates Search Text widget * This example showcases: * - Search field with SWT.SEARCH style * - Search icon prefix * - Cancel/clear button suffix * - DefaultSelection event (when Enter is pressed) */publicclassTextSearchSnippet{publicstaticvoidmain(String[]args){Config.useEquo(Text.class);Displaydisplay=newDisplay();Shellshell=newShell(display);shell.setText("TextSearchSnippet");shell.setLayout(newGridLayout(1,false));// Search field with iconLabellabel1=newLabel(shell,SWT.NONE);label1.setText("Search field:");TextsearchText=newText(shell,SWT.BORDER|SWT.SEARCH|SWT.ICON_SEARCH|SWT.ICON_CANCEL);searchText.setLayoutData(newGridData(SWT.FILL,SWT.CENTER,true,false));searchText.setMessage("Search...");searchText.addListener(SWT.Modify,e->System.out.println("Search text changed: "+searchText.getText()));searchText.addListener(SWT.DefaultSelection,e->{Eventevent=(Event)e;if(event.detail==SWT.ICON_CANCEL){System.out.println("Cancel button clicked");}else{System.out.println("Search submitted: "+searchText.getText());}});shell.pack();shell.setSize(400,150);shell.open();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}display.dispose();}}
packagedev.equo;importdev.equo.swt.Config;importorg.eclipse.swt.SWT;importorg.eclipse.swt.layout.GridData;importorg.eclipse.swt.layout.GridLayout;importorg.eclipse.swt.widgets.*;/** * Demonstrates Text widget * This example showcases: * - Single-line editable text field * - Password field */publicclassTextSnippet{publicstaticvoidmain(String[]args){Config.useEquo(Text.class);Displaydisplay=newDisplay();Shellshell=newShell(display);shell.setText("TextSnippet");shell.setLayout(newGridLayout(2,false));// Single-line text fieldLabellabel1=newLabel(shell,SWT.NONE);label1.setText("Single-line:");Texttext1=newText(shell,SWT.BORDER);text1.setLayoutData(newGridData(SWT.FILL,SWT.CENTER,true,false));text1.setMessage("Enter text here...");text1.addListener(SWT.Modify,e->System.out.println("Text modified: "+text1.getText()));text1.addListener(SWT.DefaultSelection,e->System.out.println("Enter pressed: "+text1.getText()));// Read-only text fieldLabellabel2=newLabel(shell,SWT.NONE);label2.setText("Read-only:");Texttext2=newText(shell,SWT.BORDER|SWT.READ_ONLY);text2.setLayoutData(newGridData(SWT.FILL,SWT.CENTER,true,false));text2.setText("This text is read-only");shell.pack();shell.setSize(400,450);shell.open();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}display.dispose();}}