Search in sources :

Example 1 with IClosableWizard

use of org.tigris.subversion.subclipse.ui.wizards.IClosableWizard in project subclipse by subclipse.

the class SvnWizardBranchTagPage method createControls.

public void createControls(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite top = new Composite(composite, SWT.NULL);
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    top.setLayout(gridLayout);
    top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    Group repositoryGroup = new Group(top, SWT.NULL);
    // $NON-NLS-1$
    repositoryGroup.setText(Policy.bind("BranchTagDialog.repository"));
    repositoryGroup.setLayout(new GridLayout());
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    repositoryGroup.setLayoutData(data);
    Label fromUrlLabel = new Label(repositoryGroup, SWT.NONE);
    if (resource == null)
        // $NON-NLS-1$
        fromUrlLabel.setText(Policy.bind("BranchTagDialog.fromUrl"));
    else
        // $NON-NLS-1$
        fromUrlLabel.setText(Policy.bind("BranchTagDialog.url"));
    Text urlText = new Text(repositoryGroup, SWT.BORDER);
    data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    urlText.setLayoutData(data);
    if (resource == null) {
        url = remoteResource.getUrl();
        urlText.setText(url.toString());
    } else {
        svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        try {
            url = svnResource.getStatus().getUrl();
            if (url != null)
                urlText.setText(svnResource.getStatus().getUrlString());
        } catch (SVNException e1) {
        }
    }
    urlText.setEditable(false);
    Label toUrlLabel = new Label(repositoryGroup, SWT.NONE);
    // $NON-NLS-1$
    toUrlLabel.setText(Policy.bind("BranchTagDialog.toUrl"));
    Composite urlComposite = new Composite(repositoryGroup, SWT.NULL);
    GridLayout urlLayout = new GridLayout();
    urlLayout.numColumns = 2;
    urlLayout.marginWidth = 0;
    urlLayout.marginHeight = 0;
    urlComposite.setLayout(urlLayout);
    data = new GridData(SWT.FILL, SWT.FILL, true, false);
    urlComposite.setLayoutData(data);
    toUrlCombo = new UrlCombo(urlComposite, SWT.NONE);
    toUrlCombo.init(// $NON-NLS-1$
    resource == null ? "repositoryBrowser" : resource.getProject().getName());
    toUrlCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    toUrlCombo.setText(urlText.getText());
    Button browseButton = new Button(urlComposite, SWT.PUSH);
    // $NON-NLS-1$
    browseButton.setText(Policy.bind("SwitchDialog.browse"));
    browseButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            ChooseUrlDialog dialog = new ChooseUrlDialog(getShell(), resource);
            if ((dialog.open() == ChooseUrlDialog.OK) && (dialog.getUrl() != null)) {
                toUrlCombo.setText(dialog.getUrl());
            }
        }
    });
    makeParentsButton = new Button(urlComposite, SWT.CHECK);
    // $NON-NLS-1$
    makeParentsButton.setText(Policy.bind("BranchTagDialog.makeParents"));
    data = new GridData();
    data.horizontalSpan = 2;
    makeParentsButton.setLayoutData(data);
    makeParentsButton.setSelection(// $NON-NLS-1$
    settings.getBoolean("BranchTagDialog.makeParents"));
    makeParentsButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            settings.put("BranchTagDialog.makeParents", // $NON-NLS-1$
            makeParentsButton.getSelection());
        }
    });
    // Group serverComposite = new Group(repositoryGroup, SWT.NULL);
    Group serverComposite = new Group(top, SWT.NULL);
    // $NON-NLS-1$
    serverComposite.setText(Policy.bind("BranchTagDialog.createCopy"));
    GridLayout serverLayout = new GridLayout();
    serverLayout.numColumns = 3;
    serverComposite.setLayout(serverLayout);
    data = new GridData(SWT.FILL, SWT.FILL, true, false);
    serverComposite.setLayoutData(data);
    serverButton = new Button(serverComposite, SWT.RADIO);
    // $NON-NLS-1$
    serverButton.setText(Policy.bind("BranchTagDialog.head"));
    data = new GridData();
    data.horizontalSpan = 3;
    serverButton.setLayoutData(data);
    revisionButton = new Button(serverComposite, SWT.RADIO);
    // $NON-NLS-1$
    revisionButton.setText(Policy.bind("BranchTagDialog.revision"));
    revisionText = new Text(serverComposite, SWT.BORDER);
    data = new GridData();
    data.widthHint = REVISION_WIDTH_HINT;
    revisionText.setLayoutData(data);
    if (revisionNumber == 0)
        revisionText.setEnabled(false);
    else
        revisionText.setText("" + revisionNumber);
    revisionText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            setPageComplete(canFinish());
        }
    });
    logButton = new Button(serverComposite, SWT.PUSH);
    // $NON-NLS-1$
    logButton.setText(Policy.bind("MergeDialog.showLog"));
    if (revisionNumber == 0)
        logButton.setEnabled(false);
    logButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            showLog();
        }
    });
    workingCopyButton = new Button(serverComposite, SWT.RADIO);
    // $NON-NLS-1$
    workingCopyButton.setText(Policy.bind("BranchTagDialog.working"));
    data = new GridData();
    data.horizontalSpan = 3;
    workingCopyButton.setLayoutData(data);
    if (resource == null)
        workingCopyButton.setVisible(false);
    if (revisionNumber == 0)
        serverButton.setSelection(true);
    else
        revisionButton.setSelection(true);
    SelectionListener selectionListener = new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            revisionText.setEnabled(revisionButton.getSelection());
            logButton.setEnabled(revisionButton.getSelection());
            if (revisionButton.getSelection())
                revisionText.setFocus();
            setPageComplete(canFinish());
        }
    };
    serverButton.addSelectionListener(selectionListener);
    revisionButton.addSelectionListener(selectionListener);
    workingCopyButton.addSelectionListener(selectionListener);
    if (projectProperties != null) {
        if (projectProperties.getMessage() != null) {
            addBugtrackingArea(top);
        }
    }
    commitCommentArea.createArea(composite);
    commitCommentArea.addPropertyChangeListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty() == CommitCommentArea.OK_REQUESTED && canFinish()) {
                IClosableWizard wizard = (IClosableWizard) getWizard();
                wizard.finishAndClose();
            }
        }
    });
    toUrlCombo.getCombo().setFocus();
    if (resource != null) {
        switchAfterBranchTagCheckBox = new Button(composite, SWT.CHECK);
        switchAfterBranchTagCheckBox.setText(Policy.bind("BranchTagDialog.switchAfterTagBranch"));
    }
    setPageComplete(canFinish());
    FocusListener focusListener = new FocusListener() {

        public void focusGained(FocusEvent e) {
            ((Text) e.getSource()).selectAll();
        }

        public void focusLost(FocusEvent e) {
            ((Text) e.getSource()).setText(((Text) e.getSource()).getText());
        }
    };
    revisionText.addFocusListener(focusListener);
    if (issueText != null)
        issueText.addFocusListener(focusListener);
    // set F1 help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.BRANCH_TAG_DIALOG);
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) Group(org.eclipse.swt.widgets.Group) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) UrlCombo(org.tigris.subversion.subclipse.ui.util.UrlCombo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) SVNException(org.tigris.subversion.subclipse.core.SVNException) IClosableWizard(org.tigris.subversion.subclipse.ui.wizards.IClosableWizard) FocusEvent(org.eclipse.swt.events.FocusEvent) ChooseUrlDialog(org.tigris.subversion.subclipse.ui.dialogs.ChooseUrlDialog) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 2 with IClosableWizard

use of org.tigris.subversion.subclipse.ui.wizards.IClosableWizard in project subclipse by subclipse.

the class SvnWizardCommitPage method createControls.

public void createControls(Composite composite) {
    horizontalSash = new SashForm(composite, SWT.HORIZONTAL);
    horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    verticalSash = new SashForm(horizontalSash, SWT.VERTICAL);
    // verticalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    verticalSash.setLayout(gridLayout);
    verticalSash.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite cTop = new Composite(verticalSash, SWT.NULL);
    GridLayout topLayout = new GridLayout();
    topLayout.marginHeight = 0;
    topLayout.marginWidth = 0;
    cTop.setLayout(topLayout);
    cTop.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite cBottom1 = new Composite(verticalSash, SWT.NULL);
    GridLayout bottom1Layout = new GridLayout();
    bottom1Layout.marginHeight = 0;
    bottom1Layout.marginWidth = 0;
    cBottom1.setLayout(bottom1Layout);
    cBottom1.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite cBottom2 = new Composite(cBottom1, SWT.NULL);
    GridLayout bottom2Layout = new GridLayout();
    bottom2Layout.marginHeight = 0;
    bottom2Layout.marginWidth = 0;
    cBottom2.setLayout(bottom2Layout);
    cBottom2.setLayoutData(new GridData(GridData.FILL_BOTH));
    try {
        int[] weights = new int[2];
        // $NON-NLS-1$
        weights[0] = settings.getInt("CommitDialog.weights.0");
        // $NON-NLS-1$
        weights[1] = settings.getInt("CommitDialog.weights.1");
        verticalSash.setWeights(weights);
    } catch (Exception e) {
        verticalSash.setWeights(new int[] { 5, 4 });
    }
    verticalSash.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            int[] weights = verticalSash.getWeights();
            for (int i = 0; i < weights.length; i++) // $NON-NLS-1$
            settings.put("CommitDialog.weights." + i, weights[i]);
        }
    });
    if (projectProperties != null) {
        if (projectProperties.getMessage() != null) {
            addBugtrackingArea(cTop);
        }
    }
    commitCommentArea.createArea(cTop);
    commitCommentArea.addPropertyChangeListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty() == CommitCommentArea.OK_REQUESTED && canFinish()) {
                IClosableWizard wizard = (IClosableWizard) getWizard();
                wizard.finishAndClose();
            }
        }
    });
    addResourcesArea(cBottom2);
    // set F1 help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.COMMIT_DIALOG);
    setPageComplete(canFinish());
    compareViewerPane = new CompareViewerSwitchingPane(horizontalSash, SWT.BORDER | SWT.FLAT) {

        protected Viewer getViewer(Viewer oldViewer, Object input) {
            CompareConfiguration cc = new CompareConfiguration();
            cc.setLeftEditable(false);
            cc.setRightEditable(false);
            return CompareUI.findContentViewer(oldViewer, input, this, cc);
        }
    };
    compareViewerPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    IDialogSettings section = settings.getSection(COMMIT_WIZARD_DIALOG_SETTINGS);
    showCompare = section == null ? false : section.getBoolean(SHOW_COMPARE);
    int vWeight1 = 50;
    int vWeight2 = 50;
    if (section != null) {
        try {
            vWeight1 = section.getInt(V_WEIGHT_1);
            vWeight2 = section.getInt(V_WEIGHT_2);
        } catch (NumberFormatException e) {
        }
    }
    int hWeight1 = 35;
    int hWeight2 = 65;
    if (section != null) {
        try {
            hWeight1 = section.getInt(H_WEIGHT_1);
            hWeight2 = section.getInt(H_WEIGHT_2);
        } catch (NumberFormatException e) {
        }
    }
    if (!showCompare) {
        horizontalSash.setMaximizedControl(verticalSash);
    } else {
        showCompareButton.setSelection(true);
    }
    verticalSash.setWeights(new int[] { vWeight1, vWeight2 });
    horizontalSash.setWeights(new int[] { hWeight1, hWeight2 });
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) DisposeListener(org.eclipse.swt.events.DisposeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) CompareConfiguration(org.eclipse.compare.CompareConfiguration) CompareViewerSwitchingPane(org.eclipse.compare.CompareViewerSwitchingPane) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IClosableWizard(org.tigris.subversion.subclipse.ui.wizards.IClosableWizard) SVNException(org.tigris.subversion.subclipse.core.SVNException) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GridData(org.eclipse.swt.layout.GridData)

Aggregations

IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)2 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 SVNException (org.tigris.subversion.subclipse.core.SVNException)2 IClosableWizard (org.tigris.subversion.subclipse.ui.wizards.IClosableWizard)2 CompareConfiguration (org.eclipse.compare.CompareConfiguration)1 CompareViewerSwitchingPane (org.eclipse.compare.CompareViewerSwitchingPane)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 SashForm (org.eclipse.swt.custom.SashForm)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 FocusListener (org.eclipse.swt.events.FocusListener)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1