-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3982] Add support for command palette
Bug: #3982 Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr> Signed-off-by: Guillaume Coutable <guillaume.coutable@obeo.fr>
- Loading branch information
Showing
60 changed files
with
2,877 additions
and
383 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
31 changes: 31 additions & 0 deletions
31
...rc/main/java/org/eclipse/sirius/components/collaborative/dto/GetOmniboxCommandsInput.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,31 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 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.components.collaborative.dto; | ||
|
||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.core.api.IInput; | ||
|
||
/** | ||
* The input for the get omnibox commands query. | ||
* | ||
* @author gcoutable | ||
*/ | ||
public record GetOmniboxCommandsInput(UUID id, String query) implements IInput { | ||
public GetOmniboxCommandsInput { | ||
Objects.requireNonNull(id); | ||
Objects.requireNonNull(query); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../main/java/org/eclipse/sirius/components/collaborative/dto/GetOmniboxCommandsPayload.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,32 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 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.components.collaborative.dto; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.core.api.IPayload; | ||
|
||
/** | ||
* The payload for the get omnibox commands query. | ||
* | ||
* @author gcoutable | ||
*/ | ||
public record GetOmniboxCommandsPayload(UUID id, List<OmniboxCommand> omniboxCommands) implements IPayload { | ||
public GetOmniboxCommandsPayload { | ||
Objects.requireNonNull(id); | ||
Objects.requireNonNull(omniboxCommands); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...orative/src/main/java/org/eclipse/sirius/components/collaborative/dto/OmniboxCommand.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,33 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 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.components.collaborative.dto; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
/** | ||
* The omnibox command. | ||
* | ||
* @author gcoutable | ||
*/ | ||
public record OmniboxCommand(UUID id, String label, String kind, List<String> iconURL, String description) { | ||
public OmniboxCommand { | ||
Objects.requireNonNull(id); | ||
Objects.requireNonNull(label); | ||
Objects.requireNonNull(kind); | ||
Objects.requireNonNull(iconURL); | ||
Objects.requireNonNull(description); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ve/src/main/java/org/eclipse/sirius/components/collaborative/dto/OmniboxContextEntry.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,24 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 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.components.collaborative.dto; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* The omnibox context entry. | ||
* | ||
* @author gcoutable | ||
*/ | ||
public record OmniboxContextEntry(UUID id, String label, String kind) { | ||
} |
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
113 changes: 113 additions & 0 deletions
113
.../org/eclipse/sirius/components/collaborative/handlers/GetOmniboxCommandsEventHandler.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,113 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 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.components.collaborative.handlers; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.collaborative.api.ChangeDescription; | ||
import org.eclipse.sirius.components.collaborative.api.ChangeKind; | ||
import org.eclipse.sirius.components.collaborative.api.IEditingContextEventHandler; | ||
import org.eclipse.sirius.components.collaborative.api.IQueryService; | ||
import org.eclipse.sirius.components.collaborative.api.Monitoring; | ||
import org.eclipse.sirius.components.collaborative.dto.CreateChildInput; | ||
import org.eclipse.sirius.components.collaborative.dto.GetOmniboxCommandsInput; | ||
import org.eclipse.sirius.components.collaborative.dto.GetOmniboxCommandsPayload; | ||
import org.eclipse.sirius.components.collaborative.dto.OmniboxCommand; | ||
import org.eclipse.sirius.components.collaborative.dto.QueryBasedObjectsInput; | ||
import org.eclipse.sirius.components.collaborative.dto.QueryBasedObjectsSuccessPayload; | ||
import org.eclipse.sirius.components.collaborative.messages.ICollaborativeMessageService; | ||
import org.eclipse.sirius.components.core.api.ErrorPayload; | ||
import org.eclipse.sirius.components.core.api.IEditingContext; | ||
import org.eclipse.sirius.components.core.api.IInput; | ||
import org.eclipse.sirius.components.core.api.IObjectService; | ||
import org.eclipse.sirius.components.core.api.IPayload; | ||
import org.eclipse.sirius.components.representations.Message; | ||
import org.eclipse.sirius.components.representations.MessageLevel; | ||
import org.springframework.stereotype.Service; | ||
|
||
import io.micrometer.core.instrument.Counter; | ||
import io.micrometer.core.instrument.MeterRegistry; | ||
import reactor.core.publisher.Sinks; | ||
|
||
/** | ||
* The event handler to retrieve omnibox commands in the context of an editing context. | ||
* | ||
* @author gcoutable | ||
*/ | ||
@Service | ||
public class GetOmniboxCommandsEventHandler implements IEditingContextEventHandler { | ||
|
||
private final IObjectService objectService; | ||
|
||
private final ICollaborativeMessageService messageService; | ||
|
||
private final IQueryService queryService; | ||
|
||
private final Counter counter; | ||
|
||
public GetOmniboxCommandsEventHandler(IObjectService objectService, ICollaborativeMessageService messageService, IQueryService queryService, MeterRegistry meterRegistry) { | ||
this.objectService = Objects.requireNonNull(objectService); | ||
this.messageService = Objects.requireNonNull(messageService); | ||
this.queryService = Objects.requireNonNull(queryService); | ||
|
||
this.counter = Counter.builder(Monitoring.EVENT_HANDLER) | ||
.tag(Monitoring.NAME, this.getClass().getSimpleName()) | ||
.register(meterRegistry); | ||
} | ||
|
||
@Override | ||
public boolean canHandle(IEditingContext editingContext, IInput input) { | ||
return input instanceof GetOmniboxCommandsInput; | ||
} | ||
|
||
@Override | ||
public void handle(Sinks.One<IPayload> payloadSink, Sinks.Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, IInput input) { | ||
this.counter.increment(); | ||
|
||
List<Message> messages = List.of(new Message(this.messageService.invalidInput(input.getClass().getSimpleName(), CreateChildInput.class.getSimpleName()), | ||
MessageLevel.ERROR)); | ||
ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, editingContext.getId(), input); | ||
IPayload payload = null; | ||
|
||
if (input instanceof GetOmniboxCommandsInput getOmniboxCommandsInput) { | ||
List<OmniboxCommand> omniboxCommands = new ArrayList<>(); | ||
|
||
var queryBasedObjectsInput = new QueryBasedObjectsInput(UUID.randomUUID(), "aql:editingContext.allContents()->select(e | e.name.contains('" + getOmniboxCommandsInput.query() + "'))", Map.of("editingContext", editingContext)); | ||
var objectsPayload = this.queryService.execute(editingContext, queryBasedObjectsInput); | ||
|
||
if (objectsPayload instanceof QueryBasedObjectsSuccessPayload queryBasedObjectsSuccessPayload) { | ||
queryBasedObjectsSuccessPayload.result().forEach(object -> { | ||
var id = this.objectService.getId(object); | ||
var label = this.objectService.getLabel(object); | ||
var kind = this.objectService.getKind(object); | ||
var iconURL = this.objectService.getImagePath(object); | ||
omniboxCommands.add(new OmniboxCommand(UUID.fromString(id), label, kind, iconURL, "")); | ||
}); | ||
|
||
payload = new GetOmniboxCommandsPayload(input.id(), omniboxCommands); | ||
} | ||
} | ||
|
||
if (payload == null) { | ||
payload = new ErrorPayload(input.id(), messages); | ||
} | ||
|
||
payloadSink.tryEmitValue(payload); | ||
changeDescriptionSink.tryEmitNext(changeDescription); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...s/core/backend/sirius-components-collaborative/src/main/resources/schema/omnibox.graphqls
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,25 @@ | ||
extend type Viewer { | ||
omniboxCommands(contextEntries: [OmniboxContextEntry!]!, query: String!): OmniboxCommandsConnection! | ||
} | ||
input OmniboxContextEntry { | ||
id: ID! | ||
label: String! | ||
kind: String! | ||
} | ||
|
||
type OmniboxCommandsConnection { | ||
edges: [OmniboxCommandsEdge!]! | ||
pageInfo: PageInfo! | ||
} | ||
|
||
type OmniboxCommandsEdge { | ||
node: OmniboxCommand! | ||
} | ||
|
||
type OmniboxCommand { | ||
id: ID! | ||
label: String! | ||
kind: String! | ||
iconURL: [String!]! | ||
description: String! | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/core/backend/sirius-components-core-graphql/.checkstyle
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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false"> | ||
<fileset name="all" enabled="true" check-config-name="Sirius" local="false"> | ||
<file-match-pattern match-pattern="." include-pattern="true"/> | ||
</fileset> | ||
<filter name="FilesFromPackage" enabled="true"> | ||
<filter-data value="src/main/resources"/> | ||
</filter> | ||
</fileset-config> |
57 changes: 57 additions & 0 deletions
57
packages/core/backend/sirius-components-core-graphql/.classpath
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,57 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="test" value="true"/> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> | ||
<attributes> | ||
<attribute name="ignore_optional_problems" value="true"/> | ||
<attribute name="test" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="target/generated-sources/annotations"> | ||
<attributes> | ||
<attribute name="ignore_optional_problems" value="true"/> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="m2e-apt" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations"> | ||
<attributes> | ||
<attribute name="ignore_optional_problems" value="true"/> | ||
<attribute name="test" value="true"/> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="m2e-apt" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
Oops, something went wrong.