Search in sources :

Example 1 with CompareViewerSwitchingPane

use of org.eclipse.compare.CompareViewerSwitchingPane 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)

Example 2 with CompareViewerSwitchingPane

use of org.eclipse.compare.CompareViewerSwitchingPane in project subclipse by subclipse.

the class MergeWizardRevisionsPage method createControl.

public void createControl(Composite parent) {
    final MergeWizard wizard = (MergeWizard) getWizard();
    resources = wizard.getResources();
    if (resources != null && resources.length > 0) {
        svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]);
        try {
            repositoryLocation = svnResource.getRepository();
        } catch (Exception e1) {
        }
    }
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    GridData data = new GridData(GridData.FILL_BOTH);
    composite.setLayoutData(data);
    horizontalSash = new SashForm(composite, SWT.HORIZONTAL);
    horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    verticalSash = new SashForm(horizontalSash, SWT.VERTICAL);
    GridLayout sashLayout = new GridLayout();
    sashLayout.verticalSpacing = 0;
    sashLayout.marginHeight = 0;
    verticalSash.setLayout(sashLayout);
    verticalSash.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite historyGroup = new Composite(verticalSash, SWT.NULL);
    GridLayout historyLayout = new GridLayout();
    historyLayout.verticalSpacing = 5;
    historyLayout.marginHeight = 0;
    historyGroup.setLayout(historyLayout);
    historyGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite filterGroup = new Composite(historyGroup, SWT.NULL);
    GridLayout filterLayout = new GridLayout();
    filterLayout.verticalSpacing = 0;
    filterLayout.marginHeight = 0;
    filterLayout.numColumns = 3;
    filterGroup.setLayout(filterLayout);
    filterGroup.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
    Label filterLabel = new Label(filterGroup, SWT.NULL);
    filterLabel.setText(Messages.MergeWizardRevisionsPage_filter);
    filterText = new Text(filterGroup, SWT.BORDER);
    filterText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
    filterText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            tableHistoryViewer.addFilter(new TextViewFilter());
            tableHistoryViewer.refresh();
            TableItem[] items = tableHistoryViewer.getTable().getItems();
            for (TableItem item : items) {
                ILogEntry entry = adaptToLogEntry(item.getData());
                if (entry != null) {
                    SVNRevision.Number revision = entry.getRevision();
                    item.setChecked(selectedRevisions.contains(revision));
                }
            }
            showMessage();
        }
    });
    this.moreOptionsButton = new Button(filterGroup, 8);
    this.moreOptionsButton.setText(Messages.MergeWizardRevisionsPage_moreOptions);
    SelectionListener selectionListener = getSelectionListener();
    this.moreOptionsButton.addSelectionListener(selectionListener);
    historyTableProvider = new HistoryTableProvider(SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK, pageName);
    historyTableProvider.setIncludeMergeRevisions(false);
    historyTableProvider.setIncludeTags(false);
    tableHistoryViewer = historyTableProvider.createTable(historyGroup);
    data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 500;
    data.heightHint = 100;
    tableHistoryViewer.getTable().setLayoutData(data);
    tableHistoryViewer.setContentProvider(new IStructuredContentProvider() {

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        public Object[] getElements(Object inputElement) {
            if (entries == null)
                return new ILogEntry[0];
            return entries;
        }
    });
    tableHistoryViewer.setInput(getUrl());
    tableHistoryViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            generateChangeLogButton.setEnabled(!tableHistoryViewer.getSelection().isEmpty());
            TableItem[] items = tableHistoryViewer.getTable().getItems();
            for (TableItem item : items) {
                ILogEntry entry = adaptToLogEntry(item.getData());
                SVNRevision.Number revision = entry.getRevision();
                if (item.getChecked()) {
                    selectedRevisions.add(revision);
                } else {
                    selectedRevisions.remove(revision);
                }
            }
            if (selectedRevisions.size() == 0) {
                if (message == null)
                    showMessage();
                else
                    setMessage(message);
            } else {
                // check size of entries and table data
                setMessage(selectedRevisions.size() + Messages.MergeWizardRevisionsPage_revisionsSelected);
            }
            setPageComplete(canFinish());
        }
    });
    tableHistoryViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            setPageComplete(canFinish());
            ISelection selection = event.getSelection();
            if (selection == null || !(selection instanceof IStructuredSelection)) {
                // $NON-NLS-1$
                textViewer.setDocument(new Document(""));
                changePathsViewer.setInput(null);
                return;
            }
            IStructuredSelection ss = (IStructuredSelection) selection;
            if (ss.size() != 1) {
                // $NON-NLS-1$
                textViewer.setDocument(new Document(""));
                changePathsViewer.setInput(null);
                return;
            }
            LogEntry entry = (LogEntry) ss.getFirstElement();
            textViewer.setDocument(new Document(entry.getComment()));
            changePathsViewer.setCurrentLogEntry(entry);
            changePathsViewer.setInput(entry);
        }
    });
    generateChangeLogAction = new GenerateChangeLogAction(new ISelectionProvider() {

        public void addSelectionChangedListener(ISelectionChangedListener listener) {
        }

        public ISelection getSelection() {
            return tableHistoryViewer.getSelection();
        }

        public void setSelection(ISelection selection) {
        }

        public void removeSelectionChangedListener(ISelectionChangedListener listener) {
        }
    });
    MenuManager menuMgr = new MenuManager();
    Menu menu = menuMgr.createContextMenu(tableHistoryViewer.getTable());
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager menuMgr) {
            if (!tableHistoryViewer.getSelection().isEmpty()) {
                menuMgr.add(new ToggleSelectionAction());
                menuMgr.add(generateChangeLogAction);
            }
        }
    });
    menuMgr.setRemoveAllWhenShown(true);
    tableHistoryViewer.getTable().setMenu(menu);
    Composite commentGroup = new Composite(verticalSash, SWT.NULL);
    GridLayout commentLayout = new GridLayout();
    commentLayout.verticalSpacing = 0;
    commentLayout.marginHeight = 0;
    commentGroup.setLayout(commentLayout);
    commentGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    textViewer = new TextViewer(commentGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.READ_ONLY);
    data = new GridData(GridData.FILL_BOTH);
    data.heightHint = 100;
    data.widthHint = 500;
    textViewer.getControl().setLayoutData(data);
    Composite pathGroup = new Composite(verticalSash, SWT.NULL);
    GridLayout pathLayout = new GridLayout();
    pathLayout.verticalSpacing = 0;
    pathLayout.marginHeight = 0;
    pathGroup.setLayout(pathLayout);
    pathGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    ViewForm viewerPane = new ViewForm(pathGroup, SWT.BORDER | SWT.FLAT);
    viewerPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    CLabel toolbarLabel = new CLabel(viewerPane, SWT.NONE) {

        public Point computeSize(int wHint, int hHint, boolean changed) {
            return super.computeSize(wHint, Math.max(24, hHint), changed);
        }
    };
    toolbarLabel.setText(Messages.MergeWizardRevisionsPage_2);
    viewerPane.setTopLeft(toolbarLabel);
    ToolBar toolbar = new ToolBar(viewerPane, SWT.FLAT);
    viewerPane.setTopCenter(toolbar);
    ToolBarManager toolbarManager = new ToolBarManager(toolbar);
    toolbarManager.add(new Separator());
    toolbarManager.add(new // $NON-NLS-1$
    ControlContribution(// $NON-NLS-1$
    "showCompare") {

        @Override
        protected Control createControl(Composite parent) {
            showCompareButton = new Button(parent, SWT.TOGGLE | SWT.FLAT);
            showCompareButton.setImage(SVNUIPlugin.getImage(ISVNUIConstants.IMG_SYNCPANE));
            showCompareButton.setToolTipText(Messages.MergeWizardRevisionsPage_4);
            showCompareButton.setSelection(showCompare);
            showCompareButton.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent e) {
                    showComparePane(!showCompare);
                    if (showCompare) {
                        compareRevisions();
                    }
                }
            });
            return showCompareButton;
        }
    });
    toolbarManager.update(true);
    ChangePathsTreeContentProvider contentProvider = new ChangePathsTreeContentProvider();
    changePathsViewer = new ChangePathsTreeViewer(viewerPane, contentProvider);
    viewerPane.setContent(changePathsViewer.getTree());
    changePathsViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            compareRevisions();
        }
    });
    changePathsViewer.getTree().addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (showCompare) {
                compareRevisions();
            }
        }
    });
    setPageComplete(canFinish());
    if (message == null)
        setMessage(Messages.MergeWizardRevisionsPage_specifyRevisions);
    else
        setMessage(message);
    try {
        int[] weights = new int[3];
        // $NON-NLS-1$
        weights[0] = settings.getInt("MergeWizardRevisionsPageWeights0");
        // $NON-NLS-1$
        weights[1] = settings.getInt("MergeWizardRevisionsPageWeights1");
        // $NON-NLS-1$
        weights[2] = settings.getInt("MergeWizardRevisionsPageWeights2");
        verticalSash.setWeights(weights);
    } catch (Exception e) {
    }
    compareViewerPane = new CompareViewerSwitchingPane(horizontalSash, SWT.BORDER | SWT.FLAT) {

        protected Viewer getViewer(Viewer oldViewer, Object input) {
            CompareConfiguration cc = compareInput.getCompareConfiguration();
            cc.setLeftEditable(false);
            cc.setRightEditable(false);
            cc.setLeftLabel(compareInput.getLeftLabel());
            cc.setRightLabel(compareInput.getRightLabel());
            return CompareUI.findContentViewer(oldViewer, input, this, cc);
        }
    };
    compareViewerPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    try {
        int[] weights = new int[2];
        // $NON-NLS-1$
        weights[0] = settings.getInt("MergeWizardRevisionsPageWeightsHorizontal0");
        // $NON-NLS-1$
        weights[1] = settings.getInt("MergeWizardRevisionsPageWeightsHorizontal1");
        horizontalSash.setWeights(weights);
    } catch (Exception e) {
    }
    Composite buttonGroup = new Composite(composite, SWT.NULL);
    GridLayout buttonLayout = new GridLayout();
    buttonLayout.numColumns = 3;
    buttonGroup.setLayout(buttonLayout);
    data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    buttonGroup.setLayoutData(data);
    generateChangeLogButton = new Button(buttonGroup, SWT.PUSH);
    generateChangeLogButton.setText(Messages.MergeWizardRevisionsPage_generateChangeLog);
    generateChangeLogButton.setEnabled(false);
    generateChangeLogButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            generateChangeLogAction.run();
        }
    });
    if (!showCompare) {
        horizontalSash.setMaximizedControl(verticalSash);
    } else {
        showCompareButton.setSelection(true);
    }
    setControl(composite);
}
Also used : ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) TableItem(org.eclipse.swt.widgets.TableItem) CLabel(org.eclipse.swt.custom.CLabel) Label(org.eclipse.swt.widgets.Label) ChangePathsTreeViewer(org.tigris.subversion.subclipse.ui.history.ChangePathsTreeViewer) TextViewer(org.eclipse.jface.text.TextViewer) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Document(org.eclipse.jface.text.Document) TextViewer(org.eclipse.jface.text.TextViewer) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GenerateChangeLogAction(org.tigris.subversion.subclipse.ui.actions.GenerateChangeLogAction) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) CompareViewerSwitchingPane(org.eclipse.compare.CompareViewerSwitchingPane) ChangePathsTreeViewer(org.tigris.subversion.subclipse.ui.history.ChangePathsTreeViewer) ViewForm(org.eclipse.swt.custom.ViewForm) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) SelectionListener(org.eclipse.swt.events.SelectionListener) CLabel(org.eclipse.swt.custom.CLabel) ModifyListener(org.eclipse.swt.events.ModifyListener) CompareConfiguration(org.eclipse.compare.CompareConfiguration) ToolBarManager(org.eclipse.jface.action.ToolBarManager) HistoryTableProvider(org.tigris.subversion.subclipse.ui.history.HistoryTableProvider) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelection(org.eclipse.jface.viewers.ISelection) Menu(org.eclipse.swt.widgets.Menu) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) LogEntry(org.tigris.subversion.subclipse.core.history.LogEntry) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SVNException(org.tigris.subversion.subclipse.core.SVNException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) MalformedURLException(java.net.MalformedURLException) IMenuListener(org.eclipse.jface.action.IMenuListener) SashForm(org.eclipse.swt.custom.SashForm) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Example 3 with CompareViewerSwitchingPane

use of org.eclipse.compare.CompareViewerSwitchingPane in project subclipse by subclipse.

the class MergeWizardUnblockRevisionsPage method createControl.

public void createControl(Composite parent) {
    final MergeWizard wizard = (MergeWizard) getWizard();
    resource = wizard.getResource();
    if (resource != null) {
        svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        try {
            repositoryLocation = svnResource.getRepository();
        } catch (Exception e1) {
        }
    }
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    GridData data = new GridData(GridData.FILL_BOTH);
    composite.setLayoutData(data);
    horizontalSash = new SashForm(composite, SWT.HORIZONTAL);
    horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    verticalSash = new SashForm(horizontalSash, SWT.VERTICAL);
    GridLayout sashLayout = new GridLayout();
    sashLayout.verticalSpacing = 0;
    sashLayout.marginHeight = 0;
    verticalSash.setLayout(sashLayout);
    verticalSash.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite historyGroup = new Composite(verticalSash, SWT.NULL);
    GridLayout historyLayout = new GridLayout();
    historyLayout.verticalSpacing = 0;
    historyLayout.marginHeight = 0;
    historyGroup.setLayout(historyLayout);
    historyGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    historyTableProvider = new HistoryTableProvider(SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK, // $NON-NLS-1$
    "MergeWizardUnblockRevisionsPage");
    historyTableProvider.setIncludeMergeRevisions(false);
    historyTableProvider.setIncludeTags(false);
    tableHistoryViewer = historyTableProvider.createTable(historyGroup);
    data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 500;
    data.heightHint = 100;
    tableHistoryViewer.getTable().setLayoutData(data);
    tableHistoryViewer.setContentProvider(new IStructuredContentProvider() {

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        public Object[] getElements(Object inputElement) {
            if (entries == null)
                return new ILogEntry[0];
            return entries;
        }
    });
    tableHistoryViewer.setInput(fromUrl);
    tableHistoryViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            setPageComplete(canFinish());
            ISelection selection = event.getSelection();
            if (selection == null || !(selection instanceof IStructuredSelection)) {
                // $NON-NLS-1$
                textViewer.setDocument(new Document(""));
                changePathsViewer.setInput(null);
                return;
            }
            IStructuredSelection ss = (IStructuredSelection) selection;
            if (ss.size() != 1) {
                // $NON-NLS-1$
                textViewer.setDocument(new Document(""));
                changePathsViewer.setInput(null);
                return;
            }
            LogEntry entry = (LogEntry) ss.getFirstElement();
            textViewer.setDocument(new Document(entry.getComment()));
            changePathsViewer.setCurrentLogEntry(entry);
            changePathsViewer.setInput(entry);
        }
    });
    MenuManager menuMgr = new MenuManager();
    Menu menu = menuMgr.createContextMenu(tableHistoryViewer.getTable());
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager menuMgr) {
            if (!tableHistoryViewer.getSelection().isEmpty()) {
                menuMgr.add(new ToggleSelectionAction());
            }
        }
    });
    menuMgr.setRemoveAllWhenShown(true);
    tableHistoryViewer.getTable().setMenu(menu);
    Composite commentGroup = new Composite(verticalSash, SWT.NULL);
    GridLayout commentLayout = new GridLayout();
    commentLayout.verticalSpacing = 0;
    commentLayout.marginHeight = 0;
    commentGroup.setLayout(commentLayout);
    commentGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    textViewer = new TextViewer(commentGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.READ_ONLY);
    data = new GridData(GridData.FILL_BOTH);
    data.heightHint = 100;
    data.widthHint = 500;
    textViewer.getControl().setLayoutData(data);
    Composite pathGroup = new Composite(verticalSash, SWT.NULL);
    GridLayout pathLayout = new GridLayout();
    pathLayout.verticalSpacing = 0;
    pathLayout.marginHeight = 0;
    pathGroup.setLayout(pathLayout);
    pathGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    ViewForm viewerPane = new ViewForm(pathGroup, SWT.BORDER | SWT.FLAT);
    viewerPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    CLabel toolbarLabel = new CLabel(viewerPane, SWT.NONE) {

        public Point computeSize(int wHint, int hHint, boolean changed) {
            return super.computeSize(wHint, Math.max(24, hHint), changed);
        }
    };
    toolbarLabel.setText(Messages.MergeWizardRevisionsPage_2);
    viewerPane.setTopLeft(toolbarLabel);
    ToolBar toolbar = new ToolBar(viewerPane, SWT.FLAT);
    viewerPane.setTopCenter(toolbar);
    ToolBarManager toolbarManager = new ToolBarManager(toolbar);
    toolbarManager.add(new Separator());
    toolbarManager.add(new // $NON-NLS-1$
    ControlContribution(// $NON-NLS-1$
    "showCompare") {

        @Override
        protected Control createControl(Composite parent) {
            showCompareButton = new Button(parent, SWT.TOGGLE | SWT.FLAT);
            showCompareButton.setImage(SVNUIPlugin.getImage(ISVNUIConstants.IMG_SYNCPANE));
            showCompareButton.setToolTipText(Messages.MergeWizardRevisionsPage_4);
            showCompareButton.setSelection(showCompare);
            showCompareButton.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent e) {
                    showComparePane(!showCompare);
                    if (showCompare) {
                        compareRevisions();
                    }
                }
            });
            return showCompareButton;
        }
    });
    toolbarManager.update(true);
    ChangePathsTreeContentProvider contentProvider = new ChangePathsTreeContentProvider();
    changePathsViewer = new ChangePathsTreeViewer(viewerPane, contentProvider);
    viewerPane.setContent(changePathsViewer.getTree());
    changePathsViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            compareRevisions();
        }
    });
    changePathsViewer.getTree().addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (showCompare) {
                compareRevisions();
            }
        }
    });
    setPageComplete(false);
    setMessage(Messages.MergeWizardUnblockRevisionsPage_specifyRevisions);
    try {
        int[] weights = new int[3];
        // $NON-NLS-1$
        weights[0] = settings.getInt("MergeWizardRevisionsPageWeights0");
        // $NON-NLS-1$
        weights[1] = settings.getInt("MergeWizardRevisionsPageWeights1");
        // $NON-NLS-1$
        weights[2] = settings.getInt("MergeWizardRevisionsPageWeights2");
        verticalSash.setWeights(weights);
    } catch (Exception e) {
    }
    compareViewerPane = new CompareViewerSwitchingPane(horizontalSash, SWT.BORDER | SWT.FLAT) {

        protected Viewer getViewer(Viewer oldViewer, Object input) {
            CompareConfiguration cc = compareInput.getCompareConfiguration();
            cc.setLeftEditable(false);
            cc.setRightEditable(false);
            cc.setLeftLabel(compareInput.getLeftLabel());
            cc.setRightLabel(compareInput.getRightLabel());
            return CompareUI.findContentViewer(oldViewer, input, this, cc);
        }
    };
    compareViewerPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    try {
        int[] weights = new int[2];
        // $NON-NLS-1$
        weights[0] = settings.getInt("MergeWizardRevisionsPageWeightsHorizontal0");
        // $NON-NLS-1$
        weights[1] = settings.getInt("MergeWizardRevisionsPageWeightsHorizontal1");
        horizontalSash.setWeights(weights);
    } catch (Exception e) {
    }
    if (!showCompare) {
        horizontalSash.setMaximizedControl(verticalSash);
    } else {
        showCompareButton.setSelection(true);
    }
    setControl(composite);
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) CompareConfiguration(org.eclipse.compare.CompareConfiguration) TableViewer(org.eclipse.jface.viewers.TableViewer) ChangePathsTreeViewer(org.tigris.subversion.subclipse.ui.history.ChangePathsTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) TextViewer(org.eclipse.jface.text.TextViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Document(org.eclipse.jface.text.Document) ToolBarManager(org.eclipse.jface.action.ToolBarManager) HistoryTableProvider(org.tigris.subversion.subclipse.ui.history.HistoryTableProvider) TextViewer(org.eclipse.jface.text.TextViewer) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) LogEntry(org.tigris.subversion.subclipse.core.history.LogEntry) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) CompareViewerSwitchingPane(org.eclipse.compare.CompareViewerSwitchingPane) ChangePathsTreeViewer(org.tigris.subversion.subclipse.ui.history.ChangePathsTreeViewer) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) IMenuListener(org.eclipse.jface.action.IMenuListener) SashForm(org.eclipse.swt.custom.SashForm) ViewForm(org.eclipse.swt.custom.ViewForm) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ToolBar(org.eclipse.swt.widgets.ToolBar) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Aggregations

CompareConfiguration (org.eclipse.compare.CompareConfiguration)3 CompareViewerSwitchingPane (org.eclipse.compare.CompareViewerSwitchingPane)3 Viewer (org.eclipse.jface.viewers.Viewer)3 SashForm (org.eclipse.swt.custom.SashForm)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IMenuListener (org.eclipse.jface.action.IMenuListener)2 IMenuManager (org.eclipse.jface.action.IMenuManager)2 MenuManager (org.eclipse.jface.action.MenuManager)2 Separator (org.eclipse.jface.action.Separator)2 ToolBarManager (org.eclipse.jface.action.ToolBarManager)2 Document (org.eclipse.jface.text.Document)2 TextViewer (org.eclipse.jface.text.TextViewer)2 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)2 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)2 ISelection (org.eclipse.jface.viewers.ISelection)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)2