/**
   * Creates combobox used to select molecular viewer.
   *
   * @return viewer selector
   */
  private ComboBox<String> createViewerTypeCombobox() {
    ListStore<String> store =
        new ListStore<String>(
            new ModelKeyProvider<String>() {
              @Override
              public String getKey(String item) {
                return item;
              }
            });

    store.add(AppPropertiesManager.CONSTANTS.viewer_local());
    store.add(AppPropertiesManager.CONSTANTS.viewer_jmol());
    store.add(AppPropertiesManager.CONSTANTS.viewer_pse());

    final ComboBox<String> viewerTypeComboBox =
        new ComboBox<String>(
            store,
            new LabelProvider<String>() {
              @Override
              public String getLabel(String item) {
                return item;
              }
            });

    viewerTypeComboBox.setId("viewercombo");
    viewerTypeComboBox.setTriggerAction(TriggerAction.ALL);
    viewerTypeComboBox.setEditable(false);
    viewerTypeComboBox.setWidth(100);

    viewerTypeComboBox.setToolTipConfig(createViewerTypeComboBoxToolTipConfig());

    String viewerCookie = Cookies.getCookie("crkviewer");
    if (viewerCookie != null) {
      viewerTypeComboBox.setValue(viewerCookie);
    } else {
      viewerTypeComboBox.setValue(AppPropertiesManager.CONSTANTS.viewer_jmol());
    }

    ApplicationContext.setSelectedViewer(viewerTypeComboBox.getValue());

    viewerTypeComboBox.addSelectionHandler(
        new SelectionHandler<String>() {
          @Override
          public void onSelection(SelectionEvent<String> event) {
            Cookies.setCookie("crkviewer", event.getSelectedItem());
            ApplicationContext.setSelectedViewer(event.getSelectedItem());
          }
        });

    return viewerTypeComboBox;
  }
  /**
   * sets the link in the Download Results
   *
   * @param PDBScoreItem
   */
  public void setDownloadResultsLink(String jobId) {
    showDownloadResultsPanel = new VBoxLayoutContainer();
    showDownloadResultsPanel.setBorders(false);

    showDownloadResultsPanel.setVBoxLayoutAlign(VBoxLayoutAlign.RIGHT);

    LinkWithTooltip downloadResultsLink =
        new LinkWithTooltip(
            AppPropertiesManager.CONSTANTS.info_panel_download_results_link(),
            AppPropertiesManager.CONSTANTS.info_panel_download_results_link_hint(),
            GWT.getModuleBaseURL() + "fileDownload?type=zip&id=" + jobId);
    downloadResultsLink.addStyleName("eppic-download-link");

    showDownloadResultsPanel.add(downloadResultsLink);
  }
  /**
   * Creates the tool bar of myjobs grid
   *
   * @return tool bar
   */
  private ToolBar createToolBar() {
    ToolBar tb = new ToolBar();

    tb.add(createClearAllButton());
    tb.add(new FillToolItem());

    ToolButton info = new ToolButton(ToolButton.QUESTION);
    ToolTipConfig config = new ToolTipConfig(AppPropertiesManager.CONSTANTS.myjobs_grid_tooltip());
    config.setMaxWidth(225);
    info.setToolTipConfig(config);
    tb.add(info);

    return tb;
  }
  /**
   * Creates button used to clear the list.
   *
   * @return button
   */
  private TextButton createClearAllButton() {
    TextButton clearAllButton =
        new TextButton(AppPropertiesManager.CONSTANTS.myjobs_clear_button());
    clearAllButton.addStyleName("eppic-default-font");
    clearAllButton.addSelectHandler(
        new SelectHandler() {
          @Override
          public void onSelect(SelectEvent event) {
            CrkWebServiceProvider.getServiceController().deleteAllJobs(getCurrentJobsList());
          }
        });

    String iconSource = "resources/icons/clear_icon.png";
    clearAllButton.setIcon(
        IconHelper.getImageResource(UriUtils.fromSafeConstant(iconSource), 12, 12));

    return clearAllButton;
  }
  public MyJobsPanel() {
    this.setHeadingHtml(
        StyleGenerator.defaultFontStyle(AppPropertiesManager.CONSTANTS.myjobs_panel_head()));

    VerticalLayoutContainer mainContainer = new VerticalLayoutContainer();

    List<ColumnConfig<MyJobsModel, ?>> myJobsConfigs = createColumnConfig();
    ColumnModel<MyJobsModel> myJobsColumnModel = new ColumnModel<MyJobsModel>(myJobsConfigs);
    myJobsStore = new ListStore<MyJobsModel>(props.key());

    ToolBar myJobsToolBar = createToolBar();
    mainContainer.add(myJobsToolBar, new VerticalLayoutData(1, -1, new Margins(0)));

    myJobsGrid = createJobsGrid(myJobsColumnModel);
    mainContainer.add(myJobsGrid, new VerticalLayoutData(1, 1, new Margins(0)));

    this.setWidget(mainContainer);

    initializeEventsListeners();
  }
  /**
   * Creates panel storing selector used to select type of the molecular viewer.
   *
   * @return panel with viewer selector
   */
  private VBoxLayoutContainer createViewerTypePanelLocation() {
    VBoxLayoutContainer viewerTypePanelLocation = new VBoxLayoutContainer();
    viewerTypePanelLocation.setBorders(false);

    VBoxLayoutContainer vBoxLayout = new VBoxLayoutContainer();
    vBoxLayout.setVBoxLayoutAlign(VBoxLayoutAlign.LEFT);

    FormPanel viewerTypePanel = new FormPanel();
    viewerTypePanel.setBorders(false);
    viewerTypePanel.setWidth(100);
    viewerTypePanel.getElement().setPadding(new Padding(0));

    ComboBox<String> viewerTypeComboBox = createViewerTypeCombobox();
    FieldLabel viewerTypeComboBoxLabel =
        new FieldLabel(
            viewerTypeComboBox, AppPropertiesManager.CONSTANTS.results_grid_viewer_combo_label());
    viewerTypeComboBox.setStyleName("eppic-default-label");
    viewerTypePanel.add(viewerTypeComboBoxLabel);

    viewerTypePanelLocation.add(viewerTypePanel);

    return viewerTypePanelLocation;
  }