我正在使用eclipse插件,其中Project Explorer
视图中存在的项目具有与项目实际路径不同的工作区名称。因此,当我尝试获取项目位置时考虑位于D:\test
的项目,它指向D:\test_plugin_specific_suffix
。
有没有办法从绝对路径(指向本地路径D:\test\testfile.txt
)获取IFile?
我想创建一个指向特定文件的超链接,我有绝对路径。当我点击超链接上的控制台时,它应该在编辑器中打开文件。
答案 0 :(得分:2)
您可以使用IWorkspaceRoot.findFilesForLocationURI
查找与绝对路径相对应的IFile
(如果您是,则可能会有多个File file = new File(....absolue path);
URI location = file.toURI();
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(location);
使用链接):
int main() {
char tab = '\t';
int input;
bool menu = true;
FlightSystem f;
vector <Aircraft> allAircraftList_{};
std::string flightNumber, airline, aircraftType, gridReference;
int groundSpeed, altitude, heading;
const int MaxAlt = 60000, MinAlt = 0, MaxSpeed = 800, MinHeading = 0, MaxHeading = 360;
regex fNumber{ "([a-z]{2}([a-z])?[0-9]([0-9])?([0-9])?([0-9])?([0-9])?)" };
do {
std::cout << "#########################################################" << endl;
std::cout << "#Flight Control Simulation#" << endl;
std::cout << "#########################################################" << endl;
std::cout << "" << endl;
std::cout << tab << "1. Add Aircraft" << endl;
std::cout << tab << "2. List All Aircraft" << endl;
std::cout << tab << "3. List All Cruising Aircraft" << endl;
std::cout << tab << "4. Number of Aircrafts in Sector" << endl;
std::cout << tab << "5. Remove Aircraft" << endl;
std::cout << tab << "6. Change Heading" << endl;
std::cout << tab << "7. Get Heading" << endl;
std::cout << tab << "8. Change Altitude" << endl;
std::cout << tab << "9. Get Altitude" << endl;
std::cout << "" << endl;
std::cout << "---------------------------------------------------------" << endl;
std::cout << "Please enter an option, between 1-9:" << endl;
std::cin >> input;
switch (input) {
case:
break;
default:
cout << "Your selection must be between 1 and 9" << endl;
}
return 0;
} while (input != 9);
}