Skip to content

Commit

Permalink
CHE-3583: Add new line to message area in Git commit window when Ente…
Browse files Browse the repository at this point in the history
…r pressed (eclipse-che#4280)
  • Loading branch information
Igor Vinokur authored Mar 10, 2017
1 parent 8a43395 commit 43d3607
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
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);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import org.eclipse.che.ide.ext.git.client.GitLocalizationConstant;
import org.eclipse.che.ide.ext.git.client.GitResources;
import org.eclipse.che.ide.ui.ShiftableTextArea;
import org.eclipse.che.ide.ui.window.Window;

import com.google.gwt.core.client.GWT;
Expand Down Expand Up @@ -69,7 +70,7 @@ interface CommitViewImplUiBinder extends UiBinder<Widget, CommitViewImpl> {
/**
* The commit message input field.
*/
@UiField
@UiField(provided = true)
TextArea message;
Button btnCommit;
Button btnCancel;
Expand All @@ -89,6 +90,7 @@ interface CommitViewImplUiBinder extends UiBinder<Widget, CommitViewImpl> {
protected CommitViewImpl(GitResources res, GitLocalizationConstant locale) {
this.res = res;
this.locale = locale;
this.message = new ShiftableTextArea();
this.ensureDebugId("git-commit-window");

Widget widget = ourUiBinder.createAndBindUi(this);
Expand Down

0 comments on commit 43d3607

Please sign in to comment.