Search in sources :

Example 1 with BranchRebaseModeCombo

use of org.eclipse.egit.ui.internal.components.BranchRebaseModeCombo in project egit by eclipse.

the class PullWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    try {
        this.remoteConfigs = RemoteConfig.getAllRemoteConfigs(repository.getConfig());
        Collections.sort(remoteConfigs, new Comparator<RemoteConfig>() {

            @Override
            public int compare(RemoteConfig first, RemoteConfig second) {
                return String.CASE_INSENSITIVE_ORDER.compare(first.getName(), second.getName());
            }
        });
        setDefaultUpstreamConfig();
    } catch (URISyntaxException e) {
        this.remoteConfigs = new ArrayList<>();
        handleError(e);
    }
    Composite res = new Composite(parent, SWT.NONE);
    res.setLayout(new GridLayout(3, false));
    Label remoteLabel = new Label(res, SWT.NONE);
    remoteLabel.setText(UIText.PushBranchPage_RemoteLabel);
    this.remoteSelectionCombo = new RemoteSelectionCombo(res, SWT.NONE, SelectionType.PUSH);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteSelectionCombo);
    setRemoteConfigs();
    remoteSelectionCombo.addRemoteSelectionListener(new IRemoteSelectionListener() {

        @Override
        public void remoteSelected(RemoteConfig rc) {
            remoteConfig = rc;
            setRefAssist(rc);
            checkPage();
        }
    });
    Button newRemoteButton = new Button(res, SWT.PUSH);
    newRemoteButton.setText(UIText.PushBranchPage_NewRemoteButton);
    GridDataFactory.fillDefaults().applyTo(newRemoteButton);
    newRemoteButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            showNewRemoteDialog();
        }
    });
    Label branchNameLabel = new Label(res, SWT.NONE);
    branchNameLabel.setText(UIText.PullWizardPage_referenceLabel);
    branchNameLabel.setToolTipText(UIText.PullWizardPage_referenceTooltip);
    remoteBranchNameText = new Text(res, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(remoteBranchNameText);
    UIUtils.addRefContentProposalToText(remoteBranchNameText, this.repository, () -> {
        if (PullWizardPage.this.assist != null) {
            return PullWizardPage.this.assist.getRefsForContentAssist(false, true);
        }
        return Collections.emptyList();
    }, true);
    remoteBranchNameText.setText(getSuggestedBranchName());
    remoteBranchNameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkPage();
        }
    });
    this.upstreamConfigComponent = new BranchRebaseModeCombo(res);
    GridDataFactory.fillDefaults().grab(true, false).span(2, 1).align(SWT.BEGINNING, SWT.CENTER).applyTo(upstreamConfigComponent.getViewer().getCombo());
    this.upstreamConfigComponent.getViewer().addSelectionChangedListener((event) -> upstreamConfig = upstreamConfigComponent.getRebaseMode());
    if (upstreamConfig != null) {
        upstreamConfigComponent.setRebaseMode(upstreamConfig);
    }
    if (this.fullBranch != null && this.fullBranch.startsWith(Constants.R_HEADS)) {
        this.rememberConfigForBranch = new Button(res, SWT.CHECK);
        GridData checkboxLayoutData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 3, 1);
        checkboxLayoutData.verticalIndent = 20;
        this.rememberConfigForBranch.setText(UIText.UpstreamConfigComponent_ConfigureUpstreamCheck);
        this.rememberConfigForBranch.setToolTipText(UIText.UpstreamConfigComponent_ConfigureUpstreamToolTip);
        this.rememberConfigForBranch.setLayoutData(checkboxLayoutData);
        this.rememberConfigForBranch.setSelection(this.configureUpstream);
        this.rememberConfigForBranch.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                configureUpstream = rememberConfigForBranch.getSelection();
                checkPage();
            }
        });
    }
    setPageComplete(isPageComplete());
    setControl(res);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArrayList(java.util.ArrayList) Label(org.eclipse.swt.widgets.Label) BranchRebaseModeCombo(org.eclipse.egit.ui.internal.components.BranchRebaseModeCombo) Text(org.eclipse.swt.widgets.Text) UIText(org.eclipse.egit.ui.internal.UIText) URISyntaxException(java.net.URISyntaxException) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) IRemoteSelectionListener(org.eclipse.egit.ui.internal.components.RemoteSelectionCombo.IRemoteSelectionListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig) RemoteSelectionCombo(org.eclipse.egit.ui.internal.components.RemoteSelectionCombo)

Example 2 with BranchRebaseModeCombo

use of org.eclipse.egit.ui.internal.components.BranchRebaseModeCombo in project egit by eclipse.

the class BranchConfigurationDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite main = new Composite(parent, SWT.NONE);
    main.setLayout(new GridLayout(2, false));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
    Label remoteLabel = new Label(main, SWT.NONE);
    remoteLabel.setText(UIText.BranchConfigurationDialog_RemoteLabel);
    remoteText = new Combo(main, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteText);
    Label branchLabel = new Label(main, SWT.NONE);
    branchLabel.setText(UIText.BranchConfigurationDialog_UpstreamBranchLabel);
    branchText = new Combo(main, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(branchText);
    // TODO do we have a constant somewhere?
    // $NON-NLS-1$
    remoteText.add(".");
    for (String remote : myConfig.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION)) remoteText.add(remote);
    remoteText.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateBranchItems();
        }
    });
    rebase = new BranchRebaseModeCombo(main);
    BranchRebaseMode rebaseMode = PullCommand.getRebaseMode(myBranchName, myConfig);
    rebase.setRebaseMode(rebaseMode);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.BEGINNING, SWT.CENTER).applyTo(rebase.getViewer().getCombo());
    String branch = myConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_MERGE);
    if (branch == null)
        // $NON-NLS-1$
        branch = "";
    branchText.setText(branch);
    String remote = myConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_REMOTE);
    if (remote == null)
        // $NON-NLS-1$
        remote = "";
    remoteText.setText(remote);
    updateBranchItems();
    applyDialogFont(main);
    return main;
}
Also used : BranchRebaseMode(org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) BranchRebaseModeCombo(org.eclipse.egit.ui.internal.components.BranchRebaseModeCombo) Combo(org.eclipse.swt.widgets.Combo) BranchRebaseModeCombo(org.eclipse.egit.ui.internal.components.BranchRebaseModeCombo)

Aggregations

BranchRebaseModeCombo (org.eclipse.egit.ui.internal.components.BranchRebaseModeCombo)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 UIText (org.eclipse.egit.ui.internal.UIText)1 RemoteSelectionCombo (org.eclipse.egit.ui.internal.components.RemoteSelectionCombo)1 IRemoteSelectionListener (org.eclipse.egit.ui.internal.components.RemoteSelectionCombo.IRemoteSelectionListener)1 BranchRebaseMode (org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode)1 RemoteConfig (org.eclipse.jgit.transport.RemoteConfig)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 GridData (org.eclipse.swt.layout.GridData)1 Button (org.eclipse.swt.widgets.Button)1 Combo (org.eclipse.swt.widgets.Combo)1 Text (org.eclipse.swt.widgets.Text)1