1 package org.simantics.modeling.ui.componentTypeEditor;
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.Collections;
6 import java.util.HashSet;
9 import java.util.concurrent.ScheduledFuture;
10 import java.util.concurrent.TimeUnit;
11 import java.util.regex.Matcher;
12 import java.util.regex.Pattern;
14 import org.eclipse.jface.dialogs.IDialogConstants;
15 import org.eclipse.jface.dialogs.IMessageProvider;
16 import org.eclipse.jface.layout.GridDataFactory;
17 import org.eclipse.jface.layout.GridLayoutFactory;
18 import org.eclipse.osgi.util.NLS;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.custom.StyledText;
21 import org.eclipse.swt.custom.TableEditor;
22 import org.eclipse.swt.events.SelectionAdapter;
23 import org.eclipse.swt.events.SelectionEvent;
24 import org.eclipse.swt.graphics.Point;
25 import org.eclipse.swt.graphics.Rectangle;
26 import org.eclipse.swt.widgets.Button;
27 import org.eclipse.swt.widgets.Combo;
28 import org.eclipse.swt.widgets.Composite;
29 import org.eclipse.swt.widgets.Display;
30 import org.eclipse.swt.widgets.Event;
31 import org.eclipse.swt.widgets.Label;
32 import org.eclipse.swt.widgets.Shell;
33 import org.eclipse.swt.widgets.Table;
34 import org.eclipse.swt.widgets.TableItem;
35 import org.eclipse.swt.widgets.Text;
36 import org.eclipse.ui.forms.widgets.Form;
37 import org.eclipse.ui.forms.widgets.FormToolkit;
38 import org.simantics.Simantics;
39 import org.simantics.databoard.Bindings;
40 import org.simantics.databoard.type.NumberType;
41 import org.simantics.databoard.units.internal.library.UnitLibrary;
42 import org.simantics.databoard.util.Limit;
43 import org.simantics.databoard.util.Range;
44 import org.simantics.databoard.util.RangeException;
45 import org.simantics.db.RequestProcessor;
46 import org.simantics.db.Resource;
47 import org.simantics.db.Statement;
48 import org.simantics.db.WriteGraph;
49 import org.simantics.db.common.NamedResource;
50 import org.simantics.db.common.request.IndexRoot;
51 import org.simantics.db.common.request.WriteRequest;
52 import org.simantics.db.exception.DatabaseException;
53 import org.simantics.db.function.DbConsumer;
54 import org.simantics.db.layer0.QueryIndexUtils;
55 import org.simantics.db.layer0.util.Layer0Utils;
56 import org.simantics.layer0.Layer0;
57 import org.simantics.modeling.userComponent.ComponentTypeCommands;
58 import org.simantics.scl.runtime.function.Function2;
59 import org.simantics.scl.runtime.function.Function4;
60 import org.simantics.utils.datastructures.Pair;
61 import org.simantics.utils.threads.ThreadUtils;
62 import org.simantics.utils.ui.ErrorLogger;
64 public class ComponentTypeViewerData {
66 * Used to validate property names.
68 public static final Pattern PROPERTY_NAME_PATTERN =
69 Pattern.compile("([a-z]|_[0-9a-zA-Z_])[0-9a-zA-Z_]*"); //$NON-NLS-1$
71 public static final String[] PROPERTY_TYPE_SUGGESTIONS = new String[] {
72 "Double", //$NON-NLS-1$
73 "Integer", //$NON-NLS-1$
74 "Float", //$NON-NLS-1$
75 "String", //$NON-NLS-1$
76 "Boolean", //$NON-NLS-1$
78 "[Double]", //$NON-NLS-1$
79 "[Integer]", //$NON-NLS-1$
80 "[Float]", //$NON-NLS-1$
81 "[String]", //$NON-NLS-1$
82 "[Boolean]", //$NON-NLS-1$
83 "[Long]", //$NON-NLS-1$
84 "Vector Double", //$NON-NLS-1$
85 "Vector Integer", //$NON-NLS-1$
86 "Vector Float", //$NON-NLS-1$
87 "Vector String", //$NON-NLS-1$
88 "Vector Boolean", //$NON-NLS-1$
89 "Vector Long" //$NON-NLS-1$
92 public Resource componentType;
93 public FormToolkit tk;
95 public UnitLibrary unitLibrary = UnitLibrary.createDefault();
96 public boolean readOnly;
97 public NamedResource[] connectionPoints;
98 public ComponentTypeViewerPropertyInfo[] properties;
100 public ComponentTypeViewerData(FormToolkit tk, Resource componentType, Form form) {
102 this.componentType = componentType;
106 public void editName(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column,
107 Pattern namePattern) {
108 editName(table, editor, propertyInfo, selectedItem, column, namePattern, null);
111 public void editName(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column,
112 Pattern namePattern, DbConsumer<WriteGraph> extraWriter) {
113 editName(table, editor, propertyInfo, selectedItem, column,
115 (pInfo, name) -> validatePropertyName(pInfo, name, namePattern),
119 public void editName(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column,
120 Function2<ComponentTypeViewerPropertyInfo, String, String> nameFilter, Pattern namePattern, DbConsumer<WriteGraph> extraWriter) {
121 editName(table, editor, propertyInfo, selectedItem, column, nameFilter,
122 (pInfo, name) -> validatePropertyName(pInfo, name, namePattern),
126 public void editName(Table table, TableEditor editor, ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column,
127 Function2<ComponentTypeViewerPropertyInfo, String, String> nameValidator)
129 editName(table, editor, propertyInfo, selectedItem, column, nameValidator, null);
132 public void editName(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column,
133 Function2<ComponentTypeViewerPropertyInfo, String, String> nameValidator, DbConsumer<WriteGraph> extraWriter) {
134 editName(table, editor, propertyInfo, selectedItem, column, null, nameValidator, extraWriter);
137 public void editName(
140 final ComponentTypeViewerPropertyInfo propertyInfo,
141 TableItem selectedItem,
143 Function2<ComponentTypeViewerPropertyInfo, String, String> nameFilter,
144 Function2<ComponentTypeViewerPropertyInfo, String, String> nameValidator,
145 DbConsumer<WriteGraph> extraWriter) {
146 int extraStyle = propertyInfo.immutable ? SWT.READ_ONLY : 0;
147 final Text text = new Text(table, SWT.NONE | extraStyle);
148 org.eclipse.swt.widgets.Listener listener =
149 new org.eclipse.swt.widgets.Listener() {
151 public void handleEvent(Event e) {
152 if (e.type == SWT.Dispose) {
153 form.setMessage(null);
155 } else if (e.type == SWT.Verify) {
156 // Filter input if necessary
157 e.text = nameFilter != null ? nameFilter.apply(propertyInfo, e.text) : e.text;
159 } else if (e.type == SWT.Modify) {
160 // validate current name
161 String error = nameValidator.apply(propertyInfo, text.getText());
163 text.setBackground(text.getDisplay().getSystemColor(SWT.COLOR_RED));
164 form.setMessage(error, IMessageProvider.ERROR);
166 text.setBackground(null);
167 form.setMessage(null);
170 } else if (e.type == SWT.Traverse) {
171 if (e.detail == SWT.TRAVERSE_ESCAPE) {
176 if (e.detail == SWT.TRAVERSE_ARROW_NEXT || e.detail == SWT.TRAVERSE_ARROW_PREVIOUS || e.detail == SWT.TRAVERSE_MNEMONIC)
180 final String newValue = text.getText();
183 String error = nameValidator.apply(propertyInfo, newValue);
187 if (propertyInfo.immutable)
190 Simantics.getSession().async(new WriteRequest() {
192 public void perform(WriteGraph graph)
193 throws DatabaseException {
194 graph.markUndoPoint();
195 Layer0 L0 = Layer0.getInstance(graph);
196 String prevName = graph.getPossibleRelatedValue2(propertyInfo.resource, L0.HasName);
197 String oldCamelCasedLabel = prevName != null ? ComponentTypeCommands.camelCaseNameToLabel(prevName) : ""; //$NON-NLS-1$
198 String oldLabel = graph.getPossibleRelatedValue(propertyInfo.resource, L0.HasLabel);
199 boolean setLabel = oldLabel == null
200 || oldLabel.isEmpty()
201 || oldCamelCasedLabel.isEmpty()
202 || oldCamelCasedLabel.equals(oldLabel);
204 ComponentTypeCommands.rename(graph, propertyInfo.resource, newValue);
206 ComponentTypeCommands.setLabel(graph, propertyInfo.resource, ComponentTypeCommands.camelCaseNameToLabel(newValue));
208 if (extraWriter != null)
209 extraWriter.accept(graph);
214 if (nameFilter != null)
215 text.addListener(SWT.Verify, listener);
216 text.addListener(SWT.Modify, listener);
217 text.addListener(SWT.Deactivate, listener);
218 text.addListener(SWT.Traverse, listener);
219 text.addListener(SWT.Dispose, listener);
221 text.setText(selectedItem.getText(column));
225 editor.setEditor(text, selectedItem, column);
228 public void editType(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column, String range, final boolean convertDefaultValue) {
229 int extraStyle = propertyInfo.immutable ? SWT.READ_ONLY : 0;
230 final Combo combo = new Combo(table, SWT.NONE | extraStyle);
231 combo.setText(selectedItem.getText(column));
232 for(String suggestion : PROPERTY_TYPE_SUGGESTIONS)
233 combo.add(suggestion);
234 org.eclipse.swt.widgets.Listener listener =
235 new org.eclipse.swt.widgets.Listener() {
237 public void handleEvent(Event e) {
238 if(e.type == SWT.Traverse) {
239 if (e.detail == SWT.TRAVERSE_ESCAPE) {
244 if (e.detail == SWT.TRAVERSE_ARROW_NEXT
245 || e.detail == SWT.TRAVERSE_ARROW_PREVIOUS
246 || e.detail == SWT.TRAVERSE_MNEMONIC)
249 final String newValue = combo.getText();
250 if (e.type == SWT.Traverse) {
255 if (propertyInfo.immutable)
259 Simantics.getSession().async(new WriteRequest() {
261 public void perform(WriteGraph graph)
262 throws DatabaseException {
263 graph.markUndoPoint();
265 String newValue2 = newValue;
267 Resource possibleGraphType = null;
268 Resource root = graph.syncRequest(new IndexRoot(componentType));
270 Resource L0Res = graph.getResource("http://www.simantics.org/Layer0-1.1");
271 Layer0 L0 = Layer0.getInstance(graph);
273 Collection<Resource> graphTypes1 = QueryIndexUtils.searchByTypeAndName(graph, L0Res, L0.ValueType, newValue);
274 Collection<Resource> graphTypes2 = QueryIndexUtils.searchByTypeAndName(graph, root, L0.ValueType, newValue);
276 Collection<Resource> graphTypes = new HashSet<>(graphTypes1);
277 graphTypes.addAll(graphTypes2);
279 Set<Pair<Resource, String>> candidates = new HashSet<>();
280 for (Resource graphType : graphTypes) {
281 Collection<Statement> stms = graph.getAssertedStatements(graphType, L0.HasValueType);
282 if(stms.size() == 1) {
283 // Only accept valueType if it asserts HasValueType with the same name
284 String hasValueType = graph.getValue(stms.iterator().next().getObject(), Bindings.STRING);
285 if (hasValueType.equals(newValue)) {
286 candidates.add(new Pair<>(graphType, hasValueType));
291 // We support only graph types with unique name at this point. Later we could implement UI to let the user to select from multiple graph types.
292 if (candidates.size() == 1) {
293 Pair<Resource, String> result = candidates.iterator().next();
294 possibleGraphType = result.first;
295 newValue2 = result.second;
298 ComponentTypeCommands.editType(graph, componentType, propertyInfo.resource, convertDefaultValue, newValue2, possibleGraphType);
299 if (range != null) ComponentTypeCommands.setRange(graph, componentType, propertyInfo.resource, range);
305 editor.setEditor(combo, selectedItem, column);
306 combo.addListener(SWT.FocusOut, listener);
307 combo.addListener(SWT.Traverse, listener);
310 public void editUnit(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column) {
311 // Disallow unit editing for non-numeric configuration properties
312 if (propertyInfo.numberType == null && propertyInfo.sectionSpecificData == null)
315 int extraStyle = propertyInfo.immutable ? SWT.READ_ONLY : 0;
316 final Combo combo = new Combo(table, SWT.NONE | extraStyle);
317 String initialValue = selectedItem.getText(column);
318 List<String> units = new ArrayList<>( unitLibrary.getUnits() );
319 Collections.sort(units, String.CASE_INSENSITIVE_ORDER);
322 for (String unit : units) {
324 if (unit.equals(initialValue))
328 combo.setText(initialValue);
330 org.eclipse.swt.widgets.Listener listener =
331 new org.eclipse.swt.widgets.Listener() {
333 public void handleEvent(Event e) {
334 if(e.type == SWT.Traverse) {
335 if (e.detail == SWT.TRAVERSE_ESCAPE) {
340 if (e.detail == SWT.TRAVERSE_ARROW_NEXT
341 || e.detail == SWT.TRAVERSE_ARROW_PREVIOUS
342 || e.detail == SWT.TRAVERSE_MNEMONIC)
345 final String newValue = combo.getText();
346 if(e.type == SWT.Traverse) {
351 if (propertyInfo.immutable)
354 Simantics.getSession().async(new WriteRequest() {
356 public void perform(WriteGraph graph)
357 throws DatabaseException {
358 graph.markUndoPoint();
359 ComponentTypeCommands.setUnit(graph, componentType, propertyInfo.resource, newValue);
365 editor.setEditor(combo, selectedItem, column);
366 combo.addListener(SWT.Deactivate, listener);
367 combo.addListener(SWT.Traverse, listener);
370 public void editValue(Table table, TableEditor editor,
371 final ComponentTypeViewerPropertyInfo propertyInfo,
372 TableItem selectedItem, int column,
373 final StringWriter writer,
374 final Function4<RequestProcessor, Resource, Resource, String, String> validator)
376 int extraStyle = writer == null ? SWT.READ_ONLY : 0;
377 final Text text = new Text(table, SWT.NONE | extraStyle);
378 text.setText(selectedItem.getText(column));
379 org.eclipse.swt.widgets.Listener listener =
380 new org.eclipse.swt.widgets.Listener() {
382 public void handleEvent(Event e) {
383 if(e.type == SWT.Traverse) {
384 if (e.detail == SWT.TRAVERSE_ESCAPE) {
389 if (e.detail == SWT.TRAVERSE_ARROW_NEXT
390 || e.detail == SWT.TRAVERSE_ARROW_PREVIOUS
391 || e.detail == SWT.TRAVERSE_MNEMONIC)
394 final String newValue = text.getText();
395 if(e.type == SWT.Traverse) {
400 if (validator != null) {
401 String error = validator.apply(Simantics.getSession(), componentType, propertyInfo.resource, newValue);
406 if (writer != null) {
407 Simantics.getSession().async(new WriteRequest() {
409 public void perform(WriteGraph graph) throws DatabaseException {
410 writer.perform(graph, newValue);
418 editor.setEditor(text, selectedItem, column);
419 text.addListener(SWT.FocusOut, listener);
420 text.addListener(SWT.Traverse, listener);
422 if (validator != null) {
423 org.eclipse.swt.widgets.Listener validationListener = new org.eclipse.swt.widgets.Listener() {
425 private ScheduledFuture<?> future;
428 public void handleEvent(Event e) {
429 final String newValue = text.getText();
430 if (future != null && !future.isCancelled())
432 future = ThreadUtils.getNonBlockingWorkExecutor().schedule(() -> {
433 String error = validator.apply(Simantics.getSession(), componentType, propertyInfo.resource, newValue);
434 if (!text.isDisposed()) {
435 text.getDisplay().asyncExec(() -> {
436 if (!text.isDisposed()) {
438 text.setBackground(text.getDisplay().getSystemColor(SWT.COLOR_RED));
439 text.setToolTipText(error);
442 text.setBackground(null);
443 text.setToolTipText(null);
449 }, 500, TimeUnit.MILLISECONDS);
452 text.addListener(SWT.Modify, validationListener);
456 private Range parseRange(NumberType numberType, String minStr, String maxStr, boolean lowInclusive, boolean highInclusive) throws RangeException {
458 String rangeStr = (lowInclusive ? "[" : "(") + minStr + ".." + maxStr + (highInclusive ? "]" : ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
459 return Range.valueOf(rangeStr);
460 } catch (IllegalArgumentException e) {
461 // Limits are invalid
462 throw new RangeException(e.getMessage(), e);
466 private static Combo createRangeInclusionCombo(Composite parent, boolean inclusive) {
467 Combo rng = new Combo(parent, SWT.READ_ONLY);
468 rng.add(Messages.ComponentTypeViewerData_Inclusive);
469 rng.add(Messages.ComponentTypeViewerData_Exclusive);
470 rng.select(inclusive ? 0 : 1);
474 protected void editRange(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, Rectangle selectedItemBounds, int column) {
475 // Disallow range editing when the property is not numeric
476 if (propertyInfo.numberType == null)
479 int extraTextStyle = propertyInfo.immutable ? SWT.READ_ONLY : 0;
481 // Parse initial range value
483 String rangeStr = selectedItem.getText(column);
485 range = Range.valueOf(rangeStr);
486 } catch (RangeException ex) {
487 range = new Range(Limit.nolimit(), Limit.nolimit());
490 final Shell shell = new Shell(table.getShell(), SWT.ON_TOP);
491 GridLayoutFactory.fillDefaults().applyTo(shell);
493 Composite composite = new Composite(shell, SWT.NONE);
494 GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
495 GridLayoutFactory.swtDefaults().numColumns(3).applyTo(composite);
497 Label low = new Label(composite, SWT.NONE);
498 low.setText(Messages.ComponentTypeViewerData_MinimumValue);
499 final Text lowText = new Text(composite, SWT.BORDER | extraTextStyle);
500 GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).applyTo(lowText);
501 final Combo lowSelector = createRangeInclusionCombo(composite, !range.getLower().isExclusive());
502 Label high = new Label(composite, SWT.NONE);
503 high.setText(Messages.ComponentTypeViewerData_MaximumValue);
504 final Text highText = new Text(composite, SWT.BORDER | extraTextStyle);
505 GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).applyTo(highText);
506 final Combo highSelector = createRangeInclusionCombo(composite, !range.getUpper().isExclusive());
508 Composite buttonComposite = new Composite(shell, SWT.NONE);
509 GridDataFactory.fillDefaults().grab(true, false).align(SWT.TRAIL, SWT.FILL).applyTo(buttonComposite);
510 GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(true).applyTo(buttonComposite);
512 Button ok = new Button(buttonComposite, SWT.NONE);
513 ok.setText(IDialogConstants.OK_LABEL);
514 GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).applyTo(ok);
515 Button cancel = new Button(buttonComposite, SWT.NONE);
516 cancel.setText(IDialogConstants.CANCEL_LABEL);
517 GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).applyTo(ok);
519 if (range.getLower().getValue() != null)
520 lowText.setText(range.getLower().getValue().toString());
521 if (range.getUpper().getValue() != null)
522 highText.setText(range.getUpper().getValue().toString());
524 shell.addListener(SWT.Deactivate, new org.eclipse.swt.widgets.Listener() {
526 public void handleEvent(Event event) {
531 ok.addSelectionListener(new SelectionAdapter() {
532 public void widgetSelected(SelectionEvent e) {
534 final Range newRange = parseRange(propertyInfo.numberType,
535 lowText.getText().trim(),
536 highText.getText().trim(),
537 lowSelector.getSelectionIndex() == 0 ? true : false,
538 highSelector.getSelectionIndex() == 0 ? true : false);
542 if (propertyInfo.immutable)
545 Simantics.getSession().async(new WriteRequest() {
547 public void perform(WriteGraph graph)
548 throws DatabaseException {
549 graph.markUndoPoint();
550 ComponentTypeCommands.setRange(graph, componentType, propertyInfo.resource, newRange == null ? null : newRange.toString());
553 } catch (RangeException ex) {
554 ErrorLogger.defaultLogError(ex);
558 cancel.addSelectionListener(new SelectionAdapter() {
559 public void widgetSelected(SelectionEvent e) {
565 Point size = shell.getSize();
567 Display display = table.getDisplay();
568 Rectangle clientArea = display.getClientArea();
569 Point bt = table.toDisplay(selectedItemBounds.x, selectedItemBounds.y);
570 Rectangle b = selectedItemBounds;
575 if ((b.x + b.width) > clientArea.width)
576 b.x -= b.x + b.width - clientArea.width;
577 if (b.height > clientArea.height)
578 b.height = clientArea.height;
579 if ((b.y + b.height) > clientArea.height)
580 b.y -= b.y + b.height - clientArea.height;
582 shell.setBounds(selectedItemBounds);
586 public void editMultilineText(Table table, TableEditor editor,
587 final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem,
588 Rectangle selectedItemBounds, int column, final StringWriter writer)
590 final Shell shell = new Shell(table.getShell(), SWT.ON_TOP);
591 GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(shell);
592 final StyledText text = new StyledText(shell, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | (propertyInfo.immutable ? SWT.READ_ONLY : 0));
593 GridDataFactory.fillDefaults().grab(true, true).applyTo(text);
594 text.setText(selectedItem.getText(column));
595 org.eclipse.swt.widgets.Listener listener =
596 new org.eclipse.swt.widgets.Listener() {
598 public void handleEvent(Event e) {
599 final String newValue = text.getText();
601 if (e.type == SWT.Traverse) {
602 if (e.detail == SWT.TRAVERSE_ESCAPE) {
607 if (e.detail == SWT.TRAVERSE_ARROW_NEXT
608 || e.detail == SWT.TRAVERSE_ARROW_PREVIOUS
609 || e.detail == SWT.TRAVERSE_MNEMONIC)
611 if ((e.stateMask & SWT.CTRL) == 0)
618 if (propertyInfo.immutable)
621 if (writer != null) {
622 Simantics.getSession().async(new WriteRequest() {
624 public void perform(WriteGraph graph) throws DatabaseException {
625 writer.perform(graph, newValue);
632 String helpText = propertyInfo.immutable ? Messages.ComponentTypeViewerData_ESCToClose : Messages.ComponentTypeViewerData_CtrlEnterApplyChanges;
633 Label help = tk.createLabel(shell, helpText, SWT.BORDER | SWT.FLAT);
634 GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(help);
635 help.setForeground( tk.getColors().createColor( "fg", tk.getColors().getSystemColor(SWT.COLOR_LIST_SELECTION) ) ); //$NON-NLS-1$
637 Display display = table.getDisplay();
638 Rectangle clientArea = display.getClientArea();
639 Point bt = table.toDisplay(selectedItemBounds.x, selectedItemBounds.y);
640 Rectangle b = selectedItemBounds;
644 if ((b.x + b.width) > clientArea.width)
645 b.x -= b.x + b.width - clientArea.width;
646 if (b.height > clientArea.height)
647 b.height = clientArea.height;
648 if ((b.y + b.height) > clientArea.height)
649 b.y -= b.y + b.height - clientArea.height;
651 shell.setBounds(selectedItemBounds);
657 text.addListener(SWT.Traverse, listener);
658 shell.addListener(SWT.Deactivate, listener);
661 private String validatePropertyName(ComponentTypeViewerPropertyInfo propertyInfo, String propertyName, Pattern namePattern) {
662 if (propertyName.equals(propertyInfo.name))
664 for (ComponentTypeViewerPropertyInfo info : properties) {
665 if (propertyName.equals(info.name))
666 return NLS.bind(Messages.ComponentTypeViewerData_PropertyNameInUse, propertyName);
668 for (NamedResource cp : connectionPoints) {
669 if (propertyName.equals(cp.getName()))
670 return NLS.bind(Messages.ComponentTypeViewerData_NameInUse, propertyName );
672 Matcher m = namePattern.matcher(propertyName);
674 return NLS.bind(Messages.ComponentTypeViewerData_ContainsInvalidCharacters, propertyName, namePattern.pattern());