<commit_before>/*
 * ZoteroConnectionWidget.java
 *
 * Copyright (C) 2020 by RStudio, PBC
 *
 * 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.studio.client.workbench.prefs.views;

import java.util.ArrayList;

import org.rstudio.core.client.widget.SelectWidget;
import org.rstudio.studio.client.application.Desktop;
import org.rstudio.studio.client.common.HelpLink;
import org.rstudio.studio.client.common.SuperDevMode;
import org.rstudio.studio.client.workbench.prefs.model.UserPrefsAccessor;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;

public class ZoteroConnectionWidget extends Composite
{
   public ZoteroConnectionWidget(PreferencesDialogResources res)
   {
   
      HorizontalPanel panel = new HorizontalPanel();
      
      ArrayList<String> options = new ArrayList<String>();
      if (!webOnly())
         options.add("Local");
      options.add("Web");
      
      ArrayList<String> values = new ArrayList<String>();
      if (!webOnly())
         values.add(UserPrefsAccessor.ZOTERO_CONNECTION_TYPE_LOCAL);
      values.add(UserPrefsAccessor.ZOTERO_CONNECTION_TYPE_WEB);

      zoteroConnection_ = new SelectWidget(
            "Zotero Library:",
            options.toArray(new String[] {}),
            values.toArray(new String[] {}),
            false,
            true,
            false
         );
      zoteroConnection_.getElement().getStyle().setMarginBottom(0, Unit.PX);
      panel.add(zoteroConnection_);
      HelpLink zoteroHelp = new HelpLink("Using Zotero", 
            "visual_markdown_editing-zotero",
            false);
      zoteroHelp.addStyleName(res.styles().selectWidgetHelp());
      
      panel.add(zoteroHelp);

      initWidget(panel);
   
   }
   
   public void setType(String type)
   {
      zoteroConnection_.setValue(type);
   }

   public String getType()
   {
      return zoteroConnection_.getValue();     
   }
   
   public HandlerRegistration addChangeHandler(ChangeHandler handler)
   {
      return zoteroConnection_.addChangeHandler(handler);
   }
  
   private boolean webOnly()
   {<commit_msg>updated link to zotero docs<commit_after>/*
 * ZoteroConnectionWidget.java
 *
 * Copyright (C) 2020 by RStudio, PBC
 *
 * 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.studio.client.workbench.prefs.views;

import java.util.ArrayList;

import org.rstudio.core.client.widget.SelectWidget;
import org.rstudio.studio.client.application.Desktop;
import org.rstudio.studio.client.common.HelpLink;
import org.rstudio.studio.client.common.SuperDevMode;
import org.rstudio.studio.client.workbench.prefs.model.UserPrefsAccessor;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;

public class ZoteroConnectionWidget extends Composite
{
   public ZoteroConnectionWidget(PreferencesDialogResources res)
   {
   
      HorizontalPanel panel = new HorizontalPanel();
      
      ArrayList<String> options = new ArrayList<String>();
      if (!webOnly())
         options.add("Local");
      options.add("Web");
      
      ArrayList<String> values = new ArrayList<String>();
      if (!webOnly())
         values.add(UserPrefsAccessor.ZOTERO_CONNECTION_TYPE_LOCAL);
      values.add(UserPrefsAccessor.ZOTERO_CONNECTION_TYPE_WEB);

      zoteroConnection_ = new SelectWidget(
            "Zotero Library:",
            options.toArray(new String[] {}),
            values.toArray(new String[] {}),
            false,
            true,
            false
         );
      zoteroConnection_.getElement().getStyle().setMarginBottom(0, Unit.PX);
      panel.add(zoteroConnection_);
      HelpLink zoteroHelp = new HelpLink("Using Zotero", 
            "https://rstudio.github.io/visual-markdown-editing/#/technical?id=citations-from-zotero",
            false,
            false);
      zoteroHelp.addStyleName(res.styles().selectWidgetHelp());
      
      panel.add(zoteroHelp);

      initWidget(panel);
   
   }
   
   public void setType(String type)
   {
      zoteroConnection_.setValue(type);
   }

   public String getType()
   {
      return zoteroConnection_.getValue();     
   }
   
   public HandlerRegistration addChangeHandler(ChangeHandler handler)
   {
      return zoteroConnection_.addChangeHandler(handler);
   }
  
   private boolean webOnly()
   {
{'fraction_non_alphanumeric': 0.09987493299982134, 'fraction_numerical': 0.002858674289798106, 'mean_word_length': 3.292944785276074, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7491917', 'n_tokens_mistral': 1667, 'n_tokens_neox': 1621, 'n_words': 353}