diff options
author | Eike Stepper | 2012-11-06 17:59:52 +0000 |
---|---|---|
committer | Eike Stepper | 2012-11-06 17:59:52 +0000 |
commit | 0c072215632c9877c0655f49423d83d21cdbd0dd (patch) | |
tree | 7044292ccb4d455d15cf1099fb27c57643103760 /plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples | |
parent | eb3fa06f7b08978233750a95a09b0e557f2a51b5 (diff) | |
download | cdo-0c072215632c9877c0655f49423d83d21cdbd0dd.tar.gz cdo-0c072215632c9877c0655f49423d83d21cdbd0dd.tar.xz cdo-0c072215632c9877c0655f49423d83d21cdbd0dd.zip |
Offline Example
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples')
5 files changed, 85 insertions, 24 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/ClientPerspective.java b/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/ClientPerspective.java new file mode 100644 index 0000000000..3c579117c0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/ClientPerspective.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.examples.client.offline; + +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +/** + * @author Eike Stepper + */ +public class ClientPerspective implements IPerspectiveFactory +{ + public void createInitialLayout(IPageLayout layout) + { + layout.setFixed(true); + layout.addView("org.eclipse.emf.cdo.ui.CDOSessionsView", IPageLayout.LEFT, 0.5f, IPageLayout.ID_EDITOR_AREA); + layout.addView("org.eclipse.ui.views.PropertySheet", IPageLayout.BOTTOM, 0.5f, + "org.eclipse.emf.cdo.ui.CDOSessionsView"); + } +} diff --git a/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/FailoverMonitorView.java b/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/FailoverMonitorView.java index 3f4fb8f16c..046a8d05b1 100644 --- a/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/FailoverMonitorView.java +++ b/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/FailoverMonitorView.java @@ -103,7 +103,7 @@ public class FailoverMonitorView extends AbstractView<FailoverMonitor> */ public static class OScope extends Canvas implements Runnable, PaintListener, ControlListener { - public static final int[] PEAK = { 25, 50, 100, 80, 100, 50, 25, 10, 5 }; + public static final int[] PEAK = { 10, 95, 80, 90, 50, 25, 10, 5 }; private static final String INITIAL = "#INITIAL#"; @@ -135,8 +135,6 @@ public class FailoverMonitorView extends AbstractView<FailoverMonitor> private int channelHeight; - private int x; - private boolean resizing; private Color black; @@ -230,8 +228,6 @@ public class FailoverMonitorView extends AbstractView<FailoverMonitor> return; } - x = Math.min(x, width); - int oldChannelHeight = channelHeight; if (oldChannelHeight == 0) { @@ -277,11 +273,6 @@ public class FailoverMonitorView extends AbstractView<FailoverMonitor> redraw(); - if (++x >= width) - { - x = 0; - } - getDisplay().timerExec(getTimerExecMillis(), this); } @@ -311,6 +302,8 @@ public class FailoverMonitorView extends AbstractView<FailoverMonitor> private boolean headNegate; + private int x; + private int y; public Channel(String name) @@ -367,6 +360,7 @@ public class FailoverMonitorView extends AbstractView<FailoverMonitor> } values = newValues; + x = Math.min(x, width); this.y = y; } @@ -389,6 +383,11 @@ public class FailoverMonitorView extends AbstractView<FailoverMonitor> gc.setForeground(black); gc.setLineWidth(2); gc.drawRectangle(x, fx, 2, 2); + + if (++x >= width) + { + x = 0; + } } void setName(String name) diff --git a/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/NormalRepositoryView.java b/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/NormalRepositoryView.java index 10e6689b27..919ce13cb7 100644 --- a/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/NormalRepositoryView.java +++ b/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/NormalRepositoryView.java @@ -22,7 +22,11 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; +import org.eclipse.wb.swt.ExampleResourceManager; + +import java.util.concurrent.ExecutorService; /** * @author Eike Stepper @@ -47,6 +51,25 @@ public class NormalRepositoryView extends AbstractView<IRepository> { itemProvider = new ContainerItemProvider<IContainer<Object>>() { + private Image bean = ExampleResourceManager.getPluginImage(Application.PLUGIN_ID, "icons/Bean.gif"); + + @Override + public String getText(Object obj) + { + if (obj instanceof ExecutorService) + { + return "ExecutorService"; + } + + return super.getText(obj); + } + + @Override + public Image getImage(Object obj) + { + return bean; + } + @Override protected void handleElementEvent(final IEvent event) { diff --git a/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/nodes/NodeManagerDialog.java b/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/nodes/NodeManagerDialog.java index cb025c7102..3348436bb1 100644 --- a/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/nodes/NodeManagerDialog.java +++ b/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/nodes/NodeManagerDialog.java @@ -34,7 +34,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Tree; -import org.eclipse.wb.swt.ResourceManager; +import org.eclipse.wb.swt.ExampleResourceManager; import java.util.Properties; @@ -104,7 +104,7 @@ public class NodeManagerDialog extends TitleAreaDialog }; setTitle("Node Manager"); - setTitleImage(ResourceManager.getPluginImage(Application.PLUGIN_ID, "icons/NodeManager.gif")); + setTitleImage(ExampleResourceManager.getPluginImage(Application.PLUGIN_ID, "icons/NodeManager.gif")); setMessage("Select an existing node or create a new one."); Composite area = (Composite)super.createDialogArea(parent); diff --git a/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/nodes/NodeType.java b/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/nodes/NodeType.java index 5c04b5acc3..9af2251769 100644 --- a/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/nodes/NodeType.java +++ b/plugins/org.eclipse.emf.cdo.examples.client.offline/src/org/eclipse/emf/cdo/examples/client/offline/nodes/NodeType.java @@ -61,7 +61,7 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.application.IWorkbenchWindowConfigurer; -import org.eclipse.wb.swt.ResourceManager; +import org.eclipse.wb.swt.ExampleResourceManager; import org.h2.jdbcx.JdbcDataSource; @@ -169,12 +169,12 @@ public abstract class NodeType extends SetContainer<Node> implements IElement public Image getImage() { - return ResourceManager.getPluginImage(Application.PLUGIN_ID, "icons/Folder.gif"); + return ExampleResourceManager.getPluginImage(Application.PLUGIN_ID, "icons/Folder.gif"); } public Image getInstanceImage() { - return ResourceManager.getPluginImage(Application.PLUGIN_ID, "icons/" + getTypeName() + ".gif"); + return ExampleResourceManager.getPluginImage(Application.PLUGIN_ID, "icons/" + getTypeName() + ".gif"); } public String getTypeName() @@ -512,8 +512,11 @@ public abstract class NodeType extends SetContainer<Node> implements IElement { super.start(node); + // IConnector connector = (IConnector)IPluginContainer.INSTANCE.getElement("org.eclipse.net4j.connectors", "jvm", + // "example"); + CDOSession session = (CDOSession)IPluginContainer.INSTANCE.getElement("org.eclipse.emf.cdo.sessions", "cdo", - "jvm://example"); + "jvm://example?repositoryName=" + REPOSITORY_NAME); node.getObjects().put(CDOSession.class, session); } @@ -530,25 +533,33 @@ public abstract class NodeType extends SetContainer<Node> implements IElement protected IRepository createRepository(Node node, IStore store, Map<String, String> props) { String serverName = node.getSetting(SERVER_PROPERTY); - Node serverNode = getManager().getNode(serverName); + final Node serverNode = getManager().getNode(serverName); if (serverNode == null) { throw new IllegalStateException("Server not found: " + serverName); } - final String serverAddress = "localhost:" + serverNode.getSetting(PORT_PROPERTY); - CDOSessionConfigurationFactory factory = new CDOSessionConfigurationFactory() { public CDONet4jSessionConfiguration createSessionConfiguration() { - IConnector connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE, "tcp", serverAddress); + String serverAddress = "localhost:" + serverNode.getSetting(PORT_PROPERTY); - CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration(); - configuration.setConnector(connector); - configuration.setRepositoryName(REPOSITORY_NAME); - configuration.setRevisionManager(CDORevisionUtil.createRevisionManager(CDORevisionCache.NOOP)); + CDONet4jSessionConfiguration configuration; + if (serverNode.getType() instanceof FailoverMonitor) + { + configuration = CDONet4jUtil.createFailoverSessionConfiguration(serverAddress, serverNode.getName()); + } + else + { + IConnector connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE, "tcp", serverAddress); + configuration = CDONet4jUtil.createNet4jSessionConfiguration(); + configuration.setConnector(connector); + configuration.setRepositoryName(REPOSITORY_NAME); + } + + configuration.setRevisionManager(CDORevisionUtil.createRevisionManager(CDORevisionCache.NOOP)); return configuration; } }; |