forked from eclipse-sirius/sirius-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4586] Allow to override the default behavior of commands
Bug: eclipse-sirius#4586 Signed-off-by: Gwendal Daniel <[email protected]>
- Loading branch information
Showing
10 changed files
with
177 additions
and
3 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
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
23 changes: 23 additions & 0 deletions
23
packages/core/frontend/sirius-components-omnibox/src/OmniboxExtensionPoints.ts
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,23 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 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 | ||
*******************************************************************************/ | ||
|
||
import { DataExtensionPoint } from '@eclipse-sirius/sirius-components-core'; | ||
|
||
import { OmniboxCommandOverrideContribution } from './OmniboxExtensionPoints.types'; | ||
|
||
export const omniboxCommandOverrideContributionExtensionPoint: DataExtensionPoint< | ||
Array<OmniboxCommandOverrideContribution> | ||
> = { | ||
identifier: 'omnibox#commandOverrideContribution', | ||
fallback: [], | ||
}; |
18 changes: 18 additions & 0 deletions
18
packages/core/frontend/sirius-components-omnibox/src/OmniboxExtensionPoints.types.ts
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,18 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 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 | ||
*******************************************************************************/ | ||
import { OmniboxAction, OmniboxCommandOverrideComponentProps } from './Omnibox.types'; | ||
|
||
export interface OmniboxCommandOverrideContribution { | ||
canHandle: (action: OmniboxAction) => boolean; | ||
component: (props: OmniboxCommandOverrideComponentProps) => JSX.Element | null; | ||
} |
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
50 changes: 50 additions & 0 deletions
50
...g/eclipse/sirius/web/papaya/services/commands/PapayaShowDocumentationCommandProvider.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,50 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 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.papaya.services.commands; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
import org.eclipse.sirius.components.collaborative.api.IOmniboxCommandProvider; | ||
import org.eclipse.sirius.components.collaborative.dto.GetOmniboxCommandsInput; | ||
import org.eclipse.sirius.components.collaborative.dto.OmniboxCommand; | ||
import org.eclipse.sirius.components.collaborative.dto.OmniboxContextEntry; | ||
import org.eclipse.sirius.web.papaya.services.api.IPapayaCapableEditingContextPredicate; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* Provides the show documentation command for Papaya projects. | ||
* | ||
* @author gdaniel | ||
*/ | ||
@Service | ||
public class PapayaShowDocumentationCommandProvider implements IOmniboxCommandProvider { | ||
|
||
private final IPapayaCapableEditingContextPredicate papayaCapableEditingContextPredicate; | ||
|
||
public PapayaShowDocumentationCommandProvider(IPapayaCapableEditingContextPredicate papayaCapableEditingContextPredicate) { | ||
this.papayaCapableEditingContextPredicate = Objects.requireNonNull(papayaCapableEditingContextPredicate); | ||
} | ||
|
||
@Override | ||
public List<OmniboxCommand> getCommands(GetOmniboxCommandsInput input) { | ||
List<OmniboxCommand> result = List.of(); | ||
Optional<String> optionalEditingContextId = input.contextEntries().stream().filter(entry -> Objects.equals(entry.kind(), "EditingContext")).map(OmniboxContextEntry::id).findFirst(); | ||
if (optionalEditingContextId.isPresent() && this.papayaCapableEditingContextPredicate.test(optionalEditingContextId.get())) { | ||
result = List.of(new OmniboxCommand("showDocumentation", "Show documentation", List.of("/omnibox/show-documentation.svg"), "Navigate to Sirius Web's documentation")); | ||
} | ||
return result; | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...web/backend/sirius-web-papaya/src/main/resources/omnibox/show-documentation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
20 changes: 20 additions & 0 deletions
20
...b/frontend/sirius-web-application/src/omnibox/ShowDocumentationOmniboxCommandOverride.tsx
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,20 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 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 | ||
*******************************************************************************/ | ||
|
||
import { OmniboxCommandOverrideComponentProps } from '@eclipse-sirius/sirius-components-omnibox'; | ||
|
||
export const ShowDocumentationOmniboxCommandOverride = ({ onClose }: OmniboxCommandOverrideComponentProps) => { | ||
window.open('https://www.github.com/eclipse-sirius/sirius-web', '_blank')?.focus(); | ||
onClose(); | ||
return null; | ||
}; |