-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1426] "Render" the completion proposal providers for text field comp…
…onent Bug: #1426 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
- Loading branch information
Showing
8 changed files
with
155 additions
and
12 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...components-forms/src/main/java/org/eclipse/sirius/components/forms/CompletionRequest.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,57 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 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.forms; | ||
|
||
import java.text.MessageFormat; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Represents a completion request for a text field. | ||
* | ||
* @author pcdavid | ||
*/ | ||
public final class CompletionRequest { | ||
/** | ||
* The name of the variable used to pass the current text value to the completion provider implementation. | ||
*/ | ||
public static final String CURRENT_TEXT = "currentText"; //$NON-NLS-1$ | ||
|
||
/** | ||
* The name of the variable used to pass the cursor position to the completion provider implementation. | ||
*/ | ||
public static final String CURSOR_POSITION = "cursorPosition"; //$NON-NLS-1$ | ||
|
||
private final String currentText; | ||
|
||
private final int cursorPosition; | ||
|
||
public CompletionRequest(String currentText, int cursorPosition) { | ||
this.currentText = Objects.requireNonNull(currentText); | ||
this.cursorPosition = Objects.checkIndex(cursorPosition, currentText.length()); | ||
} | ||
|
||
public String getCurrentText() { | ||
return this.currentText; | ||
} | ||
|
||
public int getCursorPosition() { | ||
return this.cursorPosition; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
String pattern = "{0} '{'currentText: {1}, cursorPosition: {2}'}'"; //$NON-NLS-1$ | ||
return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.currentText, this.cursorPosition); | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.