本文整理汇总了Java中org.eclipse.core.runtime.IPath.getFileExtension方法的典型用法代码示例。如果您正苦于以下问题:Java IPath.getFileExtension方法的具体用法?Java IPath.getFileExtension怎么用?Java IPath.getFileExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.runtime.IPath
的用法示例。
在下文中一共展示了IPath.getFileExtension方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValid
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
@Override
public String isValid(String newText) {
IPath path = new Path(newText);
String fileExtension = path.getFileExtension();
String moduleName = path.removeFileExtension().lastSegment();
if (path.removeFileExtension().segmentCount() < 1 || moduleName.isEmpty()) {
return "The module name must not be empty.";
}
if (!isValidFolderName(path.removeFileExtension().toString())) {
return "The module name is not a valid file system name.";
}
if (fileExtension == null) {
return "The module name needs to have a valid N4JS file extension.";
}
if (!(fileExtension.equals(N4JSGlobals.N4JS_FILE_EXTENSION) ||
fileExtension.equals(N4JSGlobals.N4JSD_FILE_EXTENSION))) {
return "Invalid file extension.";
}
if (!isModuleFileSpecifier(path)) {
return "Invalid module file specifier.";
}
if (path.segmentCount() > 1) {
return IPath.SEPARATOR + " is not allowed in a module file specifier.";
}
if (treeViewer.getStructuredSelection().getFirstElement() == null) {
return "Please select a module container";
}
return null;
}
示例2: isN4JSResource
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
private boolean isN4JSResource(IPath path) {
String fileExtension = path.getFileExtension();
return null != fileExtension &&
(fileExtension.equals(N4JSGlobals.N4JS_FILE_EXTENSION)
|| fileExtension.equals(N4JSGlobals.N4JSD_FILE_EXTENSION));
}
示例3: queryOverwrite
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
* The default implementation of this <code>IOverwriteQuery</code> method asks the user whether the existing
* resource at the given path should be overwritten.
*
* @param pathString
* the path of the archive
* @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, <code>"ALL"</code>, or
* <code>"CANCEL"</code>
*/
@Override
public String queryOverwrite(String pathString) {
IPath path = Path.fromOSString(pathString);
String messageString;
// Break the message up if there is a file name and a directory
// and there are at least 2 segments.
if (path.getFileExtension() == null || path.segmentCount() < 2) {
messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString);
} else {
messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion,
path.lastSegment(),
path.removeLastSegments(1).toOSString());
}
final MessageDialog dialog = new MessageDialog(getContainer()
.getShell(), IDEWorkbenchMessages.Question,
null, messageString, MessageDialog.QUESTION, new String[] {
IDialogConstants.YES_LABEL,
IDialogConstants.YES_TO_ALL_LABEL,
IDialogConstants.NO_LABEL,
IDialogConstants.NO_TO_ALL_LABEL,
IDialogConstants.CANCEL_LABEL }, 0) {
@Override
protected int getShellStyle() {
return super.getShellStyle() | SWT.SHEET;
}
};
String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL };
// run in syncExec because callback is from an operation,
// which is probably not running in the UI thread.
getControl().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
dialog.open();
}
});
return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()];
}