private void limitTextWidth(FormEntry entry) { GridData gd = (GridData) entry.getText().getLayoutData(); gd.widthHint = 30; }
public void setFocus() { if (fNameText != null) fNameText.getText().setFocus(); }
public void createClient(Section section, FormToolkit toolkit) { section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); Composite container = toolkit.createComposite(section); container.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2)); container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridData data = new GridData(GridData.FILL_BOTH); section.setLayoutData(data); fNameText = new FormEntry(container, toolkit, MDEUIMessages.CategoryDetails_name, null, false); fNameText.setFormEntryListener( new FormEntryAdapter(this) { public void textValueChanged(FormEntry text) { try { if (text.getValue().length() <= 0 || alreadyExists(text.getValue())) { setValue(PROPERTY_NAME); String message = MDEUIMessages.CategoryDetails_alreadyExists; MessageDialog.openError( MDEPlugin.getActiveWorkbenchShell(), MDEUIMessages.CategoryDetails_alreadyExists_title, message); } else { applyValue(PROPERTY_NAME, text.getValue()); } } catch (CoreException e) { MDEPlugin.logException(e); } } }); limitTextWidth(fNameText); fNameText.setEditable(isEditable()); fLabelText = new FormEntry(container, toolkit, MDEUIMessages.CategoryDetails_label, null, false); fLabelText.setFormEntryListener( new FormEntryAdapter(this) { public void textValueChanged(FormEntry text) { try { applyValue(PROPERTY_TYPE, text.getValue()); } catch (CoreException e) { MDEPlugin.logException(e); } } }); limitTextWidth(fLabelText); fLabelText.setEditable(isEditable()); fDescriptionText = new FormEntry(container, toolkit, MDEUIMessages.CategoryDetails_desc, SWT.WRAP | SWT.MULTI); fDescriptionText.getText().setLayoutData(new GridData(GridData.FILL_BOTH)); fDescriptionText.getLabel().setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); fDescriptionText.setFormEntryListener( new FormEntryAdapter(this) { public void textValueChanged(FormEntry text) { try { applyValue(PROPERTY_DESC, text.getValue()); } catch (CoreException e) { MDEPlugin.logException(e); } } }); limitTextWidth(fDescriptionText); fDescriptionText.setEditable(isEditable()); toolkit.paintBordersFor(container); section.setClient(container); ISiteModel model = (ISiteModel) getPage().getModel(); if (model != null) model.addModelChangedListener(this); }