Moved database connection to DS factory

This commit is contained in:
Eyck Jentzsch 2015-10-22 00:04:28 +02:00
parent ef3ce7273a
commit a0e29e8ae2
6 changed files with 26 additions and 20 deletions

View File

@ -21,3 +21,4 @@ Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Import-Package: com.google.common.collect Import-Package: com.google.common.collect
Service-Component: OSGI-INF/component.xml

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.ui">
<implementation class="com.minres.scviewer.ui.TxEditorPart"/>
<reference bind="bind" cardinality="1..1" interface="com.minres.scviewer.database.IWaveformDbFactory" name="IWaveformDbFactory" policy="static" unbind="unbin"/>
</scr:component>

View File

@ -1,17 +1,8 @@
###############################################################################
# Copyright (c) 2014, 2015 MINRES Technologies GmbH 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:
# MINRES Technologies GmbH - initial API and implementation
###############################################################################
bin.includes = plugin.xml,\ bin.includes = plugin.xml,\
META-INF/,\ META-INF/,\
.,\ .,\
contexts.xml,\ contexts.xml,\
res/ res/,\
source.. = src/ OSGI-INF/
jars.compile.order = . jars.compile.order = .
source.. = src/

View File

@ -46,14 +46,25 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
import com.minres.scviewer.database.IWaveformEvent; import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.WaveformDb;
import com.minres.scviewer.database.swt.GotoDirection; import com.minres.scviewer.database.swt.GotoDirection;
import com.minres.scviewer.database.swt.TxDisplay; import com.minres.scviewer.database.swt.TxDisplay;
import com.minres.scviewer.ui.views.TxOutlinePage; import com.minres.scviewer.ui.views.TxOutlinePage;
public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPageContributor { public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPageContributor {
private IWaveformDbFactory waveformDbFactory;
public synchronized void bind(IWaveformDbFactory factory){
waveformDbFactory=factory;
}
public synchronized void unbind(IWaveformDbFactory factory){
if(waveformDbFactory==factory)
waveformDbFactory=null;
}
private final static String[] zoomLevel={ private final static String[] zoomLevel={
"1fs", "10fs", "100fs", "1fs", "10fs", "100fs",
"1ps", "10ps", "100ps", "1ps", "10ps", "100ps",
@ -85,7 +96,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
@Override @Override
public void createPartControl(Composite parent) { public void createPartControl(Composite parent) {
myParent=parent; myParent=parent;
database=new WaveformDb(); database=waveformDbFactory.getDatabase();
database.addPropertyChangeListener(new PropertyChangeListener() { database.addPropertyChangeListener(new PropertyChangeListener() {
@Override @Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
@ -273,7 +284,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
public void doSaveAs() { public void doSaveAs() {
} }
@SuppressWarnings("rawtypes") @SuppressWarnings({ "rawtypes", "unchecked" })
@Override @Override
public Object getAdapter(Class type) { public Object getAdapter(Class type) {
if (type == IContentOutlinePage.class) // outline page if (type == IContentOutlinePage.class) // outline page
@ -382,8 +393,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
} }
public void removeSelected() { public void removeSelected() {
// TODO Auto-generated method stub // TODO TxDisplay needs to be extended
} }
} }

View File

@ -17,7 +17,7 @@ import com.minres.scviewer.database.ITx;
public class TxAdapterFactory implements IAdapterFactory { public class TxAdapterFactory implements IAdapterFactory {
@SuppressWarnings("rawtypes") @SuppressWarnings({ "rawtypes", "unchecked" })
@Override @Override
public Object getAdapter(Object adaptableObject, Class adapterType) { public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adapterType == IPropertySource.class) if (adapterType == IPropertySource.class)
@ -25,7 +25,7 @@ public class TxAdapterFactory implements IAdapterFactory {
return null; return null;
} }
@SuppressWarnings("rawtypes") @SuppressWarnings({ "rawtypes", "unchecked" })
@Override @Override
public Class[] getAdapterList() { public Class[] getAdapterList() {
return new Class[]{IPropertySource.class}; return new Class[]{IPropertySource.class};

View File

@ -7,7 +7,6 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.internal.misc.StringMatcher;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent; import com.minres.scviewer.database.IWaveformEvent;