-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1985] Add support for in-memory Views
Bug: #1985 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
- Loading branch information
1 parent
e99f14d
commit 6926198
Showing
5 changed files
with
112 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../main/java/org/eclipse/sirius/web/services/api/representations/IInMemoryViewRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.web.services.api.representations; | ||
|
||
import java.util.Optional; | ||
|
||
import org.eclipse.sirius.components.view.View; | ||
|
||
/** | ||
* Used to register views loaded in memory. | ||
* | ||
* @author pcdavid | ||
*/ | ||
public interface IInMemoryViewRegistry { | ||
|
||
void register(View view); | ||
|
||
Optional<View> findViewById(String viewId); | ||
} |
44 changes: 44 additions & 0 deletions
44
...s/src/main/java/org/eclipse/sirius/web/services/representations/InMemoryViewRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.web.services.representations; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import org.eclipse.sirius.components.view.View; | ||
import org.eclipse.sirius.web.services.api.representations.IInMemoryViewRegistry; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* Used to register views loaded in memory. | ||
* | ||
* @author pcdavid | ||
*/ | ||
@Service | ||
public class InMemoryViewRegistry implements IInMemoryViewRegistry { | ||
|
||
private final Map<String, View> idToView = new HashMap<>(); | ||
|
||
@Override | ||
public void register(View view) { | ||
String viewId = view.eResource().getURI().toString().split("///")[1]; | ||
this.idToView.put(viewId, view); | ||
} | ||
|
||
@Override | ||
public Optional<View> findViewById(String viewId) { | ||
return Optional.ofNullable(this.idToView.get(viewId)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters