<commit_before>/*
 * Copyright 2014 JBoss Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.kie.workbench.common.screens.explorer.client.widgets;

import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import org.guvnor.structure.repositories.Repository;

import javax.inject.Inject;

public class BranchSelector
        implements IsWidget, BranchSelectorView.Presenter {

    private BranchSelectorView view;
    private BranchChangeHandler branchChangeHandler;
    private Repository repository;

    @Inject
    public BranchSelector(BranchSelectorView view) {
        this.view = view;
        view.setPresenter(this);
    }

    public void setRepository(Repository repository) {
        this.repository = repository;
        view.clear();

        view.setCurrentBranch(repository.getCurrentBranch());

        for (String branch : repository.getBranches()) {
            if (!branch.equals(repository.getCurrentBranch())) {
                view.addBranch(branch);
            }
        }
    }

    @Override
    public void onBranchSelected(String branch) {

        if (branchChangeHandler != null) {
            branchChangeHandler.onBranchSelected(branch);
        }
    }

    public void addBranchChangeHandler(BranchChangeHandler branchChangeHandler) {<commit_msg>let's not show origin in the branch list<commit_after>/*
 * Copyright 2014 JBoss Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.kie.workbench.common.screens.explorer.client.widgets;

import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import org.guvnor.structure.repositories.Repository;

import javax.inject.Inject;

public class BranchSelector
        implements IsWidget, BranchSelectorView.Presenter {

    private BranchSelectorView view;
    private BranchChangeHandler branchChangeHandler;

    @Inject
    public BranchSelector(BranchSelectorView view) {
        this.view = view;
        view.setPresenter(this);
    }

    public void setRepository(Repository repository) {
        view.clear();

        view.setCurrentBranch(repository.getCurrentBranch());

        for (String branch : repository.getBranches()) {
            if (!branch.equals(repository.getCurrentBranch()) && !branch.equals("origin")) {
                view.addBranch(branch);
            }
        }
    }

    @Override
    public void onBranchSelected(String branch) {

        if (branchChangeHandler != null) {
            branchChangeHandler.onBranchSelected(branch);
        }
    }

    public void addBranchChangeHandler(BranchChangeHandler branchChangeHandler) {
{'fraction_non_alphanumeric': 0.08351468988030468, 'fraction_numerical': 0.004352557127312296, 'mean_word_length': 3.2459584295612007, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4236805', 'n_tokens_mistral': 953, 'n_tokens_neox': 947, 'n_words': 289}