简体   繁体   English

如何告诉Eclipse Workspace?

[英]How to tell Eclipse Workspace?

有没有办法告诉您当前正在使用的当前Eclipse工作区?

For me it work to choose File->Switch Workspace->Other... and it shows the name of current workspace. 对我来说,选择File-> Switch Workspace-> Other ...它会显示当前工作空间的名称。


I tried to confirm 我试着确认一下

" Actually, this shows the last workspace that was closed, not the current workspace. If you are opening and closing several, this is not dependable. " 实际上,这显示了关闭的最后一个工作区,而不是当前的工作区。如果你打开和关闭几个,这是不可靠的。

and I am not able to reproduce it. 我无法重现它。 Each time I get the currently loaded workspace (I was testing on Juno). 每次我获得当前加载的工作区(我在Juno上测试)。 I also checked sources and in ChooseWorkspaceDialog.java and ChooseWorkspaceData.java , and it looks like it manages simple list of last time opened workspaces which is stored as a RECENT_WORKSPACES key in org.eclipse.ui.ide.prefs file. 我还检查了源和ChooseWorkspaceDialog.javaChooseWorkspaceData.java ,它看起来像是管理上次打开的工作空间的简单列表,它在org.eclipse.ui.ide.prefs文件中存储为RECENT_WORKSPACES键。 The workspace name shown in this dialog is the first one from this list. 此对话框中显示的工作空间名称是此列表中的第一个。

start eclipse with -showlocation -showlocation启动eclipse

Here are two interesting posts about it: 这是关于它的两篇有趣的帖子:

top-10-tips-for-new-eclipse-users (archived version) top-10-tips-for-new-eclipse-users(归档版)

eclipse-startup-options-showlocation Eclipse的启动选项,showlocation

Go Window>Preferences. 转到窗口>首选项。 Then under General>Workspace there is a property: "Workspace name (shown in window title)" and put in some sort of identifying label. 然后在General> Workspace下有一个属性:“工作区名称(显示在窗口标题中)”并放入某种识别标签。

You'll need to set this up for each workspace you have, but it's an easy way to know which workspace you're in at a glance. 您需要为每个工作区设置此项,但这是一种简单的方法,可以一目了然地了解您所在的工作区。

Eclipse Neon (4.6) Eclipse Neon(4.6)

According to M7 , workspace name is shown in window title by default. 根据M7 ,工作区名称默认显示在窗口标题中

Eclipse Mars (4.5) Eclipse Mars(4.5)

Window > Preferences > General > Workspace 窗口 > 首选项 > 常规 > 工作区

窗口首选项一般工作区

There is also a check box " Show workspace path in window title ". 还有一个复选框“ 在窗口标题显示工作空间路径 ”。
The result looks like this: 结果如下:
标题栏

This feature is described here . 此功能在此处描述。

If any project exists in the workspace: 如果工作空间中存在任何项目:

Select a project and its properties (eg Menu: Project -> Properties or right mouse button->Properties ). 选择项目及其属性(例如, Menu: Project -> Propertiesright mouse button->Properties )。 Then go to Resource -> Linked Resources and the WORKSPACE_LOC 's Path Variable value shows the current workspace path. 然后转到Resource -> Linked ResourcesWORKSPACE_LOC的Path Variable值显示当前工作空间路径。

There's an environment variable called osgi.instance.area . 有一个名为osgi.instance.area的环境变量。 You can find it via "Help -> About Eclipse -> Installation Details -> Configuration" (for eclipse "Helios" 3.6) 您可以通过“帮助 - >关于Eclipse - >安装详细信息 - >配置”找到它(对于eclipse“Helios”3.6)

Or, open the properties of any project, then select "Resource". 或者,打开任何项目的属性,然后选择“资源”。 You'll find a "Location" property which is structured like this: 你会找到一个“Location”属性,其结构如下:

 
 
 
  
  <path-to-current-workspace>/<name-of-current-project>
 
  

Note - the "erased" procedure works in most cases but can not be used in general, because a project folder does not have to be located in the workspace folder. 注意 - “擦除”过程在大多数情况下都有效,但一般不能使用,因为项目文件夹不必位于工作区文件夹中。 You can choose external locations during project creation. 您可以在项目创建期间选择外部位置。 So if you never uncheck the "Use default location", the procedure is save. 因此,如果您从未取消选中“使用默认位置”,则该过程将保存。 The first procedure is reliable. 第一个程序是可靠的。

File->Properties 文件- >属性

Select a file in the workspace and then use the menu: "File->Properties". 在工作区中选择一个文件,然后使用菜单:“文件 - >属性”。 A dialog pops up and should show the 'location' of the file. 弹出一个对话框,应显示文件的“位置”。 Read the location from right to left so you go through the class, package, folder, project, then you should see the workspace. 从右到左阅读位置,以便您浏览类,包,文件夹,项目,然后您应该看到工作区。

Summary: 摘要:
(from most immediate to lesser (but more elegant), leaving out redundant ones) (从最直接到较小(但更优雅),省去多余的)

  1. File > Switch 文件>切换
    File->Switch Workspace->Other... -> full answer 文件 - >切换工作区 - >其他... - >完整答案
  2. Help > About 帮助>关于
    Help -> About Eclipse -> Installation Details -> Configuration: osgi.instance.area ->full answer 帮助 - >关于Eclipse - >安装细节 - >配置:osgi.instance.area - >完整答案
  3. Title bar (start-up parameter) 标题栏 (启动参数)
    If you start eclipse with -showlocation -> full answer 如果你用-showlocation启动eclipse - >完整答案
  4. Title bar (naming workspaces) 标题栏 (命名工作区)
    Give each workspace a name -> full answer 为每个工作区命名- >完整答案
  1. Go to File->Switch Workspace. 转到文件 - >切换工作区。
  2. You can see a list of workspaces excluding your current workspace. 您可以看到除当前工作空间之外的工作空间列表。
  3. Now go to the physical location and see which one is missing in the list. 现在转到物理位置,看看列表中缺少哪一个。

The missing one is your current workspace. 缺少的是您当前的工作区。

I just found my current Workspace with Simplest Way. 我刚刚以最简单的方式找到了我当前的工作区。

Step 1: 步骤1:

Start Your Eclipse (If default workspace is set, Eclipse never ask for Choose workspace OR it will set to path which we have used last time) 启动Eclipse(如果设置了默认工作区,Eclipse永远不会要求选择工作区,或者它将设置为我们上次使用的路径)

Step 2: 第2步:

When Eclipse start Completely, try to Start Eclipse again with same shortcut/exe file. 当Eclipse完全启动时,尝试使用相同的快捷方式/ exe文件再次启动Eclipse。 It will show you below error message and you will get your default/current workspace 它将显示以下错误消息,您将获得默认/当前工作空间

在此输入图像描述

使用文件菜单中的开关工作区,您就会知道它

start eclipse with -data -data启动eclipse

example: c:\\eclipse\\eclipse.exe -data c:\\workspaces\\myWorkspace1 示例: c:\\eclipse\\eclipse.exe -data c:\\workspaces\\myWorkspace1

-showlocation is great, but it only changes the text at the end of the title bar, so it's often not visible in the taskbar. -showlocation很棒,但它只更改标题栏末尾的文本,因此通常在任务栏中不可见。

If you want to change the beginning of the title bar, which shows the current Perspective, you can use Window -> Save Perspective As... and the new title will be visible in the Taskbar. 如果要更改显示当前Perspective的标题栏的开头,可以使用Window - > Save Perspective As ...并在任务栏中显示新标题。

I created an External Tool Launch Configuration containing the following (exported echo-workspace.launch file content): 我创建了一个外部工具启动配置,其中包含以下内容(导出的echo-workspace.launch文件内容):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration
    type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
    <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
        <listEntry value="org.eclipse.ui.externaltools.launchGroup" />
    </listAttribute>
    <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE" value="${none}" />
    <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="c:\Windows\System32\cmd.exe" />
    <stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="/c echo &quot;${workspace_loc}&quot;" />
</launchConfiguration>

So that the workspace folder path is echoed in the console. 这样工作区文件夹路径就会在控制台中回显。

Feel free to copy this into a .launch file and import it into Eclipse: File > Import ... > Run/Debug > Launch Configurations 随意将其复制到.launch文件并将其导入Eclipse:文件>导入...>运行/调试>启动配置

I'll figure out a Mac/UNIX version soon, as I was on Indigo/Win when I made this one. 我很快就会想出一个Mac / UNIX版本,就像我在Indigo / Win上做的那样。

You will often have to use multiple running Eclipse instances at a time. 您通常必须一次使用多个正在运行的Eclipse实例。 To switch between them, it's helpful to set a name for the workspace that is displayed in the title of the Eclipse window. 要在它们之间切换,为Eclipse窗口标题中显示的工作空间设置名称会很有帮助。 To do this, open Window/Preferences. 为此,请打开“窗口/首选项”。 In the Preferences window navigate to General/Workspace and give every workspace an individual workspace name. 在“首选项”窗口中,导航到“常规/工作区”,并为每个工作区指定单独的工作区名

I got into a situation which caused eclipse startup to fail completely due to workspace corruption. 我遇到了由于工作空间损坏导致eclipse启动完全失败的情况。

(Similar to Eclipse won't start, log error says: ObjectNotFoundException: Tree element ) (类似于Eclipse无法启动,日志错误说:ObjectNotFoundException:Tree element

It had been so long since i used eclipse that i forgot where my workspace was. 自从我使用eclipse以来,我忘记了我的工作空间。 This is where i found the setting. 这是我找到设置的地方。

~$ grep osgi.instance.area.default eclipse/configuration/config.ini osgi.instance.area.default=@user.home/Documents/workspace 〜$ grep osgi.instance.area.default eclipse / configuration / config.ini osgi.instance.area.default=@user.home/Documents/workspace

如果要以编程方式查找路径,请使用以下命令:

ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();

Check the path of any resource in the resource's properties. 检查资源属性中任何资源的路径。 Then you'll know. 然后你就会知道。 OR: Go to Preferences > General > Workspace and add a Workspace name (shown in window title) 或者:转到首选项>常规>工作区并添加工作区名称(显示在窗口标题中)

文件 - >切换工作区

If you want to switch wokspace, then File->Switch Workspace. 如果要切换wokspace,请单击File-> Switch Workspace。 Click "Other" and choose appropriate folder. 单击“其他”并选择适当的文件夹。 Is that what you want? 那是你要的吗? :) :)

Simple Logic... 简单逻辑......

Just Click on File menu then Switch Work Place 只需单击文件菜单,然后单击切换工作区

Click on Other 单击“其他”

Then the dialogue pops up with current workspace highlighted on the top of the list. 然后弹出对话框,列表顶部突出显示当前工作区。 If you click on this list, other workplaces are shown. 如果单击此列表,则会显示其他工作区。

clicking File->Switch Workspace gives the wrong result on my system. 单击File-> Switch Workspace会在我的系统上显示错误的结果。
This method gives the correct result: 此方法给出了正确的结果:
File -> Properties -> Resource 文件 - >属性 - >资源
now check the path in the third line labeled "location" in window labeled Resource 现在检查标记为Resource的窗口中标记为“location”的第三行中的路径
It will show the workspace folder just before the project folder. 它将在项目文件夹之前显示工作区文件夹。

windnow -> preference -> General -> startup and shutdown -> workspaces - top one将是你当前的工作区。

  1. Go to Window -> Preferences. 转到窗口 - >首选项。
  2. Search for Workspaces & select. 搜索工作区并选择。
  3. The top one is your current workspace. 最上面的是您当前的工作区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM