Search in sources :

Example 16 with IInputValidator

use of org.eclipse.jface.dialogs.IInputValidator in project tdi-studio-se by Talend.

the class RenameAction method getNewName.

/**
     * Gets the new file name.
     * 
     * @return The new file name
     */
private String getNewName() {
    IFileStore fileStore = snapshot.getFileStore();
    List<String> oldNames = new ArrayList<String>();
    try {
        for (String oldName : fileStore.getParent().childNames(EFS.NONE, null)) {
            oldNames.add(removeSuffix(oldName));
        }
    } catch (CoreException e) {
        Activator.log(IStatus.ERROR, NLS.bind(Messages.accessFileFailedMsg, fileStore.getName()), e);
        return null;
    }
    String oldName = fileStore.getName();
    IInputValidator validator = new InputValidator(oldNames, oldName);
    InputDialog dialog = new InputDialog(treeViewer.getControl().getShell(), Messages.renameTitle, Messages.newNameLabel, removeSuffix(oldName), validator);
    if (dialog.open() == Window.OK) {
        return oldName.replace(removeSuffix(oldName), dialog.getValue());
    }
    return null;
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) CoreException(org.eclipse.core.runtime.CoreException) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException) IInputValidator(org.eclipse.jface.dialogs.IInputValidator) ArrayList(java.util.ArrayList) IFileStore(org.eclipse.core.filesystem.IFileStore) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Aggregations

IInputValidator (org.eclipse.jface.dialogs.IInputValidator)16 InputDialog (org.eclipse.jface.dialogs.InputDialog)12 IStatus (org.eclipse.core.runtime.IStatus)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 SelectionListener (org.eclipse.swt.events.SelectionListener)5 FillLayout (org.eclipse.swt.layout.FillLayout)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 Button (org.eclipse.swt.widgets.Button)5 Composite (org.eclipse.swt.widgets.Composite)5 Event (org.eclipse.swt.widgets.Event)5 Group (org.eclipse.swt.widgets.Group)5 Label (org.eclipse.swt.widgets.Label)5 ArrayList (java.util.ArrayList)4 Listener (org.eclipse.swt.widgets.Listener)4 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)3 Status (org.eclipse.core.runtime.Status)3 ErrorDialog (org.eclipse.jface.dialogs.ErrorDialog)3 SashForm (org.eclipse.swt.custom.SashForm)3 List (java.util.List)2 SystemDBOperator (net.heartsome.cat.database.SystemDBOperator)2