1 /*******************************************************************************
\r
2 * Copyright (c) 2010 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.sysdyn.ui.properties.widgets.factories;
\r
14 import org.eclipse.jface.dialogs.IInputValidator;
\r
15 import org.simantics.browsing.ui.swt.widgets.impl.Widget;
\r
16 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
\r
17 import org.simantics.db.Resource;
\r
18 import org.simantics.db.management.ISessionContext;
\r
19 import org.simantics.sysdyn.ui.utils.FunctionLibraryNameValidator;
\r
20 import org.simantics.utils.ui.ISelectionUtils;
\r
23 * Name validator container for user defined function libraries.
\r
24 * @author Tuomas Miettinen
\r
27 public class FunctionLibraryNameInputValidator implements IInputValidator, Widget {
\r
29 private Resource lastInput = null;
\r
31 public FunctionLibraryNameInputValidator(WidgetSupport support) {
\r
32 support.register(this);
\r
36 * Checks that the syntax of the given name is valid and there
\r
37 * are no other components that have the same name in the configuration.
\r
40 public String isValid(final String newText) {
\r
41 if (!new FunctionLibraryNameValidator().isValid(lastInput, newText))
\r
48 public void setInput(ISessionContext context, Object input) {
\r
49 lastInput = ISelectionUtils.filterSingleSelection(input, Resource.class);
\r