|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2014 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 82-108
Link Here
|
| 82 |
public INewNameQuery createNewCompilationUnitNameQuery(ICompilationUnit cu, String initialSuggestedName) { |
82 |
public INewNameQuery createNewCompilationUnitNameQuery(ICompilationUnit cu, String initialSuggestedName) { |
| 83 |
String[] keys= { BasicElementLabels.getJavaElementName(JavaCore.removeJavaLikeExtension(cu.getElementName()))}; |
83 |
String[] keys= { BasicElementLabels.getJavaElementName(JavaCore.removeJavaLikeExtension(cu.getElementName()))}; |
| 84 |
String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys); |
84 |
String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys); |
| 85 |
return createStaticQuery(createCompilationUnitNameValidator(cu), message, initialSuggestedName, getShell()); |
85 |
return createStaticQuery(createCompilationUnitNameValidator(cu), message, initialSuggestedName, true, getShell()); |
| 86 |
} |
86 |
} |
| 87 |
|
87 |
|
| 88 |
|
88 |
|
| 89 |
public INewNameQuery createNewResourceNameQuery(IResource res, String initialSuggestedName) { |
89 |
public INewNameQuery createNewResourceNameQuery(IResource res, String initialSuggestedName) { |
| 90 |
String[] keys= { BasicElementLabels.getResourceName(res)}; |
90 |
String[] keys= { BasicElementLabels.getResourceName(res)}; |
| 91 |
String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys); |
91 |
String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys); |
| 92 |
return createStaticQuery(createResourceNameValidator(res), message, initialSuggestedName, getShell()); |
92 |
return createStaticQuery(createResourceNameValidator(res), message, initialSuggestedName, res.getType() == IResource.FILE, getShell()); |
| 93 |
} |
93 |
} |
| 94 |
|
94 |
|
| 95 |
|
95 |
|
| 96 |
public INewNameQuery createNewPackageNameQuery(IPackageFragment pack, String initialSuggestedName) { |
96 |
public INewNameQuery createNewPackageNameQuery(IPackageFragment pack, String initialSuggestedName) { |
| 97 |
String[] keys= {JavaElementLabels.getElementLabel(pack, JavaElementLabels.ALL_DEFAULT)}; |
97 |
String[] keys= {JavaElementLabels.getElementLabel(pack, JavaElementLabels.ALL_DEFAULT)}; |
| 98 |
String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys); |
98 |
String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys); |
| 99 |
return createStaticQuery(createPackageNameValidator(pack), message, initialSuggestedName, getShell()); |
99 |
return createStaticQuery(createPackageNameValidator(pack), message, initialSuggestedName, false, getShell()); |
| 100 |
} |
100 |
} |
| 101 |
|
101 |
|
| 102 |
public INewNameQuery createNewPackageFragmentRootNameQuery(IPackageFragmentRoot root, String initialSuggestedName) { |
102 |
public INewNameQuery createNewPackageFragmentRootNameQuery(IPackageFragmentRoot root, String initialSuggestedName) { |
| 103 |
String[] keys= {JavaElementLabels.getElementLabel(root, JavaElementLabels.ALL_DEFAULT)}; |
103 |
String[] keys= {JavaElementLabels.getElementLabel(root, JavaElementLabels.ALL_DEFAULT)}; |
| 104 |
String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys); |
104 |
String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys); |
| 105 |
return createStaticQuery(createPackageFragmentRootNameValidator(root), message, initialSuggestedName, getShell()); |
105 |
return createStaticQuery(createPackageFragmentRootNameValidator(root), message, initialSuggestedName, false, getShell()); |
| 106 |
} |
106 |
} |
| 107 |
|
107 |
|
| 108 |
|
108 |
|
|
Lines 119-125
Link Here
|
| 119 |
}; |
119 |
}; |
| 120 |
} |
120 |
} |
| 121 |
|
121 |
|
| 122 |
private static INewNameQuery createStaticQuery(final IInputValidator validator, final String message, final String initial, final Shell shell){ |
122 |
private static INewNameQuery createStaticQuery(final IInputValidator validator, final String message, final String initial, final boolean isFile, final Shell shell) { |
| 123 |
return new INewNameQuery(){ |
123 |
return new INewNameQuery(){ |
| 124 |
public String getNewName() throws OperationCanceledException { |
124 |
public String getNewName() throws OperationCanceledException { |
| 125 |
InputDialog dialog= new InputDialog(shell, ReorgMessages.ReorgQueries_nameConflictMessage, message, initial, validator) { |
125 |
InputDialog dialog= new InputDialog(shell, ReorgMessages.ReorgQueries_nameConflictMessage, message, initial, validator) { |
|
Lines 132-137
Link Here
|
| 132 |
TextFieldNavigationHandler.install(getText()); |
132 |
TextFieldNavigationHandler.install(getText()); |
| 133 |
return area; |
133 |
return area; |
| 134 |
} |
134 |
} |
|
|
135 |
|
| 136 |
@Override |
| 137 |
protected void createButtonsForButtonBar(Composite parent) { |
| 138 |
super.createButtonsForButtonBar(parent); |
| 139 |
int lastIndexOfDot= initial.lastIndexOf('.'); |
| 140 |
if (isFile && lastIndexOfDot > 0) { |
| 141 |
getText().setSelection(0, lastIndexOfDot); |
| 142 |
} |
| 143 |
} |
| 135 |
}; |
144 |
}; |
| 136 |
if (dialog.open() == Window.CANCEL) |
145 |
if (dialog.open() == Window.CANCEL) |
| 137 |
throw new OperationCanceledException(); |
146 |
throw new OperationCanceledException(); |