public void addExpressionRow(String expressionName) { RowData rowdata = (RowData) expressionGroup.getLayoutData(); rowdata.height += 120; expressionGroup.setLayoutData(new RowData(rowdata.width, rowdata.height)); Rectangle rect = expressionGroup.getBounds(); rect.height += 120; expressionGroup.setBounds(rect); /*Create a row*/ ExpressionBean expBean = expressions.get(new Integer(expCount - 1)); Label previousLabel = expBean.getLabel(); rect = previousLabel.getBounds(); Label lblNew = new Label(expressionGroup, SWT.NONE); lblNew.setBounds(10, rect.y + 90, 120, 15); lblNew.setText(expressionName); lblNew.setFocus(); Text previousText = expBean.getText(); rect = previousText.getBounds(); Text newText = new Text(expressionGroup, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI); newText.setBounds(135, rect.y + 90, 550, 70); expressions.put(new Integer(expCount), new ExpressionBean(lblNew, newText)); expCount++; expScrolledComposite.setMinSize(expressionGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT)); }
public void addDescriptionRow(String sectionName) { RowData rowdata = (RowData) descriptionGroup.getLayoutData(); rowdata.height += 60; descriptionGroup.setLayoutData(new RowData(rowdata.width, rowdata.height)); Rectangle rect = descriptionGroup.getBounds(); rect.height += 60; descriptionGroup.setBounds(rect); /*Add the row*/ Text prevText = sections.get(new Integer(secCount - 1)).getEndTokens(); rect = prevText.getBounds(); Text newText_1 = new Text(descriptionGroup, SWT.BORDER); newText_1.setBounds(10, rect.y + 40, 75, 20); newText_1.setFocus(); Label lblNew = new Label(descriptionGroup, SWT.NONE); lblNew.setBounds(120, rect.y + 40, 145, 20); lblNew.setText(sectionName); Text newText_2 = new Text(descriptionGroup, SWT.BORDER); newText_2.setBounds(270, rect.y + 40, 115, 20); Text newText_3 = new Text(descriptionGroup, SWT.BORDER); newText_3.setBounds(420, rect.y + 40, 115, 20); Text newText_4 = new Text(descriptionGroup, SWT.BORDER); newText_4.setBounds(570, rect.y + 40, 115, 20); sections.put( new Integer(secCount), new SectionBean(newText_1, lblNew, newText_2, newText_3, newText_4)); secCount++; descScrolledComposite.setMinSize(descriptionGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT)); }
private Text createValueText() { final Text t = new Text(this, SWT.BORDER); t.setMessage(Messages.argument); t.addKeyListener( new KeyAdapter() { @Override public void keyReleased(final KeyEvent e) { AssertionComposite.this.orCondition.updateFilter(); } }); final RowData rowData = new RowData(); rowData.width = 132; t.setLayoutData(rowData); return t; }
private Button createPerspectiveButton(final IPerspectiveDescriptor desc) { Button result = perspectiveButtonMap.get(desc); if (result == null && desc != null && desc.getLabel() != null) { Composite buttonBg = new Composite(background, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginBottom = 0; layout.marginTop = 0; layout.marginLeft = 0; layout.marginRight = 0; layout.marginWidth = 0; layout.marginHeight = 0; buttonBg.setLayout(layout); final Button perspButton = new Button(buttonBg, SWT.PUSH | SWT.FLAT); perspButton.setData(RWT.CUSTOM_VARIANT, ICSSConstants.PERSP_BOTTON); perspButton.setText(desc.getLabel()); perspButton.setImage(desc.getImageDescriptor().createImage()); perspButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, true)); Label indicator = new Label(buttonBg, SWT.NONE); indicator.setImage(bgActive); indicator.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false)); RowData rd = new RowData(); rd.height = 60; buttonBg.setLayoutData(rd); perspectiveButtonMap.put(desc, perspButton); buttonPerspectiveMap.put(perspButton, desc); buttonList.add(perspButton); perspButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { cleanButtons(perspButton); switchPerspective(desc.getId()); } }); result = perspButton; } return result; }
private Combo createAssertionCombo() { final Combo c = new Combo(this, SWT.NONE); for (final Assertion assertion : Assertion.values()) { c.add(assertion.toString()); } c.select(0); c.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { AssertionComposite.this.orCondition.updateFilter(); } }); final RowData rowData = new RowData(); rowData.width = 75; c.setLayoutData(rowData); return c; }
public void layoutWidget( Control control, String elementName, Map<String, String> attributes, Composite container, SwtMetawidget metawidget) { // Do not layout space for empty stubs if (control instanceof Stub && ((Stub) control).getChildren().length == 0) { RowData stubData = new RowData(); stubData.exclude = true; control.setLayoutData(stubData); return; } // Do nothing }
protected void manageResized() { try { final RowData layoutData = (RowData) compositeCharts.getLayoutData(); int size = Math.min(form.getClientArea().width - 40, form.getClientArea().height - 40); // not working for this chart ! // Point prefered = chartComposites.computeSize(size, SWT.DEFAULT); layoutData.width = size; layoutData.height = size; form.reflow(true); } catch (RuntimeException e) { // ignore e.printStackTrace(); } }
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); RowLayout layout = new RowLayout(SWT.HORIZONTAL); layout.wrap = true; layout.fill = false; layout.justify = true; shell.setLayout(layout); Button b = new Button(shell, SWT.PUSH); b.setText("Button 1"); b = new Button(shell, SWT.PUSH); b.setText("Button 2"); b = new Button(shell, SWT.PUSH); b.setText("Button 3"); b = new Button(shell, SWT.PUSH); b.setText("Not shown"); b.setVisible(false); RowData data = new RowData(); data.exclude = true; b.setLayoutData(data); b = new Button(shell, SWT.PUSH); b.setText("Button 200 high"); data = new RowData(); data.height = 200; b.setLayoutData(data); b = new Button(shell, SWT.PUSH); b.setText("Button 200 wide"); data = new RowData(); data.width = 200; b.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
private Text createAttributeText(final String attribute) { final Text t = new Text(this, SWT.BORDER); final Fields field = Fields.byField(attribute); if (field == null) { t.setEditable(true); t.setMessage(Messages.custom_field); } else { t.setEditable(false); t.setText(field.getName()); } t.addKeyListener( new KeyAdapter() { @Override public void keyReleased(final KeyEvent e) { AssertionComposite.this.orCondition.updateFilter(); }; }); final RowData rowData = new RowData(); rowData.width = 132; t.setLayoutData(rowData); return t; }
private void updatePreview() { Display display = mPreviewArea.getDisplay(); for (Control c : mPreviewArea.getChildren()) { c.dispose(); } if (!validatePage()) { return; } Map<String, Map<String, BufferedImage>> map = generateImages(true /*previewOnly*/); for (Entry<String, Map<String, BufferedImage>> categoryEntry : map.entrySet()) { String category = categoryEntry.getKey(); if (category.length() > 0) { Label nameLabel = new Label(mPreviewArea, SWT.NONE); nameLabel.setText(String.format("%1$s:", category)); RowData rowData = new RowData(); nameLabel.setLayoutData(rowData); // Ensure these get their own rows rowData.width = PREVIEW_AREA_WIDTH; } Map<String, BufferedImage> images = categoryEntry.getValue(); for (Entry<String, BufferedImage> entry : images.entrySet()) { BufferedImage image = entry.getValue(); Image swtImage = SwtUtils.convertToSwt(display, image, true, -1); if (swtImage != null) { @SuppressWarnings("unused") // Has side effect ImageControl imageControl = new ImageControl(mPreviewArea, SWT.NONE, swtImage); } } } mPreviewArea.layout(true); }
public void addNomenclatureRow(String name) { RowData rowdata = (RowData) nomenclatureGroup.getLayoutData(); rowdata.height += 30; nomenclatureGroup.setLayoutData(new RowData(rowdata.width, rowdata.height)); Rectangle rect = nomenclatureGroup.getBounds(); rect.height += 30; nomenclatureGroup.setBounds(rect); /*Create a row*/ NomenclatureBean nbean = nomenclatures.get(new Integer(nomenCount - 1)); Label previousLabel = nbean.getLabel(); rect = previousLabel.getBounds(); rect.y += 45; Label lblNew = new Label(nomenclatureGroup, SWT.NONE); lblNew.setBounds(rect); lblNew.setText(name); lblNew.setFocus(); /* Create the first group*/ Group prevGroup = nbean.getParent(); rect = prevGroup.getBounds(); Group group_1 = new Group(nomenclatureGroup, SWT.NONE); group_1.setBounds(100, rect.y + 45, 182, 40); Button buttonYes_1 = new Button(group_1, SWT.RADIO); buttonYes_1.setText("Yes"); buttonYes_1.setBounds(10, 13, 39, 16); Button buttonNo_1 = new Button(group_1, SWT.RADIO); buttonNo_1.setText("No"); buttonNo_1.setBounds(55, 13, 39, 16); Text text1 = new Text(group_1, SWT.BORDER); text1.setBounds(100, 11, 76, 21); nomenclatures.put( new Integer(nomenCount), new NomenclatureBean(group_1, buttonYes_1, buttonNo_1, text1, lblNew)); nomenCount++; /////////////////////////////////// /*Create the second group */ Group group_2 = new Group(nomenclatureGroup, SWT.NONE); group_2.setBounds(300, rect.y + 45, 182, 40); Button buttonYes_2 = new Button(group_2, SWT.RADIO); buttonYes_2.setText("Yes"); buttonYes_2.setBounds(10, 13, 39, 16); Button buttonNo_2 = new Button(group_2, SWT.RADIO); buttonNo_2.setText("No"); buttonNo_2.setBounds(55, 13, 39, 16); Text text2 = new Text(group_2, SWT.BORDER); text2.setBounds(100, 11, 76, 21); nomenclatures.put( new Integer(nomenCount), new NomenclatureBean(group_2, buttonYes_2, buttonNo_2, text2, lblNew)); nomenCount++; /* Create the third group */ Group group_3 = new Group(nomenclatureGroup, SWT.NONE); group_3.setBounds(500, rect.y + 45, 182, 40); Button buttonYes_3 = new Button(group_3, SWT.RADIO); buttonYes_3.setText("Yes"); buttonYes_3.setBounds(10, 13, 39, 16); Button buttonNo_3 = new Button(group_3, SWT.RADIO); buttonNo_3.setText("No"); buttonNo_3.setBounds(55, 13, 39, 16); Text text3 = new Text(group_3, SWT.BORDER); text3.setBounds(100, 11, 76, 21); nomenclatures.put( new Integer(nomenCount), new NomenclatureBean(group_3, buttonYes_3, buttonNo_3, text3, lblNew)); nomenCount++; nomenScrolledComposite.setMinSize(nomenclatureGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT)); }
/** * When this view is resized, the StyledText SWT widget is resized accordingly. This method should * be called only as a response to the ControlListener. */ public void controlResized(ControlEvent e) { Point parentSize = parentCompo.getSize(); rowData.width = parentSize.x - 36; rowData.height = parentSize.y - 11; shellTextArea.setLayoutData(rowData); }
public LoginPanel(Shell page, Composite parent) { super(parent, SWT.NONE); this.shell = page; setLayout(new GridLayout()); // ´´½¨µÇ¼ÇøÓòµÄÓû§±êÇ© Óû§ÃûÊäÈë¿ò ÃÜÂë±êÇ© ÃÜÂëÊäÈë¿ò µÇ¼°´Å¥ Composite panelTop = new Composite(this, SWT.NONE); panelTop.setBackgroundMode(SWT.INHERIT_DEFAULT); RowLayout layout = new RowLayout(); layout.spacing = 40; layout.marginBottom = 0; layout.marginRight = 10; layout.marginTop = 0; layout.wrap = false; layout.pack = true; layout.center = true; panelTop.setLayout(layout); userText = new Text(panelTop, SWT.BORDER); RowData rd = new RowData(); rd.width = 240; userText.setMessage("Õʺš¢Óû§Ãû»òÕßemail"); userText.setLayoutData(rd); userText.setData(RWT.CUSTOM_VARIANT, "loginInput"); userText.setFocus(); passwordText = new Text(panelTop, SWT.BORDER | SWT.PASSWORD); rd = new RowData(); rd.width = 220; passwordText.setMessage("ÊäÈëµÇ¼ÃÜÂë"); passwordText.setLayoutData(rd); passwordText.setData(RWT.CUSTOM_VARIANT, "loginInput"); okButton = new Button(panelTop, SWT.PUSH); okButton.setData(RWT.CUSTOM_VARIANT, "loginInput"); rd = new RowData(); rd.width = 50; rd.height = 50; okButton.setLayoutData(rd); page.setDefaultButton(okButton); okButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { buttonPressed(); } }); // ´´½¨±£´æÃÜÂë¹´Ñ¡¿òºÍ±£´æÓû§Ãû¹´Ñ¡¿ò Composite panelBottom = new Composite(this, SWT.NONE); layout = new RowLayout(); layout.spacing = 4; layout.marginBottom = 0; layout.marginRight = 10; layout.marginTop = 0; layout.wrap = false; layout.pack = true; panelBottom.setLayout(layout); saveIdButton = new Button(panelBottom, SWT.CHECK); saveIdButton.setText("±£´æµÇ¼ÕʺÅ"); saveIdButton.setData(RWT.CUSTOM_VARIANT, "loginCheck"); savePassButton = new Button(panelBottom, SWT.CHECK); savePassButton.setText("±£´æµÇ¼ÃÜÂë"); savePassButton.setData(RWT.CUSTOM_VARIANT, "loginCheck"); // cookie save String uid = RWT.getSettingStore().getAttribute(COOKIE_UI_USERID); if (uid != null && uid.length() > 0) { userText.setText(uid); saveIdButton.setSelection(true); } // cookie save String psd = RWT.getSettingStore().getAttribute(COOKIE_UI_PASSWORD); if (psd != null && psd.length() > 0) { passwordText.setText(psd); savePassButton.setSelection(true); } panelTop.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false)); panelBottom.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false)); createTooltips(); }
private void addExcludedRowData(Composite facade) { RowData rowData = new RowData(); rowData.exclude = true; facade.setLayoutData(rowData); }
@Override public void testAddClickListener() { final ITableRidget ridget = getRidget(); ridget.updateFromModel(); final Grid control = getWidget(); final RowData rowData = new RowData(); rowData.width = 300; rowData.height = 300; control.setLayoutData(rowData); control.getColumn(0).setWidth(100); control.getColumn(1).setWidth(100); control.getShell().pack(); control.getParent().update(); try { ridget.addClickListener(null); fail(); } catch (final RuntimeException npe) { ok(); } final FTClickListener listener1 = new FTClickListener(); ridget.addClickListener(listener1); final FTClickListener listener2 = new FTClickListener(); ridget.addClickListener(listener2); ridget.addClickListener(listener2); final Event mdEvent = new Event(); mdEvent.widget = control; mdEvent.type = SWT.MouseDown; mdEvent.button = 2; final GridItem row2 = control.getItem(2); mdEvent.item = row2; mdEvent.x = row2.getBounds(0).x + 1; mdEvent.y = row2.getBounds(0).y + 1; control.notifyListeners(SWT.MouseDown, mdEvent); assertEquals(0, listener1.getCount()); assertEquals(0, listener2.getCount()); mdEvent.type = SWT.MouseUp; control.notifyListeners(SWT.MouseUp, mdEvent); assertEquals(1, listener1.getCount()); assertEquals(1, listener2.getCount()); final ClickEvent event = listener2.getEvent(); assertEquals(ridget, event.getSource()); assertEquals(2, event.getButton()); assertEquals(0, event.getColumnIndex()); assertEquals(row2.getData(), event.getRow()); ridget.removeClickListener(listener1); mdEvent.type = SWT.MouseDown; control.notifyListeners(SWT.MouseDown, mdEvent); mdEvent.type = SWT.MouseUp; control.notifyListeners(SWT.MouseUp, mdEvent); assertEquals(1, listener1.getCount()); }