Skip to content
Permalink
Browse files

Merge pull request #5209 from rstudio/bugfix/a11y-import-file-setting…

…s-dlg

a11y fixes to control labeling in ImportFileSettingsDialog, declarative IDs/labeling
  • Loading branch information...
gtritchie committed Aug 10, 2019
2 parents 48dc9a6 + 6213101 commit 2d733ac1b83e608dfedb0b88ea467e89b0c07e9b
Showing with 245 additions and 55 deletions.
  1. +36 −0 src/gwt/src/org/rstudio/core/client/ElementIds.java
  2. +20 −0 src/gwt/src/org/rstudio/core/client/widget/CanSetControlId.java
  3. +9 −0 src/gwt/src/org/rstudio/core/client/widget/FieldSetPanel.java
  4. +6 −0 src/gwt/src/org/rstudio/core/client/widget/FormLabel.java
  5. +30 −0 src/gwt/src/org/rstudio/core/client/widget/FormListBox.java
  6. +30 −0 src/gwt/src/org/rstudio/core/client/widget/FormPasswordTextBox.java
  7. +30 −0 src/gwt/src/org/rstudio/core/client/widget/FormTextBox.java
  8. +13 −7 src/gwt/src/org/rstudio/core/client/widget/LabeledTextBox.java
  9. +0 −1 src/gwt/src/org/rstudio/studio/client/common/rstudioapi/ui/AskSecretDialog.java
  10. +5 −4 src/gwt/src/org/rstudio/studio/client/common/rstudioapi/ui/AskSecretDialog.ui.xml
  11. +3 −1 src/gwt/src/org/rstudio/studio/client/rmarkdown/ui/RmdTemplateChooser.ui.xml
  12. +7 −0 ...src/org/rstudio/studio/client/workbench/views/environment/dataimport/ImportFileSettingsDialog.css
  13. +2 −1 ...rc/org/rstudio/studio/client/workbench/views/environment/dataimport/ImportFileSettingsDialog.java
  14. +34 −20 .../org/rstudio/studio/client/workbench/views/environment/dataimport/ImportFileSettingsDialog.ui.xml
  15. +6 −4 src/gwt/src/org/rstudio/studio/client/workbench/views/output/find/FindInFilesDialog.ui.xml
  16. +0 −7 src/gwt/src/org/rstudio/studio/client/workbench/views/source/editors/text/ui/NewRMarkdownDialog.java
  17. +14 −10 ...wt/src/org/rstudio/studio/client/workbench/views/source/editors/text/ui/NewRMarkdownDialog.ui.xml
@@ -114,4 +114,40 @@ public static String idFromLabel(String label)

public final static String PACKAGE_MANAGEMENT_PREFS = "package_management_prefs";
public final static String PACKAGE_DEVELOPMENT_PREFS = "package_development_prefs";

// AskSecretDialog
public final static String ASK_SECRET_TEXT = "ask_secret_text";
public static String getAskSecretText() { return getElementId(ASK_SECRET_TEXT); }

// FindInFilesDialog
public final static String FIND_FILES_TEXT = "find_files_text";
public static String getFindFilesText() { return getElementId(FIND_FILES_TEXT); }

// ImportFileSettingsDialog
public final static String IMPORT_FILE_NAME = "import_file_name";
public static String getImportFileName() { return getElementId(IMPORT_FILE_NAME); }
public final static String IMPORT_FILE_ENCODING = "import_file_encoding";
public static String getImportFileEncoding() { return getElementId(IMPORT_FILE_ENCODING); }
public final static String IMPORT_FILE_ROW_NAMES = "import_file_row_names";
public static String getImportFileRowNames() { return getElementId(IMPORT_FILE_ROW_NAMES); }
public final static String IMPORT_FILE_SEPARATOR = "import_file_separator";
public static String getImportFileSeparator() { return getElementId(IMPORT_FILE_SEPARATOR); }
public final static String IMPORT_FILE_DECIMAL = "import_file_decimal";
public static String getImportFileDecimal() { return getElementId(IMPORT_FILE_DECIMAL); }
public final static String IMPORT_FILE_QUOTE = "import_file_quote";
public static String getImportFileQuote() { return getElementId(IMPORT_FILE_QUOTE); }
public final static String IMPORT_FILE_COMMENT = "import_file_comment";
public static String getImportFileComment() { return getElementId(IMPORT_FILE_COMMENT); }
public final static String IMPORT_FILE_NA_STRINGS = "import_file_na_strings";
public static String getImportFileNaStrings() { return getElementId(IMPORT_FILE_NA_STRINGS); }

// NewRMarkdownDialog
public final static String NEW_RMD_TITLE = "new_rmd_title";
public static String getNewRmdTitle() { return getElementId(NEW_RMD_TITLE); }
public final static String NEW_RMD_AUTHOR = "new_rmd_author";
public static String getNewRmdAuthor() { return getElementId(NEW_RMD_AUTHOR); }

// RmdTemplateChooser
public final static String RMD_TEMPLATE_CHOOSER_NAME = "rmd_template_chooser_name";
public static String getRmdTemplateChooserName() { return getElementId(RMD_TEMPLATE_CHOOSER_NAME); }
}
@@ -0,0 +1,20 @@
/*
* CanSetControlId.java
*
* Copyright (C) 2009-19 by RStudio, Inc.
*
* Unless you have received this program directly from RStudio pursuant
* to the terms of a commercial license agreement with RStudio, then
* this program is licensed to you under the terms of version 3 of the
* GNU Affero General Public License. This program is distributed WITHOUT
* ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
* AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
*
*/
package org.rstudio.core.client.widget;

public interface CanSetControlId
{
void setElementId(String id);
}
@@ -67,5 +67,14 @@ public void setLegend(String legend)
{
legendElement_.setInnerText(legend);
}

public void setLegendHidden(boolean hidden)
{
if (hidden)
legendElement_.setClassName(ThemeStyles.INSTANCE.visuallyHidden());
else
legendElement_.removeClassName(ThemeStyles.INSTANCE.visuallyHidden());
}

private Element legendElement_;
}
@@ -14,6 +14,7 @@
*/
package org.rstudio.core.client.widget;

import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Label;
@@ -160,4 +161,9 @@ public void setDisplay(String display)
{
getElement().getStyle().setProperty("display", display);
}

public void setAriaHidden(boolean hidden)
{
Roles.getTextboxRole().setAriaHiddenState(getElement(), hidden);
}
}
@@ -0,0 +1,30 @@
/*
* FormListBox.java
*
* Copyright (C) 2009-19 by RStudio, Inc.
*
* Unless you have received this program directly from RStudio pursuant
* to the terms of a commercial license agreement with RStudio, then
* this program is licensed to you under the terms of version 3 of the
* GNU Affero General Public License. This program is distributed WITHOUT
* ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
* AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
*
*/
package org.rstudio.core.client.widget;

import com.google.gwt.user.client.ui.ListBox;

/**
* ListBox with ability to set elementId (e.g. from UiBinder)
*/
public class FormListBox extends ListBox
implements CanSetControlId
{
@Override
public void setElementId(String id)
{
getElement().setId(id);
}
}
@@ -0,0 +1,30 @@
/*
* FormPasswordTextBox.java
*
* Copyright (C) 2009-19 by RStudio, Inc.
*
* Unless you have received this program directly from RStudio pursuant
* to the terms of a commercial license agreement with RStudio, then
* this program is licensed to you under the terms of version 3 of the
* GNU Affero General Public License. This program is distributed WITHOUT
* ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
* AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
*
*/
package org.rstudio.core.client.widget;

import com.google.gwt.user.client.ui.PasswordTextBox;

/**
* TextBox with ability to set elementId (e.g. from UiBinder)
*/
public class FormPasswordTextBox extends PasswordTextBox
implements CanSetControlId
{
@Override
public void setElementId(String id)
{
getElement().setId(id);
}
}
@@ -0,0 +1,30 @@
/*
* FormTextBox.java
*
* Copyright (C) 2009-19 by RStudio, Inc.
*
* Unless you have received this program directly from RStudio pursuant
* to the terms of a commercial license agreement with RStudio, then
* this program is licensed to you under the terms of version 3 of the
* GNU Affero General Public License. This program is distributed WITHOUT
* ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
* AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
*
*/
package org.rstudio.core.client.widget;

import com.google.gwt.user.client.ui.TextBox;

/**
* TextBox with ability to set elementId (e.g. from UiBinder)
*/
public class FormTextBox extends TextBox
implements CanSetControlId
{
@Override
public void setElementId(String id)
{
getElement().setId(id);
}
}
@@ -19,6 +19,7 @@
import com.google.gwt.event.dom.client.HasKeyUpHandlers;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.uibinder.client.UiConstructor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HasText;
@@ -31,11 +32,12 @@
public class LabeledTextBox extends Composite
implements HasText, HasKeyUpHandlers
{
public LabeledTextBox()
public @UiConstructor LabeledTextBox(String textBoxId)
{
FlowPanel flowPanel = new FlowPanel();
label_ = new FormLabel();
textBox_ = new TextBox();
textBox_.getElement().setId(textBoxId);
label_.setFor(textBox_);
setLabelInline(false);
flowPanel.add(label_);
@@ -44,12 +46,6 @@ public LabeledTextBox()
initWidget(flowPanel);
}

public LabeledTextBox(String label)
{
this();
setLabelText(label);
}

public void setLabelText(String label)
{
label_.setText(label);
@@ -131,6 +127,16 @@ public void setEnabled(boolean enabled)
textBox_.setEnabled(enabled);
}

public void setLabelStyleName(String style)
{
label_.setStyleName(style);
}

public void setTextBoxStyleName(String style)
{
textBox_.setStyleName(style);
}

FormLabel label_;
TextBox textBox_;
}
@@ -103,7 +103,6 @@ public void onKeyDown(KeyDownEvent event)
});

label_.setText(prompt);
label_.setFor(textbox_);
Roles.getTextboxRole().setAriaRequiredProperty(textbox_.getElement(), true);

install_.addClickHandler(new ClickHandler() {
@@ -1,6 +1,7 @@
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:widget="urn:import:org.rstudio.core.client.widget">
xmlns:rw="urn:import:org.rstudio.core.client.widget">
<ui:with field="ElementIds" type="org.rstudio.core.client.ElementIds"/>

<ui:style>
.panel {
@@ -33,13 +34,13 @@
<table>
<tr>
<td width="100%">
<widget:FormLabel ui:field="label_"/>
<rw:FormLabel for="{ElementIds.getAskSecretText}" ui:field="label_"/>
</td>
</tr>
<tr>
<td width="100%">
<g:PasswordTextBox ui:field="textbox_"
stylePrimaryName="{style.secret}"/>
<rw:FormPasswordTextBox elementId="{ElementIds.getAskSecretText}" ui:field="textbox_"
stylePrimaryName="{style.secret}"/>
</td>
</tr>
<tr>
@@ -2,6 +2,7 @@
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:rs="urn:import:org.rstudio.core.client.widget">
<ui:with field="ElementIds" type="org.rstudio.core.client.ElementIds"/>
<ui:style>
@external .gwt-Label;
@external .gwt-TextBox;
@@ -76,7 +77,8 @@
This template contains multiple files. Create a new directory for
these files:
</g:HTML>
<rs:LabeledTextBox labelText="Name:" styleName="{style.controlLabel} {style.interiorControlLabel}"
<rs:LabeledTextBox textBoxId="{ElementIds.getRmdTemplateChooserName}" labelText="Name:"
styleName="{style.controlLabel} {style.interiorControlLabel}"
ui:field="txtName_" text="Untitled"></rs:LabeledTextBox>

<rs:DirectoryChooserTextBox width="100%" addStyleNames="{style.directoryChooser} {style.directoryChooserInner}" ui:field="dirLocation_">
@@ -43,4 +43,11 @@
font-size: 12px;
font-family: proportionalFont;
outline: none;
}
.leftPanel fieldset {
border: none;
padding: 0;
padding-block-end: 0;
padding-inline-end: 0;
margin: 0;
}
@@ -33,6 +33,7 @@
import org.rstudio.core.client.Invalidation.Token;
import org.rstudio.core.client.files.FileSystemItem;
import org.rstudio.core.client.js.JsObject;
import org.rstudio.core.client.widget.LabeledTextBox;
import org.rstudio.core.client.widget.ModalDialog;
import org.rstudio.core.client.widget.OperationWithInput;
import org.rstudio.core.client.widget.ProgressIndicator;
@@ -405,7 +406,7 @@ public static void ensureStylesInjected()
@UiField
RadioButton headingNo_;
@UiField
TextBox varname_;
LabeledTextBox varname_;
@UiField
TextBox naStrings_;
@UiField

0 comments on commit 2d733ac

Please sign in to comment.
You can’t perform that action at this time.