forked from eclipse-che/che
-
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.
CHE-3583: Add new line to message area in Git commit window when Ente…
…r pressed (eclipse-che#4280)
- Loading branch information
Igor Vinokur
authored
Mar 10, 2017
1 parent
8a43395
commit 43d3607
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/ShiftableTextArea.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,41 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.ide.ui; | ||
|
||
import com.google.gwt.dom.client.NativeEvent; | ||
import com.google.gwt.user.client.ui.TextArea; | ||
|
||
import org.eclipse.che.ide.ui.smartTree.KeyboardNavigationHandler; | ||
|
||
/** | ||
* Text Area widget that supports shifting to new line by pressing Enter key. | ||
* | ||
* @author Igor Vinokur | ||
*/ | ||
public class ShiftableTextArea extends TextArea { | ||
public ShiftableTextArea() { | ||
super(); | ||
initializeEnterKeyHandler(); | ||
} | ||
|
||
private void initializeEnterKeyHandler() { | ||
new KeyboardNavigationHandler(this) { | ||
@Override | ||
public void onEnter(NativeEvent evt) { | ||
super.onEnter(evt); | ||
|
||
int cursorPos = getCursorPos(); | ||
setText(new StringBuilder(getText()).insert(cursorPos, '\n').toString()); | ||
setCursorPos(cursorPos + 1); | ||
} | ||
}; | ||
} | ||
} |
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