From 8a90fe2d5e0efcac1645596a209708fb22dc4b1a Mon Sep 17 00:00:00 2001 From: Vitaliy Guliy Date: Mon, 29 Feb 2016 12:38:16 +0200 Subject: [PATCH] CHE-124 Create/Import wizards are displaying errors while nothing is entered Signed-off-by: Vitaliy Guliy --- .../org/eclipse/che/ide/util/StringUtils.java | 2 +- .../resources/org/eclipse/che/ide/Core.css | 13 ++-- .../java/org/eclipse/che/ide/ui/TextBox.java | 45 +++++++++++++ .../page/GitImporterPagePresenter.java | 50 ++++++++++++--- .../importer/page/GitImporterPageView.java | 34 +++++++--- .../page/GitImporterPageViewImpl.java | 36 +++++++---- .../page/GitImporterPageViewImpl.ui.xml | 11 ++-- .../page/GitImporterPagePresenterTest.java | 24 ++++--- .../page/GithubImporterPagePresenter.java | 64 +++++++++++++------ .../importer/page/GithubImporterPageView.java | 34 +++++++--- .../page/GithubImporterPageViewImpl.java | 40 ++++++++---- .../page/GithubImporterPageViewImpl.ui.xml | 11 ++-- .../page/GithubImporterPagePresenterTest.java | 20 +++--- .../machine/client/MachineExtension.java | 6 +- .../client/processes/ProcessTreeRenderer.java | 6 +- 15 files changed, 286 insertions(+), 110 deletions(-) create mode 100644 core/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/TextBox.java diff --git a/core/commons/che-core-commons-gwt/src/main/java/org/eclipse/che/ide/util/StringUtils.java b/core/commons/che-core-commons-gwt/src/main/java/org/eclipse/che/ide/util/StringUtils.java index f735d3177e..cff2b9ac66 100644 --- a/core/commons/che-core-commons-gwt/src/main/java/org/eclipse/che/ide/util/StringUtils.java +++ b/core/commons/che-core-commons-gwt/src/main/java/org/eclipse/che/ide/util/StringUtils.java @@ -297,7 +297,7 @@ public class StringUtils { } public static boolean isNullOrEmpty(String s) { - return s == null || "".equals(s); + return s == null || s.isEmpty(); } public static boolean isNullOrWhitespace(String s) { diff --git a/core/ide/che-core-ide-app/src/main/resources/org/eclipse/che/ide/Core.css b/core/ide/che-core-ide-app/src/main/resources/org/eclipse/che/ide/Core.css index 7f919bb76f..e545f961d1 100644 --- a/core/ide/che-core-ide-app/src/main/resources/org/eclipse/che/ide/Core.css +++ b/core/ide/che-core-ide-app/src/main/resources/org/eclipse/che/ide/Core.css @@ -177,6 +177,7 @@ body, td { .gwt-TextBox { min-height: 22px; padding: 0 5px 0 5px; + transition: border-bottom 0.2s linear; } .gwt-TextArea { @@ -185,9 +186,14 @@ body, td { resize: none; } +.gwt-TextBox[success] { + border-bottom: 1px solid successColor; +} + .gwt-TextBox:invalid, .gwt-TextBox:required, -.gwt-TextBox.inputError { +.gwt-TextBox.inputError, +.gwt-TextBox[error] { border-bottom: 1px solid errorColor !important; } @@ -201,11 +207,6 @@ body, td { -webkit-animation: textFieldFocus 0.2s infinite; } -.gwt-TextBox:focus { - border-bottom: 1px solid successColor; - transition: border-bottom 0.2s linear; -} - .gwt-TextBox-readonly:focus { border-bottom: 1px solid textFieldBorderColor; } diff --git a/core/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/TextBox.java b/core/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/TextBox.java new file mode 100644 index 0000000000..ba816af287 --- /dev/null +++ b/core/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/TextBox.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 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; + +/** + * An Extension of GWT TextBox. + * Contains methods for marking the text box containing valid or invalid values. + * + * @author Vitaliy Guliy + */ +public class TextBox extends com.google.gwt.user.client.ui.TextBox { + + /** + * Marks text box containing valid value. + */ + public void markValid() { + getElement().setAttribute("success", ""); + getElement().removeAttribute("error"); + } + + /** + * Marks text box containing invalid value. + */ + public void markInvalid() { + getElement().removeAttribute("success"); + getElement().setAttribute("error", ""); + } + + /** + * Removes mark from text box. + */ + public void unmark() { + getElement().removeAttribute("success"); + getElement().removeAttribute("error"); + } + +} diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/importer/page/GitImporterPagePresenter.java b/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/importer/page/GitImporterPagePresenter.java index 022f11cd7f..c25c70c67d 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/importer/page/GitImporterPagePresenter.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/importer/page/GitImporterPagePresenter.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.ide.ext.git.client.importer.page; +import com.google.common.base.Strings; import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.user.client.ui.AcceptsOneWidget; import com.google.inject.Inject; @@ -44,6 +45,8 @@ public class GitImporterPagePresenter extends AbstractWizardPage + xmlns:g='urn:import:com.google.gwt.user.client.ui' + xmlns:ide='urn:import:org.eclipse.che.ide.ui'> @@ -20,7 +21,7 @@ - @@ -31,7 +32,7 @@ - @@ -51,7 +52,7 @@ - @@ -62,7 +63,7 @@ - diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/importer/page/GitImporterPagePresenterTest.java b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/importer/page/GitImporterPagePresenterTest.java index 7b0b4a3448..3cde9c80d1 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/importer/page/GitImporterPagePresenterTest.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/importer/page/GitImporterPagePresenterTest.java @@ -85,7 +85,9 @@ public class GitImporterPagePresenterTest { presenter.projectUrlChanged(incorrectUrl); - verify(view).showUrlError(eq(locale.importProjectMessageStartWithWhiteSpace())); + verify(view).markURLInvalid(); + verify(view).setURLErrorMessage(eq(locale.importProjectMessageStartWithWhiteSpace())); + verify(dataObject).setName(eq(name)); verify(view).setProjectName(name); verify(updateDelegate).updateControls(); @@ -174,7 +176,9 @@ public class GitImporterPagePresenterTest { presenter.projectUrlChanged(incorrectUrl); - verify(view).showUrlError(eq(locale.importProjectMessageProtocolIncorrect())); + verify(view).markURLInvalid(); + verify(view).setURLErrorMessage(eq(locale.importProjectMessageProtocolIncorrect())); + verify(source).setLocation(eq(incorrectUrl)); verify(view).setProjectName(anyString()); verify(updateDelegate).updateControls(); @@ -188,8 +192,10 @@ public class GitImporterPagePresenterTest { presenter.projectNameChanged(correctName); verify(dataObject).setName(eq(correctName)); - verify(view).hideNameError(); - verify(view, never()).showNameError(); + + verify(view).markURLValid(); + verify(view).setURLErrorMessage(eq(null)); + verify(view, never()).markURLInvalid(); verify(updateDelegate).updateControls(); } @@ -201,8 +207,8 @@ public class GitImporterPagePresenterTest { presenter.projectNameChanged(correctName); verify(dataObject).setName(eq(correctName)); - verify(view).hideNameError(); - verify(view, never()).showNameError(); + verify(view).markNameValid(); + verify(view, never()).markNameInvalid(); verify(updateDelegate).updateControls(); } @@ -225,7 +231,7 @@ public class GitImporterPagePresenterTest { presenter.projectNameChanged(incorrectName); verify(dataObject).setName(eq(incorrectName)); - verify(view).showNameError(); + verify(view).markNameInvalid(); verify(updateDelegate).updateControls(); } @@ -294,9 +300,9 @@ public class GitImporterPagePresenterTest { } private void verifyInvocationsForCorrectUrl(String correctUrl) { - verify(view, never()).showUrlError(anyString()); + verify(view, never()).markURLInvalid(); verify(source).setLocation(eq(correctUrl)); - verify(view).hideUrlError(); + verify(view).markURLValid(); verify(view).setProjectName(anyString()); verify(updateDelegate).updateControls(); } diff --git a/plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/importer/page/GithubImporterPagePresenter.java b/plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/importer/page/GithubImporterPagePresenter.java index 48914adbcb..5a0ec38c82 100644 --- a/plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/importer/page/GithubImporterPagePresenter.java +++ b/plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/importer/page/GithubImporterPagePresenter.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.ide.ext.github.client.importer.page; +import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.gwt.core.client.JsArrayMixed; import com.google.gwt.regexp.shared.RegExp; @@ -74,6 +75,8 @@ public class GithubImporterPagePresenter extends AbstractWizardPage + xmlns:g='urn:import:com.google.gwt.user.client.ui' + xmlns:ide='urn:import:org.eclipse.che.ide.ui'> @@ -22,7 +23,7 @@ - @@ -34,7 +35,7 @@ - @@ -52,7 +53,7 @@ - @@ -84,4 +85,4 @@ - \ No newline at end of file + diff --git a/plugins/plugin-github/che-plugin-github-ext-github/src/test/java/org/eclipse/che/ide/ext/github/client/importer/page/GithubImporterPagePresenterTest.java b/plugins/plugin-github/che-plugin-github-ext-github/src/test/java/org/eclipse/che/ide/ext/github/client/importer/page/GithubImporterPagePresenterTest.java index 9116d7832c..a3a715cb44 100644 --- a/plugins/plugin-github/che-plugin-github-ext-github/src/test/java/org/eclipse/che/ide/ext/github/client/importer/page/GithubImporterPagePresenterTest.java +++ b/plugins/plugin-github/che-plugin-github-ext-github/src/test/java/org/eclipse/che/ide/ext/github/client/importer/page/GithubImporterPagePresenterTest.java @@ -239,7 +239,8 @@ public class GithubImporterPagePresenterTest { presenter.projectUrlChanged(incorrectUrl); - verify(view).showUrlError(eq(locale.importProjectMessageStartWithWhiteSpace())); + verify(view).markURLInvalid(); + verify(view).setURLErrorMessage(eq(locale.importProjectMessageStartWithWhiteSpace())); verify(source).setLocation(eq(incorrectUrl)); verify(view).setProjectName(anyString()); verify(updateDelegate).updateControls(); @@ -328,7 +329,8 @@ public class GithubImporterPagePresenterTest { presenter.projectUrlChanged(correctUrl); - verify(view).showUrlError(eq(locale.importProjectMessageProtocolIncorrect())); + verify(view).markURLInvalid(); + verify(view).setURLErrorMessage(eq(locale.importProjectMessageProtocolIncorrect())); verify(source).setLocation(eq(correctUrl)); verify(view).setProjectName(anyString()); verify(updateDelegate).updateControls(); @@ -342,8 +344,8 @@ public class GithubImporterPagePresenterTest { presenter.projectNameChanged(correctName); verify(dataObject).setName(eq(correctName)); - verify(view).hideNameError(); - verify(view, never()).showNameError(); + verify(view).markNameValid(); + verify(view, never()).markNameInvalid(); verify(updateDelegate).updateControls(); } @@ -355,8 +357,8 @@ public class GithubImporterPagePresenterTest { presenter.projectNameChanged(correctName); verify(dataObject).setName(eq(correctName)); - verify(view).hideNameError(); - verify(view, never()).showNameError(); + verify(view).markNameValid(); + verify(view, never()).markNameInvalid(); verify(updateDelegate).updateControls(); } @@ -379,7 +381,7 @@ public class GithubImporterPagePresenterTest { presenter.projectNameChanged(incorrectName); verify(dataObject).setName(eq(incorrectName)); - verify(view).showNameError(); + verify(view).markNameInvalid(); verify(updateDelegate).updateControls(); } @@ -471,9 +473,9 @@ public class GithubImporterPagePresenterTest { } private void verifyInvocationsForCorrectUrl(String correctUrl) { - verify(view, never()).showUrlError(anyString()); + verify(view, never()).markURLInvalid(); verify(source).setLocation(eq(correctUrl)); - verify(view).hideUrlError(); + verify(view).markURLValid(); verify(view).setProjectName(anyString()); verify(updateDelegate).updateControls(); } diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/MachineExtension.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/MachineExtension.java index daf09b4616..eb96f6faf3 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/MachineExtension.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/MachineExtension.java @@ -86,14 +86,14 @@ public class MachineExtension { CustomCommandType arbitraryCommandType) { machineResources.getCss().ensureInjected(); + workspaceAgent.openPart(outputsContainerPresenter, PartStackType.INFORMATION); + workspaceAgent.openPart(consolesPanelPresenter, PartStackType.INFORMATION); + eventBus.addHandler(WsAgentStateEvent.TYPE, new WsAgentStateHandler() { @Override public void onWsAgentStarted(WsAgentStateEvent event) { machinePortProvider.get(); - perspectiveManager.setPerspectiveId(PROJECT_PERSPECTIVE_ID); - workspaceAgent.openPart(outputsContainerPresenter, PartStackType.INFORMATION); - workspaceAgent.openPart(consolesPanelPresenter, PartStackType.INFORMATION); } @Override diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/ProcessTreeRenderer.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/ProcessTreeRenderer.java index 5cc35ba9d0..d51f816953 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/ProcessTreeRenderer.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/ProcessTreeRenderer.java @@ -171,11 +171,7 @@ public class ProcessTreeRenderer implements NodeRenderer { private SpanElement createCommandElement(ProcessTreeNode node) { SpanElement root = Elements.createSpanElement(); - if (node.isRunning()) { - root.setAttribute("running", "true"); - } else { - root.setAttribute("running", "false"); - } + root.setAttribute("running", "" + node.isRunning()); root.appendChild(createCloseElement(node)); root.appendChild(createStopProcessElement(node));