text:
package org.kuali.rice.core.api.criteria;

import java.util.Collection;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.apache.commons.lang3.StringUtils;
import org.kuali.rice.core.api.CoreConstants;
import org.w3c.dom.Element;

/**
 * An immutable predicate which represents an "WHERE EXISTS" statement.
 *
 * This implementation assumes that there is a single field which can be related
 * between the inner and outer queries.  An equality between those fields is
 * automatically added to the predicates of the inner query.
 *
 * @see PredicateFactory for a convenient way to construct this class.
 *
 * @author Kuali Rice Team (rice.collab@kuali.org)
 * @since Rice 2.4.2
 *
 */
@XmlRootElement(name = ExistsSubQueryPredicate.Constants.ROOT_ELEMENT_NAME)
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = ExistsSubQueryPredicate.Constants.TYPE_NAME, propOrder = {
    ExistsSubQueryPredicate.Elements.SUB_QUERY_PREDICATE,
    CoreConstants.CommonElements.FUTURE_ELEMENTS
})
public final class ExistsSubQueryPredicate extends AbstractPredicate implements SubQueryPredicate {

	private static final long serialVersionUID = 2397296074921454859L;

    @XmlAttribute(name = Elements.SUB_QUERY_TYPE, required = true)
	protected String subQueryType;

    @XmlElements(value = {
            @XmlElement(name = AndPredicate.Constants.ROOT_ELEMENT_NAME, type = AndPredicate.class, required = false),
            @XmlElement(name = EqualPredicate.Constants.ROOT_ELEMENT_NAME, type = EqualPredicate.class, required = false),
            @XmlElement(name = EqualIgnoreCasePredicate.Constants.ROOT_ELEMENT_NAME, type = EqualIgnoreCasePredicate.class, required = false),
            @XmlElement(name = ExistsSubQueryPredicate.Constants.ROOT_ELEMENT_NAME, type = ExistsSubQueryPredicate.class, required = false),
            @XmlElement(name = GreaterThanPredicate.Constants.ROOT_ELEMENT_NAME, type = GreaterThanPredicate.class, required = false),
            @XmlElement(name = GreaterThanOrEqualPredicate.Constants.ROOT_ELEMENT_NAME, type = GreaterThanOrEqualPredicate.class, required = false),
            @XmlElement(name = InPredicate.Constants.ROOT_ELEMENT_NAME, type = InPredicate.class, required = false),
            @XmlElement(name = InIgnoreCasePredicate.Constants.ROOT_ELEMENT_NAME, type = InIgnoreCasePredicate.class, required = false),
            @XmlElement(name = LessThanPredicate.Constants.ROOT_ELEMENT_NAME, type = LessThanPredicate.class, required = false),
            @XmlElement(name = LessThanOrEqualPredicate.Constants.ROOT_ELEMENT_NAME, type = LessThanOrEqualPredicate.class, required = false),
            @XmlElement(name = LikePredicate.Constants.ROOT_ELEMENT_NAME, type = LikePredicate.class, required = false),
            @XmlElement(name = LikeIgnoreCasePredicate.Constants.ROOT_ELEMENT_NAME, type = LikeIgnoreCasePredicate.class, required = false),
            @XmlElement(name = NotEqualPredicate.Constants.ROOT_ELEMENT_NAME, type = NotEqualPredicate.class, required = false),
            @XmlElement(name = NotEqualIgnoreCasePredicate.Constants.ROOT_ELEMENT_NAME, type = NotEqualIgnoreCasePredicate.class, required = false),
            @XmlElement(name = NotInPredicate.Constants.ROOT_ELEMENT_NAME, type = NotInPredicate.class, required = false),
            @XmlElement(name = NotInIgnoreCasePredicate.Constants.ROOT_ELEMENT_NAME, type = NotInIgnoreCasePredicate.class, required = false),
            @XmlElement(name = NotLikeIgnoreCasePredicate.Constants.ROOT_ELEMENT_NAME, type = NotLikeIgnoreCasePredicate.class, required = false),
            @XmlElement(name = NotLikePredicate.Constants.ROOT_ELEMENT_NAME, type = NotLikePredicate.class, required = false),
            @XmlElement(name = NotNullPredicate.Constants.ROOT_ELEMENT_NAME, type = NotNullPredicate.class, required = false),
            @XmlElement(name = NullPredicate.Constants.ROOT_ELEMENT_NAME, type = NullPredicate.class, required = false),
            @XmlElement(name = OrPredicate.Constants.ROOT_ELEMENT_NAME, type = OrPredicate.class, required = false)
        })
	protected Predicate subQueryPredicate;

    @XmlAnyElement
    private final Collection<Element> _futureElements = null;

	/**
     * Should only be invoked by JAXB.
     */
    @SuppressWarnings("unused")
    private ExistsSubQueryPredicate() {
    }

    public ExistsSubQueryPredicate(String subQueryType, Predicate subQueryPredicate) {
        super();
        if ( StringUtils.isBlank(subQueryType) ) {
            throw new IllegalArgumentException("subQueryType is required");
        }
        this.subQueryType = subQueryType;
        this.subQueryPredicate = subQueryPredicate;
    }

    @Override
    public String getSubQueryType() {
        return this.subQueryType;
    }

    @Override
    public Predicate getSubQueryPredicate() {
        return this.subQueryPredicate;
    }

    @Override
    public String toString() {
        return new StringBuilder(CriteriaSupportUtils.findDynName(this.getClass().getSimpleName()))
                .append("(").append(getSubQueryType())
                .append(" WHERE ").append(getSubQueryPredicate())
                .append(")").toString();
    }
    /**
     * Defines some internal constants used on this class.
     */
    static class Constants {
        final static String ROOT_ELEMENT_NAME = "existsSubQuery";
        final static String TYPE_NAME = "ExistsSubQueryType";
    }

    /**
     * A private class which exposes constants which define the XML element
     * names to use when this object is marshaled to XML.
     */
    static class Elements {
        final static String SUB_QUERY_TYPE = "subQueryType";
        final static String SUB_QUERY_PREDICATE = "subQueryPredicate";
    }
}


text:
package com.github.britter.beanvalidators.file.internal;

import com.github.britter.beanvalidators.file.Existing;

import javax.validation.ConstraintValidatorContext;
import java.io.File;

public final class ExistingStringFileConstraintValidator implements StringToFileConvertingConstraintValidator<Existing> {

    @Override
    public boolean isValidNonNullFile(File file, ConstraintValidatorContext context) {
        return file.exists();
    }
}

redpajama_set_name: RedPajamaGithub


text:
from quixote.errors import TraversalError
from vilya.libs.template import st
from vilya.views.util import jsonize

from vilya.models.pull import PullRequest
from vilya.models.project import CodeDoubanProject
from vilya.models.linecomment import CommitLineComment, PullLineComment

class DiffMixin(object):

    def _toggle_whitespace(self, request):
        raise NotImplementedError('Subclasses should implement this!')

    @jsonize
    def moreline(self, request):
        resp = request.response
        resp.set_header("Content-Type", "application/json")

        MAX_CONTEXT_LINES = 10
        current_user = request.user
        project = self.project
        old_sha = request.get_form_var('old_sha')
        old_path = request.get_form_var('old_path')
        _type = request.get_form_var('type')
        old_start = request.get_form_var('old_start')
        new_start = request.get_form_var('new_start')
        old_end = request.get_form_var('old_end')
        new_end = request.get_form_var('new_end')

        old_start = old_start and old_start.isdigit() and int(old_start)
        new_start = new_start and new_start.isdigit() and int(new_start)
        old_end = old_end and old_end.isdigit() and int(old_end)
        new_end = new_end and new_end.isdigit() and int(new_end)

        if _type == 'after':
            context_old_start = old_end - MAX_CONTEXT_LINES + 1
            context_new_start = new_end - MAX_CONTEXT_LINES + 1
            context_old_end = old_end
            context_new_end = new_end
            if context_old_start <= old_start:
                _type = 'all'
        elif _type == 'before':
            context_old_start = old_start
            context_new_start = new_start
            context_old_end = old_start + MAX_CONTEXT_LINES - 1
            context_new_end = new_start + MAX_CONTEXT_LINES - 1
            if context_old_end >= old_end:
                _type = 'all'
        if _type == 'all':
            context_old_start = old_start
            context_new_start = new_start
            context_old_end = old_end
            context_new_end = new_end

        context_lines = project.repo.get_contexts(old_sha, old_path,
                                                  context_old_start,
                                                  context_old_end + 1)
        html = st('/widgets/diff/diff_lines.html', **locals())
        return dict(r=0, html=html)

    def prepare(self, request):
        project = self.project
        filepath = request.get_form_var('filepath')
        new_filepath = request.get_form_var('new_filepath')

        if new_filepath:
            paths = [filepath, new_filepath]
        else:
            paths = [filepath]

        whitespace = request.get_form_var('w', '0')
        if whitespace.isdigit() and int(whitespace) == 1:
            ignore_space = True
        else:
            ignore_space = False

        return project, paths, ignore_space

    @jsonize
    def toggle_whitespace(self, request, sha1=None, context_lines=None,
                          **kwargs):
        project, paths, ignore_space = self.prepare(request)
        diff = self._toggle_whitespace(
            request, project, paths, ignore_space, sha1=sha1,
            context_lines=context_lines, **kwargs)
        return self.send_response(request, diff)

    def send_response(self, request, diff):
        resp = request.response
        resp.set_header("Content-Type", "application/json")
        current_user = request.user
        kwargs = {
            'diff': diff,
            'current_user': current_user,
        }
        html = st('/widgets/diff/diff_full.html', **kwargs)

        return dict(r=0, html=html)

    def fulltext(self, request, sha1=None, **kwargs):
        return self.toggle_whitespace(request, sha1=sha1, context_lines=9999,
                                      **kwargs)

class CommitDiffMixin(DiffMixin):

    def _toggle_whitespace(self, request, project, paths, ignore_space,
                           **kwargs):
        sha1 = kwargs.get('sha1')
        context_lines = kwargs.get('context_lines')
        ref = sha1
        if ref is None:
            ref = project.default_branch
        linecomments = CommitLineComment.gets_by_target_and_ref(project.id,
                                                                ref)
        kw = {
            'ref': sha1,
            'paths': paths,
            'ignore_space': ignore_space,
            'rename_detection': True,
            'linecomments': linecomments
        }
        if context_lines is not None:
            kw.update({'context_lines': context_lines})
        try:
            commit = project.repo.get_commit(sha1)
            # get_diff 默认与 parent diff
            diff = project.repo.get_diff(**kw)
            if not commit:
                raise TraversalError("not a valid commit ref")
        except IOError:
            raise TraversalError()
        return diff

class PullDiffMixin(DiffMixin):

    def _toggle_whitespace(self, request, project, paths, ignore_space,
                           **kwargs):
        # For pull/new
        from_proj = request.get_form_var('from_proj')
        from_ref = request.get_form_var('from_ref')
        to_ref = request.get_form_var('to_ref')
        to_proj = request.get_form_var('to_proj')

        sha1 = kwargs.get('sha1')
        context_lines = kwargs.get('context_lines')
        ref = sha1
        if ref is None:
            ref = project.default_branch
        if hasattr(self, 'ticket'):
            pullreq = PullRequest.get_by_proj_and_ticket(
                project.id, self.ticket.ticket_number)
            linecomments = PullLineComment.gets_by_target(self.ticket.id)
        else:
            from_proj = CodeDoubanProject.get_by_name(from_proj)
            parent_proj = from_proj.get_forked_from()
            if to_proj:
                to_proj = CodeDoubanProject.get_by_name(to_proj)
            elif parent_proj:
                to_proj = parent_proj
            else:
                to_proj = from_proj
            pullreq = PullRequest.open(from_proj, from_ref, to_proj, to_ref)
            linecomments = []

        kw = {
            'paths': paths,
            'rename_detection': True,
            'linecomments': linecomments
        }
        if context_lines is not None:
            kw.update({'context_lines': context_lines})
        diff = pullreq.get_diff(**kw)
        return diff

class PullDiffUI(PullDiffMixin):
    _q_exports = ['fulltext', 'moreline', 'toggle_whitespace']

    def __init__(self, request, proj_name):
        self.project = CodeDoubanProject.get_by_name(proj_name)


text:
import Vue from 'vue';

require('./bootstrap');
require('./bootstrap-echo');

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

Vue.component('broadcast-test', require('./components/BroadcastTest.vue').default);

const app = new Vue({
    el: '#vue-app'
});


text:
import * as React from "react";
import { useState, useEffect } from "react";
import { getAttachmentUrl, IRuntimeInitInteractive, writeAttachment,
         WriteAttachmentParams, IAttachmentInfo, useInteractiveState } from "../../../interactive-api-client";
import { IInteractiveState } from "./types";

interface Props {
  initMessage: IRuntimeInitInteractive<any, {}>;
}

interface UserAttachmentInfo extends IAttachmentInfo {
  url?: string;
  err?: any;
  loading?: boolean;
}
type UserAttachmentMap = Record<string, UserAttachmentInfo>;

export const RuntimeComponent: React.FC<Props> = ({initMessage}) => {
  const [uploading, setUploading] = useState<boolean>(false);
  const [attachments, setAttachments] = useState<UserAttachmentMap>({});
  const {setInteractiveState} = useInteractiveState<IInteractiveState>();

  // for now this is the best way to know in authoring runtime mode
  const inAuthoringRuntimeMode = !initMessage.hostFeatures.getFirebaseJwt;

  useEffect(() => {
    const initialAttachments: UserAttachmentMap = {};
    if (initMessage.attachments) {
      Object.keys(initMessage.attachments).forEach(key => initialAttachments[key] = {});
    }
    setAttachments(initialAttachments);
  }, [initMessage]);

  const handleUploadAttachment = (e: React.ChangeEvent<HTMLInputElement>) => {
    const file = e.target.files?.[0];
    if (file) {
      const reader = new FileReader();
      reader.onload = async () => {
        const params: WriteAttachmentParams = {
          name: file.name,
          content: reader.result,
          contentType: file.type,
        };
        try {
          setUploading(true);
          const response = await writeAttachment(params);
          if (response.ok) {
            setAttachments(map => ({...map, [file.name]: {}}));

            // to show the attachment in the report
            setInteractiveState({uploadedAttachments: true});
          }
        } catch (err) {
          alert(`Unable to save attachment: ${err}`);
          setAttachments(map => ({...map, [file.name]: {err}}));
        } finally {
          setUploading(false);
        }
      };
      reader.readAsArrayBuffer(file);
    }
  };

  const loadAttachment = async (name: string) => {
    const attachment = attachments[name];
    if (!attachment.url) {
      setAttachments(map => ({...map, [name]: {loading: true}}));
      try {
        const url = await getAttachmentUrl({name});
        setAttachments(map => ({...map, [name]: {url, loading: false}}));
      } catch (err) {
        // tslint:disable-next-line:no-console
        console.error(`Unable to get attachment url: ${err}`);
        setAttachments(map => ({...map, [name]: {err}}));
      }
    }
  };

  const renderAttachmentUrl = (name: string) => {
    const {url, err, loading} = attachments[name];
    let content: JSX.Element;

    const handleLoadAttachment = () => loadAttachment(name);
    const clickHereStyle: React.CSSProperties = {
      cursor: "pointer",
      textDecoration: "underline",
    };

    if (loading) {
      content = Loading...;
    } else if (url) {
      content = <audio controls={true} src={url} />;
    } else if (err) {
      content = {err.toString()};
    } else {
      content = Click to here to load...;
    }

    return
{name}: {content}
;
  };

  const renderAttachmentUrls = () => {
    const names = Object.keys(attachments);
    if (names.length > 0) {
      return (

          {names.map(name => renderAttachmentUrl(name))}

      );
    }
  };

  return (

Attachments Example Interactive

      <fieldset>
        <legend>Audio Attachments</legend>

        {inAuthoringRuntimeMode
          ?
When this interactive is used by a student an upload button will be visible here.

          : <input type="file" title="Upload Audio File" accept="audio/*" onChange={handleUploadAttachment} />
        }

        {uploading ?
Uploading...
 : null}

        {renderAttachmentUrls()}
      </fieldset>

      <fieldset>
        <legend>Runtime Init Message</legend>

{JSON.stringify(initMessage, null, 2)}

      </fieldset>

  );
};


text:
package de.lessvoid.nifty.examples.defaultcontrols.treebox;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.NiftyEventSubscriber;
import de.lessvoid.nifty.controls.*;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.input.NiftyInputEvent;
import de.lessvoid.nifty.screen.Screen;

import javax.annotation.Nonnull;

/**
 * The TreeboxControlDialogController registers a new control with Nifty
 * that represents the whole Dialog. This gives us later an appropriate
 * ControlBuilder to actual construct the Dialog (as a control).
 * @author ractoc
 */
public class TreeboxControlDialogController implements Controller {

  private Nifty nifty;

    @Override
    public void bind(
            @Nonnull final Nifty nifty,
            @Nonnull final Screen screen,
            @Nonnull final Element element,
            @Nonnull final Parameters parameter) {
      TreeBox<String> treebox = screen.findNiftyControl("tree-box", TreeBox.class);
        this.nifty = nifty;

        treebox.setTree(setupTree());
    }

    @Override
    public void init(@Nonnull final Parameters parameter) {
    }

    @Override
    public void onStartScreen() {
    }

    @Override
    public void onFocus(final boolean getFocus) {
    }

    @Override
    public boolean inputEvent(@Nonnull final NiftyInputEvent inputEvent) {
        return false;
    }

  @Override
  public void onEndScreen() {

  }

  @Nonnull
    private TreeItem<String> setupTree() {
        TreeItem<String> treeRoot = new TreeItem<String>();
        TreeItem<String> branch1 = new TreeItem<String>("branch 1");
        branch1.setExpanded(true);
        TreeItem<String> branch11 = new TreeItem<String>("branch 1 1");
        TreeItem<String> branch12 = new TreeItem<String>("branch 1 2");
        branch1.addTreeItem(branch11);
        branch1.addTreeItem(branch12);
        TreeItem<String> branch2 = new TreeItem<String>("branch 2");
        TreeItem<String> branch21 = new TreeItem<String>("branch 2 1");
        TreeItem<String> branch211 = new TreeItem<String>("branch 2 1 1");
        branch2.addTreeItem(branch21);
        branch21.addTreeItem(branch211);
        treeRoot.addTreeItem(branch1);
        treeRoot.addTreeItem(branch2);

        return treeRoot;
    }

    @NiftyEventSubscriber(id="tree-box")
    public void treeItemSelected(final String id, @Nonnull final TreeItemSelectionChangedEvent<String> event) {
      final TextField text = nifty.getCurrentScreen().findNiftyControl("selectedItemText", TextField.class);

      if (!event.getSelection().isEmpty()) {
        text.setText(event.getSelection().get(0).getValue());
      }
    }
}


text:
class Embed
  include Mongoid::Document
  field :name, :type => String

  embedded_in :field_test
end


text:
package org.pentaho.di.ui.trans.steps.http;

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.util.Utils;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.row.RowMetaInterface;
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStepMeta;
import org.pentaho.di.trans.step.StepDialogInterface;
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.steps.http.HTTPMeta;
import org.pentaho.di.ui.core.PropsUI;
import org.pentaho.di.ui.core.dialog.ErrorDialog;
import org.pentaho.di.ui.core.widget.ColumnInfo;
import org.pentaho.di.ui.core.widget.ComboVar;
import org.pentaho.di.ui.core.widget.PasswordTextVar;
import org.pentaho.di.ui.core.widget.TableView;
import org.pentaho.di.ui.core.widget.TextVar;
import org.pentaho.di.ui.trans.step.BaseStepDialog;

public class HTTPDialog extends BaseStepDialog implements StepDialogInterface {
  private static Class<?> PKG = HTTPMeta.class; // for i18n purposes, needed by Translator2!!

  private Label wlUrl;
  private TextVar wUrl;
  private FormData fdlUrl, fdUrl;

  private Label wlResult;
  private TextVar wResult;
  private FormData fdlResult, fdResult;

  private Label wlFields;
  private TableView wFields;
  private FormData fdlFields, fdFields;

  private Label wlHeaders;
  private TableView wHeaders;
  private FormData fdlHeaders, fdHeaders;

  private Label wlUrlInField;
  private Button wUrlInField;
  private FormData fdlUrlInField, fdUrlInField;

  private Label wlUrlField;
  private ComboVar wUrlField;
  private FormData fdlUrlField, fdUrlField;

  private ComboVar wEncoding;

  private Button wGet, wGetHeaders;
  private Listener lsGet, lsGetHeaders;

  private Label wlHttpLogin;
  private TextVar wHttpLogin;

  private Label wlHttpPassword;
  private TextVar wHttpPassword;

  private Label wlProxyHost;
  private TextVar wProxyHost;

  private Label wlProxyPort;
  private TextVar wProxyPort;

  private CTabFolder wTabFolder;

  private CTabItem wGeneralTab, wAdditionalTab;
  private FormData fdTabFolder;

  private Composite wGeneralComp, wAdditionalComp;
  private FormData fdGeneralComp, fdAdditionalComp;

  private Label wlResultCode;
  private TextVar wResultCode;
  private FormData fdlResultCode, fdResultCode;

  private Label wlResponseTime;
  private TextVar wResponseTime;
  private FormData fdlResponseTime, fdResponseTime;

  private Label wlResponseHeader;
  private TextVar wResponseHeader;
  private FormData fdlResponseHeader, fdResponseHeader;

  private HTTPMeta input;

  private ColumnInfo[] colinf;
  private ColumnInfo[] colinfHeaders;

  private Map<String, Integer> inputFields;

  private boolean gotEncodings = false;

  private Label wlConnectionTimeOut;
  private TextVar wConnectionTimeOut;

  private Label wlSocketTimeOut;
  private TextVar wSocketTimeOut;

  private Label wlCloseIdleConnectionsTime;
  private TextVar wCloseIdleConnectionsTime;

  public HTTPDialog( Shell parent, Object in, TransMeta transMeta, String sname ) {
    super( parent, (BaseStepMeta) in, transMeta, sname );
    input = (HTTPMeta) in;
    inputFields = new HashMap<String, Integer>();
  }

  public String open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

    shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN );
    props.setLook( shell );
    setShellImage( shell, input );

    ModifyListener lsMod = new ModifyListener() {
      public void modifyText( ModifyEvent e ) {
        input.setChanged();
      }
    };

    changed = input.hasChanged();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout( formLayout );
    shell.setText( BaseMessages.getString( PKG, "HTTPDialog.Shell.Title" ) );

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    // Stepname line
    //
    wlStepname = new Label( shell, SWT.RIGHT );
    wlStepname.setText( BaseMessages.getString( PKG, "HTTPDialog.Stepname.Label" ) );
    props.setLook( wlStepname );
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment( 0, 0 );
    fdlStepname.right = new FormAttachment( middle, -margin );
    fdlStepname.top = new FormAttachment( 0, margin );
    wlStepname.setLayoutData( fdlStepname );
    wStepname = new Text( shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    wStepname.setText( stepname );
    props.setLook( wStepname );
    wStepname.addModifyListener( lsMod );
    fdStepname = new FormData();
    fdStepname.left = new FormAttachment( middle, 0 );
    fdStepname.top = new FormAttachment( 0, margin );
    fdStepname.right = new FormAttachment( 100, 0 );
    wStepname.setLayoutData( fdStepname );
    Control lastControl = wStepname;

    wTabFolder = new CTabFolder( shell, SWT.BORDER );
    props.setLook( wTabFolder, PropsUI.WIDGET_STYLE_TAB );

    // ////////////////////////
    // START OF GENERAL TAB ///
    // ////////////////////////
    wGeneralTab = new CTabItem( wTabFolder, SWT.NONE );
    wGeneralTab.setText( BaseMessages.getString( PKG, "HTTPDialog.GeneralTab.Title" ) );

    wGeneralComp = new Composite( wTabFolder, SWT.NONE );
    props.setLook( wGeneralComp );

    FormLayout fileLayout = new FormLayout();
    fileLayout.marginWidth = 3;
    fileLayout.marginHeight = 3;
    wGeneralComp.setLayout( fileLayout );

    // ////////////////////////
    // START Settings GROUP

    Group gSettings = new Group( wGeneralComp, SWT.SHADOW_ETCHED_IN );
    gSettings.setText( BaseMessages.getString( PKG, "HTTPDialog.SettingsGroup.Label" ) );
    FormLayout SettingsLayout = new FormLayout();
    SettingsLayout.marginWidth = 3;
    SettingsLayout.marginHeight = 3;
    gSettings.setLayout( SettingsLayout );
    props.setLook( gSettings );

    // The URL to use
    //
    wlUrl = new Label( gSettings, SWT.RIGHT );
    wlUrl.setText( BaseMessages.getString( PKG, "HTTPDialog.URL.Label" ) );
    props.setLook( wlUrl );
    fdlUrl = new FormData();
    fdlUrl.left = new FormAttachment( 0, 0 );
    fdlUrl.right = new FormAttachment( middle, -margin );
    fdlUrl.top = new FormAttachment( lastControl, margin );
    wlUrl.setLayoutData( fdlUrl );

    wUrl = new TextVar( transMeta, gSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    props.setLook( wUrl );
    wUrl.addModifyListener( lsMod );
    fdUrl = new FormData();
    fdUrl.left = new FormAttachment( middle, 0 );
    fdUrl.top = new FormAttachment( lastControl, margin );
    fdUrl.right = new FormAttachment( 100, 0 );
    wUrl.setLayoutData( fdUrl );
    lastControl = wUrl;

    // UrlInField line
    //
    wlUrlInField = new Label( gSettings, SWT.RIGHT );
    wlUrlInField.setText( BaseMessages.getString( PKG, "HTTPDialog.UrlInField.Label" ) );
    props.setLook( wlUrlInField );
    fdlUrlInField = new FormData();
    fdlUrlInField.left = new FormAttachment( 0, 0 );
    fdlUrlInField.top = new FormAttachment( lastControl, margin );
    fdlUrlInField.right = new FormAttachment( middle, -margin );
    wlUrlInField.setLayoutData( fdlUrlInField );
    wUrlInField = new Button( gSettings, SWT.CHECK );
    props.setLook( wUrlInField );
    fdUrlInField = new FormData();
    fdUrlInField.left = new FormAttachment( middle, 0 );
    fdUrlInField.top = new FormAttachment( lastControl, margin );
    fdUrlInField.right = new FormAttachment( 100, 0 );
    wUrlInField.setLayoutData( fdUrlInField );
    wUrlInField.addSelectionListener( new SelectionAdapter() {
      public void widgetSelected( SelectionEvent e ) {
        input.setChanged();
        activeUrlInfield();
      }
    } );
    lastControl = wUrlInField;

    // UrlField Line
    //
    wlUrlField = new Label( gSettings, SWT.RIGHT );
    wlUrlField.setText( BaseMessages.getString( PKG, "HTTPDialog.UrlField.Label" ) );
    props.setLook( wlUrlField );
    fdlUrlField = new FormData();
    fdlUrlField.left = new FormAttachment( 0, 0 );
    fdlUrlField.right = new FormAttachment( middle, -margin );
    fdlUrlField.top = new FormAttachment( lastControl, margin );
    wlUrlField.setLayoutData( fdlUrlField );

    wUrlField = new ComboVar( transMeta, gSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    wUrlField.setToolTipText( BaseMessages.getString( PKG, "HTTPDialog.UrlField.Tooltip" ) );
    props.setLook( wUrlField );
    wUrlField.addModifyListener( lsMod );
    fdUrlField = new FormData();
    fdUrlField.left = new FormAttachment( middle, 0 );
    fdUrlField.top = new FormAttachment( lastControl, margin );
    fdUrlField.right = new FormAttachment( 100, 0 );
    wUrlField.setLayoutData( fdUrlField );
    wUrlField.setEnabled( false );
    wUrlField.addFocusListener( new FocusListener() {
      public void focusLost( org.eclipse.swt.events.FocusEvent e ) {
      }

      public void focusGained( org.eclipse.swt.events.FocusEvent e ) {
        Cursor busy = new Cursor( shell.getDisplay(), SWT.CURSOR_WAIT );
        shell.setCursor( busy );
        BaseStepDialog.getFieldsFromPrevious( wUrlField, transMeta, stepMeta );
        shell.setCursor( null );
        busy.dispose();
      }
    } );
    lastControl = wUrlField;

    // Encoding
    //
    Label wlEncoding = new Label( gSettings, SWT.RIGHT );
    wlEncoding.setText( BaseMessages.getString( PKG, "HTTPDialog.Encoding.Label" ) );
    props.setLook( wlEncoding );
    FormData fdlEncoding = new FormData();
    fdlEncoding.top = new FormAttachment( lastControl, margin );
    fdlEncoding.left = new FormAttachment( 0, 0 );
    fdlEncoding.right = new FormAttachment( middle, -margin );
    wlEncoding.setLayoutData( fdlEncoding );
    wEncoding = new ComboVar( transMeta, gSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    props.setLook( wEncoding );
    wEncoding.addModifyListener( lsMod );
    FormData fdEncoding = new FormData();
    fdEncoding.top = new FormAttachment( lastControl, margin );
    fdEncoding.left = new FormAttachment( middle, 0 );
    fdEncoding.right = new FormAttachment( 100, 0 );
    wEncoding.setLayoutData( fdEncoding );
    lastControl = wEncoding;
    wEncoding.addFocusListener( new FocusListener() {
      public void focusLost( org.eclipse.swt.events.FocusEvent e ) {
      }

      public void focusGained( org.eclipse.swt.events.FocusEvent e ) {
        Cursor busy = new Cursor( shell.getDisplay(), SWT.CURSOR_WAIT );
        shell.setCursor( busy );
        setEncodings();
        shell.setCursor( null );
        busy.dispose();
      }
    } );

    wlConnectionTimeOut = new Label( gSettings, SWT.RIGHT );
    wlConnectionTimeOut.setText( BaseMessages.getString( PKG, "HTTPDialog.ConnectionTimeOut.Label" ) );
    props.setLook( wlConnectionTimeOut );
    FormData fdlConnectionTimeOut = new FormData();
    fdlConnectionTimeOut.top = new FormAttachment( wEncoding, margin );
    fdlConnectionTimeOut.left = new FormAttachment( 0, 0 );
    fdlConnectionTimeOut.right = new FormAttachment( middle, -margin );
    wlConnectionTimeOut.setLayoutData( fdlConnectionTimeOut );
    wConnectionTimeOut = new TextVar( transMeta, gSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    wConnectionTimeOut.addModifyListener( lsMod );
    wConnectionTimeOut.setToolTipText( BaseMessages.getString( PKG, "HTTPDialog.ConnectionTimeOut.Tooltip" ) );
    props.setLook( wConnectionTimeOut );
    FormData fdConnectionTimeOut = new FormData();
    fdConnectionTimeOut.top = new FormAttachment( wEncoding, margin );
    fdConnectionTimeOut.left = new FormAttachment( middle, 0 );
    fdConnectionTimeOut.right = new FormAttachment( 100, 0 );
    wConnectionTimeOut.setLayoutData( fdConnectionTimeOut );

    wlSocketTimeOut = new Label( gSettings, SWT.RIGHT );
    wlSocketTimeOut.setText( BaseMessages.getString( PKG, "HTTPDialog.SocketTimeOut.Label" ) );
    props.setLook( wlSocketTimeOut );
    FormData fdlSocketTimeOut = new FormData();
    fdlSocketTimeOut.top = new FormAttachment( wConnectionTimeOut, margin );
    fdlSocketTimeOut.left = new FormAttachment( 0, 0 );
    fdlSocketTimeOut.right = new FormAttachment( middle, -margin );
    wlSocketTimeOut.setLayoutData( fdlSocketTimeOut );
    wSocketTimeOut = new TextVar( transMeta, gSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    wSocketTimeOut.addModifyListener( lsMod );
    wSocketTimeOut.setToolTipText( BaseMessages.getString( PKG, "HTTPDialog.SocketTimeOut.Tooltip" ) );
    props.setLook( wSocketTimeOut );
    FormData fdSocketTimeOut = new FormData();
    fdSocketTimeOut.top = new FormAttachment( wConnectionTimeOut, margin );
    fdSocketTimeOut.left = new FormAttachment( middle, 0 );
    fdSocketTimeOut.right = new FormAttachment( 100, 0 );
    wSocketTimeOut.setLayoutData( fdSocketTimeOut );

    wlCloseIdleConnectionsTime = new Label( gSettings, SWT.RIGHT );
    wlCloseIdleConnectionsTime
      .setText( BaseMessages.getString( PKG, "HTTPDialog.CloseIdleConnectionsTime.Label" ) );
    props.setLook( wlCloseIdleConnectionsTime );
    FormData fdlCloseIdleConnectionsTime = new FormData();
    fdlCloseIdleConnectionsTime.top = new FormAttachment( wSocketTimeOut, margin );
    fdlCloseIdleConnectionsTime.left = new FormAttachment( 0, 0 );
    fdlCloseIdleConnectionsTime.right = new FormAttachment( middle, -margin );
    wlCloseIdleConnectionsTime.setLayoutData( fdlCloseIdleConnectionsTime );
    wCloseIdleConnectionsTime = new TextVar( transMeta, gSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    wCloseIdleConnectionsTime.addModifyListener( lsMod );
    wCloseIdleConnectionsTime.setToolTipText( BaseMessages.getString(
      PKG, "HTTPDialog.CloseIdleConnectionsTime.Tooltip" ) );
    props.setLook( wCloseIdleConnectionsTime );
    FormData fdCloseIdleConnectionsTime = new FormData();
    fdCloseIdleConnectionsTime.top = new FormAttachment( wSocketTimeOut, margin );
    fdCloseIdleConnectionsTime.left = new FormAttachment( middle, 0 );
    fdCloseIdleConnectionsTime.right = new FormAttachment( 100, 0 );
    wCloseIdleConnectionsTime.setLayoutData( fdCloseIdleConnectionsTime );

    FormData fdSettings = new FormData();
    fdSettings.left = new FormAttachment( 0, 0 );
    fdSettings.right = new FormAttachment( 100, 0 );
    fdSettings.top = new FormAttachment( lastControl, margin );
    gSettings.setLayoutData( fdSettings );

    // END Output Settings GROUP
    // ////////////////////////
    lastControl = gSettings;
    // ////////////////////////
    // START Output Fields GROUP

    Group gOutputFields = new Group( wGeneralComp, SWT.SHADOW_ETCHED_IN );
    gOutputFields.setText( BaseMessages.getString( PKG, "HTTPDialog.OutputFieldsGroup.Label" ) );
    FormLayout OutputFieldsLayout = new FormLayout();
    OutputFieldsLayout.marginWidth = 3;
    OutputFieldsLayout.marginHeight = 3;
    gOutputFields.setLayout( OutputFieldsLayout );
    props.setLook( gOutputFields );

    // Result line...
    //
    wlResult = new Label( gOutputFields, SWT.RIGHT );
    wlResult.setText( BaseMessages.getString( PKG, "HTTPDialog.Result.Label" ) );
    props.setLook( wlResult );
    fdlResult = new FormData();
    fdlResult.left = new FormAttachment( 0, 0 );
    fdlResult.right = new FormAttachment( middle, -margin );
    fdlResult.top = new FormAttachment( lastControl, margin );
    wlResult.setLayoutData( fdlResult );
    wResult = new TextVar( transMeta, gOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    props.setLook( wResult );
    wResult.addModifyListener( lsMod );
    fdResult = new FormData();
    fdResult.left = new FormAttachment( middle, 0 );
    fdResult.top = new FormAttachment( lastControl, margin );
    fdResult.right = new FormAttachment( 100, 0 );
    wResult.setLayoutData( fdResult );

    // Resultcode line...
    wlResultCode = new Label( gOutputFields, SWT.RIGHT );
    wlResultCode.setText( BaseMessages.getString( PKG, "HTTPDialog.ResultCode.Label" ) );
    props.setLook( wlResultCode );
    fdlResultCode = new FormData();
    fdlResultCode.left = new FormAttachment( 0, 0 );
    fdlResultCode.right = new FormAttachment( middle, -margin );
    fdlResultCode.top = new FormAttachment( wResult, margin );
    wlResultCode.setLayoutData( fdlResultCode );
    wResultCode = new TextVar( transMeta, gOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    props.setLook( wResultCode );
    wResultCode.addModifyListener( lsMod );
    fdResultCode = new FormData();
    fdResultCode.left = new FormAttachment( middle, 0 );
    fdResultCode.top = new FormAttachment( wResult, margin );
    fdResultCode.right = new FormAttachment( 100, 0 );
    wResultCode.setLayoutData( fdResultCode );

    // Response time line...
    wlResponseTime = new Label( gOutputFields, SWT.RIGHT );
    wlResponseTime.setText( BaseMessages.getString( PKG, "HTTPDialog.ResponseTime.Label" ) );
    props.setLook( wlResponseTime );
    fdlResponseTime = new FormData();
    fdlResponseTime.left = new FormAttachment( 0, 0 );
    fdlResponseTime.right = new FormAttachment( middle, -margin );
    fdlResponseTime.top = new FormAttachment( wResultCode, margin );
    wlResponseTime.setLayoutData( fdlResponseTime );
    wResponseTime = new TextVar( transMeta, gOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    props.setLook( wResponseTime );
    wResponseTime.addModifyListener( lsMod );
    fdResponseTime = new FormData();
    fdResponseTime.left = new FormAttachment( middle, 0 );
    fdResponseTime.top = new FormAttachment( wResultCode, margin );
    fdResponseTime.right = new FormAttachment( 100, 0 );
    wResponseTime.setLayoutData( fdResponseTime );
    // Response header line...
    wlResponseHeader = new Label( gOutputFields, SWT.RIGHT );
    wlResponseHeader.setText( BaseMessages.getString( PKG, "HTTPDialog.ResponseHeader.Label" ) );
    props.setLook( wlResponseHeader );
    fdlResponseHeader = new FormData();
    fdlResponseHeader.left = new FormAttachment( 0, 0 );
    fdlResponseHeader.right = new FormAttachment( middle, -margin );
    fdlResponseHeader.top = new FormAttachment( wResponseTime, margin );
    wlResponseHeader.setLayoutData( fdlResponseHeader );
    wResponseHeader = new TextVar( transMeta, gOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    props.setLook( wResponseHeader );
    wResponseHeader.addModifyListener( lsMod );
    fdResponseHeader = new FormData();
    fdResponseHeader.left = new FormAttachment( middle, 0 );
    fdResponseHeader.top = new FormAttachment( wResponseTime, margin );
    fdResponseHeader.right = new FormAttachment( 100, 0 );
    wResponseHeader.setLayoutData( fdResponseHeader );

    FormData fdOutputFields = new FormData();
    fdOutputFields.left = new FormAttachment( 0, 0 );
    fdOutputFields.right = new FormAttachment( 100, 0 );
    fdOutputFields.top = new FormAttachment( lastControl, margin );
    gOutputFields.setLayoutData( fdOutputFields );

    // END Output Fields GROUP
    // ////////////////////////

    lastControl = gOutputFields;

    // ////////////////////////
    // START HTTP AUTH GROUP

    Group gHttpAuth = new Group( wGeneralComp, SWT.SHADOW_ETCHED_IN );
    gHttpAuth.setText( BaseMessages.getString( PKG, "HTTPDialog.HttpAuthGroup.Label" ) );
    FormLayout httpAuthLayout = new FormLayout();
    httpAuthLayout.marginWidth = 3;
    httpAuthLayout.marginHeight = 3;
    gHttpAuth.setLayout( httpAuthLayout );
    props.setLook( gHttpAuth );

    // HTTP Login
    wlHttpLogin = new Label( gHttpAuth, SWT.RIGHT );
    wlHttpLogin.setText( BaseMessages.getString( PKG, "HTTPDialog.HttpLogin.Label" ) );
    props.setLook( wlHttpLogin );
    FormData fdlHttpLogin = new FormData();
    fdlHttpLogin.top = new FormAttachment( 0, margin );
    fdlHttpLogin.left = new FormAttachment( 0, 0 );
    fdlHttpLogin.right = new FormAttachment( middle, -margin );
    wlHttpLogin.setLayoutData( fdlHttpLogin );
    wHttpLogin = new TextVar( transMeta, gHttpAuth, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    wHttpLogin.addModifyListener( lsMod );
    wHttpLogin.setToolTipText( BaseMessages.getString( PKG, "HTTPDialog.HttpLogin.Tooltip" ) );
    props.setLook( wHttpLogin );
    FormData fdHttpLogin = new FormData();
    fdHttpLogin.top = new FormAttachment( 0, margin );
    fdHttpLogin.left = new FormAttachment( middle, 0 );
    fdHttpLogin.right = new FormAttachment( 100, 0 );
    wHttpLogin.setLayoutData( fdHttpLogin );

    // HTTP Password
    wlHttpPassword = new Label( gHttpAuth, SWT.RIGHT );
    wlHttpPassword.setText( BaseMessages.getString( PKG, "HTTPDialog.HttpPassword.Label" ) );
    props.setLook( wlHttpPassword );
    FormData fdlHttpPassword = new FormData();
    fdlHttpPassword.top = new FormAttachment( wHttpLogin, margin );
    fdlHttpPassword.left = new FormAttachment( 0, 0 );
    fdlHttpPassword.right = new FormAttachment( middle, -margin );
    wlHttpPassword.setLayoutData( fdlHttpPassword );
    wHttpPassword = new PasswordTextVar( transMeta, gHttpAuth, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    wHttpPassword.addModifyListener( lsMod );
    wHttpPassword.setToolTipText( BaseMessages.getString( PKG, "HTTPDialog.HttpPassword.Tooltip" ) );
    props.setLook( wHttpPassword );
    FormData fdHttpPassword = new FormData();
    fdHttpPassword.top = new FormAttachment( wHttpLogin, margin );
    fdHttpPassword.left = new FormAttachment( middle, 0 );
    fdHttpPassword.right = new FormAttachment( 100, 0 );
    wHttpPassword.setLayoutData( fdHttpPassword );

    FormData fdHttpAuth = new FormData();
    fdHttpAuth.left = new FormAttachment( 0, 0 );
    fdHttpAuth.right = new FormAttachment( 100, 0 );
    fdHttpAuth.top = new FormAttachment( lastControl, margin );
    gHttpAuth.setLayoutData( fdHttpAuth );

    // END HTTP AUTH GROUP
    // ////////////////////////

    lastControl = gHttpAuth;

    // ////////////////////////
    // START PROXY GROUP

    Group gProxy = new Group( wGeneralComp, SWT.SHADOW_ETCHED_IN );
    gProxy.setText( BaseMessages.getString( PKG, "HTTPDialog.ProxyGroup.Label" ) );
    FormLayout proxyLayout = new FormLayout();
    proxyLayout.marginWidth = 3;
    proxyLayout.marginHeight = 3;
    gProxy.setLayout( proxyLayout );
    props.setLook( gProxy );

    // HTTP Login
    wlProxyHost = new Label( gProxy, SWT.RIGHT );
    wlProxyHost.setText( BaseMessages.getString( PKG, "HTTPDialog.ProxyHost.Label" ) );
    props.setLook( wlProxyHost );
    FormData fdlProxyHost = new FormData();
    fdlProxyHost.top = new FormAttachment( 0, margin );
    fdlProxyHost.left = new FormAttachment( 0, 0 );
    fdlProxyHost.right = new FormAttachment( middle, -margin );
    wlProxyHost.setLayoutData( fdlProxyHost );
    wProxyHost = new TextVar( transMeta, gProxy, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    wProxyHost.addModifyListener( lsMod );
    wProxyHost.setToolTipText( BaseMessages.getString( PKG, "HTTPDialog.ProxyHost.Tooltip" ) );
    props.setLook( wProxyHost );
    FormData fdProxyHost = new FormData();
    fdProxyHost.top = new FormAttachment( 0, margin );
    fdProxyHost.left = new FormAttachment( middle, 0 );
    fdProxyHost.right = new FormAttachment( 100, 0 );
    wProxyHost.setLayoutData( fdProxyHost );

    // HTTP Password
    wlProxyPort = new Label( gProxy, SWT.RIGHT );
    wlProxyPort.setText( BaseMessages.getString( PKG, "HTTPDialog.ProxyPort.Label" ) );
    props.setLook( wlProxyPort );
    FormData fdlProxyPort = new FormData();
    fdlProxyPort.top = new FormAttachment( wProxyHost, margin );
    fdlProxyPort.left = new FormAttachment( 0, 0 );
    fdlProxyPort.right = new FormAttachment( middle, -margin );
    wlProxyPort.setLayoutData( fdlProxyPort );
    wProxyPort = new TextVar( transMeta, gProxy, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
    wProxyPort.addModifyListener( lsMod );
    wProxyPort.setToolTipText( BaseMessages.getString( PKG, "HTTPDialog.ProxyPort.Tooltip" ) );
    props.setLook( wProxyPort );
    FormData fdProxyPort = new FormData();
    fdProxyPort.top = new FormAttachment( wProxyHost, margin );
    fdProxyPort.left = new FormAttachment( middle, 0 );
    fdProxyPort.right = new FormAttachment( 100, 0 );
    wProxyPort.setLayoutData( fdProxyPort );

    FormData fdProxy = new FormData();
    fdProxy.left = new FormAttachment( 0, 0 );
    fdProxy.right = new FormAttachment( 100, 0 );
    fdProxy.top = new FormAttachment( lastControl, margin );
    gProxy.setLayoutData( fdProxy );

    // END HTTP Proxy GROUP
    // ////////////////////////
    lastControl = gProxy;

    fdGeneralComp = new FormData();
    fdGeneralComp.left = new FormAttachment( 0, 0 );
    fdGeneralComp.top = new FormAttachment( wStepname, margin );
    fdGeneralComp.right = new FormAttachment( 100, 0 );
    fdGeneralComp.bottom = new FormAttachment( 100, 0 );
    wGeneralComp.setLayoutData( fdGeneralComp );

    wGeneralComp.layout();
    wGeneralTab.setControl( wGeneralComp );

    // ///////////////////////////////////////////////////////////
    // / END OF GENERAL TAB
    // ///////////////////////////////////////////////////////////
    // Additional tab...
    //
    wAdditionalTab = new CTabItem( wTabFolder, SWT.NONE );
    wAdditionalTab.setText( BaseMessages.getString( PKG, "HTTPDialog.FieldsTab.Title" ) );

    FormLayout addLayout = new FormLayout();
    addLayout.marginWidth = Const.FORM_MARGIN;
    addLayout.marginHeight = Const.FORM_MARGIN;

    wAdditionalComp = new Composite( wTabFolder, SWT.NONE );
    wAdditionalComp.setLayout( addLayout );
    props.setLook( wAdditionalComp );

    wlFields = new Label( wAdditionalComp, SWT.NONE );
    wlFields.setText( BaseMessages.getString( PKG, "HTTPDialog.Parameters.Label" ) );
    props.setLook( wlFields );
    fdlFields = new FormData();
    fdlFields.left = new FormAttachment( 0, 0 );
    fdlFields.top = new FormAttachment( lastControl, margin );
    wlFields.setLayoutData( fdlFields );
    lastControl = wlFields;

    wGet = new Button( wAdditionalComp, SWT.PUSH );
    wGet.setText( BaseMessages.getString( PKG, "HTTPDialog.GetFields.Button" ) );
    FormData fdGet = new FormData();
    fdGet.top = new FormAttachment( wlFields, margin );
    fdGet.right = new FormAttachment( 100, 0 );
    wGet.setLayoutData( fdGet );

    final int FieldsRows = input.getArgumentField().length;

    colinf =
      new ColumnInfo[] {
        new ColumnInfo(
          BaseMessages.getString( PKG, "HTTPDialog.ColumnInfo.Name" ), ColumnInfo.COLUMN_TYPE_CCOMBO,
          new String[] { "" }, false ),
        new ColumnInfo(
          BaseMessages.getString( PKG, "HTTPDialog.ColumnInfo.Parameter" ), ColumnInfo.COLUMN_TYPE_TEXT,
          false ), };

    wFields =
      new TableView(
        transMeta, wAdditionalComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod,
        props );

    fdFields = new FormData();
    fdFields.left = new FormAttachment( 0, 0 );
    fdFields.top = new FormAttachment( wlFields, margin );
    fdFields.right = new FormAttachment( wGet, -margin );
    fdFields.bottom = new FormAttachment( wlFields, 200 );
    wFields.setLayoutData( fdFields );

    wlHeaders = new Label( wAdditionalComp, SWT.NONE );
    wlHeaders.setText( BaseMessages.getString( PKG, "HTTPDialog.Headers.Label" ) );
    props.setLook( wlHeaders );
    fdlHeaders = new FormData();
    fdlHeaders.left = new FormAttachment( 0, 0 );
    fdlHeaders.top = new FormAttachment( wFields, margin );
    wlHeaders.setLayoutData( fdlHeaders );

    final int HeadersRows = input.getHeaderParameter().length;

    colinfHeaders =
      new ColumnInfo[] {
        new ColumnInfo(
          BaseMessages.getString( PKG, "HTTPDialog.ColumnInfo.Field" ), ColumnInfo.COLUMN_TYPE_CCOMBO,
          new String[] { "" }, false ),
        new ColumnInfo(
          BaseMessages.getString( PKG, "HTTPDialog.ColumnInfo.Header" ), ColumnInfo.COLUMN_TYPE_TEXT, false ), };
    colinfHeaders[1].setUsingVariables( true );
    wHeaders =
      new TableView(
        transMeta, wAdditionalComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinfHeaders, HeadersRows,
        lsMod, props );

    wGetHeaders = new Button( wAdditionalComp, SWT.PUSH );
    wGetHeaders.setText( BaseMessages.getString( PKG, "HTTPDialog.GetHeaders.Button" ) );
    FormData fdGetHeaders = new FormData();
    fdGetHeaders.top = new FormAttachment( wlHeaders, margin );
    fdGetHeaders.right = new FormAttachment( 100, 0 );
    wGetHeaders.setLayoutData( fdGetHeaders );

    fdHeaders = new FormData();
    fdHeaders.left = new FormAttachment( 0, 0 );
    fdHeaders.top = new FormAttachment( wlHeaders, margin );
    fdHeaders.right = new FormAttachment( wGetHeaders, -margin );
    fdHeaders.bottom = new FormAttachment( 100, -margin );
    wHeaders.setLayoutData( fdHeaders );

    //
    // Search the fields in the background

    final Runnable runnable = new Runnable() {
      public void run() {
        StepMeta stepMeta = transMeta.findStep( stepname );
        if ( stepMeta != null ) {
          try {
            RowMetaInterface row = transMeta.getPrevStepFields( stepMeta );

            // Remember these fields...
            for ( int i = 0; i < row.size(); i++ ) {
              inputFields.put( row.getValueMeta( i ).getName(), Integer.valueOf( i ) );
            }
            setComboBoxes();
          } catch ( KettleException e ) {
            logError( BaseMessages.getString( PKG, "System.Dialog.GetFieldsFailed.Message" ) );
          }
        }
      }
    };
    new Thread( runnable ).start();

    fdAdditionalComp = new FormData();
    fdAdditionalComp.left = new FormAttachment( 0, 0 );
    fdAdditionalComp.top = new FormAttachment( wStepname, margin );
    fdAdditionalComp.right = new FormAttachment( 100, 0 );
    fdAdditionalComp.bottom = new FormAttachment( 100, 0 );
    wAdditionalComp.setLayoutData( fdAdditionalComp );

    wAdditionalComp.layout();
    wAdditionalTab.setControl( wAdditionalComp );
    // ////// END of Additional Tab

    fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment( 0, 0 );
    fdTabFolder.top = new FormAttachment( wStepname, margin );
    fdTabFolder.right = new FormAttachment( 100, 0 );
    fdTabFolder.bottom = new FormAttachment( 100, -50 );
    wTabFolder.setLayoutData( fdTabFolder );

    // THE BUTTONS
    wOK = new Button( shell, SWT.PUSH );
    wOK.setText( BaseMessages.getString( PKG, "System.Button.OK" ) );
    wCancel = new Button( shell, SWT.PUSH );
    wCancel.setText( BaseMessages.getString( PKG, "System.Button.Cancel" ) );

    setButtonPositions( new Button[] { wOK, wCancel }, margin, wTabFolder );

    // Add listeners
    lsOK = new Listener() {
      public void handleEvent( Event e ) {
        ok();
      }
    };
    lsGet = new Listener() {
      public void handleEvent( Event e ) {
        get();
      }
    };
    lsCancel = new Listener() {
      public void handleEvent( Event e ) {
        cancel();
      }
    };
    lsGetHeaders = new Listener() {
      public void handleEvent( Event e ) {
        getHeadersFields();
      }
    };

    wOK.addListener( SWT.Selection, lsOK );
    wGet.addListener( SWT.Selection, lsGet );
    wCancel.addListener( SWT.Selection, lsCancel );
    wGetHeaders.addListener( SWT.Selection, lsGetHeaders );

    lsDef = new SelectionAdapter() {
      public void widgetDefaultSelected( SelectionEvent e ) {
        ok();
      }
    };

    wStepname.addSelectionListener( lsDef );
    wUrl.addSelectionListener( lsDef );
    wResult.addSelectionListener( lsDef );

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener( new ShellAdapter() {
      public void shellClosed( ShellEvent e ) {
        cancel();
      }
    } );

    lsResize = new Listener() {
      public void handleEvent( Event event ) {
        Point size = shell.getSize();
        wFields.setSize( size.x - 10, size.y - 50 );
        wFields.table.setSize( size.x - 10, size.y - 50 );
        wFields.redraw();
      }
    };
    shell.addListener( SWT.Resize, lsResize );

    // Set the shell size, based upon previous time...
    setSize();

    getData();
    wTabFolder.setSelection( 0 );
    activeUrlInfield();
    input.setChanged( changed );

    shell.open();
    while ( !shell.isDisposed() ) {
      if ( !display.readAndDispatch() ) {
        display.sleep();
      }
    }
    return stepname;
  }

  private void setEncodings() {
    // Encoding of the text file:
    if ( !gotEncodings ) {
      gotEncodings = true;

      wEncoding.removeAll();
      List<Charset> values = new ArrayList<Charset>( Charset.availableCharsets().values() );
      for ( int i = 0; i < values.size(); i++ ) {
        Charset charSet = values.get( i );
        wEncoding.add( charSet.displayName() );
      }

      // Now select the default!
      String defEncoding = Const.getEnvironmentVariable( "file.encoding", "UTF-8" );
      int idx = Const.indexOfString( defEncoding, wEncoding.getItems() );
      if ( idx >= 0 ) {
        wEncoding.select( idx );
      }
    }
  }

  protected void setComboBoxes() {
    // Something was changed in the row.
    //
    final Map<String, Integer> fields = new HashMap<String, Integer>();

    // Add the currentMeta fields...
    fields.putAll( inputFields );

    Set<String> keySet = fields.keySet();
    List<String> entries = new ArrayList<String>( keySet );

    String[] fieldNames = entries.toArray( new String[entries.size()] );

    Const.sortStrings( fieldNames );
    colinf[0].setComboValues( fieldNames );
    colinfHeaders[0].setComboValues( fieldNames );
  }

  private void activeUrlInfield() {
    wlUrlField.setEnabled( wUrlInField.getSelection() );
    wUrlField.setEnabled( wUrlInField.getSelection() );
    wlUrl.setEnabled( !wUrlInField.getSelection() );
    wUrl.setEnabled( !wUrlInField.getSelection() );
  }

  /**
   * Copy information from the meta-data input to the dialog fields.
   */
  public void getData() {
    if ( isDebug() ) {
      logDebug( BaseMessages.getString( PKG, "HTTPDialog.Log.GettingKeyInfo" ) );
    }

    if ( input.getArgumentField() != null ) {
      for ( int i = 0; i < input.getArgumentField().length; i++ ) {
        TableItem item = wFields.table.getItem( i );
        item.setText( 1, Const.NVL( input.getArgumentField()[i], "" ) );
        item.setText( 2, Const.NVL( input.getArgumentParameter()[i], "" ) );
      }
    }

    if ( input.getHeaderField() != null ) {
      for ( int i = 0; i < input.getHeaderField().length; i++ ) {
        TableItem item = wHeaders.table.getItem( i );
        if ( input.getHeaderField()[i] != null ) {
          item.setText( 1, input.getHeaderField()[i] );
        }
        if ( input.getHeaderParameter()[i] != null ) {
          item.setText( 2, input.getHeaderParameter()[i] );
        }
      }
    }
    wSocketTimeOut.setText( Const.NVL( input.getSocketTimeout(), "" ) );
    wConnectionTimeOut.setText( Const.NVL( input.getConnectionTimeout(), "" ) );
    wCloseIdleConnectionsTime.setText( Const.NVL( input.getCloseIdleConnectionsTime(), "" ) );

    wUrl.setText( Const.NVL( input.getUrl(), "" ) );
    wUrlInField.setSelection( input.isUrlInField() );
    wUrlField.setText( Const.NVL( input.getUrlField(), "" ) );
    wEncoding.setText( Const.NVL( input.getEncoding(), "" ) );

    wResult.setText( Const.NVL( input.getFieldName(), "" ) );
    if ( input.getHttpLogin() != null ) {
      wHttpLogin.setText( input.getHttpLogin() );
    }
    if ( input.getHttpPassword() != null ) {
      wHttpPassword.setText( input.getHttpPassword() );
    }
    if ( input.getProxyHost() != null ) {
      wProxyHost.setText( input.getProxyHost() );
    }
    if ( input.getProxyPort() != null ) {
      wProxyPort.setText( input.getProxyPort() );
    }
    if ( input.getResultCodeFieldName() != null ) {
      wResultCode.setText( input.getResultCodeFieldName() );
    }
    if ( input.getResponseTimeFieldName() != null ) {
      wResponseTime.setText( input.getResponseTimeFieldName() );
    }
    if ( input.getResponseHeaderFieldName() != null ) {
      wResponseHeader.setText( input.getResponseHeaderFieldName() );
    }

    wFields.setRowNums();
    wFields.optWidth( true );
    wHeaders.setRowNums();
    wHeaders.optWidth( true );

    wStepname.selectAll();
    wStepname.setFocus();
  }

  private void cancel() {
    stepname = null;
    input.setChanged( changed );
    dispose();
  }

  private void ok() {
    if ( Utils.isEmpty( wStepname.getText() ) ) {
      return;
    }

    int nrargs = wFields.nrNonEmpty();
    int nrheaders = wHeaders.nrNonEmpty();

    input.allocate( nrargs, nrheaders );

    if ( isDebug() ) {
      logDebug( BaseMessages.getString( PKG, "HTTPDialog.Log.FoundArguments", String.valueOf( nrargs ) ) );
    }
    //CHECKSTYLE:Indentation:OFF
    for ( int i = 0; i < nrargs; i++ ) {
      TableItem item = wFields.getNonEmpty( i );
      input.getArgumentField()[i] = item.getText( 1 );
      input.getArgumentParameter()[i] = item.getText( 2 );
    }

    if ( log.isDebug() ) {
      logDebug( BaseMessages.getString( PKG, "HTTPDialog.Log.FoundHeaders", String.valueOf( nrheaders ) ) );
    }
    //CHECKSTYLE:Indentation:OFF
    for ( int i = 0; i < nrheaders; i++ ) {
      TableItem item = wHeaders.getNonEmpty( i );
      input.getHeaderField()[i] = item.getText( 1 );
      input.getHeaderParameter()[i] = item.getText( 2 );
    }

    input.setUrl( wUrl.getText() );
    input.setUrlField( wUrlField.getText() );
    input.setUrlInField( wUrlInField.getSelection() );
    input.setFieldName( wResult.getText() );
    input.setEncoding( wEncoding.getText() );
    input.setHttpLogin( wHttpLogin.getText() );
    input.setHttpPassword( wHttpPassword.getText() );
    input.setProxyHost( wProxyHost.getText() );
    input.setProxyPort( wProxyPort.getText() );
    input.setResultCodeFieldName( wResultCode.getText() );
    input.setResponseTimeFieldName( wResponseTime.getText() );
    input.setResponseHeaderFieldName( wResponseHeader.getText() );
    input.setSocketTimeout( wSocketTimeOut.getText() );
    input.setConnectionTimeout( wConnectionTimeOut.getText() );
    input.setCloseIdleConnectionsTime( wCloseIdleConnectionsTime.getText() );

    stepname = wStepname.getText(); // return value

    dispose();
  }

  private void get() {
    try {
      RowMetaInterface r = transMeta.getPrevStepFields( stepname );
      if ( r != null && !r.isEmpty() ) {
        BaseStepDialog.getFieldsFromPrevious( r, wFields, 1, new int[] { 1, 2 }, new int[] { 3 }, -1, -1, null );
      }
    } catch ( KettleException ke ) {
      new ErrorDialog(
        shell, BaseMessages.getString( PKG, "HTTPDialog.FailedToGetFields.DialogTitle" ), BaseMessages
          .getString( PKG, "HTTPDialog.FailedToGetFields.DialogMessage" ), ke );
    }
  }

  private void getHeadersFields() {
    try {
      RowMetaInterface r = transMeta.getPrevStepFields( stepname );
      if ( r != null && !r.isEmpty() ) {
        BaseStepDialog.getFieldsFromPrevious( r, wHeaders, 1, new int[] { 1, 2 }, new int[] { 3 }, -1, -1, null );
      }
    } catch ( KettleException ke ) {
      new ErrorDialog(
        shell, BaseMessages.getString( PKG, "HTTPDialog.FailedToGetFields.DialogTitle" ), BaseMessages
          .getString( PKG, "HTTPDialog.FailedToGetFields.DialogMessage" ), ke );
    }

  }
}


text:
#include "CopyLocation.moc.h"

#include <QtToolbox/ComboBox.moc.h>
#include <EPI/Document/Property.moc.h>
#include <EPI/Document/DocumentBase.moc.h>
#include <EPI/Document/Properties/PtyTransform.moc.h>
#include <EPI/Constants.h>

#include <QPushButton>

namespace EPI
{
Ptr<PtyTransform> getPtyTransformFromPtyTest(const Ptr<Property>& pPty)
{
    Ptr<PtyTransform> ret;

    if (pPty->isTransformable() == true)
    {
        Ptr<ITransformable> pTransformable = LM_DEBUG_PTR_CAST<ITransformable>(pPty);
        ret = LM_DEBUG_PTR_CAST<PtyTransform>(pTransformable->getPtyTransform());
    }
    else
    {
        ret = null;
    }

    return ret;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
struct GizmoLocation
{
    String          name;
    Core::Vector3f  worldPosition;
    Core::Matrix3f  worldAxis;
};

struct CopyLocation::implementation
{
    CopyLocation::implementation(const DocumentBase& document) : _doc(document){}

public:
    Core::List<Ptr<Property> >  _pties;
    Ptr<Property>               _pContainer;
    Core::List<GizmoLocation>   _locationGizmoDoc;
    Core::List<GizmoLocation>   _locationGizmoWorldDeco;
    const DocumentBase&         _doc;
    Core::Vector3f  _pivotInWorldAxis;
    Core::Vector3f  _centerBoundingBoxInWorldAxis;
    Core::Matrix3f  _axis;
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
CopyLocation::CopyLocation(const Ptr<StateRecorder>& pStateRecorder, const DocumentBase& doc, const Core::List<Ptr<Property> > pties):
    IViewportTool(pStateRecorder),
    _impl(new CopyLocation::implementation (doc))
{
    updatePropertiesTargets(pties);

    updateGizmoDocument();
    updateGizmoWorldDeco();

    connect (&_impl->_doc, SIGNAL(documentContentUpdated()),
             this, SLOT(updateGizmoDocument()));
}
//-----------------------------------------------------------------------------
CopyLocation::~CopyLocation()
{
    delete _impl;
}
//-----------------------------------------------------------------------------
void CopyLocation::updateGizmoDocument()
{
    Core::List<Ptr<Property> > ptiesGizmo = _impl->_doc.getAllGizmoContent();
    _impl->_locationGizmoDoc.clear();

    for (int32 ii=0; ii<ptiesGizmo.size(); ii++)
    {
        Ptr<Property> pPtyT = ptiesGizmo[ii]->getPtyTransform();

        if (pPtyT!=null)
        {
            GizmoLocation gl;
                gl.name          = ptiesGizmo[ii]->getName();
                gl.worldPosition = LM_DEBUG_PTR_CAST<PtyTransform>(pPtyT)->getWorldPosition();
                gl.worldAxis     = LM_DEBUG_PTR_CAST<PtyTransform>(pPtyT)->getWorldAxis();
            _impl->_locationGizmoDoc.push_back(gl);
        }
    }

    emit viewportToolChanged();
}
//-----------------------------------------------------------------------------
void CopyLocation::computeActionCenters()
{
    _impl->_pivotInWorldAxis.setZero();
    _impl->_centerBoundingBoxInWorldAxis.setZero();

    for (int32 ii=0; ii<_impl->_pties.size(); ++ii)
    {
        _impl->_pivotInWorldAxis               += LM_DEBUG_PTR_CAST<PtyTransform>(_impl->_pties[ii])->getWorldPosition();
        _impl->_centerBoundingBoxInWorldAxis   += LM_DEBUG_PTR_CAST<PtyTransform>(_impl->_pties[ii])->getCenterBoundingBoxInWorldAxis();
    }

    _impl->_pivotInWorldAxis               /= _impl->_pties.size();
    _impl->_centerBoundingBoxInWorldAxis   /= _impl->_pties.size();
}
//-----------------------------------------------------------------------------
void CopyLocation::computeActionOrientations()
{
    if (_impl->_pties.size()> 0)
    {
        _impl->_axis = LM_DEBUG_PTR_CAST<PtyTransform>(_impl->_pties[0])->getWorldAxis();
    }
}
//-----------------------------------------------------------------------------
void CopyLocation::updatePropertiesTargets(const Core::List<Ptr<Property> >& ptiesSelected)
{
    _impl->_pties.clear();

    for (int32 ii=0; ii<ptiesSelected.size(); ++ii)
    {
        Ptr<PtyTransform> pPtyTransform = getPtyTransformFromPtyTest(ptiesSelected[ii]);

        if (pPtyTransform!=null)
        {
            _impl->_pties.push_back(pPtyTransform);
        }
    }

    _impl->_pties = removeChildren(_impl->_pties);

    updateViewportTool();
}
//-----------------------------------------------------------------------------
void CopyLocation::updateGizmoWorldDeco()
{
    Ptr<Universe::World> pWorld = const_cast<DocumentBase&>(_impl->_doc).getWorldDeco();

    _impl->_locationGizmoWorldDeco.clear();

    if (pWorld!=null)
    {
        Core::List<Ptr<Universe::Node> > nodesGizmo;
        pWorld->getNodesWithTag(TAG_GIZMO, nodesGizmo);

        for (int32 ii=0; ii<nodesGizmo.size(); ii++)
        {
            GizmoLocation gl;
                gl.name          = nodesGizmo[ii]->getName();
                gl.worldPosition = nodesGizmo[ii]->getWorldPosition();
                gl.worldAxis     = nodesGizmo[ii]->getLocalToWorldMatrix().getRotation();
            _impl->_locationGizmoWorldDeco.push_back(gl);
        }
    }
    emit viewportToolChanged();
}
//-----------------------------------------------------------------------------
Ptr<IViewportToolWidget> CopyLocation::createViewportToolWidget(QWidget * parent)
{
    return Ptr<IViewportToolWidget> (new CopyLocationWidget(*this, parent));
}
//-----------------------------------------------------------------------------
void CopyLocation::guiConfigure(Ptr<Universe::World>& pWorld, const DrawContext& dc)
{

}
//-----------------------------------------------------------------------------
const Core::List<Ptr<Property> >& CopyLocation::getProperties() const
{
    return _impl->_pties;
}
//-----------------------------------------------------------------------------
Core::List<Ptr<Property> >& CopyLocation::getProperties()
{
    return _impl->_pties;
}
//-----------------------------------------------------------------------------
void CopyLocation::selectionChanged(const Core::List<Ptr<Property> >& pties)
{
    updatePropertiesTargets(pties);
}
//-----------------------------------------------------------------------------
bool CopyLocation::isHighlighted() const
{
    return false;
}
//-----------------------------------------------------------------------------
bool CopyLocation::isSelected() const
{
    return false;
}
//-----------------------------------------------------------------------------
void CopyLocation::updateViewportTool()
{
    computeActionCenters();
    computeActionOrientations();
}
//-----------------------------------------------------------------------------
void CopyLocation::setContainer(const Ptr<Property>& pContainer)
{
    _impl->_pContainer = pContainer;
}
//-----------------------------------------------------------------------------
bool CopyLocation::getLocation(const String& name, Core::Vector3f& worldPos, Core::Matrix3f& worldAxis)
{
    bool ret = false;

    for (int32 ii=0; ii<_impl->_locationGizmoDoc.size(); ii++)
    {
        if (_impl->_locationGizmoDoc[ii].name == name)
        {
            worldPos  = _impl->_locationGizmoDoc[ii].worldPosition;
            worldAxis = _impl->_locationGizmoDoc[ii].worldAxis;
            ret = true;
            break;
        }
    }

    if (ret == false)
    {
        for (int32 ii=0; ii<_impl->_locationGizmoWorldDeco.size(); ii++)
        {
            if (_impl->_locationGizmoWorldDeco[ii].name == name)
            {
                worldPos  = _impl->_locationGizmoWorldDeco[ii].worldPosition;
                worldAxis = _impl->_locationGizmoWorldDeco[ii].worldAxis;
                ret = true;
                break;
            }
        }
    }

    return ret;
}
//-----------------------------------------------------------------------------
void CopyLocation::apply(const String& name)
{
    Core::Vector3f worldPos;
    Core::Matrix3f worldAxis;

    if (getLocation(name, worldPos, worldAxis) == true)
    {
        bool isModified = false;
        beginPropertiesChange();

        Core::Vector3f offset     = worldPos - _impl->_pivotInWorldAxis;
        Core::Matrix3f offsetAxis = _impl->_axis.getTransposed() * worldAxis;

        for (int32 ii=0; ii<_impl->_pties.size(); ++ii)
        {
            Ptr<PtyTransform>   pPtyT = LM_DEBUG_PTR_CAST<PtyTransform>(_impl->_pties[ii]);
            pPtyT->translateInWorldAxis(offset);
            pPtyT->addRotateInWorldAxis(offsetAxis);
            pPtyT->updateData();
            isModified = true;
        }

        if (isModified==true)
        {
            finishPropertiesChange();
        }
        else
        {
            cancelPropertiesChange();
        }
    }

    if (_impl->_pContainer!=null)
    {
        _impl->_pContainer->updateData();
    }

    updateViewportTool();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
CopyLocationWidget::CopyLocationWidget(CopyLocation& tool, QWidget * parent) :
    IViewportToolWidget(parent),
    _tool(tool)
{
    setupUi();
    updateViewportToolWidget();
}
//-----------------------------------------------------------------------------
CopyLocationWidget::~CopyLocationWidget()
{
}
//-----------------------------------------------------------------------------
IViewportTool& CopyLocationWidget::getViewportTool()
{
    return _tool;
}
//-----------------------------------------------------------------------------
void CopyLocationWidget::setupUi()
{
    _layout = new QGridLayout(NULL);

    _combo = new QtToolbox::ComboBox(this);
    _apply = new QPushButton("apply", this);
        _apply->setFixedSize(80, 20);

    _layout->addWidget(_combo, 0, 0, Qt::AlignCenter);
    _layout->addWidget(_apply, 0, 1, Qt::AlignCenter);

    setLayout(_layout);

    connect(_apply, SIGNAL(released()), this, SLOT(applyLocation()));

    IViewportToolWidget::setupUi();
}
//-----------------------------------------------------------------------------
void CopyLocationWidget::applyLocation()
{
    _tool.apply(_combo->selectedText());
}
//-----------------------------------------------------------------------------
void CopyLocationWidget::readViewportTool()
{
    Core::List<GizmoLocation>& gizmoDoc       = _tool._impl->_locationGizmoDoc;
    Core::List<GizmoLocation>& gizmoWorldDeco = _tool._impl->_locationGizmoWorldDeco;

    _combo->clear();

    for (int32 ii=0; ii<gizmoDoc.size(); ++ii)
    {
        _combo->addItem(gizmoDoc[ii].name);
    }

    for (int32 ii=0; ii<gizmoWorldDeco.size(); ++ii)
    {
        _combo->addItem(gizmoWorldDeco[ii].name);
    }
}
//-----------------------------------------------------------------------------
void CopyLocationWidget::writeViewportTool(QWidget* pWidget)
{

}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
}


text:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="false"
        android:color="@color/theme_color" /> <!-- pressed -->
    <item android:state_pressed="true"
        android:color="@color/theme_gray" /> <!-- focused -->
    <item
        android:color="@color/theme_color" />
</selector>


text:
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.wm.ex;

import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;

import java.util.EventListener;

public interface ToolWindowManagerListener extends EventListener {
  Topic<ToolWindowManagerListener> TOPIC = new Topic<>("tool window events", ToolWindowManagerListener.class);

  /**
   * Invoked when tool window with specified {@code id} is registered in {@link ToolWindowManager}.
   *
   * @param id {@code id} of registered tool window.
   */
  default void toolWindowRegistered(@NotNull String id) {
  }

  /**
   * Invoked when tool window with specified {@code id} is unregistered in {@link ToolWindowManager}.
   *
   * @param id {@code id} of tool window.
   * @param toolWindow
   */
  default void toolWindowUnregistered(@NotNull String id, @NotNull ToolWindow toolWindow) {
  }

  /**
   * Not fired on tool window registered and unregistered.
   */
  default void stateChanged(@NotNull ToolWindowManager toolWindowManager) {
    stateChanged();
  }

  /**
   * Invoked when tool window with specified {@code id} is shown.
   *
   * @param id {@code id} of shown tool window.
   * @param toolWindow shown tool window
   */
  default void toolWindowShown(@NotNull String id, @NotNull ToolWindow toolWindow) {
  }

  /**
   * @deprecated Use {{@link #stateChanged(ToolWindowManager)}}
   */
  @Deprecated
  default void stateChanged() {
  }
}


text:
<?php

namespace Sensio\Bundle\FrameworkExtraBundle\Configuration;

/**
 *
 *
 * @author     Fabien Potencier <fabien@symfony.com>
 */
class Cache implements ConfigurationInterface
{
    protected $expires;
    protected $maxage;
    protected $smaxage;

    public function getExpires()
    {
        return $this->expires;
    }

    public function setExpires($expires)
    {
        $this->expires = $expires;
    }

    public function setMaxAge($maxage)
    {
        $this->maxage = $maxage;
    }

    public function getMaxAge()
    {
        return $this->maxage;
    }

    public function setSMaxAge($smaxage)
    {
        $this->smaxage = $smaxage;
    }

    public function getSMaxAge()
    {
        return $this->smaxage;
    }

    public function getAliasName()
    {
        return 'cache';
    }
}


text:
// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.controllers' is found in controllers.js
angular.module('marvelous', ['ionic', 'marvelous.services', 'marvelous.controllers'])

.run(function ($ionicPlatform) {
    $ionicPlatform.ready(function () {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
            cordova.plugins.Keyboard.disableScroll(true);

        }
        if (window.StatusBar) {
            // org.apache.cordova.statusbar required
            StatusBar.styleDefault();
        }
    });
})

.config(function ($ionicConfigProvider) {
    if (!ionic.Platform.isIOS()) {
        $ionicConfigProvider.scrolling.jsScrolling(false);
    }
})

.config(function ($stateProvider, $urlRouterProvider) {
    $stateProvider

      .state('app', {
          url: '/app',
          abstract: true,
          templateUrl: 'templates/menu.html',
          controller: 'AppCtrl'
      })

    .state('app.comics', {
        url: '/comics',
        views: {
            'menuContent': {
                templateUrl: 'templates/comics.html'
            }
        }
    })
    .state('app.comic', {
        url: '/comic/:comicId',
        views: {
            'menuContent': {
                templateUrl: 'templates/comic.html',
                controller: 'ComicCtrl'
            }
        }
    })

    .state('app.camera', {
        url: '/camera',
        views: {
            'menuContent': {
                templateUrl: 'templates/camera.html',
                controller: 'CameraCtrl'
            }
        }
    })
    .state('app.characters', {
        url: '/characters',
        views: {
            'menuContent': {
                templateUrl: 'templates/characters.html',
                controller: 'CharactersCtrl'
            }
        }
    })
    .state('app.character', {
        url: '/character/:characterId',
        views: {
            'menuContent': {
                templateUrl: 'templates/character.html',
                controller: 'CharacterCtrl'
            }
        }
    })
    .state('app.donate', {
        url: '/donate',
        views: {
            'menuContent': {
                templateUrl: 'templates/donate.html',
                controller: 'DonateCtrl'
            }
        }
    });
    // if none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/app/characters');
});

angular.module('marvelous.services', []);

angular.module('marvelous.controllers', ['marvelous.services', 'ngCordova'])
.controller('AppCtrl', function ($scope, $rootScope, $ionicModal, $timeout) {

    // With the new view caching in Ionic, Controllers are only called
    // when they are recreated or on app start, instead of every page change.
    // To listen for when this page is active (for example, to refresh data),
    // listen for the $ionicView.enter event:
    //$scope.$on('$ionicView.enter', function(e) {
    //});

    //setup IAP junk here
    document.addEventListener('deviceready', initializeStore, false);

    function initializeStore() {

        if (!store) {
            //Where the fuck is the store?
            return;
        }

        //Testing IAPs
        if (store.plugin && store.plugin.setTestMode) {
            store.plugin.setTestMode(true);
        }

        store.register({
            id: "donate_1",
            alias: "Buy me a beer",
            type: store.CONSUMABLE
        });

        store.register({
            id: "donate_2",
            alias: "Beer beer beer!",
            type: store.CONSUMABLE
        });

        store.when("donate_1").approved(function () {
            $rootScope.$broadcast('purchase', "donate_1");
        });

        store.when("donate_2").approved(function () {
            $rootScope.$broadcast('purchase', "donate_2");
        });

        store.refresh();
    };

    //global scope methods
    $scope.buildThumbnailPath = function (thumbnail) {
        if (!thumbnail) {
            return null;
        }
        return thumbnail.path + "." + thumbnail.extension;
    };

    $scope.extractIdFromUrl = function (url) {
        try{
            return url.substring(url.lastIndexOf('/') + 1);
        }
        catch(ex) {
            return null;
        }
    };

});


text:
class Fixnum
  # Fixnum#hash already implemented for you
end

class Array
  def hash
    sum = 0
    self.each_with_index do |item, i|
      sum += (item * i) if item.is_a?(Fixnum)
    end
    sum.hash
  end
end

class String
  def hash
    sum = 0
    self.each_char.with_index do |char, i|
      sum += (char.ord * i)
    end
    sum.hash
  end
end

class Hash
  # This returns 0 because rspec will break if it returns nil
  # Make sure to implement an actual Hash#hash method
  def hash
    sum = 0
    self.each do |key, val|
      sum += (key.to_s.ord + val.ord)
    end
    sum.hash
  end
end


text:
import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
import { FieldType } from '@ngx-formly/core';

@Component({
	selector: 'lu-formly-field-checkbox',
	styleUrls: ['formly-field.common.scss'],
	templateUrl: './checkbox.html',
	// changeDetection: ChangeDetectionStrategy.OnPush,
})
// eslint-disable-next-line @angular-eslint/component-class-suffix
export class LuFormlyFieldCheckbox extends FieldType {
	override readonly formControl: FormControl;
	focus() {
		this.to['_isFocused'] = true;
	}
	blur() {
		this.to['_isFocused'] = false;
	}
}


text:
<?php
namespace Chamilo\Libraries\Format\Form\Element\AdvancedElementFinder;

/**
 * Defines an element for an advanced element finder
 * When the element has children it becomes a category
 *
 * @package Chamilo\Libraries\Format\Form\Element\AdvancedElementFinder
 * @author Sven Vanpoucke
 */
class AdvancedElementFinderElement
{
    const PROPERTY_ID = 'id';
    const PROPERTY_TITLE = 'title';
    const PROPERTY_DESCRIPTION = 'description';
    const PROPERTY_CLASS = 'classes';
    const PROPERTY_CHILDREN = 'children';
    const PROPERTY_TYPE = 'type';
    const TYPE_SELECTABLE = 1;
    const TYPE_SELECTABLE_AND_FILTER = 2;
    const TYPE_FILTER = 3;

    /**
     * Associative array for the properties
     *
     * @var string[]
     */
    private $properties;

    /**
     *
     * @param string $id
     * @param string $class
     * @param string $title
     * @param string $description
     * @param integer $type
     */
    public function __construct($id, $class, $title, $description, $type = self :: TYPE_SELECTABLE)
    {
        $this->set_id($id);
        $this->set_class($class);
        $this->set_title($title);
        $this->set_description($description);
        $this->set_type($type);
    }

    /**
     * Sets a property in the associative array of properties
     *
     * @param string $propertyName
     * @param mixed $value
     */
    public function set_property($propertyName, $value)
    {
        $this->properties[$propertyName] = $value;
    }

    /**
     * Retrieves a property from the associative array of properties
     *
     * @param string $propertyName
     * @return mixed
     */
    public function get_property($propertyName)
    {
        return $this->properties[$propertyName];
    }

    /**
     * Sets the id of this element
     *
     * @param string $id
     */
    public function set_id($id)
    {
        $this->set_property(self::PROPERTY_ID, $id);
    }

    /**
     * Returns the id of this element
     *
     * @return string
     */
    public function get_id()
    {
        return $this->get_property(self::PROPERTY_ID);
    }

    /**
     * Sets the title of this element
     *
     * @param string $title
     */
    public function set_title($title)
    {
        $this->set_property(self::PROPERTY_TITLE, $title);
    }

    /**
     * Sets the description of this element
     *
     * @param string $description
     */
    public function set_description($description)
    {
        $this->set_property(self::PROPERTY_DESCRIPTION, $description);
    }

    /**
     * Sets the class of this element
     *
     * @param string $class
     */
    public function set_class($class)
    {
        $this->set_property(self::PROPERTY_CLASS, $class);
    }

    /**
     * Sets the type of this element
     *
     * @param string $type
     */
    public function set_type($type)
    {
        $this->set_property(self::PROPERTY_TYPE, $type);
    }

    /**
     * Sets the children of this element
     *
     * @param Array $children
     */
    public function set_children($children)
    {
        $this->set_property(self::PROPERTY_CHILDREN, $children);
    }

    /**
     * Retrieves the children of this element
     *
     * @return \Chamilo\Libraries\Format\Form\Element\AdvancedElementFinder\AdvancedElementFinderElement[]
     */
    public function get_children()
    {
        return $this->get_property(self::PROPERTY_CHILDREN);
    }

    /**
     * Adds a child to this element
     *
     * @param \Chamilo\Libraries\Format\Form\Element\AdvancedElementFinder\AdvancedElementFinderElement $child
     */
    public function add_child(AdvancedElementFinderElement $child)
    {
        $children = $this->get_children();

        $children[] = $child;

        $this->set_children($children);
    }

    /**
     * Returns this element as an array
     *
     * @return string[][]
     */
    public function as_array()
    {
        $array = $this->properties;
        $array[self::PROPERTY_CHILDREN] = array();

        $children = $this->get_children();

        foreach ($children as $child)
        {
            $array[self::PROPERTY_CHILDREN][] = $child->as_array();
        }

        return $array;
    }
}


text:
package de.zib.gndms.stuff.mold;

import org.jetbrains.annotations.NotNull;
import java.lang.reflect.InvocationHandler;

import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * This class provides methods to copy an instance which either has implemented {@link Molding} or at least has a method
 * {@code void mold(D molded)}.
 * See {@link Molder} for further details about the actual copy process and the difference to a 'normal' copy.
 *
 * @author  try ste fan pla nti kow zib
 * @version $Id$
 *
 *          User: stepn Date: 01.12.2008 Time: 11:25:18
 */
@SuppressWarnings({ "unchecked", "StaticMethodOnlyUsedInOneClass", "RawUseOfParameterizedType" })
public final class Mold {

	private Mold() {}

    /**
     * Copies {@code molding} to {@code molded} using a {@code Molder}<D>.
     * This means only the <i>D-part</i> of {@code molding} will be copied.
     * The instance {@code molding} must either implement {@link Molding} or at least it must have a method
     * {@code mold(D molded)}.
     * See {@link Molder} for further details about the copy process.
     *
     * @param moldingClass the class of the molder
     * @param molding the instance which will mold a new instance
     * @param molded the instance to be molded out of {@code molding}-instance
     */
    public static <C, D> void dynCopyMolding(final Class<C> moldingClass, final C molding, final D molded) {
		if (molding == null) return;
		if (molded == null)	return;
		final @NotNull Class<D> moldedClass = (Class<D>) molded.getClass();
		final @NotNull Molder<D> molder;
		if (molding instanceof Molding)
			molder = ((Molding) molding).molder(moldedClass);
		else
			molder = newMolderProxy( moldingClass, molding, moldedClass );
        molder.mold(molded);
	}

    /**
     * Copies an Object implementing {@code Molding} to a new instance.
     * In this case it is the same like {@code dynCopyMolding(molding.getClass(),molding,molded)}
     *
     * @param molding the instance which will mold a new instance
     * @param molded the instance to be molded out of {@code molding}-instance
     */
	public static <C extends Molding, D> void copyMolding(final C molding, final D molded) {
		if (molding == null) return;
		if (molded == null)	return;
		final Class<D> aClass = (Class<D>) molded.getClass();
		molding.molder(aClass).mold(molded);
	}

    /**
     * Implements the {@code Molder}-Interface at runtime for {@code moldingParam} and returns a {@code Molder}<D>
     * out of {@code moldingParam}.
     * Therefore {@code moldingParam} must have a method {@code void mold(D obj)}, at least in a superclass.
     *
     * @param moldingClassParam the Class of the instance supposed to mold a new instance
     * @param moldingParam the instance supposed to mold a new instance
     * @param moldedClassParam the Class of the instance to be molded
     * @return a {@code Molder}<D> out of {@code moldingParam}
     */
	public static <C, D> Molder<D> newMolderProxy(
		  @NotNull Class<C> moldingClassParam, @NotNull C moldingParam,
		  @NotNull Class<D> moldedClassParam) {
		final @NotNull Method method;
		try {
			method = Molder.class.getMethod("mold", Object.class);
		}
		catch (NoSuchMethodException e) {
			// Shouldnt happen
			throw new RuntimeException("This should not happen", e);
		}
		final @NotNull InvocationHandler handler =
			  new MoldInvocationHandler<C, D>(moldingClassParam, moldingParam,
											   method,
											   moldedClassParam);
		return (Molder<D>) Proxy.newProxyInstance(Molder.class.getClassLoader(),
												  new Class[] { Molder.class }, handler);
	}

    /**
     * An InvocationHandler for classes having a {@code mold} method.
     *
     * @see Mold
     */
	private static final class MoldInvocationHandler<C, D> implements InvocationHandler {

        /**
         * the Class of the molding instance, which should be copied
         */
        private final @NotNull Class<C> moldingClass;

        /**
         * the molding instance, which should be copied
         */
        private final @NotNull C molding;

        /**
         * the mold method of the molding instance,signature: mold(Object o)
         */
        private final @NotNull Method moldMethod;

        /**
         * the Class of the molded instance, which will be a copy of the molding instance
         */
        private final @NotNull Class<D> moldedClass;

		private MoldInvocationHandler(
			  @NotNull final Class<C> moldingClassParam,
			  @NotNull final C moldingParam, @NotNull final Method moldMethodParam,
			  @NotNull final Class<D> moldedClassParam
		) {
			moldingClass = moldingClassParam;
			moldedClass = moldedClassParam;
			molding = moldingParam;
			moldMethod = moldMethodParam;
		}

        /**
         * Tries to invoke {@code mold(molded)} on the Object {@code molding}.
         * @param proxy
         * @param method
         * @param args
         * @return
         * @throws Throwable  if {@code moldingClass} and all it's superclasses dont have a method {@code void mold(Object )}
         *
         */
        @SuppressWarnings({ "unchecked" })
		public Object invoke(final Object proxy, final Method method, final Object[] args)
			  throws Throwable {
			if (moldMethod.equals(method) && args[0] != null)
					doMold(args[0]);
			else
				if (Object.class.equals(method.getDeclaringClass()))
					method.invoke(molding, args);
				else
					throw new IllegalArgumentException("Unknown method: " + method);
			return null;
		}

        /**
         * Tries to invoke {@code mold(molded)} on the Object {@code molding}.
         * If {@code molding} does not have a method {@code mold(C molded)} where {@code C} is
         * {@code moldedClass} or one of its superclasses, an exception will be thrown.
         *
         * @param molded the Object, the {@code mold} method should be invoked with
         * @throws Throwable if {@code moldingClass} and all it's superclasses dont have a method {@code void mold(Object )}
         */
        private void doMold(final @NotNull Object molded)
			  throws Throwable {
            Class curClass = moldedClass;
            while (! Object.class.equals(curClass)) {
                try {
                    moldingClass.getMethod("mold", curClass).invoke(molding,  curClass.cast(molded));
                    return;
                }
                catch (NoSuchMethodException nme) {
                    curClass = curClass.getSuperclass();
                    if (Object.class.equals(curClass))
                        throw nme;
                }
            }
        }
	}
}


text:
'use strict';

const models = require('./index');

/**
 * @class
 * Initializes a new instance of the SearchGetSchemaResponse class.
 * @constructor
 * The get schema operation response.
 *
 * @member {object} [metadata] The metadata from search results.
 *
 * @member {string} [metadata.searchId] The request id of the search.
 *
 * @member {string} [metadata.resultType] The search result type.
 *
 * @member {number} [metadata.total] The total number of search results.
 *
 * @member {number} [metadata.top] The number of top search results.
 *
 * @member {string} [metadata.id] The id of the search results request.
 *
 * @member {array} [metadata.coreSummaries] The core summaries.
 *
 * @member {string} [metadata.status] The status of the search results.
 *
 * @member {date} [metadata.startTime] The start time for the search.
 *
 * @member {date} [metadata.lastUpdated] The time of last update.
 *
 * @member {string} [metadata.eTag] The ETag of the search results.
 *
 * @member {array} [metadata.sort] How the results are sorted.
 *
 * @member {number} [metadata.requestTime] The request time.
 *
 * @member {string} [metadata.aggregatedValueField] The aggregated value field.
 *
 * @member {string} [metadata.aggregatedGroupingFields] The aggregated grouping
 * fields.
 *
 * @member {number} [metadata.sum] The sum of all aggregates returned in the
 * result set.
 *
 * @member {number} [metadata.max] The max of all aggregates returned in the
 * result set.
 *
 * @member {object} [metadata.schema] The schema.
 *
 * @member {string} [metadata.schema.name] The name of the metadata schema.
 *
 * @member {number} [metadata.schema.version] The version of the metadata
 * schema.
 *
 * @member {array} [value] The array of result values.
 *
 */
class SearchGetSchemaResponse {
  constructor() {
  }

  /**
   * Defines the metadata of SearchGetSchemaResponse
   *
   * @returns {object} metadata of SearchGetSchemaResponse
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'SearchGetSchemaResponse',
      type: {
        name: 'Composite',
        className: 'SearchGetSchemaResponse',
        modelProperties: {
          metadata: {
            required: false,
            serializedName: '__metadata',
            type: {
              name: 'Composite',
              className: 'SearchMetadata'
            }
          },
          value: {
            required: false,
            serializedName: 'value',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'SearchSchemaValueElementType',
                  type: {
                    name: 'Composite',
                    className: 'SearchSchemaValue'
                  }
              }
            }
          }
        }
      }
    };
  }
}

module.exports = SearchGetSchemaResponse;


text:
package table

import (
	"testing"
	"time"

	"github.com/osrg/gobgp/v3/pkg/packet/bgp"

	"github.com/stretchr/testify/assert"
)

func TestAddPath(t *testing.T) {
	pi := &PeerInfo{}
	attrs := []bgp.PathAttributeInterface{bgp.NewPathAttributeOrigin(0)}

	nlri1 := bgp.NewIPAddrPrefix(24, "20.20.20.0")
	nlri1.SetPathIdentifier(1)
	p1 := NewPath(pi, nlri1, false, attrs, time.Now(), false)
	nlri2 := bgp.NewIPAddrPrefix(24, "20.20.20.0")
	nlri2.SetPathIdentifier(2)
	p2 := NewPath(pi, nlri2, false, attrs, time.Now(), false)
	family := p1.GetRouteFamily()
	families := []bgp.RouteFamily{family}

	adj := NewAdjRib(logger, families)
	adj.Update([]*Path{p1, p2})
	assert.Equal(t, len(adj.table[family].destinations), 1)
	assert.Equal(t, adj.Count([]bgp.RouteFamily{family}), 2)

	p3 := NewPath(pi, nlri2, false, attrs, time.Now(), false)
	adj.Update([]*Path{p3})

	var found *Path
	for _, d := range adj.table[family].destinations {
		for _, p := range d.knownPathList {
			if p.GetNlri().PathIdentifier() == nlri2.PathIdentifier() {
				found = p
				break
			}
		}
	}
	assert.Equal(t, found, p3)
	adj.Update([]*Path{p3.Clone(true)})
	assert.Equal(t, adj.Count([]bgp.RouteFamily{family}), 1)
	adj.Update([]*Path{p1.Clone(true)})
	assert.Equal(t, 0, len(adj.table[family].destinations))
}

func TestAddPathAdjOut(t *testing.T) {
	pi := &PeerInfo{}
	attrs := []bgp.PathAttributeInterface{bgp.NewPathAttributeOrigin(0)}

	nlri1 := bgp.NewIPAddrPrefix(24, "20.20.20.0")
	nlri1.SetPathIdentifier(1)
	nlri1.SetPathLocalIdentifier(1)
	p1 := NewPath(pi, nlri1, false, attrs, time.Now(), false)
	nlri2 := bgp.NewIPAddrPrefix(24, "20.20.20.0")
	nlri2.SetPathIdentifier(1)
	nlri2.SetPathLocalIdentifier(2)
	p2 := NewPath(pi, nlri2, false, attrs, time.Now(), false)
	nlri3 := bgp.NewIPAddrPrefix(24, "20.20.20.0")
	nlri3.SetPathIdentifier(2)
	nlri3.SetPathLocalIdentifier(3)
	p3 := NewPath(pi, nlri3, false, attrs, time.Now(), false)
	nlri4 := bgp.NewIPAddrPrefix(24, "20.20.20.0")
	nlri4.SetPathIdentifier(3)
	nlri4.SetPathLocalIdentifier(4)
	p4 := NewPath(pi, nlri4, false, attrs, time.Now(), false)
	family := p1.GetRouteFamily()
	families := []bgp.RouteFamily{family}

	adj := NewAdjRib(logger, families)
	adj.UpdateAdjRibOut([]*Path{p1, p2, p3, p4})
	assert.Equal(t, len(adj.table[family].destinations), 1)
	assert.Equal(t, adj.Count([]bgp.RouteFamily{family}), 4)
}

func TestStale(t *testing.T) {
	pi := &PeerInfo{}
	attrs := []bgp.PathAttributeInterface{bgp.NewPathAttributeOrigin(0)}

	nlri1 := bgp.NewIPAddrPrefix(24, "20.20.10.0")
	p1 := NewPath(pi, nlri1, false, attrs, time.Now(), false)
	nlri2 := bgp.NewIPAddrPrefix(24, "20.20.20.0")
	p2 := NewPath(pi, nlri2, false, attrs, time.Now(), false)
	p2.SetRejected(true)

	family := p1.GetRouteFamily()
	families := []bgp.RouteFamily{family}

	adj := NewAdjRib(logger, families)
	adj.Update([]*Path{p1, p2})
	assert.Equal(t, adj.Count([]bgp.RouteFamily{family}), 2)
	assert.Equal(t, adj.Accepted([]bgp.RouteFamily{family}), 1)

	stalePathList := adj.StaleAll(families)
	// As looped path should not be returned
	assert.Equal(t, 1, len(stalePathList))

	for _, p := range adj.PathList([]bgp.RouteFamily{family}, false) {
		assert.True(t, p.IsStale())
	}

	nlri3 := bgp.NewIPAddrPrefix(24, "20.20.30.0")
	p3 := NewPath(pi, nlri3, false, attrs, time.Now(), false)
	adj.Update([]*Path{p1, p3})

	droppedPathList := adj.DropStale(families)
	assert.Equal(t, 2, len(droppedPathList))
	assert.Equal(t, adj.Count([]bgp.RouteFamily{family}), 1)
	assert.Equal(t, 1, len(adj.table[family].destinations))
}

func TestLLGRStale(t *testing.T) {
	pi := &PeerInfo{}
	attrs := []bgp.PathAttributeInterface{bgp.NewPathAttributeOrigin(0)}

	nlri1 := bgp.NewIPAddrPrefix(24, "20.20.10.0")
	p1 := NewPath(pi, nlri1, false, attrs, time.Now(), false)

	nlri2 := bgp.NewIPAddrPrefix(24, "20.20.20.0")
	p2 := NewPath(pi, nlri2, false, attrs, time.Now(), false)
	p2.SetRejected(true) // Not accepted

	nlri3 := bgp.NewIPAddrPrefix(24, "20.20.30.0")
	p3 := NewPath(pi, nlri3, false, attrs, time.Now(), false)
	p3.SetRejected(true)
	// Not accepted and then dropped on MarkLLGRStaleOrDrop
	p3.SetCommunities([]uint32{uint32(bgp.COMMUNITY_NO_LLGR)}, false)

	nlri4 := bgp.NewIPAddrPrefix(24, "20.20.40.0")
	p4 := NewPath(pi, nlri4, false, attrs, time.Now(), false)
	// dropped on MarkLLGRStaleOrDrop
	p4.SetCommunities([]uint32{uint32(bgp.COMMUNITY_NO_LLGR)}, false)

	family := p1.GetRouteFamily()
	families := []bgp.RouteFamily{family}

	adj := NewAdjRib(logger, families)
	adj.Update([]*Path{p1, p2, p3, p4})
	assert.Equal(t, adj.Count([]bgp.RouteFamily{family}), 4)
	assert.Equal(t, adj.Accepted([]bgp.RouteFamily{family}), 2)

	pathList := adj.MarkLLGRStaleOrDrop(families)
	assert.Equal(t, 3, len(pathList)) // Does not return aslooped path that is retained in adjrib
	assert.Equal(t, adj.Count([]bgp.RouteFamily{family}), 2)
	assert.Equal(t, adj.Accepted([]bgp.RouteFamily{family}), 1)
	assert.Equal(t, 2, len(adj.table[family].destinations))
}


text:
if (process.env.NODE_ENV !== 'development' || Meteor.isTest)
  return;

Meteor.settings.public.HOT_PORT = parseInt(process.env.HOT_PORT);