Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-04-28 15:44:22 +0000
committerMichael Valenta2004-04-28 15:44:22 +0000
commit9a132b16227c28211eb4a9e5c799c67b26615b84 (patch)
treee72af8169dfcea20e3ddeee8a7cf49908ed65005 /tests/org.eclipse.team.tests.core
parente91862badfc991f88a65f6a32e7a0c3bb214560a (diff)
downloadeclipse.platform.team-9a132b16227c28211eb4a9e5c799c67b26615b84.tar.gz
eclipse.platform.team-9a132b16227c28211eb4a9e5c799c67b26615b84.tar.xz
eclipse.platform.team-9a132b16227c28211eb4a9e5c799c67b26615b84.zip
Initial release of page based synchronize API
Diffstat (limited to 'tests/org.eclipse.team.tests.core')
-rw-r--r--tests/org.eclipse.team.tests.core/plugin.xml8
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java28
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestPage.java118
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestParticipant.java65
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestTreeViewerAdvisor.java42
5 files changed, 253 insertions, 8 deletions
diff --git a/tests/org.eclipse.team.tests.core/plugin.xml b/tests/org.eclipse.team.tests.core/plugin.xml
index 6b1b468a1..e6787f1ca 100644
--- a/tests/org.eclipse.team.tests.core/plugin.xml
+++ b/tests/org.eclipse.team.tests.core/plugin.xml
@@ -105,5 +105,13 @@
</view>
</extension>
+<!-- *************** Synchronize Participants **************** -->
+ <participant
+ name="Test Particpant"
+ type="static"
+ class="org.eclipse.team.tests.ui.synchronize.TestParticipant"
+ multipleInstances="false"
+ id="org.eclipse.team.tests.ui.test-participant">
+ </participant>
</plugin>
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java
index e54a53773..795738887 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java
@@ -12,9 +12,7 @@ package org.eclipse.team.tests.ui.synchronize;
import java.util.ArrayList;
import java.util.List;
-
import junit.framework.Test;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -26,6 +24,9 @@ import org.eclipse.team.internal.ui.synchronize.*;
import org.eclipse.team.tests.core.TeamTest;
import org.eclipse.team.tests.ui.views.ContentProviderTestView;
import org.eclipse.team.tests.ui.views.TestTreeViewer;
+import org.eclipse.team.ui.TeamUI;
+import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
import org.eclipse.team.ui.synchronize.TreeViewerAdvisor;
@@ -52,16 +53,27 @@ public class TestDiffNodePresentationModel extends TeamTest {
*/
protected void setUp() throws Exception {
super.setUp();
- this.set = new SyncInfoTree();
- this.configuration = new TreeViewerAdvisor(set) {
- protected ISynchronizeModelProvider getModelProvider() {
- return TestDiffNodePresentationModel.this.getDiffNodeController(set);
- }
- };
+ TestParticipant p = (TestParticipant)getParticipant(TestParticipant.ID);
+ p.reset();
+ this.set = p.getSyncInfoSet();
view = ContentProviderTestView.findViewInActivePage(null);
configuration.initializeViewer(view.getViewer());
}
+ /**
+ *
+ */
+ private ISynchronizeParticipant getParticipant(String id) throws TeamException {
+ ISynchronizeParticipantReference[] refs = TeamUI.getSynchronizeManager().getSynchronizeParticipants();
+ for (int i = 0; i < refs.length; i++) {
+ ISynchronizeParticipantReference reference = refs[i];
+ if (reference.getId().equals(id)) {
+ return reference.getParticipant();
+ }
+ }
+ return null;
+ }
+
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestPage.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestPage.java
new file mode 100644
index 000000000..430f9c86f
--- /dev/null
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestPage.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.tests.ui.synchronize;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.part.Page;
+
+/**
+ * Page for testing
+ */
+public class TestPage extends Page implements ISynchronizePage {
+
+ private ISynchronizePageConfiguration configuration;
+ private Composite composite;
+ private Viewer changesViewer;
+ private TreeViewerAdvisor viewerAdvisor;
+
+ public TestPage(ISynchronizePageConfiguration configuration) {
+ this.configuration = configuration;
+ configuration.setPage(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ composite = new Composite(parent, SWT.NONE);
+ //sc.setContent(composite);
+ GridLayout gridLayout= new GridLayout();
+ gridLayout.makeColumnsEqualWidth= false;
+ gridLayout.marginWidth= 0;
+ gridLayout.marginHeight = 0;
+ gridLayout.verticalSpacing = 0;
+ composite.setLayout(gridLayout);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.grabExcessVerticalSpace = true;
+ composite.setLayoutData(data);
+
+ // Create the changes section which, in turn, creates the changes viewer and its configuration
+ this.changesViewer = createChangesViewer(composite);
+ }
+
+ protected Viewer createChangesViewer(Composite parent) {
+ viewerAdvisor = new TreeViewerAdvisor(parent, configuration);
+ return viewerAdvisor.getViewer();
+ }
+
+ public StructuredViewerAdvisor getViewerAdvisor() {
+ return viewerAdvisor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.IPage#getControl()
+ */
+ public Control getControl() {
+ return composite;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.IPage#setFocus()
+ */
+ public void setFocus() {
+ changesViewer.getControl().setFocus();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.ISynchronizePage#init(org.eclipse.team.ui.synchronize.ISynchronizePageSite)
+ */
+ public void init(ISynchronizePageSite site) {
+ // Noop
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars)
+ */
+ public void setActionBars(IActionBars actionBars) {
+ // Delegate menu creation to the advisor
+ viewerAdvisor.setActionBars(actionBars);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.Page#dispose()
+ */
+ public void dispose() {
+ composite.dispose();
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.ISynchronizePage#getViewer()
+ */
+ public Viewer getViewer() {
+ return changesViewer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.ISynchronizePage#aboutToChangeProperty(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration, java.lang.String, java.lang.Object)
+ */
+ public boolean aboutToChangeProperty(ISynchronizePageConfiguration configuration, String key, Object newValue) {
+ // Allow all changes
+ return true;
+ }
+}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestParticipant.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestParticipant.java
new file mode 100644
index 000000000..af837b141
--- /dev/null
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestParticipant.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.tests.ui.synchronize;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.team.core.synchronize.SyncInfoTree;
+import org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+import org.eclipse.ui.part.IPageBookViewPage;
+
+public class TestParticipant extends AbstractSynchronizeParticipant {
+
+ public static final String ID = "org.eclipse.team.tests.ui.test-participant"; //$NON-NLS-1$
+
+ private SyncInfoTree set = new SyncInfoTree();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
+ */
+ protected void initializeConfiguration(ISynchronizePageConfiguration configuration) {
+ configuration.setProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET, set);
+ configuration.setMode(ISynchronizePageConfiguration.BOTH_MODE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#createPage(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
+ */
+ public IPageBookViewPage createPage(ISynchronizePageConfiguration configuration) {
+ return new TestPage(configuration);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#createSynchronizeWizard()
+ */
+ public IWizard createSynchronizeWizard() {
+ return null;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#dispose()
+ */
+ public void dispose() {
+ // Noop
+ }
+
+ /**
+ *
+ */
+ public void reset() {
+ set.clear();
+ }
+
+ /**
+ * @return
+ */
+ public SyncInfoTree getSyncInfoSet() {
+ return set;
+ }
+}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestTreeViewerAdvisor.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestTreeViewerAdvisor.java
new file mode 100644
index 000000000..5d0132396
--- /dev/null
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestTreeViewerAdvisor.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.tests.ui.synchronize;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.team.core.synchronize.SyncInfoTree;
+import org.eclipse.team.internal.ui.synchronize.*;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+import org.eclipse.team.ui.synchronize.TreeViewerAdvisor;
+
+public class TestTreeViewerAdvisor extends TreeViewerAdvisor {
+
+ public TestTreeViewerAdvisor(Composite parent, ISynchronizePageConfiguration configuration) {
+ super(parent, configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.TreeViewerAdvisor#createModelManager(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
+ */
+ protected SynchronizeModelManager createModelManager(ISynchronizePageConfiguration configuration) {
+ return new SynchronizeModelManager(this, configuration) {
+ protected ISynchronizeModelProvider createModelProvider(String id) {
+ return new HierarchicalModelProvider(getSyncInfoSet());
+ }
+ protected ISynchronizeModelProviderDescriptor[] getSupportedModelProviders() {
+ return new ISynchronizeModelProviderDescriptor[] {
+ new HierarchicalModelProvider.HierarchicalModelProviderDescriptor()};
+ }
+ private SyncInfoTree getSyncInfoSet() {
+ return (SyncInfoTree)getConfiguration().getProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET);
+ }
+ };
+ }
+}

Back to the top