How to know workspace Id
Hi,
I would like to know if there is a way to know in a plugin the current workspace id. There is a listener that I can use for that?
Thanks
I don't know scope of your question... If you ask about current GWT IDE, so you can inject and use: https://github.com/eclipse/che/blob/master/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/context/AppContextImpl.java#L140
To indicate that workspace is ready or running we have workspace ready event and workspace running event
Hi @AndreyChizhikov,
Thanks :) Is it possible to retrieve this information by workspace id?
"dev-machine": { "attributes": { "memoryLimitBytes": "2147483648" }, "servers": { "5000/tcp": { "url": "http://172.17.0.1:32771", "attributes": {}, "status": "UNKNOWN" }, "wsagent/ws": { "url": "ws://172.17.0.1:32775/wsagent", "attributes": {}, "status": "UNKNOWN" },
I can fetch it through the webservice, but I would like to have it through Java code like I did for workspace Id.
@mstavares In the GWT code you can use WorkspaceServiceClient: Get workspace config by Id
You can use also https://github.com/eclipse/che/blob/master/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/context/AppContextImpl.java#L130
Hi @AndrienkoAleksandr I'm trying to use AppContext but I have some issues.
"runtime": { "machines": { "frontend": { "attributes": { "memoryLimitBytes": "1073741824" }, "servers": { "exec-agent/ws": { "url": "ws://172.17.0.1:32943/connect", "attributes": {}, "status": "UNKNOWN" }, "8081/tcp": { "url": "http://172.17.0.1:32942", "attributes": { "type": "frontend" },
I need to discover this URL dynamically in order to load it in an iFrame.
"url": "http://172.17.0.1:32942", <<
`
@Singleton
public class FrontendAction extends BaseAction {
...
@Override public void actionPerformed(ActionEvent e) {
Map<String, ServerImpl> servers = appContext.getWorkspace().getRuntime().getMachines().get("frontend").getServers();
for (Map.Entry<String, ServerImpl> entry : servers.entrySet()) {
if(entry.getValue().getAttributes().get("type").equalsIgnoreCase("frontend")) {
frontEndViewPresenter.setUrl(entry.getValue().getUrl());
}
}
workspaceAgent.openPart(frontEndViewPresenter, PartStackType.TOOLING);
workspaceAgent.setActivePart(frontEndViewPresenter);
}`
I don't know why but right now my button is not working, and to get worse I can't debug this class and I don't know why. I set the break point there but isn't working.
Could you help me again please?
Hi @AndrienkoAleksandr ,
I have already found a way to solve it. I have subscribed for an event which is triggered when my workspace is up, then I use the AppContext in order to fetch the information that I need.
Thanks for your help.