diff --git a/com.minres.scviewer.database.leveldb/META-INF/MANIFEST.MF b/com.minres.scviewer.database.leveldb/META-INF/MANIFEST.MF index 7e68178..ff10c05 100644 --- a/com.minres.scviewer.database.leveldb/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.database.leveldb/META-INF/MANIFEST.MF @@ -9,7 +9,6 @@ Import-Package: org.osgi.framework;version="1.3.0" Automatic-Module-Name: com.minres.scviewer.database.leveldb Service-Component: OSGI-INF/*.xml Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0", - org.eclipse.equinox.util;bundle-version="1.0.500", org.eclipse.equinox.ds;bundle-version="1.4.200", org.eclipse.osgi.services;bundle-version="3.4.0" Bundle-ActivationPolicy: lazy diff --git a/com.minres.scviewer.database.leveldb/src/com/minres/scviewer/database/leveldb/LevelDBLoader.java b/com.minres.scviewer.database.leveldb/src/com/minres/scviewer/database/leveldb/LevelDBLoader.java index 8f7ee35..c5c844a 100644 --- a/com.minres.scviewer.database.leveldb/src/com/minres/scviewer/database/leveldb/LevelDBLoader.java +++ b/com.minres.scviewer.database.leveldb/src/com/minres/scviewer/database/leveldb/LevelDBLoader.java @@ -64,7 +64,7 @@ public class LevelDBLoader implements IWaveformDbLoader { } @Override - public List getAllWaves() { + public Collection getAllWaves() { List streams=new ArrayList(); SeekingIterator it = levelDb.iterator(); it.seek("s~"); diff --git a/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java b/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java index d677b73..a1f2ac6 100644 --- a/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java +++ b/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java @@ -61,7 +61,7 @@ public class SQLiteDbLoader implements IWaveformDbLoader { } @Override - public List getAllWaves() { + public Collection getAllWaves() { SQLiteDatabaseSelectHandler handler = new SQLiteDatabaseSelectHandler(ScvStream.class, database); List streams=new ArrayList(); try { @@ -81,6 +81,7 @@ public class SQLiteDbLoader implements IWaveformDbLoader { @Override public boolean load(IWaveformDb db, File file) throws Exception { + if(file.isDirectory() || !file.exists()) return false; this.db=db; try { FileInputStream fis = new FileInputStream(file); diff --git a/com.minres.scviewer.database.test/DatabaseServicesTest.launch b/com.minres.scviewer.database.test/DatabaseServicesTest.launch index c44770d..f8e3594 100644 --- a/com.minres.scviewer.database.test/DatabaseServicesTest.launch +++ b/com.minres.scviewer.database.test/DatabaseServicesTest.launch @@ -1,46 +1,104 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.minres.scviewer.database.text/META-INF/MANIFEST.MF b/com.minres.scviewer.database.text/META-INF/MANIFEST.MF index 605975f..d073c7a 100644 --- a/com.minres.scviewer.database.text/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.database.text/META-INF/MANIFEST.MF @@ -8,7 +8,6 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: org.osgi.framework;version="1.3.0" Require-Bundle: com.minres.scviewer.database, org.codehaus.groovy;bundle-version="2.5.8", - org.eclipse.equinox.util;bundle-version="1.0.500", org.eclipse.equinox.ds;bundle-version="1.4.200", org.eclipse.osgi.services;bundle-version="3.4.0", com.google.guava;bundle-version="15.0.0" diff --git a/com.minres.scviewer.database.text/pom.xml b/com.minres.scviewer.database.text/pom.xml index 24efc0c..c09a4f5 100644 --- a/com.minres.scviewer.database.text/pom.xml +++ b/com.minres.scviewer.database.text/pom.xml @@ -24,8 +24,8 @@ - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.groovy b/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.groovy index 3979c91..6fd56d6 100644 --- a/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.groovy +++ b/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.groovy @@ -50,8 +50,8 @@ public class TextDbLoader implements IWaveformDbLoader{ } @Override - public List getAllWaves() { - return new LinkedList(streams); + public Collection getAllWaves() { + return streams; } public Map getGeneratorsById() { @@ -64,6 +64,7 @@ public class TextDbLoader implements IWaveformDbLoader{ @Override boolean load(IWaveformDb db, File file) throws Exception { + if(file.isDirectory() || !file.exists()) return false; this.db=db this.streams=[] try { @@ -82,7 +83,7 @@ public class TextDbLoader implements IWaveformDbLoader{ .make() // NPE here ---> parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file)) - calculateConcurrencyIndicees() + streams.each{ TxStream stream -> stream.getMaxConcurrency() } return true } } catch (IndexOutOfBoundsException e) { @@ -135,7 +136,7 @@ public class TextDbLoader implements IWaveformDbLoader{ case "ms":return 1000000000000L case "s": return 1000000000000000L } - return "fs" + return 1L } private def parseInput(InputStream inputStream){ @@ -152,23 +153,29 @@ public class TextDbLoader implements IWaveformDbLoader{ def tokens = line.split(/\s+/) as ArrayList switch(tokens[0]){ case "scv_tr_stream": - case "scv_tr_generator": - case "begin_attribute": - case "end_attribute": if ((matcher = line =~ /^scv_tr_stream\s+\(ID (\d+),\s+name\s+"([^"]+)",\s+kind\s+"([^"]+)"\)$/)) { def id = Integer.parseInt(matcher[0][1]) def stream = new TxStream(this, id, matcher[0][2], matcher[0][3]) streams< stream.getMaxConcurrency() } - } - - public Collection getAllRelationTypes(){ return relationTypes.values(); } diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java index 087e0f6..c6b448c 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java @@ -4,15 +4,13 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.Widget; import com.minres.scviewer.database.swt.Constants; @@ -74,13 +72,17 @@ class ToolTipHandler { Point pt = new Point (event.x, event.y); tipPosition = control.toDisplay(pt); if (tip != null && !tip.isDisposed ()) tip.dispose (); - tip = new Shell (parentShell, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); + tip = new Shell (parentShell, SWT.NO_FOCUS | SWT.TOOL); tip.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND)); - RowLayout layout=new RowLayout(SWT.VERTICAL); - layout.fill=true; + GridLayout layout = new GridLayout(1, true); + layout.verticalSpacing=0; + layout.horizontalSpacing=0; + layout.marginWidth = 0; + layout.marginHeight = 0; tip.setLayout(layout); boolean visible = provider.createContent(tip, pt); tip.pack(); + tip.setSize(tip.computeSize(SWT.DEFAULT, SWT.DEFAULT)); setHoverLocation(tip, tipPosition); tip.setVisible (visible); if(visible) diff --git a/com.minres.scviewer.database.ui/META-INF/MANIFEST.MF b/com.minres.scviewer.database.ui/META-INF/MANIFEST.MF index 7895eed..91e16dc 100644 --- a/com.minres.scviewer.database.ui/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.database.ui/META-INF/MANIFEST.MF @@ -7,5 +7,6 @@ Bundle-Vendor: MINRES Technologies GmbH Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: com.minres.scviewer.database.ui Require-Bundle: com.minres.scviewer.database, - org.eclipse.jface + org.eclipse.jface, + org.eclipse.swt Automatic-Module-Name: com.minres.scviewer.database.ui diff --git a/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/TrackEntry.java b/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/TrackEntry.java index 534d4a9..3bc00a5 100644 --- a/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/TrackEntry.java +++ b/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/TrackEntry.java @@ -51,31 +51,12 @@ public class TrackEntry { result[0] = fallback; result[1] = highlightedFallback; - - // assign colors to standard values - if (streamValue.contains("read")){ - result[0] = new Color(86,174,53); - result[1] = new Color (86,194,53); - }else if (streamValue.contains("rdata")){ - result[0] = new Color(138,151,71); - result[1] = new Color (138,171,71); - }else if (streamValue.contains("addr")){ - result[0] = new Color(233,187,68); - result[1] = new Color (233,207,68); - }else if (streamValue.contains("write")){ - result[0] = new Color(1,128,191); - result[1] = new Color (1,128,211); - }else if (streamValue.contains("wdata")){ - result[0] = new Color(2,181,160); - result[1] = new Color (2,201,160); - - }else { - // assign "random" color here, one name always results in the same color! - if( randomColors.length > 0 ) { - int index = Math.abs(streamValue.hashCode()) % randomColors.length; - result[0] = randomColors[index][0]; - result[1] = randomColors[index][1]; - } + + // assign "random" color here, one name always results in the same color! + if( streamValue!=null && randomColors.length > 0 ) { + int index = Math.abs(streamValue.hashCode()) % randomColors.length; + result[0] = randomColors[index][0]; + result[1] = randomColors[index][1]; } return result; diff --git a/com.minres.scviewer.database.vcd/META-INF/MANIFEST.MF b/com.minres.scviewer.database.vcd/META-INF/MANIFEST.MF index 3f0cc56..f83fd29 100644 --- a/com.minres.scviewer.database.vcd/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.database.vcd/META-INF/MANIFEST.MF @@ -6,7 +6,6 @@ Bundle-Version: 2.0.2.qualifier Bundle-Vendor: MINRES Technologies GmbH Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0", - org.eclipse.equinox.util;bundle-version="1.0.500", org.eclipse.equinox.ds;bundle-version="1.4.200", org.eclipse.osgi.services;bundle-version="3.4.0", com.google.guava;bundle-version="15.0.0" diff --git a/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java b/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java index bde1c9b..fb7f474 100644 --- a/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java +++ b/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java @@ -79,6 +79,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder { @SuppressWarnings("unchecked") @Override public boolean load(IWaveformDb db, File file) throws Exception { + if(file.isDirectory() || !file.exists()) return false; this.db=db; this.maxTime=0; String name = file.getCanonicalFile().getName(); @@ -127,7 +128,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder { * @see com.minres.scviewer.database.ITrDb#getAllWaves() */ @Override - public List getAllWaves() { + public Collection getAllWaves() { return signals; } diff --git a/com.minres.scviewer.database/src/com/minres/scviewer/database/IWaveformDbLoader.java b/com.minres.scviewer.database/src/com/minres/scviewer/database/IWaveformDbLoader.java index 16f897d..1ccba07 100644 --- a/com.minres.scviewer.database/src/com/minres/scviewer/database/IWaveformDbLoader.java +++ b/com.minres.scviewer.database/src/com/minres/scviewer/database/IWaveformDbLoader.java @@ -12,7 +12,6 @@ package com.minres.scviewer.database; import java.io.File; import java.util.Collection; -import java.util.List; public interface IWaveformDbLoader { @@ -20,7 +19,7 @@ public interface IWaveformDbLoader { public Long getMaxTime(); - public List getAllWaves() ; + public Collection getAllWaves() ; public Collection getAllRelationTypes() ; diff --git a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF index a5566e3..7fcaa46 100644 --- a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true -Bundle-Version: 2.4.0.qualifier +Bundle-Version: 2.6.0.qualifier Bundle-Vendor: %Bundle-Vendor Require-Bundle: javax.inject;bundle-version="1.0.0", org.eclipse.core.runtime;bundle-version="3.11.1", @@ -18,7 +18,6 @@ Require-Bundle: javax.inject;bundle-version="1.0.0", com.minres.scviewer.database.ui, com.minres.scviewer.database;bundle-version="1.0.0", org.eclipse.equinox.ds;bundle-version="1.4.300", - org.eclipse.equinox.util;bundle-version="1.0.500", org.eclipse.osgi.services;bundle-version="3.5.0", org.eclipse.e4.core.services;bundle-version="2.0.0", org.eclipse.osgi.services;bundle-version="3.5.0", @@ -31,7 +30,9 @@ Require-Bundle: javax.inject;bundle-version="1.0.0", org.eclipse.e4.ui.workbench.addons.swt, com.opcoach.e4.preferences, org.eclipse.e4.core.di.extensions, - org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0" + org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0", + org.eclipse.core.resources;bundle-version="3.13.0", + com.opcoach.e4.preferences.mainmenu;bundle-version="1.2.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: com.minres.scviewer.database, javax.inject;version="1.0.0" diff --git a/com.minres.scviewer.e4.application/icons/arrow_up.png b/com.minres.scviewer.e4.application/icons/arrow_up.png new file mode 100644 index 0000000..1ebb193 Binary files /dev/null and b/com.minres.scviewer.e4.application/icons/arrow_up.png differ diff --git a/com.minres.scviewer.e4.application/icons/page_white.png b/com.minres.scviewer.e4.application/icons/page_white.png new file mode 100644 index 0000000..8b8b1ca Binary files /dev/null and b/com.minres.scviewer.e4.application/icons/page_white.png differ diff --git a/com.minres.scviewer.e4.application/plugin.xml b/com.minres.scviewer.e4.application/plugin.xml index 236f625..f585ee3 100644 --- a/com.minres.scviewer.e4.application/plugin.xml +++ b/com.minres.scviewer.e4.application/plugin.xml @@ -84,5 +84,12 @@ category="com.minres.scviewer.e4.application.preferences.scviewer"> + + + + diff --git a/com.minres.scviewer.e4.application/pom.xml b/com.minres.scviewer.e4.application/pom.xml index 2fb3288..4ab7a62 100644 --- a/com.minres.scviewer.e4.application/pom.xml +++ b/com.minres.scviewer.e4.application/pom.xml @@ -1,7 +1,7 @@ 4.0.0 com.minres.scviewer.e4.application - 2.4.0-SNAPSHOT + 2.6.0-SNAPSHOT com.minres.scviewer com.minres.scviewer.parent diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java index e0d15fc..7532fb8 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java @@ -11,10 +11,12 @@ package com.minres.scviewer.e4.application; import java.io.File; +import java.io.IOException; import javax.annotation.PostConstruct; import javax.inject.Inject; +import org.eclipse.core.runtime.Platform; import org.eclipse.e4.core.contexts.ContextInjectionFactory; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.services.events.IEventBroker; @@ -30,6 +32,7 @@ import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.e4.ui.workbench.modeling.EPartService; import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.osgi.service.datalocation.Location; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; @@ -91,6 +94,20 @@ public class E4LifeCycle { } } }); + eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, new EventHandler() { + @Override + public void handleEvent(Event event) { + Location instanceLocation = Platform.getInstanceLocation(); + try { + boolean isLocked = instanceLocation.isLocked(); + if(isLocked) + instanceLocation.release(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); } /** diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableHover.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableHover.java index 557c61a..2990c28 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableHover.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableHover.java @@ -7,26 +7,22 @@ import java.util.List; import javax.annotation.PostConstruct; import javax.inject.Inject; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.ConfigurationScope; import org.eclipse.e4.core.contexts.Active; import org.eclipse.e4.core.di.annotations.Execute; -import org.eclipse.e4.core.di.extensions.Preference; import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.e4.ui.model.application.ui.basic.MWindow; import org.eclipse.e4.ui.model.application.ui.menu.MHandledItem; import org.eclipse.e4.ui.workbench.modeling.EModelService; +import org.eclipse.jface.preference.IPreferenceStore; import com.minres.scviewer.e4.application.preferences.PreferenceConstants; +import com.opcoach.e4.preferences.ScopedPreferenceStore; -@SuppressWarnings("restriction") public class EnableHover { static final String TAG_NAME = "EnableHover"; //$NON-NLS-1$ - @Inject - @Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE) - IEclipsePreferences prefs; - @Inject MApplication application; @@ -36,14 +32,17 @@ public class EnableHover { tags.add(TAG_NAME); List elements = modelService.findElements(application, null, MHandledItem.class, tags ); // cover initialization stuff, sync it with code + IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); + boolean state = store.getBoolean(PreferenceConstants.SHOW_HOVER); for( MHandledItem hi : elements ){ - hi.setSelected(prefs.getBoolean(PreferenceConstants.SHOW_HOVER, true)); + hi.setSelected(state); } } @Execute public void execute(@Active MPart part, @Active MWindow window, MHandledItem handledItem, EModelService modelService ) { - prefs.putBoolean(PreferenceConstants.SHOW_HOVER, handledItem.isSelected()); + IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); + store.setValue(PreferenceConstants.SHOW_HOVER, handledItem.isSelected()); } } \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/OpenHandler.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/OpenHandler.java index 48dbb7b..9d6f034 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/OpenHandler.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/OpenHandler.java @@ -11,7 +11,7 @@ package com.minres.scviewer.e4.application.handlers; import java.io.File; -import java.util.ArrayList; +import java.util.List; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.di.annotations.Execute; @@ -21,27 +21,20 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.e4.ui.workbench.modeling.EPartService; import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Shell; import com.minres.scviewer.e4.application.Messages; +import com.minres.scviewer.e4.application.parts.FileBrowserDialog; public class OpenHandler { @Execute public void execute(Shell shell, MApplication app, EModelService modelService, EPartService partService){ - FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI); - dialog.setFilterExtensions (new String []{Messages.OpenHandler_0}); - String ret = dialog.open(); - if(ret==null) - return; - String path = dialog.getFilterPath(); - ArrayList files = new ArrayList(); - for(String fileName: dialog.getFileNames()){ - File file = new File(path+File.separator+fileName); - if(file.exists()) - files.add(file); - } + FileBrowserDialog dlg = new FileBrowserDialog(shell); + //dlg.create(); + dlg.setFilterExtensions (new String []{Messages.OpenHandler_0, "*"}); + if (dlg.open() != Window.OK) return; + List files = dlg.getSelectedFiles(); MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$ part.setLabel(files.get(0).getName()); MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$ diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties index 264be16..ea3c33b 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties @@ -1,5 +1,5 @@ AboutDialog_0=\nSCViewer - a SystemC waveform viewer\n\nVersion: {0}\n -AboutDialog_1=\nCopyright (c) 2015, 2019 MINRES Technologies GmbH and others.\n\nAll rights reserved. MINRES and the MINRES logo are trademarks of MINRES Technologies GmbH, http://www.minres.com/. 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\n\nParts of the software are governed by the Apache License Version 2.0 available at http://www.apache.org/licenses/. These are namely org.mapdb and org.sqlite JDBC driver\n\nSource code is hosted at https://git.minres.com/VP-Tools/SCViewer and the master branch is mirrored to GitHub: https://github.com/minres/SCViewer\n +AboutDialog_1=\nCopyright (c) 2015, 2019, 2020 MINRES Technologies GmbH and others.\n\nAll rights reserved. MINRES and the MINRES logo are trademarks of MINRES Technologies GmbH, http://www.minres.com/. 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\n\nParts of the software are governed by the Apache License Version 2.0 available at http://www.apache.org/licenses/. These are namely org.mapdb and org.sqlite JDBC driver\n\nSource code is hosted at https://git.minres.com/VP-Tools/SCViewer and the master branch is mirrored to GitHub: https://github.com/minres/SCViewer\n DesignBrowser_12=Append all after DesignBrowser_16=Insert all before DesignBrowser_2=Enter text to filter waveforms @@ -9,7 +9,7 @@ DesignBrowser_8=Insert before LoadingWaveformDb_0=Database loading... LoadStoreSettingsHandler_2=*.scview LoadStoreSettingsHandler_3=SCViewer.scview -OpenHandler_0=*.vcd;*.txdb;*.txlog;CURRENT +OpenHandler_0=*.vcd;*.txdb;*.txlog;*.fbrdb QuitHandler_0=Confirmation QuitHandler_1=Do you want to exit? RelationTypeToolControl_0=------------ @@ -45,7 +45,7 @@ WaveformViewer_18=Would you like to reload the database? WaveformViewer_19=vcd WaveformViewer_20=txdb WaveformViewer_21=txlog -WaveformViewer_22=txldb +WaveformViewer_22=fbrdb WaveformViewer_37=Database open WaveformViewer_38=Would you like to open the adjacent database WaveformViewer_39=\ as well? diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/DesignBrowser.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/DesignBrowser.java index e49a360..37be256 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/DesignBrowser.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/DesignBrowser.java @@ -328,13 +328,15 @@ public class DesignBrowser { */ @Focus public void setFocus() { - txTableViewer.getTable().setFocus(); - IStructuredSelection selection = (IStructuredSelection)txTableViewer.getSelection(); - if(selection.size()==0){ - appendItem.setEnabled(false); + if(txTableViewer!=null) { + txTableViewer.getTable().setFocus(); + IStructuredSelection selection = (IStructuredSelection)txTableViewer.getSelection(); + if(selection.size()==0){ + appendItem.setEnabled(false); + } + selectionService.setSelection(selection); + thisSelectionCount=selection.toList().size(); } - selectionService.setSelection(selection); - thisSelectionCount=selection.toList().size(); updateButtons(); } diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/FileBrowserDialog.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/FileBrowserDialog.java new file mode 100644 index 0000000..49ee835 --- /dev/null +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/FileBrowserDialog.java @@ -0,0 +1,482 @@ +package com.minres.scviewer.e4.application.parts; + +import java.io.File; +import java.nio.file.FileSystems; +import java.nio.file.PathMatcher; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.TrayDialog; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.TreePath; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; +import org.eclipse.wb.swt.ResourceManager; + +public class FileBrowserDialog extends TrayDialog { + + private Image folderImage; + + private Image fileImage; + + private Image dbImage; + + File currentDirFile; + + TreeViewer dirTreeViewer; + + TableViewer tableViewer; + + Text fileNameEntry; + + Combo filterCombo; + + FileTableComparator fileTableComparator; + + private FileGlobber globber = new FileGlobber(); + + private FileGlobber imageGlobber = new FileGlobber(); + + private File selectedDir; + + private List selectedFiles; + + String[] filterStrings = new String[] {"*"}; + + public FileBrowserDialog(Shell parentShell) { + super(parentShell); + folderImage=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/folder.png"); //$NON-NLS-1$ //$NON-NLS-2$ + dbImage=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database.png"); //$NON-NLS-1$ //$NON-NLS-2$ + fileImage=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/page_white.png"); //$NON-NLS-1$ //$NON-NLS-2$ + currentDirFile = new File("."); + } + + public void setFilterExtensions(String[] filterStrings) { + if(filterStrings.length==0){ + globber = new FileGlobber(); + } else { + globber= new FileGlobber(filterStrings[0]); + imageGlobber = new FileGlobber(filterStrings[0]); + if(filterCombo!=null) { + filterCombo.setItems(filterStrings); + filterCombo.select(0); + filterCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT); + } + } + this.filterStrings=filterStrings; + } + + public List getSelectedFiles(){ + return selectedFiles; + } + + @Override + protected Control createContents(Composite parent) { + Control ret = super.createContents(parent); + setDirSelection(currentDirFile.getAbsoluteFile().getParentFile()); + getButton(IDialogConstants.OK_ID).setEnabled(!tableViewer.getSelection().isEmpty()); + if(parent instanceof Shell) { + Point size = ((Shell)parent).computeSize(SWT.DEFAULT, SWT.DEFAULT); + ((Shell)parent).setSize(size.x, 400); + ((Shell)parent).setText("Select database"); + } + return ret; + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite area = (Composite) super.createDialogArea(parent); + final SashForm sashForm = new SashForm(area, SWT.HORIZONTAL); + sashForm.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); + + dirTreeViewer = new TreeViewer(sashForm); + dirTreeViewer.setContentProvider(new FileTreeContentProvider()); + dirTreeViewer.setLabelProvider(new FileTreeLabelProvider()); + dirTreeViewer.addSelectionChangedListener(event -> { + IStructuredSelection sel = event.getStructuredSelection(); + File entry = (File) sel.getFirstElement(); + if(entry!=null && entry.isDirectory()) { + selectedDir = entry; + tableViewer.setInput(selectedDir.listFiles()); + } + }); + dirTreeViewer.setInput("root"); + + final Composite tableViewerParent = new Composite(sashForm, SWT.NONE); + GridLayout gridLayout = new GridLayout(1, true); + gridLayout.horizontalSpacing=0; + gridLayout.verticalSpacing=5; + gridLayout.marginHeight=0; + gridLayout.marginHeight=0; + tableViewerParent.setLayout(gridLayout); + final ToolBar toolBar = new ToolBar(tableViewerParent, SWT.HORIZONTAL |SWT.SHADOW_OUT); + toolBar.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); + final ToolItem toolbarItemUp = new ToolItem(toolBar, SWT.PUSH); + toolbarItemUp.setToolTipText("up one level"); + toolbarItemUp.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/arrow_up.png")); //$NON-NLS-1$ //$NON-NLS-2$); + toolbarItemUp.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if(selectedDir.getParentFile()!=null) { + selectedDir=selectedDir.getParentFile(); + tableViewer.setInput(selectedDir.listFiles()); + } + } + }); + tableViewer = new TableViewer(tableViewerParent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI); + tableViewer.getTable().setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); + tableViewer.addSelectionChangedListener(event -> { + IStructuredSelection sel = event.getStructuredSelection(); + getButton(IDialogConstants.OK_ID).setEnabled(!sel.isEmpty()); + @SuppressWarnings("unchecked") + Object text = sel.toList().stream().map(e -> ((File)e).getName()).collect(Collectors.joining(";")); + fileNameEntry.setText(text.toString()); + }); + tableViewer.addDoubleClickListener(event -> { + IStructuredSelection sel = tableViewer.getStructuredSelection(); + if(sel.isEmpty()) return; + if(sel.size()==1) { + File elem = (File) sel.getFirstElement(); + if(globber.matches(elem)) + buttonPressed(IDialogConstants.OK_ID); + else if(elem.isDirectory()) + setDirSelection(elem); + } else + buttonPressed(IDialogConstants.OK_ID); + }); + tableViewer.setContentProvider(ArrayContentProvider.getInstance()); + tableViewer.getTable().setHeaderVisible(true); + tableViewer.getTable().setLinesVisible(true); + tableViewer.getTable().addMouseListener(new MouseAdapter() { + @Override + public void mouseDown(MouseEvent e) { mouseUp(e); } + @Override + public void mouseUp(MouseEvent e) { + TableItem element = (TableItem)tableViewer.getTable().getItem(new Point(e.x, e.y)); + final Table table = tableViewer.getTable(); + if (element == null )//&& (e.stateMask&SWT.MODIFIER_MASK)!=0) + table.deselectAll(); + else { + int[] indices = table.getSelectionIndices(); + if(indices.length==1) { + TableItem ti = table.getItem(indices[0]); + if(!globber.matches(ti.getData()) && !((File)ti.getData()).isDirectory()) + table.deselect(indices[0]); + } else { + for (int idx : indices) { + TableItem ti = table.getItem(idx); + if(!globber.matches(ti.getData())) + table.deselect(idx); + } + } + } + } + }); + TableViewerColumn colName = new TableViewerColumn(tableViewer, SWT.NONE); + colName.setLabelProvider(new FileTableLabelProvider() { + @Override public String getText(Object element) { return ((File) element).getName(); } + @Override public Image getImage(Object element){ + if(imageGlobber.matches(element)) return dbImage; + return ((File) element).isDirectory()?folderImage:fileImage; + } + }); + colName.getColumn().setWidth(300); + colName.getColumn().setText("Name"); + colName.getColumn().addSelectionListener(getSelectionAdapter(colName.getColumn(), 0)); + + TableViewerColumn colSize = new TableViewerColumn(tableViewer, SWT.RIGHT); + colSize.setLabelProvider(new FileTableLabelProvider() { + @Override public String getText(Object element) { return String.format("%d", ((File) element).length()); } + }); + colSize.getColumn().setWidth(100); + colSize.getColumn().setText("Size"); + colSize.getColumn().addSelectionListener(getSelectionAdapter(colSize.getColumn(), 1)); + + TableViewerColumn colEmpty = new TableViewerColumn(tableViewer, SWT.CENTER); + colEmpty.setLabelProvider(new FileTableLabelProvider() { + @Override public String getText(Object element) { return ""; } + }); + //colEmpty.getColumn().setWidth(200); + colEmpty.getColumn().setText(""); + + fileTableComparator = new FileTableComparator(); + tableViewer.setComparator(fileTableComparator); + tableViewer.addFilter(new FileTableFilter()); + + Composite bottomBar = new Composite(tableViewerParent, SWT.NONE); + bottomBar.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); + GridLayout gridLayoutBottom = new GridLayout(2, false); + gridLayoutBottom.horizontalSpacing=0; + gridLayoutBottom.verticalSpacing=0; + gridLayoutBottom.marginHeight=0; + gridLayoutBottom.marginWidth=0; + bottomBar.setLayout(gridLayoutBottom); + + fileNameEntry = new Text(bottomBar, SWT.BORDER); + fileNameEntry.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); + fileNameEntry.setEditable(false); //TODO: temporary disabled + fileNameEntry.setEnabled(false); + + filterCombo = new Combo(bottomBar, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); + filterCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + filterCombo.setItems(filterStrings); + filterCombo.select(0); + filterCombo.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + globber= new FileGlobber(filterCombo.getText()); + tableViewer.setInput(selectedDir.listFiles()); + } + }); + sashForm.setWeights(new int[]{3, 3}); + return area; + } + + private SelectionAdapter getSelectionAdapter(final TableColumn column, final int index) { + SelectionAdapter selectionAdapter = new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fileTableComparator.setColumn(index); + int dir = fileTableComparator.getDirection(); + tableViewer.getTable().setSortDirection(dir); + tableViewer.getTable().setSortColumn(column); + tableViewer.refresh(); + } + }; + return selectionAdapter; + } + + private void setDirSelection(File f) { + ArrayList fileTree = getParentDirList(f); + TreeSelection selection = new TreeSelection(new TreePath(fileTree.toArray())); + dirTreeViewer.setSelection(selection, true); + } + + private ArrayList getParentDirList(File actual){ + if(actual==null) + return new ArrayList<>(); + else { + ArrayList l = getParentDirList(actual.getParentFile()); + l.add(actual); + return l; + } + } + + @Override + protected boolean isResizable() { + return true; + } + + // save content of the Text fields because they get disposed + // as soon as the Dialog closes + @SuppressWarnings("unchecked") + private void saveInput() { + selectedFiles= tableViewer.getStructuredSelection().toList(); + } + + @Override + protected void okPressed() { + saveInput(); + super.okPressed(); + } + + class FileGlobber { + + List matchers; + + public FileGlobber() { + matchers = new ArrayList<>(); } + + public FileGlobber(String expr) { + ArrayList m = new ArrayList<>(); + if(expr.length()>0) { + String[] tok = expr.split(";"); + for (String string : tok) { + m.add(FileSystems.getDefault().getPathMatcher("glob:**/"+string)); + } + } + matchers = m; + } + + public boolean matches(Object f) { + assert(f instanceof File); + if(matchers.size()==0) return true; + for (PathMatcher m : matchers) { + if(m.matches(((File)f).toPath())) return true; + } + return false; + } + } + + class FileTreeContentProvider implements ITreeContentProvider { + public Object[] getChildren(Object arg0) { + File[] entries = ((File) arg0).listFiles(); + if(entries != null) { + List res = Arrays.stream(entries) + .filter(file -> !(file.isFile()||file.getName().startsWith(".") ||globber.matches(file))) + .sorted(new Comparator(){ + public int compare(File f1, File f2){return f1.getName().compareTo(f2.getName());} + }) + .collect(Collectors.toList()); ; + return res.toArray(); + } else + return new Object[0]; + } + + public Object getParent(Object arg0) { + return ((File) arg0).getParentFile(); + } + + public boolean hasChildren(Object arg0) { + Object[] obj = getChildren(arg0); + return obj == null ? false : obj.length > 0; + } + + public Object[] getElements(Object arg0) { + return File.listRoots(); + } + + public void dispose() { + } + + public void inputChanged(Viewer arg0, Object arg1, Object arg2) { + } + } + + class FileTreeLabelProvider implements ILabelProvider { + private List listeners; + + private Image file; + + private Image dir; + + public FileTreeLabelProvider() { + listeners = new ArrayList(); + } + + public Image getImage(Object arg0) { + return ((File) arg0).isDirectory() ? folderImage : file; + } + + public String getText(Object arg0) { + File f = (File)arg0; + return f.getName().length() == 0? f.getPath() : f.getName(); + } + + public void addListener(ILabelProviderListener arg0) { + listeners.add(arg0); + } + + public void dispose() { + // Dispose the images + if (dir != null) + dir.dispose(); + if (file != null) + file.dispose(); + } + + public boolean isLabelProperty(Object arg0, String arg1) { + return false; + } + + public void removeListener(ILabelProviderListener arg0) { + listeners.remove(arg0); + } + + } + + public class FileTableFilter extends ViewerFilter { + + @Override + public boolean select(Viewer viewer, Object parentElement, Object element) { + File p = (File) element; + return !p.getName().startsWith("."); + } + } + + public class FileTableComparator extends ViewerComparator { + private int propertyIndex = 0; + private boolean descending = false; + + public FileTableComparator() { + } + + public int getDirection() { + return descending ? SWT.DOWN : SWT.UP; + } + + public void setColumn(int column) { + descending = column == this.propertyIndex?!descending : false; + this.propertyIndex = column; + } + + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + File p1 = (File) e1; + File p2 = (File) e2; + int rc = 0; + switch (propertyIndex) { + case 0: + rc = p1.getName().compareTo(p2.getName()); + break; + case 1: + rc = Long.valueOf(p1.length()).compareTo(p2.length()); + break; + default: + rc = 0; + } + // If descending order, flip the direction + return descending? -rc : rc; + } + + } + + public class FileTableLabelProvider extends ColumnLabelProvider { + @Override + public Color getBackground(Object element) { + return null; + } + + @Override + public Color getForeground(Object element) { + return globber.matches(element) || ((File)element).isDirectory()? null: ResourceManager.getColor(SWT.COLOR_GRAY); + } + + } +} + diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java index a562c1e..db80d80 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java @@ -10,8 +10,14 @@ *******************************************************************************/ package com.minres.scviewer.e4.application.parts; +import java.util.AbstractMap; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.TreeMap; import java.util.Vector; +import java.util.regex.PatternSyntaxException; +import java.util.stream.Collectors; import javax.annotation.PostConstruct; import javax.inject.Inject; @@ -477,12 +483,19 @@ public class TransactionDetails { return true; } if(element instanceof ITxAttribute){ - return (((ITxAttribute) element).getName().toLowerCase().matches(searchString.toLowerCase())); + try { + return (((ITxAttribute) element).getName().toLowerCase().matches(searchString.toLowerCase())); + } catch (PatternSyntaxException e) { + return true; + } } if(element instanceof Object[]) { - return (((Object[])element)[0]).toString().toLowerCase().matches(searchString.toLowerCase()); + try { + return (((Object[])element)[0]).toString().toLowerCase().matches(searchString.toLowerCase()); + } catch (PatternSyntaxException e) { + return true; + } } - return false; } } @@ -490,11 +503,13 @@ public class TransactionDetails { /** * The Enum Type. */ - enum Type {/** The props. */ - PROPS, /** The attrs. */ - ATTRS, /** The in rel. */ - IN_REL, /** The out rel. */ - OUT_REL} + enum Type { + PROPS, /** The props. */ + ATTRS, /** The attrs. */ + IN_REL, /** The in rel. */ + OUT_REL,/** The out rel. */ + HIER + } /** * The Class TreeNode. @@ -507,6 +522,7 @@ public class TransactionDetails { /** The element. */ public ITx element; + private String hier_path; /** * Instantiates a new tree node. * @@ -516,6 +532,13 @@ public class TransactionDetails { public TreeNode(ITx element, Type type){ this.element=element; this.type=type; + this.hier_path=""; + } + + public TreeNode(ITx element, String path){ + this.element=element; + this.type=Type.HIER; + this.hier_path=path; } /* (non-Javadoc) @@ -527,9 +550,33 @@ public class TransactionDetails { case ATTRS: return Messages.TransactionDetails_11; case IN_REL: return Messages.TransactionDetails_12; case OUT_REL: return Messages.TransactionDetails_13; + case HIER:{ + String[] tokens = hier_path.split("\\."); + return tokens[tokens.length-1]; + } } return ""; //$NON-NLS-1$ } + + public Object[] getAttributeListForHier() { + if(childs==null) { + Map res = element.getAttributes().stream() + .filter(txAttr -> txAttr.getName().startsWith(hier_path)) + .map(txAttr -> { + String target = hier_path.length()==0?txAttr.getName():txAttr.getName().replace(hier_path+'.', ""); + String[] tokens = target.split("\\."); + if(tokens.length==1) + return new AbstractMap.SimpleEntry<>(tokens[0], txAttr); + else + return new AbstractMap.SimpleEntry<>(tokens[0], new TreeNode(element, hier_path.length()>0?hier_path+"."+tokens[0]:tokens[0])); + }) + .collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue(), (first, second) -> first)); + childs = new TreeMap(res).values().toArray(); + } + return childs; + } + + private Object[] childs=null; } /** @@ -577,8 +624,8 @@ public class TransactionDetails { {Messages.TransactionDetails_19, Messages.TransactionDetails_20, timeToString(propertyHolder.element.getBeginTime())}, {Messages.TransactionDetails_21, Messages.TransactionDetails_20, timeToString(propertyHolder.element.getEndTime())} }; - }else if(propertyHolder.type == Type.ATTRS) - return propertyHolder.element.getAttributes().toArray(); + }else if(propertyHolder.type == Type.ATTRS || propertyHolder.type == Type.HIER) + return propertyHolder.getAttributeListForHier(); else if(propertyHolder.type == Type.IN_REL){ Vector res = new Vector<>(); for(ITxRelation rel:propertyHolder.element.getIncomingRelations()){ @@ -655,7 +702,8 @@ public class TransactionDetails { case NAME: if (element instanceof ITxAttribute) { ITxAttribute attribute = (ITxAttribute) element; - return new StyledString(attribute.getName()); + String[] tokens = attribute.getName().split("\\."); + return new StyledString(tokens[tokens.length-1]); }else if (element instanceof ITxRelation) { return new StyledString(Messages.TransactionDetails_4); }else if(element instanceof Object[]){ diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index 3993103..aea6b89 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -31,6 +31,7 @@ import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; +import org.eclipse.core.internal.preferences.InstancePreferences; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; @@ -41,11 +42,10 @@ import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; import org.eclipse.core.runtime.jobs.JobGroup; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.ConfigurationScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; import org.eclipse.e4.core.di.annotations.Optional; -import org.eclipse.e4.core.di.extensions.Preference; import org.eclipse.e4.core.services.events.IEventBroker; import org.eclipse.e4.ui.di.Focus; import org.eclipse.e4.ui.di.PersistState; @@ -56,7 +56,9 @@ import org.eclipse.e4.ui.services.EMenuService; import org.eclipse.e4.ui.workbench.modeling.EPartService; import org.eclipse.e4.ui.workbench.modeling.ESelectionService; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.StringConverter; +import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; @@ -72,6 +74,7 @@ import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; @@ -81,6 +84,7 @@ import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Widget; +import org.osgi.service.prefs.BackingStoreException; import com.minres.scviewer.database.DataType; import com.minres.scviewer.database.ITx; @@ -107,8 +111,8 @@ import com.minres.scviewer.e4.application.internal.status.WaveStatusBarControl; import com.minres.scviewer.e4.application.internal.util.FileMonitor; import com.minres.scviewer.e4.application.internal.util.IFileChangeListener; import com.minres.scviewer.e4.application.internal.util.IModificationChecker; -import com.minres.scviewer.e4.application.preferences.DefaultValuesInitializer; import com.minres.scviewer.e4.application.preferences.PreferenceConstants; +import com.opcoach.e4.preferences.ScopedPreferenceStore; /** * The Class WaveformViewerPart. @@ -190,11 +194,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis @Inject EPartService ePartService; - /** The prefs. */ - @Inject - @Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE) - IEclipsePreferences prefs; - + IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); + @Inject @Optional DesignBrowser designBrowser; /** The database. */ @@ -240,7 +241,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis @PostConstruct public void createComposite(MPart part, Composite parent, IWaveformDbFactory dbFactory) { disposeListenerNumber += 1; - + myPart = part; myParent = parent; database = dbFactory.getDatabase(); @@ -348,7 +349,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis zoomLevel = waveformPane.getZoomLevels(); setupColors(); - checkForUpdates = prefs.getBoolean(PreferenceConstants.DATABASE_RELOAD, true); + checkForUpdates = store.getBoolean(PreferenceConstants.DATABASE_RELOAD); filesToLoad = new ArrayList(); persistedState = part.getPersistedState(); Integer files = persistedState.containsKey(DATABASE_FILE + "S") //$NON-NLS-1$ @@ -377,7 +378,22 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis } } }); - prefs.addPreferenceChangeListener(this); + store.addPropertyChangeListener(new IPropertyChangeListener() { + @Override + public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) { + if (PreferenceConstants.DATABASE_RELOAD.equals(event.getProperty())) { + checkForUpdates = (Boolean)event.getNewValue(); + fileChecker = null; + if (checkForUpdates) + fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad, + FILE_CHECK_INTERVAL); + else + fileMonitor.removeFileChangeListener(WaveformViewer.this); + } else if (!PreferenceConstants.SHOW_HOVER.equals(event.getProperty())){ + setupColors(); + } + } + }); waveformPane.addDisposeListener(this); @@ -390,7 +406,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis waveformPane.getWaveformControl().setData(Constants.CONTENT_PROVIDER_TAG, new ToolTipContentProvider() { @Override public boolean createContent(Composite parent, Point pt) { - if(!prefs.getBoolean(PreferenceConstants.SHOW_HOVER, true)) return false; + if(!store.getBoolean(PreferenceConstants.SHOW_HOVER)) return false; List res = waveformPane.getElementsAt(pt); if(res.size()>0) if(res.get(0) instanceof ITx) { @@ -398,19 +414,26 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis final Display display = parent.getDisplay(); final Font font = new Font(Display.getCurrent(), "Terminal", 10, SWT.NORMAL); - final Label label = new Label(parent, SWT.NONE); - label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + final Label label = new Label(parent, SWT.SHADOW_IN); + label.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + label.setBackground(display.getSystemColor(SWT.COLOR_GRAY)); label.setText(tx.toString()); label.setFont(font); + GridData labelGridData = new GridData(); + labelGridData.horizontalAlignment = GridData.FILL; + labelGridData.grabExcessHorizontalSpace = true; + label.setLayoutData(labelGridData); final Table table = new Table(parent, SWT.NONE); table.setHeaderVisible(true); table.setLinesVisible(true); table.setFont(font); - table.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - table.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - table.setRedraw(false); + label.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + label.setBackground(display.getSystemColor(SWT.COLOR_GRAY)); + GridData tableGridData = new GridData(); + tableGridData.horizontalAlignment = GridData.FILL; + tableGridData.grabExcessHorizontalSpace = true; + table.setLayoutData(tableGridData); final TableColumn nameCol = new TableColumn(table, SWT.LEFT); nameCol.setText("Attribute"); @@ -428,10 +451,15 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis item.setText(0, iTxAttribute.getName()); item.setText(1, value); } + if(table.getHeaderVisible()) { + // add dummy row to get make last row visible + TableItem item = new TableItem(table, SWT.NONE); + item.setText(0, ""); + item.setText(1, ""); + } nameCol.pack(); valueCol.pack(); - table.setRedraw(true); - + table.setSize(table.computeSize(SWT.DEFAULT, SWT.DEFAULT)); parent.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { @@ -445,14 +473,17 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis return true; } else if(res.get(0) instanceof TrackEntry) { TrackEntry te = (TrackEntry)res.get(0); - final Display display = parent.getDisplay(); final Font font = new Font(Display.getCurrent(), "Terminal", 10, SWT.NORMAL); final Label label = new Label(parent, SWT.NONE); - label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + //label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + //label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); label.setText(te.waveform.getFullName()); label.setFont(font); + GridData labelGridData = new GridData(); + labelGridData.horizontalAlignment = GridData.FILL; + labelGridData.grabExcessHorizontalSpace = true; + label.setLayoutData(labelGridData); return true; } return false; @@ -465,28 +496,30 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis */ @Override public void preferenceChange(PreferenceChangeEvent event) { + InstancePreferences pref = (InstancePreferences)event.getSource(); if (PreferenceConstants.DATABASE_RELOAD.equals(event.getKey())) { - checkForUpdates = (Boolean) event.getNewValue(); + checkForUpdates = pref.getBoolean(PreferenceConstants.DATABASE_RELOAD, true); fileChecker = null; if (checkForUpdates) fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad, FILE_CHECK_INTERVAL); else fileMonitor.removeFileChangeListener(this); - } else { + } else if (!PreferenceConstants.SHOW_HOVER.equals(event.getKey())){ setupColors(); } + try { + pref.flush(); + } catch (BackingStoreException e) { } } /** * Setup colors. */ protected void setupColors() { - DefaultValuesInitializer initializer = new DefaultValuesInitializer(); HashMap colorPref = new HashMap<>(); for (WaveformColors c : WaveformColors.values()) { - String prefValue = prefs.get(c.name() + "_COLOR", //$NON-NLS-1$ - StringConverter.asString(initializer.colors[c.ordinal()].getRGB())); + String prefValue = store.getString(c.name() + "_COLOR"); //$NON-NLS-1$ RGB rgb = StringConverter.asRGB(prefValue); colorPref.put(c, rgb); } @@ -636,7 +669,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis } if (filesToLoad.size() > 0) loadDatabase(persistedState); - if(partConfig instanceof String) { + if(partConfig instanceof String && ((String)partConfig).length()>0) { loadState((String) partConfig); } } diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java index a2fdd5c..ca89128 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java @@ -11,7 +11,7 @@ package com.minres.scviewer.e4.application.preferences; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.StringConverter; import org.eclipse.swt.SWT; @@ -64,7 +64,16 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer { */ @Override public void initializeDefaultPreferences() { - IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); +// IEclipsePreferences node = DefaultScope.INSTANCE.getNode(PreferenceConstants.PREFERENCES_SCOPE); +// if (node != null) +// { +// node.putBoolean(PreferenceConstants.DATABASE_RELOAD, true); +// node.putBoolean(PreferenceConstants.SHOW_HOVER, true); +// for (WaveformColors c : WaveformColors.values()) { +// node.put(c.name()+"_COLOR", StringConverter.asString(colors[c.ordinal()].getRGB())); //$NON-NLS-1$ +// } +// } + IPreferenceStore store = new ScopedPreferenceStore(DefaultScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); store.setDefault(PreferenceConstants.DATABASE_RELOAD, true); store.setDefault(PreferenceConstants.SHOW_HOVER, true); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferencesStoreProvider.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferencesStoreProvider.java new file mode 100644 index 0000000..ad4e320 --- /dev/null +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferencesStoreProvider.java @@ -0,0 +1,18 @@ +package com.minres.scviewer.e4.application.preferences; +import org.eclipse.core.runtime.preferences.ConfigurationScope; +import org.eclipse.jface.preference.IPreferenceStore; + +import com.opcoach.e4.preferences.IPreferenceStoreProvider; +import com.opcoach.e4.preferences.ScopedPreferenceStore; + +public class PreferencesStoreProvider implements IPreferenceStoreProvider{ + + public PreferencesStoreProvider(){ + } + + @Override + public IPreferenceStore getPreferenceStore() { + return new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); + } + +} \ No newline at end of file diff --git a/com.minres.scviewer.e4.product/pom.xml b/com.minres.scviewer.e4.product/pom.xml index b23c351..f87674d 100644 --- a/com.minres.scviewer.e4.product/pom.xml +++ b/com.minres.scviewer.e4.product/pom.xml @@ -10,7 +10,7 @@ ../com.minres.scviewer.parent com.minres.scviewer.e4.product - 2.4.0-SNAPSHOT + 2.6.0-SNAPSHOT eclipse-repository com.minres.scviewer diff --git a/com.minres.scviewer.e4.product/scviewer.product b/com.minres.scviewer.e4.product/scviewer.product index 90c16d6..0e3f141 100644 --- a/com.minres.scviewer.e4.product/scviewer.product +++ b/com.minres.scviewer.e4.product/scviewer.product @@ -1,15 +1,17 @@ - + - -clearPersistedState -data @none + -clearPersistedState -Xmx2G +-Dosgi.instance.area=@user.home/.scviewer +-Dosgi.instance.area.default=@user.home/.scviewer -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts @@ -54,6 +56,7 @@ + @@ -111,7 +114,6 @@ - @@ -140,4 +142,11 @@ + + + + + + + diff --git a/com.minres.scviewer.feature/feature.xml b/com.minres.scviewer.feature/feature.xml index 289e335..f32b411 100644 --- a/com.minres.scviewer.feature/feature.xml +++ b/com.minres.scviewer.feature/feature.xml @@ -30,11 +30,12 @@ http://www.eclipse.org/legal/epl-v10.html - - - + + + + @@ -43,15 +44,12 @@ http://www.eclipse.org/legal/epl-v10.html - - - - - + + ../com.minres.scviewer.database.sqlite ../com.minres.scviewer.database.text ../com.minres.scviewer.database.vcd - ../com.minres.scviewer.database.test ../com.minres.scviewer.database.ui ../com.minres.scviewer.database.ui.swt - ../com.opcoach.e4.preferences ../com.minres.scviewer.e4.application ../com.minres.scviewer.ui ../com.minres.scviewer.feature @@ -26,8 +24,8 @@ 1.5.0 - 3.5.0 - 2.5.8-03 + 3.6.0-03 + 3.0.3-01 diff --git a/com.minres.scviewer.target/com.minres.scviewer.target.target b/com.minres.scviewer.target/com.minres.scviewer.target.target index 35d5d82..4571d61 100644 --- a/com.minres.scviewer.target/com.minres.scviewer.target.target +++ b/com.minres.scviewer.target/com.minres.scviewer.target.target @@ -17,6 +17,10 @@ + + + + x86_64 diff --git a/com.opcoach.e4.preferences/.classpath b/com.opcoach.e4.preferences/.classpath deleted file mode 100644 index 4f83b23..0000000 --- a/com.opcoach.e4.preferences/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/com.opcoach.e4.preferences/.gitignore b/com.opcoach.e4.preferences/.gitignore deleted file mode 100644 index 0f63015..0000000 --- a/com.opcoach.e4.preferences/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target/ -/bin/ diff --git a/com.opcoach.e4.preferences/.project b/com.opcoach.e4.preferences/.project deleted file mode 100644 index 8a820c7..0000000 --- a/com.opcoach.e4.preferences/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.opcoach.e4.preferences - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/com.opcoach.e4.preferences/.settings/org.eclipse.jdt.core.prefs b/com.opcoach.e4.preferences/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index a698e59..0000000 --- a/com.opcoach.e4.preferences/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/com.opcoach.e4.preferences/META-INF/MANIFEST.MF b/com.opcoach.e4.preferences/META-INF/MANIFEST.MF deleted file mode 100644 index 5ec77eb..0000000 --- a/com.opcoach.e4.preferences/META-INF/MANIFEST.MF +++ /dev/null @@ -1,19 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Preferences -Bundle-SymbolicName: com.opcoach.e4.preferences;singleton:=true -Bundle-Version: 1.0.0.qualifier -Bundle-Vendor: OPCOACH -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Require-Bundle: javax.inject, - org.eclipse.core.runtime;bundle-version="3.9.0", - org.eclipse.jface;bundle-version="3.9.0", - org.eclipse.e4.core.di;bundle-version="1.3.0", - org.eclipse.e4.ui.model.workbench;bundle-version="1.0.0", - org.eclipse.e4.core.services;bundle-version="1.1.0", - org.eclipse.e4.core.contexts;bundle-version="1.3.0", - org.eclipse.e4.ui.services;bundle-version="1.0.0" -Export-Package: com.opcoach.e4.preferences, - com.opcoach.e4.preferences.handlers -Bundle-ActivationPolicy: lazy -Automatic-Module-Name: com.opcoach.e4.preferences diff --git a/com.opcoach.e4.preferences/build.properties b/com.opcoach.e4.preferences/build.properties deleted file mode 100644 index e9863e2..0000000 --- a/com.opcoach.e4.preferences/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml diff --git a/com.opcoach.e4.preferences/plugin.xml b/com.opcoach.e4.preferences/plugin.xml deleted file mode 100644 index bd6f696..0000000 --- a/com.opcoach.e4.preferences/plugin.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/com.opcoach.e4.preferences/pom.xml b/com.opcoach.e4.preferences/pom.xml deleted file mode 100644 index 4dafa82..0000000 --- a/com.opcoach.e4.preferences/pom.xml +++ /dev/null @@ -1,13 +0,0 @@ - - 4.0.0 - com.opcoach.e4.preferences - - com.minres.scviewer - com.minres.scviewer.parent - 2.0.0-SNAPSHOT - ../com.minres.scviewer.parent - - eclipse-plugin - 1.0.0-SNAPSHOT - com.minres.scviewer - \ No newline at end of file diff --git a/com.opcoach.e4.preferences/schema/e4PreferencePages.exsd b/com.opcoach.e4.preferences/schema/e4PreferencePages.exsd deleted file mode 100644 index bcae797..0000000 --- a/com.opcoach.e4.preferences/schema/e4PreferencePages.exsd +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - - - - [Enter description of this extension point.] - - - - - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - - - - - - - - - a unique name that will be used to identify this page. - - - - - - - a translatable name that will be used in the UI for this page. - - - - - - - - - - a name of the fully qualified class that implements -<samp>org.eclipse.jface.preference.IPreferencePage</samp>. - -IT IS EASYER to extend FieldEditorPreferencePage - -If this class extends directly org.eclipse.jface.preference.FieldEditorPreferencePage preferenceStore is automatically set on it. - - - - - - - - - - a path indicating the location of the page in the preference tree. The path may either be a parent node ID or a sequence - of IDs separated by '/', representing the full path from the root node. - - - - - - - - - - - - - A reference by a preference page to a keyword. See the keywords extension point. - - - - - - - The id of the keyword being referred to. - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/com.opcoach.e4.preferences/schema/e4PreferenceStoreProvider.exsd b/com.opcoach.e4.preferences/schema/e4PreferenceStoreProvider.exsd deleted file mode 100644 index 93e4127..0000000 --- a/com.opcoach.e4.preferences/schema/e4PreferenceStoreProvider.exsd +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - This extension point is used to associate a preference store to a plugin. -You can choose either to implement the IPreferenceStoreProvider interface or to give the ID of the IPreferenceStore to use (stored in the workbench context of your E4 application). -If this extension point is not used, a default ScopedPreferenceStore will be used for the preference page. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Set here the plugin Id concerned by this extension. -Must be a valid plugin ID (control will be done at runtime) - - - - - - - Set a class to get the IPreferenceStore for the defined pluginID. -This parameter is optional if you use the contextId attribute. - - - - - - - - - - If no class is defined, you can set here the ID of the IPreferenceStore available in the context. -This object must be set in the workbenchContext using an Addon for instance, with the following code (in addon): - -@PostContextCreate -public void initMyAddon(IEclipseContext ctx) -{ - IPreferenceStore ps = new ... . // The code to create your pref store - ctx.set(ID set in this extension, ps); -} - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - The definition could be like the following : - -pluginId="yourPluginID" -provider="a class implementing IPreferenceStoreProvider" - - -Or using the key in context (usefull to share the same preference store between plugins) : - -pluginId="yourPluginID" -keyInContext="the key of the IPreferenceStore stored in context" - - - - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - - - - - @OPCoach 2014 - - - - diff --git a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/IPreferenceStoreProvider.java b/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/IPreferenceStoreProvider.java deleted file mode 100644 index b1a3307..0000000 --- a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/IPreferenceStoreProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 OPCoach. - * 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: - * OPCoach - initial API and implementation - *******************************************************************************/ -package com.opcoach.e4.preferences; - -import org.eclipse.jface.preference.IPreferenceStore; - -/** This interface can be implemented to provide a PreferenceStore for a given plugin. - * This associatino must be done in the e4PreferenceStoreProvider extension point. - * @author olivier - * - */ -public interface IPreferenceStoreProvider -{ - /** Must be implemented to return a preference store */ - public IPreferenceStore getPreferenceStore(); - -} diff --git a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/ScopedPreferenceStore.java b/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/ScopedPreferenceStore.java deleted file mode 100644 index 3017845..0000000 --- a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/ScopedPreferenceStore.java +++ /dev/null @@ -1,861 +0,0 @@ - -/******************************************************************************* - * Copyright (c) 2014 OPCoach. - * 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: - * Eclipse - copy of the implementation coming from jface - *******************************************************************************/ - -package com.opcoach.e4.preferences; - -import java.io.IOException; - -import org.eclipse.core.commands.common.EventManager; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.SafeRunner; -import org.eclipse.core.runtime.preferences.DefaultScope; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.IScopeContext; -import org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener; -import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent; -import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; -import org.eclipse.jface.preference.IPersistentPreferenceStore; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.util.SafeRunnable; -import org.osgi.service.prefs.BackingStoreException; - -/** - * The ScopedPreferenceStore is an IPreferenceStore that uses the scopes - * provided in org.eclipse.core.runtime.preferences. - *

- * A ScopedPreferenceStore does the lookup of a preference based on it's search - * scopes and sets the value of the preference based on its store scope. - *

- *

- * The default scope is always included in the search scopes when searching for - * preference values. - *

- * - * @see org.eclipse.core.runtime.preferences - * @since 3.1 - */ -public class ScopedPreferenceStore extends EventManager implements - IPreferenceStore, IPersistentPreferenceStore { - - /** - * The storeContext is the context where values will stored with the - * setValue methods. If there are no searchContexts this will be the search - * context. (along with the "default" context) - */ - private IScopeContext storeContext; - - /** - * The searchContext is the array of contexts that will be used by the get - * methods for searching for values. - */ - private IScopeContext[] searchContexts; - - /** - * A boolean to indicate the property changes should not be propagated. - */ - protected boolean silentRunning = false; - - /** - * The listener on the IEclipsePreferences. This is used to forward updates - * to the property change listeners on the preference store. - */ - IEclipsePreferences.IPreferenceChangeListener preferencesListener; - - /** - * The default context is the context where getDefault and setDefault - * methods will search. This context is also used in the search. - */ - private IScopeContext defaultContext = DefaultScope.INSTANCE; - - /** - * The nodeQualifer is the string used to look up the node in the contexts. - */ - String nodeQualifier; - - /** - * The defaultQualifier is the string used to look up the default node. - */ - String defaultQualifier; - - /** - * Boolean value indicating whether or not this store has changes to be - * saved. - */ - private boolean dirty; - - /** - * Create a new instance of the receiver. Store the values in context in the - * node looked up by qualifier. NOTE: Any instance of - * ScopedPreferenceStore should call - * - * @param context - * the scope to store to - * @param qualifier - * the qualifier used to look up the preference node - * @param defaultQualifierPath - * the qualifier used when looking up the defaults - */ - public ScopedPreferenceStore(IScopeContext context, String qualifier, - String defaultQualifierPath) { - this(context, qualifier); - this.defaultQualifier = defaultQualifierPath; - } - - /** - * Create a new instance of the receiver. Store the values in context in the - * node looked up by qualifier. - * - * @param context - * the scope to store to - * @param qualifier - * the qualifer used to look up the preference node - */ - public ScopedPreferenceStore(IScopeContext context, String qualifier) { - storeContext = context; - this.nodeQualifier = qualifier; - this.defaultQualifier = qualifier; - - ((IEclipsePreferences) getStorePreferences().parent()) - .addNodeChangeListener(getNodeChangeListener()); - } - - /** - * Return a node change listener that adds a removes the receiver when nodes - * change. - * - * @return INodeChangeListener - */ - private INodeChangeListener getNodeChangeListener() { - return new IEclipsePreferences.INodeChangeListener() { - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#added(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent) - */ - public void added(NodeChangeEvent event) { - if (nodeQualifier.equals(event.getChild().name()) - && isListenerAttached()) { - getStorePreferences().addPreferenceChangeListener( - preferencesListener); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#removed(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent) - */ - public void removed(NodeChangeEvent event) { - // Do nothing as there are no events from removed node - } - }; - } - - /** - * Initialize the preferences listener. - */ - private void initializePreferencesListener() { - if (preferencesListener == null) { - preferencesListener = new IEclipsePreferences.IPreferenceChangeListener() { - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) - */ - public void preferenceChange(PreferenceChangeEvent event) { - - if (silentRunning) { - return; - } - - Object oldValue = event.getOldValue(); - Object newValue = event.getNewValue(); - String key = event.getKey(); - if (newValue == null) { - newValue = getDefault(key, oldValue); - } else if (oldValue == null) { - oldValue = getDefault(key, newValue); - } - firePropertyChangeEvent(event.getKey(), oldValue, newValue); - } - }; - getStorePreferences().addPreferenceChangeListener( - preferencesListener); - } - - } - - /** - * Does its best at determining the default value for the given key. Checks - * the given object's type and then looks in the list of defaults to see if - * a value exists. If not or if there is a problem converting the value, the - * default default value for that type is returned. - * - * @param key - * the key to search - * @param obj - * the object who default we are looking for - * @return Object or null - */ - Object getDefault(String key, Object obj) { - IEclipsePreferences defaults = getDefaultPreferences(); - if (obj instanceof String) { - return defaults.get(key, STRING_DEFAULT_DEFAULT); - } else if (obj instanceof Integer) { - return new Integer(defaults.getInt(key, INT_DEFAULT_DEFAULT)); - } else if (obj instanceof Double) { - return new Double(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT)); - } else if (obj instanceof Float) { - return new Float(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT)); - } else if (obj instanceof Long) { - return new Long(defaults.getLong(key, LONG_DEFAULT_DEFAULT)); - } else if (obj instanceof Boolean) { - return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE - : Boolean.FALSE; - } else { - return null; - } - } - - /** - * Return the IEclipsePreferences node associated with this store. - * - * @return the preference node for this store - */ - IEclipsePreferences getStorePreferences() { - return storeContext.getNode(nodeQualifier); - } - - /** - * Return the default IEclipsePreferences for this store. - * - * @return this store's default preference node - */ - private IEclipsePreferences getDefaultPreferences() { - return defaultContext.getNode(defaultQualifier); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - initializePreferencesListener();// Create the preferences listener if it - // does not exist - addListenerObject(listener); - } - - /** - * Return the preference path to search preferences on. This is the list of - * preference nodes based on the scope contexts for this store. If there are - * no search contexts set, then return this store's context. - *

- * Whether or not the default context should be included in the resulting - * list is specified by the includeDefault parameter. - *

- * - * @param includeDefault - * true if the default context should be included - * and false otherwise - * @return IEclipsePreferences[] - * @since 3.4 public, was added in 3.1 as private method - */ - public IEclipsePreferences[] getPreferenceNodes(boolean includeDefault) { - // if the user didn't specify a search order, then return the scope that - // this store was created on. (and optionally the default) - if (searchContexts == null) { - if (includeDefault) { - return new IEclipsePreferences[] { getStorePreferences(), - getDefaultPreferences() }; - } - return new IEclipsePreferences[] { getStorePreferences() }; - } - // otherwise the user specified a search order so return the appropriate - // nodes based on it - int length = searchContexts.length; - if (includeDefault) { - length++; - } - IEclipsePreferences[] preferences = new IEclipsePreferences[length]; - for (int i = 0; i < searchContexts.length; i++) { - preferences[i] = searchContexts[i].getNode(nodeQualifier); - } - if (includeDefault) { - preferences[length - 1] = getDefaultPreferences(); - } - return preferences; - } - - /** - * Set the search contexts to scopes. When searching for a value the seach - * will be done in the order of scope contexts and will not search the - * storeContext unless it is in this list. - *

- * If the given list is null, then clear this store's search - * contexts. This means that only this store's scope context and default - * scope will be used during preference value searching. - *

- *

- * The defaultContext will be added to the end of this list automatically - * and MUST NOT be included by the user. - *

- * - * @param scopes - * a list of scope contexts to use when searching, or - * null - */ - public void setSearchContexts(IScopeContext[] scopes) { - this.searchContexts = scopes; - if (scopes == null) { - return; - } - - // Assert that the default was not included (we automatically add it to - // the end) - for (int i = 0; i < scopes.length; i++) { - if (scopes[i].equals(defaultContext)) { - Assert - .isTrue( - false, - "Do not add the default to the search contexts"); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String) - */ - public boolean contains(String name) { - if (name == null) { - return false; - } - return (Platform.getPreferencesService().get(name, null, - getPreferenceNodes(true))) != null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent(java.lang.String, - * java.lang.Object, java.lang.Object) - */ - public void firePropertyChangeEvent(String name, Object oldValue, - Object newValue) { - // important: create intermediate array to protect against listeners - // being added/removed during the notification - final Object[] list = getListeners(); - if (list.length == 0) { - return; - } - final PropertyChangeEvent event = new PropertyChangeEvent(this, name, - oldValue, newValue); - for (int i = 0; i < list.length; i++) { - final IPropertyChangeListener listener = (IPropertyChangeListener) list[i]; - SafeRunner.run(new SafeRunnable(JFaceResources - .getString("PreferenceStore.changeError")) { //$NON-NLS-1$ - public void run() { - listener.propertyChange(event); - } - }); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String) - */ - public boolean getBoolean(String name) { - String value = internalGet(name); - return value == null ? BOOLEAN_DEFAULT_DEFAULT : Boolean.valueOf(value) - .booleanValue(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultBoolean(java.lang.String) - */ - public boolean getDefaultBoolean(String name) { - return getDefaultPreferences() - .getBoolean(name, BOOLEAN_DEFAULT_DEFAULT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultDouble(java.lang.String) - */ - public double getDefaultDouble(String name) { - return getDefaultPreferences().getDouble(name, DOUBLE_DEFAULT_DEFAULT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultFloat(java.lang.String) - */ - public float getDefaultFloat(String name) { - return getDefaultPreferences().getFloat(name, FLOAT_DEFAULT_DEFAULT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultInt(java.lang.String) - */ - public int getDefaultInt(String name) { - return getDefaultPreferences().getInt(name, INT_DEFAULT_DEFAULT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultLong(java.lang.String) - */ - public long getDefaultLong(String name) { - return getDefaultPreferences().getLong(name, LONG_DEFAULT_DEFAULT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultString(java.lang.String) - */ - public String getDefaultString(String name) { - return getDefaultPreferences().get(name, STRING_DEFAULT_DEFAULT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDouble(java.lang.String) - */ - public double getDouble(String name) { - String value = internalGet(name); - if (value == null) { - return DOUBLE_DEFAULT_DEFAULT; - } - try { - return Double.parseDouble(value); - } catch (NumberFormatException e) { - return DOUBLE_DEFAULT_DEFAULT; - } - } - - /** - * Return the string value for the specified key. Look in the nodes which - * are specified by this object's list of search scopes. If the value does - * not exist then return null. - * - * @param key - * the key to search with - * @return String or null if the value does not exist. - */ - private String internalGet(String key) { - return Platform.getPreferencesService().get(key, null, - getPreferenceNodes(true)); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getFloat(java.lang.String) - */ - public float getFloat(String name) { - String value = internalGet(name); - if (value == null) { - return FLOAT_DEFAULT_DEFAULT; - } - try { - return Float.parseFloat(value); - } catch (NumberFormatException e) { - return FLOAT_DEFAULT_DEFAULT; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getInt(java.lang.String) - */ - public int getInt(String name) { - String value = internalGet(name); - if (value == null) { - return INT_DEFAULT_DEFAULT; - } - try { - return Integer.parseInt(value); - } catch (NumberFormatException e) { - return INT_DEFAULT_DEFAULT; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getLong(java.lang.String) - */ - public long getLong(String name) { - String value = internalGet(name); - if (value == null) { - return LONG_DEFAULT_DEFAULT; - } - try { - return Long.parseLong(value); - } catch (NumberFormatException e) { - return LONG_DEFAULT_DEFAULT; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String) - */ - public String getString(String name) { - String value = internalGet(name); - return value == null ? STRING_DEFAULT_DEFAULT : value; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#isDefault(java.lang.String) - */ - public boolean isDefault(String name) { - if (name == null) { - return false; - } - return (Platform.getPreferencesService().get(name, null, - getPreferenceNodes(false))) == null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#needsSaving() - */ - public boolean needsSaving() { - return dirty; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String, - * java.lang.String) - */ - public void putValue(String name, String value) { - try { - // Do not notify listeners - silentRunning = true; - getStorePreferences().put(name, value); - } finally { - // Be sure that an exception does not stop property updates - silentRunning = false; - dirty = true; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - removeListenerObject(listener); - if (!isListenerAttached()) { - disposePreferenceStoreListener(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, - * double) - */ - public void setDefault(String name, double value) { - getDefaultPreferences().putDouble(name, value); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, - * float) - */ - public void setDefault(String name, float value) { - getDefaultPreferences().putFloat(name, value); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, - * int) - */ - public void setDefault(String name, int value) { - getDefaultPreferences().putInt(name, value); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, - * long) - */ - public void setDefault(String name, long value) { - getDefaultPreferences().putLong(name, value); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, - * java.lang.String) - */ - public void setDefault(String name, String defaultObject) { - getDefaultPreferences().put(name, defaultObject); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, - * boolean) - */ - public void setDefault(String name, boolean value) { - getDefaultPreferences().putBoolean(name, value); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setToDefault(java.lang.String) - */ - public void setToDefault(String name) { - - String oldValue = getString(name); - String defaultValue = getDefaultString(name); - try { - silentRunning = true;// Turn off updates from the store - // removing a non-existing preference is a no-op so call the Core - // API directly - getStorePreferences().remove(name); - if (oldValue != defaultValue){ - dirty = true; - firePropertyChangeEvent(name, oldValue, defaultValue); - } - - } finally { - silentRunning = false;// Restart listening to preferences - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, - * double) - */ - public void setValue(String name, double value) { - double oldValue = getDouble(name); - if (oldValue == value) { - return; - } - try { - silentRunning = true;// Turn off updates from the store - if (getDefaultDouble(name) == value) { - getStorePreferences().remove(name); - } else { - getStorePreferences().putDouble(name, value); - } - dirty = true; - firePropertyChangeEvent(name, new Double(oldValue), new Double( - value)); - } finally { - silentRunning = false;// Restart listening to preferences - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, - * float) - */ - public void setValue(String name, float value) { - float oldValue = getFloat(name); - if (oldValue == value) { - return; - } - try { - silentRunning = true;// Turn off updates from the store - if (getDefaultFloat(name) == value) { - getStorePreferences().remove(name); - } else { - getStorePreferences().putFloat(name, value); - } - dirty = true; - firePropertyChangeEvent(name, new Float(oldValue), new Float(value)); - } finally { - silentRunning = false;// Restart listening to preferences - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, - * int) - */ - public void setValue(String name, int value) { - int oldValue = getInt(name); - if (oldValue == value) { - return; - } - try { - silentRunning = true;// Turn off updates from the store - if (getDefaultInt(name) == value) { - getStorePreferences().remove(name); - } else { - getStorePreferences().putInt(name, value); - } - dirty = true; - firePropertyChangeEvent(name, new Integer(oldValue), new Integer( - value)); - } finally { - silentRunning = false;// Restart listening to preferences - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, - * long) - */ - public void setValue(String name, long value) { - long oldValue = getLong(name); - if (oldValue == value) { - return; - } - try { - silentRunning = true;// Turn off updates from the store - if (getDefaultLong(name) == value) { - getStorePreferences().remove(name); - } else { - getStorePreferences().putLong(name, value); - } - dirty = true; - firePropertyChangeEvent(name, new Long(oldValue), new Long(value)); - } finally { - silentRunning = false;// Restart listening to preferences - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, - * java.lang.String) - */ - public void setValue(String name, String value) { - // Do not turn on silent running here as Strings are propagated - if (getDefaultString(name).equals(value)) { - getStorePreferences().remove(name); - } else { - getStorePreferences().put(name, value); - } - dirty = true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, - * boolean) - */ - public void setValue(String name, boolean value) { - boolean oldValue = getBoolean(name); - if (oldValue == value) { - return; - } - try { - silentRunning = true;// Turn off updates from the store - if (getDefaultBoolean(name) == value) { - getStorePreferences().remove(name); - } else { - getStorePreferences().putBoolean(name, value); - } - dirty = true; - firePropertyChangeEvent(name, oldValue ? Boolean.TRUE - : Boolean.FALSE, value ? Boolean.TRUE : Boolean.FALSE); - } finally { - silentRunning = false;// Restart listening to preferences - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPersistentPreferenceStore#save() - */ - public void save() throws IOException { - try { - getStorePreferences().flush(); - dirty = false; - } catch (BackingStoreException e) { - throw new IOException(e.getMessage()); - } - - } - - /** - * Dispose the receiver. - */ - private void disposePreferenceStoreListener() { - - IEclipsePreferences root = (IEclipsePreferences) Platform - .getPreferencesService().getRootNode().node( - Plugin.PLUGIN_PREFERENCE_SCOPE); - try { - if (!(root.nodeExists(nodeQualifier))) { - return; - } - } catch (BackingStoreException e) { - return;// No need to report here as the node won't have the - // listener - } - - IEclipsePreferences preferences = getStorePreferences(); - if (preferences == null) { - return; - } - if (preferencesListener != null) { - preferences.removePreferenceChangeListener(preferencesListener); - preferencesListener = null; - } - } - -} diff --git a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/handlers/E4PreferencesHandler.java b/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/handlers/E4PreferencesHandler.java deleted file mode 100644 index 166989b..0000000 --- a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/handlers/E4PreferencesHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 OPCoach. - * 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: - * Manumitting Technologies : Brian de Alwis for initial API and implementation - * OPCoach : O.Prouvost fix bugs on hierarchy - *******************************************************************************//* - * Handler to open up a configured preferences dialog. - * Written by Brian de Alwis, Manumitting Technologies. - * Placed in the public domain. - * This code comes from : http://www.eclipse.org/forums/index.php/fa/4347/ - * and was referenced in the thread : http://www.eclipse.org/forums/index.php/m/750139/ - */ -package com.opcoach.e4.preferences.handlers; - -import javax.inject.Named; - -import org.eclipse.e4.core.di.annotations.CanExecute; -import org.eclipse.e4.core.di.annotations.Execute; -import org.eclipse.e4.ui.services.IServiceConstants; -import org.eclipse.jface.preference.PreferenceDialog; -import org.eclipse.jface.preference.PreferenceManager; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.swt.widgets.Shell; - -import com.opcoach.e4.preferences.internal.E4PreferenceRegistry; - - -public class E4PreferencesHandler -{ - - - @CanExecute - public boolean canExecute() - { - return true; - } - - @Execute - public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, E4PreferenceRegistry prefReg) - { - PreferenceManager pm = prefReg.getPreferenceManager(); - PreferenceDialog dialog = new PreferenceDialog(shell, pm); - dialog.create(); - dialog.getTreeViewer().setComparator(new ViewerComparator()); - dialog.getTreeViewer().expandAll(); - dialog.open(); - } - - - - -} diff --git a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/internal/E4PreferenceRegistry.java b/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/internal/E4PreferenceRegistry.java index 5623c9d..de4baf8 100644 --- a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/internal/E4PreferenceRegistry.java +++ b/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/internal/E4PreferenceRegistry.java @@ -46,6 +46,7 @@ public class E4PreferenceRegistry public static final String PREFS_PAGE_XP = "com.opcoach.e4.preferences.e4PreferencePages"; // $NON-NLS-1$ public static final String PREF_STORE_PROVIDER = "com.opcoach.e4.preferences.e4PreferenceStoreProvider"; // $NON-NLS-1$ + public static final String KEY_PREF_STORE_PROVIDERS = "com.opcoach.e4.preferences.e4PreferenceStoreProviders"; // $NON-NLS-1$ protected static final String ELMT_PAGE = "page"; // $NON-NLS-1$ protected static final String ATTR_ID = "id"; // $NON-NLS-1$ protected static final String ATTR_CATEGORY = "category"; // $NON-NLS-1$ @@ -235,6 +236,7 @@ public class E4PreferenceRegistry IContributionFactory factory = context.get(IContributionFactory.class); psProviders = new HashMap(); + IExtensionRegistry registry = context.get(IExtensionRegistry.class); // Read extensions and fill the map... for (IConfigurationElement elmt : registry.getConfigurationElementsFor(PREF_STORE_PROVIDER)) @@ -261,7 +263,7 @@ public class E4PreferenceRegistry Object data = objectId; if (classname != null) { - data = factory.create(classname, context); + data = factory.create("bundleclass://"+declaringBundle+"/"+classname, context); if (!(data instanceof IPreferenceStoreProvider)) { logger.warn("In extension " + PREF_STORE_PROVIDER + " the class must implements IPreferenceStoreProvider. Check the plugin " + declaringBundle); @@ -272,6 +274,8 @@ public class E4PreferenceRegistry psProviders.put(pluginId, data); } + + context.set(KEY_PREF_STORE_PROVIDERS, psProviders); } }