From 929cf21ff80e093aa0265bcc7ac5d07239e0775f Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 22 Nov 2015 12:07:50 +0100 Subject: [PATCH 1/8] 3: Zoom in/out should try its best to keep cursor at the same position Task-Url: https://github.com/eyck/txviewer/issues/issue/3 --- .../database/swt/internal/WaveformCanvas.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java index 8b9f0bd..841e80b 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java @@ -222,16 +222,32 @@ public class WaveformCanvas extends Canvas { } public void setZoomLevel(int level) { + long oldScaleFactor=scaleFactor; if(level0) + origin.x=(int) -originX; // new cursor time offset relative to left border + else + origin.x=0; syncScrollBars(); - arrowPainter.setTx(tx); + arrowPainter.setTx(tx); redraw(); - } + } } public long getScaleFactor() { From 316647031af50c94cf838cc69f000959dba93dd2 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 22 Nov 2015 12:14:27 +0100 Subject: [PATCH 2/8] 2: Reload dialog opens while dialog is open Task-Url: https://github.com/eyck/txviewer/issues/issue/2 --- .../internal/util/FileMonitor.java | 56 +- .../e4/application/parts/WaveformViewer.java | 836 ++++++++++++++++++ 2 files changed, 878 insertions(+), 14 deletions(-) create mode 100644 com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/FileMonitor.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/FileMonitor.java index 5c42523..3989582 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/FileMonitor.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/FileMonitor.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Timer; import java.util.TimerTask; +// TODO: Auto-generated Javadoc /** * Class monitoring a {@link File} for changes. * @@ -25,8 +26,12 @@ import java.util.TimerTask; */ public class FileMonitor { + /** The timer. */ private Timer timer; + private boolean enabled; + + /** The timer entries. */ private Hashtable timerEntries; /** @@ -36,17 +41,16 @@ public class FileMonitor { // Create timer, run timer thread as daemon. timer = new Timer(true); timerEntries = new Hashtable(); + enabled=true; } /** * Adds a monitored file with a FileChangeListener. - * - * @param listener - * listener to notify when the file changed. - * @param fileName - * name of the file to monitor. - * @param period - * polling period in milliseconds. + * + * @param listener listener to notify when the file changed. + * @param file the file + * @param period polling period in milliseconds. + * @return the i modification checker */ public IModificationChecker addFileChangeListener(IFileChangeListener listener, File file, long period) { return addFileChangeListener(listener, Arrays.asList(new File[]{file}), period); @@ -55,12 +59,11 @@ public class FileMonitor { /** * Adds a monitored file with a FileChangeListener. * List filesToLoad - * @param listener - * listener to notify when the file changed. - * @param fileName - * name of the file to monitor. - * @param period - * polling period in milliseconds. + * + * @param listener listener to notify when the file changed. + * @param files the files + * @param period polling period in milliseconds. + * @return the i modification checker */ public IModificationChecker addFileChangeListener(IFileChangeListener listener, List files, long period) { removeFileChangeListener(listener); @@ -90,7 +93,15 @@ public class FileMonitor { * the file that changed */ protected void fireFileChangeEvent(IFileChangeListener listener, List file) { - listener.fileChanged(file); + if(enabled) listener.fileChanged(file); + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; } /** @@ -98,14 +109,25 @@ public class FileMonitor { */ class FileSetMonitorTask extends TimerTask implements IModificationChecker{ + /** The listener. */ IFileChangeListener listener; + /** The monitored files. */ private List monitoredFiles; + /** The last modified times. */ private List lastModifiedTimes; + /** The period. */ public final long period; + /** + * Instantiates a new file set monitor task. + * + * @param listener the listener + * @param monitoredFiles the monitored files + * @param period the period + */ public FileSetMonitorTask(IFileChangeListener listener, List monitoredFiles, long period) { this.period=period; this.monitoredFiles = monitoredFiles; @@ -120,10 +142,16 @@ public class FileMonitor { } } + /* (non-Javadoc) + * @see java.util.TimerTask#run() + */ public void run() { check(); } + /* (non-Javadoc) + * @see com.minres.scviewer.e4.application.internal.util.IModificationChecker#check() + */ public void check() { boolean res = false; for(int i=0; i filesToLoad; + + /** The persisted state. */ + Map persistedState; + + /** The browser state. */ + private Object browserState; + + /** The details settings. */ + private Object detailsSettings; + + /** The navigation relation type. */ + private RelationType navigationRelationType=IWaveformViewer.NEXT_PREV_IN_STREAM ; + + /** The file monitor. */ + FileMonitor fileMonitor = new FileMonitor(); + + /** The file checker. */ + IModificationChecker fileChecker; + + /** + * Creates the composite. + * + * @param part the part + * @param parent the parent + * @param dbFactory the db factory + */ + @PostConstruct + public void createComposite(MPart part, Composite parent, IWaveformDbFactory dbFactory) { + myPart = part; + myParent = parent; + database = dbFactory.getDatabase(); + database.addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + if ("WAVEFORMS".equals(evt.getPropertyName())) { + myParent.getDisplay().syncExec(new Runnable() { + @Override + public void run() { + waveformPane.setMaxTime(database.getMaxTime()); + } + }); + } + } + }); + waveformPane = factory.createPanel(parent); + waveformPane.setMaxTime(0); + waveformPane.addPropertyChangeListener(IWaveformViewer.CURSOR_PROPERTY, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Long time = (Long) evt.getNewValue(); + eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(time)); + long marker = waveformPane.getSelectedMarkerTime(); + eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(time - marker)); + + } + }); + waveformPane.addPropertyChangeListener(IWaveformViewer.MARKER_PROPERTY, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Long time = (Long) evt.getNewValue(); + eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getScaledTime(time)); + long cursor = waveformPane.getCursorTime(); + eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - time)); + } + }); + waveformPane.addSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + if (event.getSelection() instanceof IStructuredSelection) + selectionService.setSelection(event.getSelection()); + } + }); + zoomLevel = waveformPane.getZoomLevels(); + setupColors(); + checkForUpdates = prefs.getBoolean(PreferenceConstants.DATABASE_RELOAD, true); + filesToLoad = new ArrayList(); + persistedState = part.getPersistedState(); + Integer files = persistedState.containsKey(DATABASE_FILE + "S") + ? Integer.parseInt(persistedState.get(DATABASE_FILE + "S")) : 0; + for (int i = 0; i < files; i++) { + filesToLoad.add(new File(persistedState.get(DATABASE_FILE + i))); + } + if (filesToLoad.size() > 0) + loadDatabase(persistedState); + eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]); + menuService.registerContextMenu(waveformPane.getNameControl(), + "com.minres.scviewer.e4.application.popupmenu.namecontext"); + menuService.registerContextMenu(waveformPane.getValueControl(), + "com.minres.scviewer.e4.application.popupmenu.namecontext"); + menuService.registerContextMenu(waveformPane.getWaveformControl(), + "com.minres.scviewer.e4.application.popupmenu.wavecontext"); + ePartService.addPartListener(new PartListener() { + @Override + public void partActivated(MPart part) { + if (part == myPart) { + if (fileChecker != null) + fileChecker.check(); + updateAll(); + } + } + }); + prefs.addPreferenceChangeListener(this); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) + */ + @Override + public void preferenceChange(PreferenceChangeEvent event) { + if (PreferenceConstants.DATABASE_RELOAD.equals(event.getKey())) { + checkForUpdates = (Boolean) event.getNewValue(); + fileChecker = null; + if (checkForUpdates) + fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad, + FILE_CHECK_INTERVAL); + else + fileMonitor.removeFileChangeListener(this); + } else { + setupColors(); + } + } + + /** + * 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", + StringConverter.asString(initializer.colors[c.ordinal()].getRGB())); + RGB rgb = StringConverter.asRGB(prefValue); + colorPref.put(c, rgb); + } + waveformPane.setColors(colorPref); + } + + /** + * Load database. + * + * @param state the state + */ + protected void loadDatabase(final Map state) { + fileMonitor.removeFileChangeListener(this); + Job job = new Job(" My Job") { + @Override + protected IStatus run(IProgressMonitor monitor) { + // convert to SubMonitor and set total number of work units + SubMonitor subMonitor = SubMonitor.convert(monitor, filesToLoad.size()); + subMonitor.setTaskName("Loading database"); + try { + for (File file : filesToLoad) { + // TimeUnit.SECONDS.sleep(2); + database.load(file); + database.addPropertyChangeListener(waveformPane); + subMonitor.worked(1); + if (monitor.isCanceled()) + return Status.CANCEL_STATUS; + } + // sleep a second + } catch (Exception e) { + database = null; + e.printStackTrace(); + return Status.CANCEL_STATUS; + } + subMonitor.done(); + monitor.done(); + return Status.OK_STATUS; + } + }; + job.addJobChangeListener(new JobChangeAdapter() { + @Override + public void done(IJobChangeEvent event) { + if (event.getResult() == Status.OK_STATUS) + myParent.getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + waveformPane.setMaxTime(database.getMaxTime()); + if (state != null) + restoreWaveformViewerState(state); + fileChecker = null; + if (checkForUpdates) + fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad, + FILE_CHECK_INTERVAL); + } + }); + } + }); + job.schedule(0); + } + + /* (non-Javadoc) + * @see com.minres.scviewer.e4.application.internal.util.IFileChangeListener#fileChanged(java.util.List) + */ + @Override + public void fileChanged(List file) { + final Display display = myParent.getDisplay(); + display.asyncExec(new Runnable() { + @Override + public void run() { + if (MessageDialog.openQuestion(display.getActiveShell(), "Database re-load", + "Would you like to reload the database?")) { + Map state = new HashMap<>(); + saveWaveformViewerState(state); + waveformPane.getStreamList().clear(); + database.clear(); + if (filesToLoad.size() > 0) + loadDatabase(state); + } + } + }); + fileMonitor.removeFileChangeListener(this); + } + + /** + * Sets the part input. + * + * @param partInput the new part input + */ + @Inject + @Optional + public void setPartInput(@Named("input") Object partInput) { + if (partInput instanceof File) { + filesToLoad = new ArrayList(); + File file = (File) partInput; + if (file.exists()) { + filesToLoad.add(file); + try { + String ext = getFileExtension(file.getName()); + if ("vcd".equals(ext.toLowerCase())) { + if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), "txdb")))) { + filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), "txdb"))); + } else if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), "txlog")))) { + filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), "txlog"))); + } + } else if ("txdb".equals(ext.toLowerCase()) || "txlog".equals(ext.toLowerCase())) { + if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), "vcd")))) { + filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), "vcd"))); + } + } + } catch (IOException e) { // silently ignore any error + } + } + if (filesToLoad.size() > 0) + loadDatabase(persistedState); + } + } + + /** + * Sets the focus. + */ + @Focus + public void setFocus() { + myParent.setFocus(); + } + + /** + * Save state. + * + * @param part the part + */ + @PersistState + public void saveState(MPart part) { + // save changes + Map persistedState = part.getPersistedState(); + persistedState.put(DATABASE_FILE + "S", Integer.toString(filesToLoad.size())); + Integer index = 0; + for (File file : filesToLoad) { + persistedState.put(DATABASE_FILE + index, file.getAbsolutePath()); + index++; + } + saveWaveformViewerState(persistedState); + } + + /** + * Save waveform viewer state. + * + * @param persistedState the persisted state + */ + protected void saveWaveformViewerState(Map persistedState) { + Integer index; + persistedState.put(SHOWN_WAVEFORM + "S", Integer.toString(waveformPane.getStreamList().size())); + index = 0; + for (TrackEntry trackEntry : waveformPane.getStreamList()) { + persistedState.put(SHOWN_WAVEFORM + index, trackEntry.waveform.getFullName()); + index++; + } + List cursors = waveformPane.getCursorList(); + persistedState.put(SHOWN_CURSOR + "S", Integer.toString(cursors.size())); + index = 0; + for (ICursor cursor : cursors) { + persistedState.put(SHOWN_CURSOR + index, Long.toString(cursor.getTime())); + index++; + } + persistedState.put(ZOOM_LEVEL, Integer.toString(waveformPane.getZoomLevel())); + } + + /** + * Restore waveform viewer state. + * + * @param state the state + */ + protected void restoreWaveformViewerState(Map state) { + updateAll(); + Integer waves = state.containsKey(SHOWN_WAVEFORM + "S") ? Integer.parseInt(state.get(SHOWN_WAVEFORM + "S")) : 0; + List res = new LinkedList<>(); + for (int i = 0; i < waves; i++) { + IWaveform waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i)); + if (waveform != null) + res.add(new TrackEntry(waveform)); + } + if (res.size() > 0) + waveformPane.getStreamList().addAll(res); + Integer cursorLength = state.containsKey(SHOWN_CURSOR + "S") ? Integer.parseInt(state.get(SHOWN_CURSOR + "S")) + : 0; + List cursors = waveformPane.getCursorList(); + if (cursorLength == cursors.size()) { + for (int i = 0; i < cursorLength; i++) { + Long time = Long.parseLong(state.get(SHOWN_CURSOR + i)); + cursors.get(i).setTime(time); + } + } + if (state.containsKey(ZOOM_LEVEL)) { + try { + Integer scale = Integer.parseInt(state.get(ZOOM_LEVEL)); + waveformPane.setZoomLevel(scale); + } catch (NumberFormatException e) { + } + } + } + + /** + * Update all. + */ + private void updateAll() { + eventBroker.post(ACTIVE_WAVEFORMVIEW, this); + eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]); + long cursor = waveformPane.getCursorTime(); + long marker = waveformPane.getSelectedMarkerTime(); + eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(cursor)); + eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getScaledTime(marker)); + eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - marker)); + } + + /** + * Gets the adds the waveform event. + * + * @param o the o + * @return the adds the waveform event + */ + @Inject + @Optional + public void getAddWaveformEvent(@UIEventTopic(WaveformViewer.ADD_WAVEFORM) Object o) { + Object sel = o == null ? selectionService.getSelection() : o; + if (sel instanceof IStructuredSelection) + for (Object el : ((IStructuredSelection) sel).toArray()) { + if (el instanceof IWaveform) + addStreamToList((IWaveform) el, false); + } + } + + /** + * Ask if to load. + * + * @param txFile the tx file + * @return true, if successful + */ + protected boolean askIfToLoad(File txFile) { + if (txFile.exists() && MessageDialog.openQuestion(myParent.getDisplay().getActiveShell(), "Database open", + "Would you like to open the adjacent database " + txFile.getName() + " as well?")) { + return true; + } + return false; + } + + /** + * Rename file extension. + * + * @param source the source + * @param newExt the new ext + * @return the string + */ + protected static String renameFileExtension(String source, String newExt) { + String target; + String currentExt = getFileExtension(source); + if (currentExt.equals("")) { + target = source + "." + newExt; + } else { + target = source.replaceFirst(Pattern.quote("." + currentExt) + "$", Matcher.quoteReplacement("." + newExt)); + } + return target; + } + + /** + * Gets the file extension. + * + * @param f the f + * @return the file extension + */ + protected static String getFileExtension(String f) { + String ext = ""; + int i = f.lastIndexOf('.'); + if (i > 0 && i < f.length() - 1) { + ext = f.substring(i + 1); + } + return ext; + } + + /** + * Gets the model. + * + * @return the model + */ + public IWaveformDb getModel() { + return database; + } + + /** + * Gets the database. + * + * @return the database + */ + public IWaveformDb getDatabase() { + return database; + } + + /** + * Adds the stream to list. + * + * @param obj the obj + * @param insert the insert + */ + public void addStreamToList(IWaveform obj, boolean insert) { + addStreamsToList(new IWaveform[] { obj }, insert); + } + + /** + * Adds the streams to list. + * + * @param iWaveforms the i waveforms + * @param insert the insert + */ + public void addStreamsToList(IWaveform[] iWaveforms, boolean insert) { + List streams = new LinkedList<>(); + for (IWaveform stream : iWaveforms) + streams.add(new TrackEntry(stream)); + IStructuredSelection selection = (IStructuredSelection) waveformPane.getSelection(); + if (selection.size() == 0) { + waveformPane.getStreamList().addAll(streams); + } else { + Object first = selection.getFirstElement(); + IWaveform stream = (first instanceof ITx) ? ((ITx) first).getStream() : (IWaveform) first; + TrackEntry trackEntry = waveformPane.getEntryForStream(stream); + int index = waveformPane.getStreamList().indexOf(trackEntry); + if (!insert) + index++; + waveformPane.getStreamList().addAll(index, streams); + } + } + + /** + * Removes the stream from list. + * + * @param stream the stream + */ + public void removeStreamFromList(IWaveform stream) { + TrackEntry trackEntry = waveformPane.getEntryForStream(stream); + waveformPane.getStreamList().remove(trackEntry); + } + + /** + * Removes the streams from list. + * + * @param iWaveforms the i waveforms + */ + public void removeStreamsFromList(IWaveform[] iWaveforms) { + for (IWaveform stream : iWaveforms) + removeStreamFromList(stream); + } + + /** + * Move selected. + * + * @param i the i + */ + public void moveSelected(int i) { + waveformPane.moveSelectedTrack(i); + } + + + /** + * Move selection. + * + * @param direction the direction + */ + public void moveSelection(GotoDirection direction ) { + moveSelection(direction, navigationRelationType); + } + + /** + * Move selection. + * + * @param direction the direction + * @param relationType the relation type + */ + public void moveSelection(GotoDirection direction, RelationType relationType) { + waveformPane.moveSelection(direction, relationType); + } + + /** + * Move cursor. + * + * @param direction the direction + */ + public void moveCursor(GotoDirection direction) { + waveformPane.moveCursor(direction); + } + + /** + * Sets the zoom level. + * + * @param level the new zoom level + */ + public void setZoomLevel(Integer level) { + if (level < 0) + level = 0; + if (level > zoomLevel.length - 1) + level = zoomLevel.length - 1; + waveformPane.setZoomLevel(level); + updateAll(); + } + + /** + * Sets the zoom fit. + */ + public void setZoomFit() { + waveformPane.setZoomLevel(6); + updateAll(); + } + + /** + * Gets the zoom level. + * + * @return the zoom level + */ + public int getZoomLevel() { + return waveformPane.getZoomLevel(); + } + + /** + * Gets the selection. + * + * @return the selection + */ + public ISelection getSelection() { + return waveformPane.getSelection(); + } + + /** + * Sets the selection. + * + * @param structuredSelection the new selection + */ + public void setSelection(IStructuredSelection structuredSelection) { + waveformPane.setSelection(structuredSelection, true); + } + + /** + * Gets the scaled time. + * + * @param time the time + * @return the scaled time + */ + public String getScaledTime(Long time) { + return waveformPane.getScaledTime(time); + } + + /** + * Store design brower state. + * + * @param browserState the browser state + */ + public void storeDesignBrowerState(Object browserState) { + this.browserState=browserState; + } + + /** + * Retrieve design brower state. + * + * @return the object + */ + public Object retrieveDesignBrowerState() { + return browserState; + } + + /** + * Store transaction details settings + * + * @param detailsSettings the details settings + */ + public void storeDetailsSettings(Object detailsSettings) { + this.detailsSettings=detailsSettings; + } + + /** + * Retrieve design details settings. + * + * @return the details settings + */ + public Object retrieveDetailsSettings() { + return detailsSettings; + } + + /** + * Gets the all relation types. + * + * @return the all relation types + */ + public List getAllRelationTypes() { + List res =new ArrayList<>(); + res.add(IWaveformViewer.NEXT_PREV_IN_STREAM); + res.addAll(database.getAllRelationTypes()); + return res; + } + + /** + * Gets the selection relation types. + * + * @return the selection relation types + */ + public List getSelectionRelationTypes() { + List res =new ArrayList<>(); + res.add(IWaveformViewer.NEXT_PREV_IN_STREAM); + ISelection selection = waveformPane.getSelection(); + if(selection instanceof IStructuredSelection && !selection.isEmpty()){ + IStructuredSelection sel=(IStructuredSelection) selection; + if(sel.getFirstElement() instanceof ITx){ + ITx tx = (ITx) sel.getFirstElement(); + for(ITxRelation rel:tx.getIncomingRelations()){ + if(!res.contains(rel.getRelationType())) + res.add(rel.getRelationType()); + } + for(ITxRelation rel:tx.getOutgoingRelations()){ + if(!res.contains(rel.getRelationType())) + res.add(rel.getRelationType()); + } + } + } + return res; + } + + /** + * Gets the relation type filter. + * + * @return the relation type filter + */ + public RelationType getRelationTypeFilter() { + return navigationRelationType; + } + + /** + * Sets the navigation relation type. + * + * @param relationName the new navigation relation type + */ + public void setNavigationRelationType(String relationName) { + setNavigationRelationType(RelationType.create(relationName)); + } + + /** + * Sets the navigation relation type. + * + * @param relationType the new navigation relation type + */ + public void setNavigationRelationType(RelationType relationType) { + if(navigationRelationType!=relationType) waveformPane.setHighliteRelation(relationType); + navigationRelationType=relationType; + } + +} \ No newline at end of file From af1b3d00dc0f01d6c47f71ad23f21ef1d09c96aa Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 22 Nov 2015 12:17:17 +0100 Subject: [PATCH 3/8] Changed AboutDialog to be a ApplicationModel element --- .../Application.e4xmi | 5 +- .../e4/application/handlers/AboutHandler.java | 16 +- .../e4/application/parts/AboutDialog.java | 119 ++-- .../application/parts/WaveformViewerPart.java | 591 ------------------ 4 files changed, 67 insertions(+), 664 deletions(-) delete mode 100644 com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewerPart.java diff --git a/com.minres.scviewer.e4.application/Application.e4xmi b/com.minres.scviewer.e4.application/Application.e4xmi index ce8672d..55e48fa 100644 --- a/com.minres.scviewer.e4.application/Application.e4xmi +++ b/com.minres.scviewer.e4.application/Application.e4xmi @@ -134,6 +134,9 @@ + + + @@ -152,7 +155,7 @@ - + categoryTag:General diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AboutHandler.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AboutHandler.java index 4220ee4..5bd6d4e 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AboutHandler.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AboutHandler.java @@ -11,15 +11,19 @@ package com.minres.scviewer.e4.application.handlers; import org.eclipse.e4.core.di.annotations.Execute; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; +import org.eclipse.e4.ui.model.application.MApplication; +import org.eclipse.e4.ui.model.application.ui.basic.MDialog; +import org.eclipse.e4.ui.model.application.ui.basic.MWindow; +import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.swt.widgets.Shell; -import com.minres.scviewer.e4.application.parts.AboutDialog; - public class AboutHandler { + @Execute - public void execute(Shell shell) { - AboutDialog.open(shell, SWT.NONE); + public void execute(Shell shell, MApplication app, MWindow window, EModelService ms /*@Named("mdialog01.dialog.0") MDialog dialog*/) { + MDialog dialog = (MDialog) ms.find("com.minres.scviewer.e4.application.dialog.aboutscviewer", app); + dialog.setToBeRendered(true); + dialog.setToBeRendered(false); } + } diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java index 1a6cc41..327f3a6 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java @@ -16,45 +16,44 @@ import java.net.URISyntaxException; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.annotation.PostConstruct; +import javax.inject.Inject; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; -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.Button; import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.wb.swt.ResourceManager; import org.eclipse.wb.swt.SWTResourceManager; +// TODO: Auto-generated Javadoc +/** + * The Class AboutDialog. + */ public class AboutDialog extends Dialog { - protected int result; - protected Shell shell; - private Color white; - protected StyledText styledText; - /* - Eclipse IDE for Java Developers - -Version: Mars.1 Release (4.5.1) -Build id: 20150924-1200 -(c) Copyright Eclipse contributors and others 2000, 2015. All rights reserved. Eclipse and the Eclipse logo are trademarks of the Eclipse Foundation, Inc., https://www.eclipse.org/. The Eclipse logo cannot be altered without Eclipse's permission. Eclipse logos are provided for use under the Eclipse logo and trademark guidelines, https://www.eclipse.org/logotm/. Oracle and Java are trademarks or registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. - */ + /** The styled text. */ +// protected StyledText styledText; + + /** The product title. */ private String productTitle= "\nSCViewer - a SystemC waveform viewer\n\nVersion: 1.0\n"; + + /** The copyright text. */ private String copyrightText="\nCopyright (c) 2015 MINRES Technologies GmbH and others.\n"+ "\n"+ "All rights reserved. MINRES and the MINRES logo are trademarks of MINRES Technologies GmbH, http://www.minres.com/ . "+ @@ -64,44 +63,33 @@ Build id: 20150924-1200 /** * Create the dialog. - * @param parent - * @param style + * + * @param parent the parent + * @param style the style */ - public AboutDialog(Shell parent, int style) { - super(parent, style); - setText("SWT Dialog"); - white=SWTResourceManager.getColor(SWT.COLOR_WHITE); - } - - /** - * Open the dialog. - * @return the result - */ - public int open() { - createContents(); - shell.open(); - shell.layout(); - Display display = getParent().getDisplay(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } - return result; + @Inject + public AboutDialog(Shell parentShell) { + super(parentShell); + } /** * Create contents of the dialog. */ - private void createContents() { - shell = new Shell(getParent(), getStyle()); - shell.setSize(600, 300); - shell.setText(getText()); - shell.setLayout(new GridLayout(2, false)); + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + GridData gd_composite = new GridData(SWT.LEFT, SWT.FILL, true, true); + gd_composite.widthHint = 600; + gd_composite.heightHint =250; + composite.setLayoutData(gd_composite); + composite.setLayout(new GridLayout(2, false)); + + final Color white=SWTResourceManager.getColor(SWT.COLOR_WHITE); final Image scviewerLogo=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/SCViewer_logo.png"); final Image minresLogo=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/Minres_logo.png"); - Canvas canvas = new Canvas(shell,SWT.NO_REDRAW_RESIZE); + Canvas canvas = new Canvas(composite,SWT.NO_REDRAW_RESIZE); GridData gd_canvas = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_canvas.widthHint = 200; gd_canvas.heightHint =250; @@ -115,7 +103,7 @@ Build id: 20150924-1200 } }); - styledText = new StyledText(shell, SWT.BORDER); + StyledText styledText = new StyledText(composite, SWT.BORDER); styledText.setEditable(false); GridData gd_styledText = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); styledText.setLayoutData(gd_styledText); @@ -151,8 +139,8 @@ Build id: 20150924-1200 // links are activated on mouse down when the control key is held down // if ((event.stateMask & SWT.MOD1) != 0) { try { - int offset = styledText.getOffsetAtLocation(new Point (event.x, event.y)); - StyleRange style = styledText.getStyleRangeAtOffset(offset); + int offset = ((StyledText)event.widget).getOffsetAtLocation(new Point (event.x, event.y)); + StyleRange style = ((StyledText)event.widget).getStyleRangeAtOffset(offset); if (style != null && style.underline && style.underlineStyle == SWT.UNDERLINE_LINK) { Desktop.getDesktop().browse(new java.net.URI(style.data.toString())); } @@ -162,23 +150,22 @@ Build id: 20150924-1200 }); styleRange.start = 0; - new Label(shell, SWT.NONE); - - Button okButton = new Button(shell, SWT.NONE); - okButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - okButton.setBounds(0, 0, 94, 28); - okButton.setText("Close"); - okButton.setFocus(); - okButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if(!shell.isDisposed()) shell.dispose(); - } - }); + return composite; + } + + protected void createButtonsForButtonBar(Composite parent) { + // create OK button + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true); } - public static boolean open(Shell parent, int style) { - AboutDialog dialog = new AboutDialog(parent, style | SWT.SHEET); - return dialog.open() == 0; + /** + * Open the dialog. + * @return the result + */ + @PostConstruct + @Override + public int open() { + return super.open(); } + } diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewerPart.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewerPart.java deleted file mode 100644 index 6355895..0000000 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewerPart.java +++ /dev/null @@ -1,591 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 MINRES Technologies GmbH and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * MINRES Technologies GmbH - initial API and implementation - *******************************************************************************/ -package com.minres.scviewer.e4.application.parts; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.annotation.PostConstruct; -import javax.inject.Inject; -import javax.inject.Named; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubMonitor; -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.preferences.IEclipsePreferences; -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; -import org.eclipse.e4.ui.di.UIEventTopic; -import org.eclipse.e4.ui.model.application.ui.basic.MPart; -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.resource.StringConverter; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -import com.minres.scviewer.database.ITx; -import com.minres.scviewer.database.ITxRelation; -import com.minres.scviewer.database.IWaveform; -import com.minres.scviewer.database.IWaveformDb; -import com.minres.scviewer.database.IWaveformDbFactory; -import com.minres.scviewer.database.IWaveformEvent; -import com.minres.scviewer.database.RelationType; -import com.minres.scviewer.database.swt.WaveformViewerFactory; -import com.minres.scviewer.database.ui.GotoDirection; -import com.minres.scviewer.database.ui.ICursor; -import com.minres.scviewer.database.ui.IWaveformViewer; -import com.minres.scviewer.database.ui.TrackEntry; -import com.minres.scviewer.database.ui.WaveformColors; -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; - -@SuppressWarnings("restriction") -public class WaveformViewerPart implements IFileChangeListener, IPreferenceChangeListener { - - public static final String ACTIVE_WAVEFORMVIEW = "Active_Waveform_View"; - - public static final String ADD_WAVEFORM = "AddWaveform"; - - protected static final String DATABASE_FILE = "DATABASE_FILE"; - protected static final String SHOWN_WAVEFORM = "SHOWN_WAVEFORM"; - protected static final String SHOWN_CURSOR = "SHOWN_CURSOR"; - protected static final String ZOOM_LEVEL = "ZOOM_LEVEL"; - - protected static final long FILE_CHECK_INTERVAL = 60000; - - private String[] zoomLevel; - - public static final String ID = "com.minres.scviewer.ui.TxEditorPart"; //$NON-NLS-1$ - - public static final String WAVE_ACTION_ID = "com.minres.scviewer.ui.action.AddToWave"; - - WaveformViewerFactory factory = new WaveformViewerFactory(); - - private IWaveformViewer waveformPane; - - @Inject - private IEventBroker eventBroker; - - @Inject - EMenuService menuService; - - @Inject - ESelectionService selectionService; - - @Inject - EPartService ePartService; - - @Inject - @Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE) - IEclipsePreferences prefs; - - private IWaveformDb database; - - private boolean checkForUpdates; - - private MPart myPart; - - private Composite myParent; - - ArrayList filesToLoad; - - Map persistedState; - - private Object browserState; - - private RelationType navigationRelationType=IWaveformViewer.NEXT_PREV_IN_STREAM ; - - FileMonitor fileMonitor = new FileMonitor(); - - IModificationChecker fileChecker; - - @PostConstruct - public void createComposite(MPart part, Composite parent, IWaveformDbFactory dbFactory) { - myPart = part; - myParent = parent; - database = dbFactory.getDatabase(); - database.addPropertyChangeListener(new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - if ("WAVEFORMS".equals(evt.getPropertyName())) { - myParent.getDisplay().syncExec(new Runnable() { - @Override - public void run() { - waveformPane.setMaxTime(database.getMaxTime()); - } - }); - } - } - }); - waveformPane = factory.createPanel(parent); - waveformPane.setMaxTime(0); - waveformPane.addPropertyChangeListener(IWaveformViewer.CURSOR_PROPERTY, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - Long time = (Long) evt.getNewValue(); - eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(time)); - long marker = waveformPane.getSelectedMarkerTime(); - eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(time - marker)); - - } - }); - waveformPane.addPropertyChangeListener(IWaveformViewer.MARKER_PROPERTY, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - Long time = (Long) evt.getNewValue(); - eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getScaledTime(time)); - long cursor = waveformPane.getCursorTime(); - eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - time)); - } - }); - waveformPane.addSelectionChangedListener(new ISelectionChangedListener() { - @Override - public void selectionChanged(SelectionChangedEvent event) { - if (event.getSelection() instanceof IStructuredSelection) - selectionService.setSelection(event.getSelection()); - } - }); - zoomLevel = waveformPane.getZoomLevels(); - setupColors(); - checkForUpdates = prefs.getBoolean(PreferenceConstants.DATABASE_RELOAD, true); - filesToLoad = new ArrayList(); - persistedState = part.getPersistedState(); - Integer files = persistedState.containsKey(DATABASE_FILE + "S") - ? Integer.parseInt(persistedState.get(DATABASE_FILE + "S")) : 0; - for (int i = 0; i < files; i++) { - filesToLoad.add(new File(persistedState.get(DATABASE_FILE + i))); - } - if (filesToLoad.size() > 0) - loadDatabase(persistedState); - eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]); - menuService.registerContextMenu(waveformPane.getNameControl(), - "com.minres.scviewer.e4.application.popupmenu.namecontext"); - menuService.registerContextMenu(waveformPane.getValueControl(), - "com.minres.scviewer.e4.application.popupmenu.namecontext"); - menuService.registerContextMenu(waveformPane.getWaveformControl(), - "com.minres.scviewer.e4.application.popupmenu.wavecontext"); - ePartService.addPartListener(new PartListener() { - @Override - public void partActivated(MPart part) { - if (part == myPart) { - if (fileChecker != null) - fileChecker.check(); - updateAll(); - } - } - }); - prefs.addPreferenceChangeListener(this); - } - - @Override - public void preferenceChange(PreferenceChangeEvent event) { - if (PreferenceConstants.DATABASE_RELOAD.equals(event.getKey())) { - checkForUpdates = (Boolean) event.getNewValue(); - fileChecker = null; - if (checkForUpdates) - fileChecker = fileMonitor.addFileChangeListener(WaveformViewerPart.this, filesToLoad, - FILE_CHECK_INTERVAL); - else - fileMonitor.removeFileChangeListener(this); - } else { - setupColors(); - } - } - - protected void setupColors() { - DefaultValuesInitializer initializer = new DefaultValuesInitializer(); - HashMap colorPref = new HashMap<>(); - for (WaveformColors c : WaveformColors.values()) { - String prefValue = prefs.get(c.name() + "_COLOR", - StringConverter.asString(initializer.colors[c.ordinal()].getRGB())); - RGB rgb = StringConverter.asRGB(prefValue); - colorPref.put(c, rgb); - } - waveformPane.setColors(colorPref); - } - - protected void loadDatabase(final Map state) { - fileMonitor.removeFileChangeListener(this); - Job job = new Job(" My Job") { - @Override - protected IStatus run(IProgressMonitor monitor) { - // convert to SubMonitor and set total number of work units - SubMonitor subMonitor = SubMonitor.convert(monitor, filesToLoad.size()); - subMonitor.setTaskName("Loading database"); - try { - for (File file : filesToLoad) { - // TimeUnit.SECONDS.sleep(2); - database.load(file); - database.addPropertyChangeListener(waveformPane); - subMonitor.worked(1); - if (monitor.isCanceled()) - return Status.CANCEL_STATUS; - } - // sleep a second - } catch (Exception e) { - database = null; - e.printStackTrace(); - return Status.CANCEL_STATUS; - } - subMonitor.done(); - monitor.done(); - return Status.OK_STATUS; - } - }; - job.addJobChangeListener(new JobChangeAdapter() { - @Override - public void done(IJobChangeEvent event) { - if (event.getResult() == Status.OK_STATUS) - myParent.getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - waveformPane.setMaxTime(database.getMaxTime()); - if (state != null) - restoreWaveformViewerState(state); - fileChecker = null; - if (checkForUpdates) - fileChecker = fileMonitor.addFileChangeListener(WaveformViewerPart.this, filesToLoad, - FILE_CHECK_INTERVAL); - } - }); - } - }); - job.schedule(0); - } - - @Override - public void fileChanged(List file) { - final Display display = myParent.getDisplay(); - display.asyncExec(new Runnable() { - @Override - public void run() { - if (MessageDialog.openQuestion(display.getActiveShell(), "Database re-load", - "Would you like to reload the database?")) { - Map state = new HashMap<>(); - saveWaveformViewerState(state); - waveformPane.getStreamList().clear(); - database.clear(); - if (filesToLoad.size() > 0) - loadDatabase(state); - } - } - }); - } - - @Inject - @Optional - public void setPartInput(@Named("input") Object partInput) { - if (partInput instanceof File) { - filesToLoad = new ArrayList(); - File file = (File) partInput; - if (file.exists()) { - filesToLoad.add(file); - try { - String ext = getFileExtension(file.getName()); - if ("vcd".equals(ext.toLowerCase())) { - if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), "txdb")))) { - filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), "txdb"))); - } else if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), "txlog")))) { - filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), "txlog"))); - } - } else if ("txdb".equals(ext.toLowerCase()) || "txlog".equals(ext.toLowerCase())) { - if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), "vcd")))) { - filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), "vcd"))); - } - } - } catch (IOException e) { // silently ignore any error - } - } - if (filesToLoad.size() > 0) - loadDatabase(persistedState); - } - } - - @Focus - public void setFocus() { - myParent.setFocus(); - } - - @PersistState - public void saveState(MPart part) { - // save changes - Map persistedState = part.getPersistedState(); - persistedState.put(DATABASE_FILE + "S", Integer.toString(filesToLoad.size())); - Integer index = 0; - for (File file : filesToLoad) { - persistedState.put(DATABASE_FILE + index, file.getAbsolutePath()); - index++; - } - saveWaveformViewerState(persistedState); - } - - protected void saveWaveformViewerState(Map persistedState) { - Integer index; - persistedState.put(SHOWN_WAVEFORM + "S", Integer.toString(waveformPane.getStreamList().size())); - index = 0; - for (TrackEntry trackEntry : waveformPane.getStreamList()) { - persistedState.put(SHOWN_WAVEFORM + index, trackEntry.waveform.getFullName()); - index++; - } - List cursors = waveformPane.getCursorList(); - persistedState.put(SHOWN_CURSOR + "S", Integer.toString(cursors.size())); - index = 0; - for (ICursor cursor : cursors) { - persistedState.put(SHOWN_CURSOR + index, Long.toString(cursor.getTime())); - index++; - } - persistedState.put(ZOOM_LEVEL, Integer.toString(waveformPane.getZoomLevel())); - } - - protected void restoreWaveformViewerState(Map state) { - updateAll(); - Integer waves = state.containsKey(SHOWN_WAVEFORM + "S") ? Integer.parseInt(state.get(SHOWN_WAVEFORM + "S")) : 0; - List res = new LinkedList<>(); - for (int i = 0; i < waves; i++) { - IWaveform waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i)); - if (waveform != null) - res.add(new TrackEntry(waveform)); - } - if (res.size() > 0) - waveformPane.getStreamList().addAll(res); - Integer cursorLength = state.containsKey(SHOWN_CURSOR + "S") ? Integer.parseInt(state.get(SHOWN_CURSOR + "S")) - : 0; - List cursors = waveformPane.getCursorList(); - if (cursorLength == cursors.size()) { - for (int i = 0; i < cursorLength; i++) { - Long time = Long.parseLong(state.get(SHOWN_CURSOR + i)); - cursors.get(i).setTime(time); - } - } - if (state.containsKey(ZOOM_LEVEL)) { - try { - Integer scale = Integer.parseInt(state.get(ZOOM_LEVEL)); - waveformPane.setZoomLevel(scale); - } catch (NumberFormatException e) { - } - } - } - - private void updateAll() { - eventBroker.post(ACTIVE_WAVEFORMVIEW, this); - eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]); - long cursor = waveformPane.getCursorTime(); - long marker = waveformPane.getSelectedMarkerTime(); - eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(cursor)); - eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getScaledTime(marker)); - eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - marker)); - } - - @Inject - @Optional - public void getAddWaveformEvent(@UIEventTopic(WaveformViewerPart.ADD_WAVEFORM) Object o) { - Object sel = o == null ? selectionService.getSelection() : o; - if (sel instanceof IStructuredSelection) - for (Object el : ((IStructuredSelection) sel).toArray()) { - if (el instanceof IWaveform) - addStreamToList((IWaveform) el, false); - } - } - - protected boolean askIfToLoad(File txFile) { - if (txFile.exists() && MessageDialog.openQuestion(myParent.getDisplay().getActiveShell(), "Database open", - "Would you like to open the adjacent database " + txFile.getName() + " as well?")) { - return true; - } - return false; - } - - protected static String renameFileExtension(String source, String newExt) { - String target; - String currentExt = getFileExtension(source); - if (currentExt.equals("")) { - target = source + "." + newExt; - } else { - target = source.replaceFirst(Pattern.quote("." + currentExt) + "$", Matcher.quoteReplacement("." + newExt)); - } - return target; - } - - protected static String getFileExtension(String f) { - String ext = ""; - int i = f.lastIndexOf('.'); - if (i > 0 && i < f.length() - 1) { - ext = f.substring(i + 1); - } - return ext; - } - - public IWaveformDb getModel() { - return database; - } - - public IWaveformDb getDatabase() { - return database; - } - - public void addStreamToList(IWaveform obj, boolean insert) { - addStreamsToList(new IWaveform[] { obj }, insert); - } - - public void addStreamsToList(IWaveform[] iWaveforms, boolean insert) { - List streams = new LinkedList<>(); - for (IWaveform stream : iWaveforms) - streams.add(new TrackEntry(stream)); - IStructuredSelection selection = (IStructuredSelection) waveformPane.getSelection(); - if (selection.size() == 0) { - waveformPane.getStreamList().addAll(streams); - } else { - Object first = selection.getFirstElement(); - IWaveform stream = (first instanceof ITx) ? ((ITx) first).getStream() : (IWaveform) first; - TrackEntry trackEntry = waveformPane.getEntryForStream(stream); - int index = waveformPane.getStreamList().indexOf(trackEntry); - if (!insert) - index++; - waveformPane.getStreamList().addAll(index, streams); - } - } - - public void removeStreamFromList(IWaveform stream) { - TrackEntry trackEntry = waveformPane.getEntryForStream(stream); - waveformPane.getStreamList().remove(trackEntry); - } - - public void removeStreamsFromList(IWaveform[] iWaveforms) { - for (IWaveform stream : iWaveforms) - removeStreamFromList(stream); - } - - public void moveSelected(int i) { - waveformPane.moveSelectedTrack(i); - } - - - public void moveSelection(GotoDirection direction ) { - moveSelection(direction, navigationRelationType); - } - - public void moveSelection(GotoDirection direction, RelationType relationType) { - waveformPane.moveSelection(direction, relationType); - } - - public void moveCursor(GotoDirection direction) { - waveformPane.moveCursor(direction); - } - - public void setZoomLevel(Integer level) { - if (level < 0) - level = 0; - if (level > zoomLevel.length - 1) - level = zoomLevel.length - 1; - waveformPane.setZoomLevel(level); - updateAll(); - } - - public void setZoomFit() { - waveformPane.setZoomLevel(6); - updateAll(); - } - - public int getZoomLevel() { - return waveformPane.getZoomLevel(); - } - - public ISelection getSelection() { - return waveformPane.getSelection(); - } - - public void setSelection(IStructuredSelection structuredSelection) { - waveformPane.setSelection(structuredSelection, true); - } - - public String getScaledTime(Long time) { - return waveformPane.getScaledTime(time); - } - - public void storeDesignBrowerState(Object browserState) { - this.browserState=browserState; - } - - public Object retrieveDesignBrowerState() { - return browserState; - } - - public List getAllRelationTypes() { - List res =new ArrayList<>(); - res.add(IWaveformViewer.NEXT_PREV_IN_STREAM); - res.addAll(database.getAllRelationTypes()); - return res; - } - - public List getSelectionRelationTypes() { - List res =new ArrayList<>(); - res.add(IWaveformViewer.NEXT_PREV_IN_STREAM); - ISelection selection = waveformPane.getSelection(); - if(selection instanceof IStructuredSelection && !selection.isEmpty()){ - IStructuredSelection sel=(IStructuredSelection) selection; - if(sel.getFirstElement() instanceof ITx){ - ITx tx = (ITx) sel.getFirstElement(); - for(ITxRelation rel:tx.getIncomingRelations()){ - if(!res.contains(rel.getRelationType())) - res.add(rel.getRelationType()); - } - for(ITxRelation rel:tx.getOutgoingRelations()){ - if(!res.contains(rel.getRelationType())) - res.add(rel.getRelationType()); - } - } - } - return res; - } - - public RelationType getRelationTypeFilter() { - return navigationRelationType; - } - - public void setNavigationRelationType(String relationName) { - setNavigationRelationType(RelationType.create(relationName)); - } - - public void setNavigationRelationType(RelationType relationType) { - if(navigationRelationType!=relationType) waveformPane.setHighliteRelation(relationType); - navigationRelationType=relationType; - } - -} \ No newline at end of file From f723a770c758ee551fd1bc35b1beae619570657f Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 22 Nov 2015 12:47:07 +0100 Subject: [PATCH 4/8] - small refactoring of part class names - tried to improve Javadoc --- README.md | 11 +- .../database/vcd/IVCDDatabaseBuilder.java | 3 +- .../scviewer/database/vcd/VCDDbLoader.java | 22 ++- .../scviewer/e4/application/E4LifeCycle.java | 50 ++++- .../elements/NavigateContribution.java | 18 +- .../elements/RelationTypeToolControl.java | 48 ++++- .../handlers/DeleteWaveformHandler.java | 6 +- .../handlers/MoveWaveformHandler.java | 8 +- .../application/handlers/NavigateEvent.java | 8 +- .../application/handlers/NavigateTrans.java | 8 +- .../handlers/SetRelationTypeHandler.java | 6 +- .../e4/application/handlers/ZoomHandler.java | 6 +- .../internal/status/HeapStatus.java | 175 +++++++++++++++++- .../internal/status/IHeapStatusConstants.java | 2 - .../internal/status/StatusBarControl.java | 76 +++++++- .../application/internal/status/TrimUtil.java | 2 - .../internal/status/WaveStatusBarControl.java | 73 ++++++++ .../internal/util/FileMonitor.java | 13 +- .../internal/util/IFileChangeListener.java | 7 +- .../internal/util/IModificationChecker.java | 6 + .../e4/application/parts/AboutDialog.java | 13 +- .../e4/application/parts/DesignBrowser.java | 113 ++++++++++- .../e4/application/parts/PartListener.java | 27 +++ .../application/parts/TransactionDetails.java | 145 ++++++++++++++- .../e4/application/parts/WaveformViewer.java | 1 - .../preferences/DefaultValuesInitializer.java | 10 + .../preferences/PreferenceConstants.java | 42 +++++ .../preferences/SCViewerPreferencesPage.java | 11 +- .../preferences/WaveformPreferencesPage.java | 10 +- .../provider/TxDbContentProvider.java | 30 +++ .../provider/TxDbLabelProvider.java | 26 +++ .../provider/TxPropertiesContentProvider.java | 13 ++ .../provider/TxPropertiesLabelProvider.java | 25 +++ .../SCViewer.launch | 34 ---- 34 files changed, 926 insertions(+), 122 deletions(-) delete mode 100644 com.minres.scviewer.e4.product/SCViewer.launch diff --git a/README.md b/README.md index 62d112e..fa2805b 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,10 @@ The plugins are structured as follows: - com.minres.scviewer.feature the feature combining the plugins above into a somhow usable form - scv_tr_sqlite - a C++ project containing the SQLite based SCV database implementation. A simple - example (scv_tr_recording_example.cpp) for testig purposes is provided. + a C++ project containing the SQLite based SCV database implementation and the scv4tlm + socket implementations. + A simple example (scv_tr_recording_example.cpp) for testig purposes of the database is + provided. To build the plugins the Eclipse SDK or PDE can be used. In both cases the Groovy eclipse plugin (http://groovy.codehaus.org/Eclipse+Plugin or Market) has to be @@ -34,6 +36,7 @@ installed. TODO ==== -- refactor the graphical viewer (again) - add more tests -- additional analysis means +- move to feature based product to allow automatic updates +- improve graphics +- catch-up e3 plugin to functionality of e4 product \ No newline at end of file diff --git a/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/IVCDDatabaseBuilder.java b/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/IVCDDatabaseBuilder.java index d184e63..e74f195 100644 --- a/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/IVCDDatabaseBuilder.java +++ b/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/IVCDDatabaseBuilder.java @@ -12,9 +12,8 @@ package com.minres.scviewer.database.vcd; import com.minres.scviewer.database.BitVector; -// TODO: Auto-generated Javadoc /** - * The Interface ITraceBuilder. + * The Interface IVCDDatabaseBuilder. It allows to add VCD events into the database */ public interface IVCDDatabaseBuilder { 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 45fdd38..eb25d41 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 @@ -31,15 +31,16 @@ import com.minres.scviewer.database.IWaveformEvent; import com.minres.scviewer.database.InputFormatException; import com.minres.scviewer.database.RelationType; -// TODO: Auto-generated Javadoc /** * The Class VCDDb. */ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder { + /** The Constant TIME_RES. */ private static final Long TIME_RES = 1000L; // ps; + /** The db. */ private IWaveformDb db; /** The module stack. */ @@ -48,17 +49,17 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder { /** The signals. */ private List> signals; + /** The max time. */ private long maxTime; /** * Instantiates a new VCD db. - * - * @param netName the net name */ public VCDDbLoader() { } - private byte[] x = "$date".getBytes(); + /** The date bytes. */ + private byte[] dateBytes = "$date".getBytes(); /* (non-Javadoc) * @see com.minres.scviewer.database.ITrDb#load(java.io.File) @@ -68,12 +69,12 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder { public boolean load(IWaveformDb db, File file) throws Exception { this.db=db; FileInputStream fis = new FileInputStream(file); - byte[] buffer = new byte[x.length]; - int read = fis.read(buffer, 0, x.length); + byte[] buffer = new byte[dateBytes.length]; + int read = fis.read(buffer, 0, dateBytes.length); fis.close(); - if (read == x.length) - for (int i = 0; i < x.length; i++) - if (buffer[i] != x[i]) + if (read == dateBytes.length) + for (int i = 0; i < dateBytes.length; i++) + if (buffer[i] != dateBytes[i]) return false; signals = new Vector>(); @@ -180,6 +181,9 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder { } } + /* (non-Javadoc) + * @see com.minres.scviewer.database.IWaveformDbLoader#getAllRelationTypes() + */ @Override public Collection getAllRelationTypes(){ return Collections.emptyList(); 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 8a617b8..d04500b 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 @@ -34,7 +34,7 @@ import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; /** - * This is a stub implementation containing e4 LifeCycle annotated methods.
+ * This implementation contains e4 LifeCycle annotated methods.
* There is a corresponding entry in plugin.xml (under the * org.eclipse.core.runtime.products' extension point) that references * this class. @@ -42,10 +42,21 @@ import org.osgi.service.event.EventHandler; @SuppressWarnings("restriction") public class E4LifeCycle { + /** + * Post construct. + * + * @param eventBroker the event broker + */ @PostConstruct private static void postConstruct(final IEventBroker eventBroker) { } + /** + * Post context create. Open a database if given on command line using the OpenViewHandler + * + * @param appContext the app context + * @param eventBroker the event broker + */ @PostContextCreate void postContextCreate(IApplicationContext appContext, final IEventBroker eventBroker) { final String[] args = (String[])appContext.getArguments().get(IApplicationContext.APPLICATION_ARGS); @@ -66,18 +77,40 @@ public class E4LifeCycle { } }); } + + /** + * Pre save. + * + * @param workbenchContext the workbench context + */ @PreSave void preSave(IEclipseContext workbenchContext) { } + /** + * Process additions. + * + * @param workbenchContext the workbench context + */ @ProcessAdditions void processAdditions(IEclipseContext workbenchContext) { } + /** + * Process removals. + * + * @param workbenchContext the workbench context + */ @ProcessRemovals void processRemovals(IEclipseContext workbenchContext) { } + /** + * Join. + * + * @param tokens the tokens + * @return the string + */ String join(String[] tokens){ StringBuilder sb = new StringBuilder(); boolean first=true; @@ -89,10 +122,25 @@ public class E4LifeCycle { return sb.toString(); } + /** + * The Class OpenViewHandler. + */ private class OpenViewHandler { + + /** The app. */ @Inject MApplication app; + + /** The model service. */ @Inject EModelService modelService; + + /** The part service. */ @Inject EPartService partService; + + /** + * Open view for file. + * + * @param name the name + */ public void openViewForFile(String name){ File file = new File(name); MPart part = partService.createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/elements/NavigateContribution.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/elements/NavigateContribution.java index 5f6658e..4daebfa 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/elements/NavigateContribution.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/elements/NavigateContribution.java @@ -27,19 +27,31 @@ import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.e4.ui.workbench.modeling.EPartService; import com.minres.scviewer.database.RelationType; -import com.minres.scviewer.e4.application.parts.WaveformViewerPart; +import com.minres.scviewer.e4.application.parts.WaveformViewer; +/** + * The Class NavigateContribution. Currently not used in Application.e4xmi + */ public class NavigateContribution { + + /** The part service. */ @Inject EPartService partService; + /** + * About to show. + * + * @param items the items + * @param application the application + * @param modelService the model service + */ @AboutToShow public void aboutToShow(List items, MApplication application, EModelService modelService) { // modelService.getActivePerspective(window) // modelService.findElements(application,"myID",MPart.class, EModelService.IN_ACTIVE_PERSPECTIVE); // MDirectMenuItem dynamicItem = MMenuFactory.INSTANCE.createDirectMenuItem(); MPart part = partService.getActivePart(); - if(part.getObject()instanceof WaveformViewerPart){ - WaveformViewerPart waveformViewerPart = (WaveformViewerPart) part.getObject(); + if(part.getObject()instanceof WaveformViewer){ + WaveformViewer waveformViewerPart = (WaveformViewer) part.getObject(); RelationType relationTypeFilter = waveformViewerPart.getRelationTypeFilter(); MCommand command = modelService.findElements(application, "com.minres.scviewer.e4.application.command.setrelationtype", MCommand.class, null).get(0); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/elements/RelationTypeToolControl.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/elements/RelationTypeToolControl.java index ad18b66..80c4e4a 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/elements/RelationTypeToolControl.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/elements/RelationTypeToolControl.java @@ -32,24 +32,41 @@ import org.eclipse.swt.widgets.Composite; import com.minres.scviewer.database.ITx; import com.minres.scviewer.database.RelationType; import com.minres.scviewer.e4.application.parts.PartListener; -import com.minres.scviewer.e4.application.parts.WaveformViewerPart; +import com.minres.scviewer.e4.application.parts.WaveformViewer; +/** + * The Class RelationTypeToolControl allowing to control which TX relation is used for navigation. + */ public class RelationTypeToolControl extends PartListener implements ISelectionChangedListener { + /** The part service. */ EPartService partService; + /** The combo viewer. */ ComboViewer comboViewer; - WaveformViewerPart waveformViewerPart; + /** The waveform viewer part. */ + WaveformViewer waveformViewerPart; + /** The dummy. */ RelationType dummy = RelationType.create("------------"); + /** + * Instantiates a new relation type tool control. + * + * @param partService the part service + */ @Inject public RelationTypeToolControl(EPartService partService) { this.partService=partService; partService.addPartListener(this); } + /** + * Creates the gui. + * + * @param parent the parent + */ @PostConstruct public void createGui(Composite parent) { comboViewer = new ComboViewer(parent, SWT.NONE); @@ -62,10 +79,13 @@ public class RelationTypeToolControl extends PartListener implements ISelectionC comboViewer.addSelectionChangedListener(this); } + /* (non-Javadoc) + * @see com.minres.scviewer.e4.application.parts.PartListener#partActivated(org.eclipse.e4.ui.model.application.ui.basic.MPart) + */ @Override public void partActivated(MPart part) { - if(part.getObject() instanceof WaveformViewerPart){ - waveformViewerPart=(WaveformViewerPart) part.getObject(); + if(part.getObject() instanceof WaveformViewer){ + waveformViewerPart=(WaveformViewer) part.getObject(); checkSelection(waveformViewerPart.getSelection()); } else { waveformViewerPart=null; @@ -73,14 +93,25 @@ public class RelationTypeToolControl extends PartListener implements ISelectionC } } + /** + * Sets the selection. + * + * @param selection the selection + * @param partService the part service + */ @Inject public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){ MPart part = partService.getActivePart(); - if(part!=null && part.getObject() instanceof WaveformViewerPart && comboViewer!=null){ + if(part!=null && part.getObject() instanceof WaveformViewer && comboViewer!=null){ checkSelection(selection); } } + /** + * Check selection. + * + * @param selection the selection + */ protected void checkSelection(ISelection selection) { if( selection instanceof IStructuredSelection) { Object object= ((IStructuredSelection)selection).getFirstElement(); @@ -94,11 +125,14 @@ public class RelationTypeToolControl extends PartListener implements ISelectionC comboViewer.getCombo().setEnabled(false); } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) + */ @Override public void selectionChanged(SelectionChangedEvent event) { MPart part = partService.getActivePart(); - if(part!=null && part.getObject() instanceof WaveformViewerPart && !event.getSelection().isEmpty()){ - WaveformViewerPart waveformViewerPart=(WaveformViewerPart) part.getObject(); + if(part!=null && part.getObject() instanceof WaveformViewer && !event.getSelection().isEmpty()){ + WaveformViewer waveformViewerPart=(WaveformViewer) part.getObject(); if(event.getSelection() instanceof IStructuredSelection){ waveformViewerPart.setNavigationRelationType( (RelationType)((IStructuredSelection)event.getSelection()).getFirstElement()); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/DeleteWaveformHandler.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/DeleteWaveformHandler.java index 5c407ac..0572107 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/DeleteWaveformHandler.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/DeleteWaveformHandler.java @@ -18,7 +18,7 @@ import org.eclipse.e4.ui.workbench.modeling.ESelectionService; import org.eclipse.jface.viewers.IStructuredSelection; import com.minres.scviewer.database.IWaveform; -import com.minres.scviewer.e4.application.parts.WaveformViewerPart; +import com.minres.scviewer.e4.application.parts.WaveformViewer; public class DeleteWaveformHandler { @@ -32,8 +32,8 @@ public class DeleteWaveformHandler { public void execute(ESelectionService selectionService, MPart activePart) { Object o = activePart.getObject(); Object sel = selectionService.getSelection(); - if(o instanceof WaveformViewerPart && ((IStructuredSelection)sel).getFirstElement() instanceof IWaveform){ - ((WaveformViewerPart)o).removeStreamFromList((IWaveform) ((IStructuredSelection)sel).getFirstElement()); + if(o instanceof WaveformViewer && ((IStructuredSelection)sel).getFirstElement() instanceof IWaveform){ + ((WaveformViewer)o).removeStreamFromList((IWaveform) ((IStructuredSelection)sel).getFirstElement()); } } } \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/MoveWaveformHandler.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/MoveWaveformHandler.java index efb262a..71a7d79 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/MoveWaveformHandler.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/MoveWaveformHandler.java @@ -22,7 +22,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import com.minres.scviewer.database.ITx; import com.minres.scviewer.database.IWaveform; -import com.minres.scviewer.e4.application.parts.WaveformViewerPart; +import com.minres.scviewer.e4.application.parts.WaveformViewer; public class MoveWaveformHandler { @@ -42,11 +42,11 @@ public class MoveWaveformHandler { public void execute(@Named(PARAMETER_ID) String param, EPartService partService) { MPart part = partService.getActivePart(); Object obj = part.getObject(); - if(obj instanceof WaveformViewerPart){ + if(obj instanceof WaveformViewer){ if("up".equalsIgnoreCase(param)) - ((WaveformViewerPart)obj).moveSelected(-1); + ((WaveformViewer)obj).moveSelected(-1); else if("down".equalsIgnoreCase(param)) - ((WaveformViewerPart)obj).moveSelected(1); + ((WaveformViewer)obj).moveSelected(1); } } diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/NavigateEvent.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/NavigateEvent.java index 8a528d0..8c2a220 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/NavigateEvent.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/NavigateEvent.java @@ -23,7 +23,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import com.minres.scviewer.database.ITx; import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.ui.GotoDirection; -import com.minres.scviewer.e4.application.parts.WaveformViewerPart; +import com.minres.scviewer.e4.application.parts.WaveformViewer; public class NavigateEvent { @@ -45,11 +45,11 @@ public class NavigateEvent { // String param="next"; MPart part = partService.getActivePart(); Object obj = part.getObject(); - if(obj instanceof WaveformViewerPart){ + if(obj instanceof WaveformViewer){ if("next".equalsIgnoreCase(param)) - ((WaveformViewerPart)obj).moveCursor(GotoDirection.NEXT); + ((WaveformViewer)obj).moveCursor(GotoDirection.NEXT); else if("prev".equalsIgnoreCase(param)) - ((WaveformViewerPart)obj).moveCursor(GotoDirection.PREV); + ((WaveformViewer)obj).moveCursor(GotoDirection.PREV); } } } \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/NavigateTrans.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/NavigateTrans.java index 28aeb58..70eff98 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/NavigateTrans.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/NavigateTrans.java @@ -22,7 +22,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import com.minres.scviewer.database.ITx; import com.minres.scviewer.database.ui.GotoDirection; -import com.minres.scviewer.e4.application.parts.WaveformViewerPart; +import com.minres.scviewer.e4.application.parts.WaveformViewer; public class NavigateTrans { @@ -42,11 +42,11 @@ public class NavigateTrans { public void execute(@Named(PARAMTER_ID) String param, EPartService partService) { MPart part = partService.getActivePart(); Object obj = part.getObject(); - if(obj instanceof WaveformViewerPart){ + if(obj instanceof WaveformViewer){ if("next".equalsIgnoreCase(param)) - ((WaveformViewerPart)obj).moveSelection(GotoDirection.NEXT); + ((WaveformViewer)obj).moveSelection(GotoDirection.NEXT); else if("prev".equalsIgnoreCase(param)) - ((WaveformViewerPart)obj).moveSelection(GotoDirection.PREV); + ((WaveformViewer)obj).moveSelection(GotoDirection.PREV); } } } \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/SetRelationTypeHandler.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/SetRelationTypeHandler.java index 10c28c4..968a34b 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/SetRelationTypeHandler.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/SetRelationTypeHandler.java @@ -17,7 +17,7 @@ import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.e4.ui.workbench.modeling.EPartService; -import com.minres.scviewer.e4.application.parts.WaveformViewerPart; +import com.minres.scviewer.e4.application.parts.WaveformViewer; public class SetRelationTypeHandler { final static String PARAMTER_ID="com.minres.scviewer.e4.application.commandparameter.relationName"; @@ -26,8 +26,8 @@ public class SetRelationTypeHandler { public void execute(@Named(PARAMTER_ID) String relationName, EPartService partService) { MPart part = partService.getActivePart(); Object obj = part.getObject(); - if(obj instanceof WaveformViewerPart){ - WaveformViewerPart waveformViewerPart = (WaveformViewerPart) obj; + if(obj instanceof WaveformViewer){ + WaveformViewer waveformViewerPart = (WaveformViewer) obj; waveformViewerPart.setNavigationRelationType(relationName); } } diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/ZoomHandler.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/ZoomHandler.java index 9626bc4..97dfcd1 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/ZoomHandler.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/ZoomHandler.java @@ -18,7 +18,7 @@ import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.e4.ui.workbench.modeling.EPartService; -import com.minres.scviewer.e4.application.parts.WaveformViewerPart; +import com.minres.scviewer.e4.application.parts.WaveformViewer; public class ZoomHandler { @@ -33,8 +33,8 @@ public class ZoomHandler { public void execute(@Named(PARAMTER_ID) String level, EPartService partService) { MPart part = partService.getActivePart(); Object obj = part.getObject(); - if(obj instanceof WaveformViewerPart){ - WaveformViewerPart waveformViewerPart = (WaveformViewerPart) obj; + if(obj instanceof WaveformViewer){ + WaveformViewer waveformViewerPart = (WaveformViewer) obj; int zoomLevel = waveformViewerPart.getZoomLevel(); if("in".equalsIgnoreCase(level)) waveformViewerPart.setZoomLevel(zoomLevel-1); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/HeapStatus.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/HeapStatus.java index c42638b..d94a9ea 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/HeapStatus.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/HeapStatus.java @@ -38,35 +38,75 @@ import org.osgi.service.prefs.Preferences; /** * The Heap Status control, which shows the heap usage statistics in the window trim. - * - * @since 3.1 + * Part of the code is taken from the eclipse internal implementation */ public class HeapStatus extends Composite { + /** The armed. */ private boolean armed; + + /** The gc image. */ private Image gcImage; + + /** The disabled gc image. */ private Image disabledGcImage; + + /** The arm col. */ private Color bgCol, usedMemCol, lowMemCol, freeMemCol, topLeftCol, bottomRightCol, sepCol, textCol, markCol, armCol; + + /** The button. */ private Canvas button; + + /** The preferences. */ private Preferences preferences; + + /** The update interval. */ private int updateInterval; + + /** The show max. */ private boolean showMax; + + /** The total mem. */ private long totalMem; + + /** The prev total mem. */ private long prevTotalMem = -1L; + + /** The prev used mem. */ private long prevUsedMem = -1L; + + /** The has changed. */ private boolean hasChanged; + + /** The used mem. */ private long usedMem; + + /** The mark. */ private long mark = -1; + + /** The img bounds. */ // start with 12x12 private Rectangle imgBounds = new Rectangle(0,0,12,12); + + /** The max mem. */ private long maxMem = Long.MAX_VALUE; + + /** The max mem known. */ private boolean maxMemKnown; + + /** The low mem threshold. */ private float lowMemThreshold = 0.05f; + + /** The show low mem threshold. */ private boolean showLowMemThreshold = true; + + /** The update tooltip. */ private boolean updateTooltip = false; + /** The is in gc. */ protected volatile boolean isInGC = false; + /** The timer. */ private final Runnable timer = new Runnable() { @Override public void run() { @@ -84,6 +124,7 @@ public class HeapStatus extends Composite { } }; + /** The pref listener. */ private final IPreferenceChangeListener prefListener = new IPreferenceChangeListener() { @Override public void preferenceChange(PreferenceChangeEvent event) { @@ -215,6 +256,9 @@ public class HeapStatus extends Composite { }); } + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color) + */ @Override public void setBackground(Color color) { bgCol = color; @@ -222,6 +266,9 @@ public class HeapStatus extends Composite { button.update(); } + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Control#setForeground(org.eclipse.swt.graphics.Color) + */ @Override public void setForeground(Color color) { if (color == null) { @@ -234,6 +281,9 @@ public class HeapStatus extends Composite { button.update(); } + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Control#getForeground() + */ @Override public Color getForeground() { if (usedMemCol != null) { @@ -244,6 +294,8 @@ public class HeapStatus extends Composite { /** * Returns the maximum memory limit, or Long.MAX_VALUE if the max is not known. + * + * @return the max mem */ private long getMaxMem() { long max = Long.MAX_VALUE; @@ -261,10 +313,18 @@ public class HeapStatus extends Composite { return max; } + /** + * Sets the update interval in ms. + * + * @param interval the new update interval in ms + */ private void setUpdateIntervalInMS(int interval) { updateInterval = Math.max(100, interval); } + /** + * Do dispose. + */ private void doDispose() { if(preferences instanceof IEclipsePreferences) ((IEclipsePreferences)preferences).removePreferenceChangeListener(prefListener); @@ -276,6 +336,9 @@ public class HeapStatus extends Composite { } } + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Composite#computeSize(int, int, boolean) + */ @Override public Point computeSize(int wHint, int hHint, boolean changed) { GC gc = new GC(this); @@ -291,6 +354,11 @@ public class HeapStatus extends Composite { return new Point(p.x + 15, height); } + /** + * Arm. + * + * @param armed the armed + */ private void arm(boolean armed) { if (this.armed == armed) { return; @@ -300,6 +368,11 @@ public class HeapStatus extends Composite { button.update(); } + /** + * Gc running. + * + * @param isInGC the is in gc + */ private void gcRunning(boolean isInGC) { if (this.isInGC == isInGC) { return; @@ -310,7 +383,7 @@ public class HeapStatus extends Composite { } /** - * Creates the context menu + * Creates the context menu. */ private void createContextMenu() { MenuManager menuMgr = new MenuManager(); @@ -325,6 +398,11 @@ public class HeapStatus extends Composite { setMenu(menu); } + /** + * Fill menu. + * + * @param menuMgr the menu mgr + */ private void fillMenu(IMenuManager menuMgr) { menuMgr.add(new SetMarkAction()); menuMgr.add(new ClearMarkAction()); @@ -354,6 +432,9 @@ public class HeapStatus extends Composite { redraw(); } + /** + * Gc. + */ private void gc() { gcRunning(true); Thread t = new Thread() { @@ -373,6 +454,9 @@ public class HeapStatus extends Composite { t.start(); } + /** + * Busy gc. + */ private void busyGC() { for (int i = 0; i < 2; ++i) { System.gc(); @@ -380,6 +464,11 @@ public class HeapStatus extends Composite { } } + /** + * Paint button. + * + * @param gc the gc + */ private void paintButton(GC gc) { Rectangle rect = button.getClientArea(); if (isInGC) { @@ -399,6 +488,11 @@ public class HeapStatus extends Composite { } } + /** + * Paint composite. + * + * @param gc the gc + */ private void paintComposite(GC gc) { if (showMax && maxMemKnown) { paintCompositeMaxKnown(gc); @@ -407,6 +501,11 @@ public class HeapStatus extends Composite { } } + /** + * Paint composite max unknown. + * + * @param gc the gc + */ private void paintCompositeMaxUnknown(GC gc) { Rectangle rect = getClientArea(); int x = rect.x; @@ -449,6 +548,11 @@ public class HeapStatus extends Composite { } } + /** + * Paint composite max known. + * + * @param gc the gc + */ private void paintCompositeMaxKnown(GC gc) { Rectangle rect = getClientArea(); int x = rect.x; @@ -509,6 +613,14 @@ public class HeapStatus extends Composite { } } + /** + * Paint mark. + * + * @param gc the gc + * @param x the x + * @param y the y + * @param h the h + */ private void paintMark(GC gc, int x, int y, int h) { gc.setForeground(markCol); gc.drawLine(x, y+1, x, y+h-2); @@ -516,6 +628,9 @@ public class HeapStatus extends Composite { gc.drawLine(x-1, y+h-2, x+1, y+h-2); } + /** + * Update stats. + */ private void updateStats() { Runtime runtime = Runtime.getRuntime(); totalMem = runtime.totalMemory(); @@ -533,6 +648,9 @@ public class HeapStatus extends Composite { } } + /** + * Update tool tip. + */ private void updateToolTip() { String usedStr = convertToMegString(usedMem); String totalStr = convertToMegString(totalMem); @@ -546,6 +664,9 @@ public class HeapStatus extends Composite { /** * Converts the given number of bytes to a printable number of megabytes (rounded up). + * + * @param numBytes the num bytes + * @return the string */ private String convertToMegString(long numBytes) { return new Long(convertToMeg(numBytes)).toString()+"M"; @@ -553,41 +674,74 @@ public class HeapStatus extends Composite { /** * Converts the given number of bytes to the corresponding number of megabytes (rounded up). + * + * @param numBytes the num bytes + * @return the long */ private long convertToMeg(long numBytes) { return (numBytes + (512 * 1024)) / (1024 * 1024); } + /** + * The Class SetMarkAction. + */ class SetMarkAction extends Action { + + /** + * Instantiates a new sets the mark action. + */ SetMarkAction() { super("&Set Mark"); } + /* (non-Javadoc) + * @see org.eclipse.jface.action.Action#run() + */ @Override public void run() { setMark(); } } + /** + * The Class ClearMarkAction. + */ class ClearMarkAction extends Action { + + /** + * Instantiates a new clear mark action. + */ ClearMarkAction() { super("&Clear Mark"); } + /* (non-Javadoc) + * @see org.eclipse.jface.action.Action#run() + */ @Override public void run() { clearMark(); } } + /** + * The Class ShowMaxAction. + */ class ShowMaxAction extends Action { - ShowMaxAction() { + + /** + * Instantiates a new show max action. + */ + ShowMaxAction() { super("Show &Max Heap", IAction.AS_CHECK_BOX); setEnabled(maxMemKnown); setChecked(showMax); } + /* (non-Javadoc) + * @see org.eclipse.jface.action.Action#run() + */ @Override public void run() { preferences.putBoolean(IHeapStatusConstants.PREF_SHOW_MAX, isChecked()); @@ -595,13 +749,22 @@ public class HeapStatus extends Composite { } } + /** + * The Class CloseHeapStatusAction. + */ class CloseHeapStatusAction extends Action{ - CloseHeapStatusAction(){ + /** + * Instantiates a new close heap status action. + */ + CloseHeapStatusAction(){ super("&Close"); } - @Override + /* (non-Javadoc) + * @see org.eclipse.jface.action.Action#run() + */ + @Override public void run(){ // WorkbenchWindow wbw = (WorkbenchWindow) PlatformUI.getWorkbench() // .getActiveWorkbenchWindow(); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/IHeapStatusConstants.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/IHeapStatusConstants.java index b79fb51..d6713e3 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/IHeapStatusConstants.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/IHeapStatusConstants.java @@ -11,8 +11,6 @@ package com.minres.scviewer.e4.application.internal.status; /** * Preference constants for the heap status. - * - * @since 3.1 */ public interface IHeapStatusConstants { diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/StatusBarControl.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/StatusBarControl.java index 85f9a21..66609af 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/StatusBarControl.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/StatusBarControl.java @@ -32,21 +32,37 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.ProgressBar; import org.osgi.service.prefs.PreferencesService; +/** + * The Class StatusBarControl. + */ public class StatusBarControl { + /** The Constant STATUS_UPDATE. */ public static final String STATUS_UPDATE="StatusUpdate"; + /** The model service. */ @Inject EModelService modelService; + /** The osgi preverences. */ @Inject @Optional PreferencesService osgiPreverences; + /** The sync. */ private final UISynchronize sync; + /** The manager. */ protected StatusLineManager manager; + /** The monitor. */ private SyncedProgressMonitor monitor; + + /** The progress bar. */ private ProgressBar progressBar; + /** + * Instantiates a new status bar control. + * + * @param sync the sync + */ @Inject public StatusBarControl(UISynchronize sync) { this.sync=sync; @@ -54,6 +70,12 @@ public class StatusBarControl { manager.update(true); } + /** + * Creates the widget. + * + * @param parent the parent + * @param toolControl the tool control + */ @PostConstruct void createWidget(Composite parent, MToolControl toolControl) { if (toolControl.getElementId().equals("org.eclipse.ui.StatusLine")) { //$NON-NLS-1$ @@ -65,6 +87,9 @@ public class StatusBarControl { } } + /** + * Destroy. + */ @PreDestroy void destroy() { if (manager != null) { @@ -74,8 +99,10 @@ public class StatusBarControl { } /** - * @param parent - * @param toolControl + * Creates the progress bar. + * + * @param parent the parent + * @param toolControl the tool control */ private void createProgressBar(Composite parent, MToolControl toolControl) { new Label(parent, SWT.NONE); @@ -92,22 +119,32 @@ public class StatusBarControl { } /** - * @param parent - * @param toolControl + * Creates the heap status. + * + * @param parent the parent + * @param toolControl the tool control */ private void createHeapStatus(Composite parent, MToolControl toolControl) { new HeapStatus(parent, osgiPreverences.getSystemPreferences()); } /** - * @param parent - * @param toolControl + * Creates the status line. + * + * @param parent the parent + * @param toolControl the tool control */ private void createStatusLine(Composite parent, MToolControl toolControl) { // IEclipseContext context = modelService.getContainingContext(toolControl); manager.createControl(parent); } + /** + * Gets the status event. + * + * @param text the text + * @return the status event + */ @Inject @Optional public void getStatusEvent(@UIEventTopic(STATUS_UPDATE) String text) { if(manager!=null ){ @@ -115,13 +152,24 @@ public class StatusBarControl { } } + /** + * The Class SyncedProgressMonitor. + */ private final class SyncedProgressMonitor extends NullProgressMonitor { // thread-Safe via thread confinement of the UI-Thread + /** The running tasks. */ // (means access only via UI-Thread) private long runningTasks = 0L; + + /** The progress bar. */ private ProgressBar progressBar; + /** + * Instantiates a new synced progress monitor. + * + * @param progressBar the progress bar + */ public SyncedProgressMonitor(ProgressBar progressBar) { super(); this.progressBar = progressBar; @@ -130,6 +178,9 @@ public class StatusBarControl { progressBar.setEnabled(false); } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.NullProgressMonitor#beginTask(java.lang.String, int) + */ @Override public void beginTask(final String name, final int totalWork) { sync.syncExec(new Runnable() { @@ -148,6 +199,9 @@ public class StatusBarControl { }); } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.NullProgressMonitor#worked(int) + */ @Override public void worked(final int work) { sync.syncExec(new Runnable() { @@ -158,6 +212,9 @@ public class StatusBarControl { }); } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.NullProgressMonitor#done() + */ @Override public void done() { sync.syncExec(new Runnable() { @@ -169,6 +226,13 @@ public class StatusBarControl { } }); } + +/** + * Adds the job. + * + * @param job the job + * @return the i progress monitor + */ /* @Override public boolean isCanceled() { diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/TrimUtil.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/TrimUtil.java index 14d5b20..81d7974 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/TrimUtil.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/TrimUtil.java @@ -24,8 +24,6 @@ import org.eclipse.swt.widgets.ToolItem; /** * Simple class to provide some common internal Trim support. * - * @since 3.2 - * */ public class TrimUtil { diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/WaveStatusBarControl.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/WaveStatusBarControl.java index 5a44cc8..5ca6820 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/WaveStatusBarControl.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/WaveStatusBarControl.java @@ -27,23 +27,50 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; +/** + * The Class WaveStatusBarControl. + */ public class WaveStatusBarControl extends StatusBarControl { + /** The Constant ZOOM_LEVEL. */ public static final String ZOOM_LEVEL="ZoomLevelUpdate"; + + /** The Constant CURSOR_TIME. */ public static final String CURSOR_TIME="CursorPosUpdate"; + + /** The Constant MARKER_TIME. */ public static final String MARKER_TIME="MarkerPosUpdate"; + + /** The Constant MARKER_DIFF. */ public static final String MARKER_DIFF="MarlerDiffUpdate"; + /** The model service. */ @Inject EModelService modelService; + /** + * The Class TextContributionItem. + */ class TextContributionItem extends ContributionItem { + /** The label string. */ final String labelString; + + /** The width. */ final int width; + + /** The text. */ CLabel label, text; + + /** The content. */ private String content; + /** + * Instantiates a new text contribution item. + * + * @param labelString the label string + * @param width the width + */ public TextContributionItem(String labelString, int width) { super(); this.labelString = labelString; @@ -51,6 +78,9 @@ public class WaveStatusBarControl extends StatusBarControl { content=""; } + /* (non-Javadoc) + * @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Composite) + */ @Override public void fill(Composite parent) { Composite box=new Composite(parent, SWT.NONE); @@ -63,11 +93,19 @@ public class WaveStatusBarControl extends StatusBarControl { text.setLayoutData(layoutData); } + /* (non-Javadoc) + * @see org.eclipse.jface.action.ContributionItem#isDynamic() + */ @Override public boolean isDynamic() { return true; } + /** + * Sets the text. + * + * @param message the new text + */ public void setText(String message){ this.content=message; if(text!=null && !text.isDisposed()) text.setText(content); @@ -75,8 +113,14 @@ public class WaveStatusBarControl extends StatusBarControl { } + /** The zoom contribution. */ TextContributionItem cursorContribution, markerContribution, markerDiffContribution, zoomContribution; + /** + * Instantiates a new wave status bar control. + * + * @param sync the sync + */ @Inject public WaveStatusBarControl(UISynchronize sync) { super(sync); @@ -90,6 +134,11 @@ public class WaveStatusBarControl extends StatusBarControl { manager.appendToGroup(StatusLineManager.BEGIN_GROUP, zoomContribution); } + /** + * Sets the selection. + * + * @param selection the new selection + */ @Inject public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION)@Optional IStructuredSelection selection){ if(manager!=null && selection!=null){ @@ -107,21 +156,45 @@ public class WaveStatusBarControl extends StatusBarControl { } } + /** + * Gets the zoom event. + * + * @param text the text + * @return the zoom event + */ @Inject @Optional public void getZoomEvent(@UIEventTopic(ZOOM_LEVEL) String text) { zoomContribution.setText(text); } + /** + * Gets the cursor event. + * + * @param text the text + * @return the cursor event + */ @Inject @Optional public void getCursorEvent(@UIEventTopic(CURSOR_TIME) String text) { cursorContribution.setText(text); } + /** + * Gets the marker event. + * + * @param text the text + * @return the marker event + */ @Inject @Optional public void getMarkerEvent(@UIEventTopic(MARKER_TIME) String text) { markerContribution.setText(text); } + /** + * Gets the diff event. + * + * @param text the text + * @return the diff event + */ @Inject @Optional public void getDiffEvent(@UIEventTopic(MARKER_DIFF) String text) { markerDiffContribution.setText(text); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/FileMonitor.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/FileMonitor.java index 3989582..cd4fdc9 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/FileMonitor.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/FileMonitor.java @@ -18,17 +18,16 @@ import java.util.List; import java.util.Timer; import java.util.TimerTask; -// TODO: Auto-generated Javadoc /** * Class monitoring a {@link File} for changes. * - * @author Pascal Essiembre */ public class FileMonitor { /** The timer. */ private Timer timer; + /** The enabled. */ private boolean enabled; /** The timer entries. */ @@ -96,10 +95,20 @@ public class FileMonitor { if(enabled) listener.fileChanged(file); } + /** + * Checks if is enabled. + * + * @return true, if is enabled + */ public boolean isEnabled() { return enabled; } + /** + * Sets the enabled. + * + * @param enabled the new enabled + */ public void setEnabled(boolean enabled) { this.enabled = enabled; } diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/IFileChangeListener.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/IFileChangeListener.java index 00483a6..550f21d 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/IFileChangeListener.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/IFileChangeListener.java @@ -18,14 +18,13 @@ import java.util.List; /** * Listener interested in {@link File} changes. * - * @author Pascal Essiembre */ public interface IFileChangeListener { + /** * Invoked when a file changes. - * - * @param fileName - * name of changed file. + * + * @param file the file */ public void fileChanged(List file); } \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/IModificationChecker.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/IModificationChecker.java index 8da175a..b002def 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/IModificationChecker.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/util/IModificationChecker.java @@ -10,8 +10,14 @@ *******************************************************************************/ package com.minres.scviewer.e4.application.internal.util; +/** + * The Interface IModificationChecker. Allows to trigger a check independent of the timer + */ public interface IModificationChecker { + /** + * Check. + */ public void check(); } diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java index 327f3a6..79b767a 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java @@ -40,15 +40,11 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.wb.swt.ResourceManager; import org.eclipse.wb.swt.SWTResourceManager; -// TODO: Auto-generated Javadoc /** * The Class AboutDialog. */ public class AboutDialog extends Dialog { - /** The styled text. */ -// protected StyledText styledText; - /** The product title. */ private String productTitle= "\nSCViewer - a SystemC waveform viewer\n\nVersion: 1.0\n"; @@ -64,8 +60,7 @@ public class AboutDialog extends Dialog { /** * Create the dialog. * - * @param parent the parent - * @param style the style + * @param parentShell the parent shell */ @Inject public AboutDialog(Shell parentShell) { @@ -75,6 +70,9 @@ public class AboutDialog extends Dialog { /** * Create contents of the dialog. + * + * @param parent the parent + * @return the control */ @Override protected Control createDialogArea(Composite parent) { @@ -153,6 +151,9 @@ public class AboutDialog extends Dialog { return composite; } + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + */ protected void createButtonsForButtonBar(Composite parent) { // create OK button createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true); 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 2616263..84598c1 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 @@ -72,36 +72,55 @@ import com.minres.scviewer.e4.application.handlers.AddWaveformHandler; import com.minres.scviewer.e4.application.provider.TxDbContentProvider; import com.minres.scviewer.e4.application.provider.TxDbLabelProvider; +/** + * The Class DesignBrowser. It contains the design tree, a list of Streams & signals and a few buttons to + * add them them to the waveform view + */ public class DesignBrowser { + /** The Constant POPUP_ID. */ private static final String POPUP_ID="com.minres.scviewer.e4.application.parts.DesignBrowser.popupmenu"; + /** The event broker. */ @Inject IEventBroker eventBroker; + /** The selection service. */ @Inject ESelectionService selectionService; + /** The menu service. */ @Inject EMenuService menuService; + /** The eclipse ctx. */ @Inject IEclipseContext eclipseCtx; + /** The sash form. */ private SashForm sashForm; + /** The top. */ Composite top; + /** The bottom. */ private Composite bottom; + /** The tree viewer. */ private TreeViewer treeViewer; + /** The name filter. */ private Text nameFilter; + /** The tx table viewer. */ private TableViewer txTableViewer; + /** The append all item. */ ToolItem appendItem, insertItem, insertAllItem, appendAllItem; + /** The attribute filter. */ WaveformAttributeFilter attributeFilter; + /** The other selection count. */ int thisSelectionCount=0, otherSelectionCount=0; + /** The tree viewer pcl. */ private PropertyChangeListener treeViewerPCL = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { @@ -116,8 +135,10 @@ public class DesignBrowser { } }; - private WaveformViewerPart waveformViewerPart; + /** The waveform viewer part. */ + private WaveformViewer waveformViewerPart; + /** The sash paint listener. */ protected PaintListener sashPaintListener=new PaintListener() { @Override public void paintControl(PaintEvent e) { @@ -132,6 +153,11 @@ public class DesignBrowser { }; + /** + * Creates the composite. + * + * @param parent the parent + */ @PostConstruct public void createComposite(Composite parent) { sashForm = new SashForm(parent, SWT.BORDER | SWT.SMOOTH | SWT.VERTICAL); @@ -151,6 +177,11 @@ public class DesignBrowser { }); } + /** + * Creates the tree viewer composite. + * + * @param parent the parent + */ public void createTreeViewerComposite(Composite parent) { parent.setLayout(new GridLayout(1, false)); treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); @@ -175,6 +206,11 @@ public class DesignBrowser { }); } + /** + * Creates the table composite. + * + * @param parent the parent + */ public void createTableComposite(Composite parent) { parent.setLayout(new GridLayout(1, false)); @@ -293,6 +329,9 @@ public class DesignBrowser { }); } + /** + * Sets the focus. + */ @Focus public void setFocus() { txTableViewer.getTable().setFocus(); @@ -305,9 +344,15 @@ public class DesignBrowser { updateButtons(); } + /** + * Gets the status event. + * + * @param waveformViewerPart the waveform viewer part + * @return the status event + */ @SuppressWarnings("unchecked") @Inject @Optional - public void getStatusEvent(@UIEventTopic(WaveformViewerPart.ACTIVE_WAVEFORMVIEW) WaveformViewerPart waveformViewerPart) { + public void getActiveWaveformViewerEvent(@UIEventTopic(WaveformViewer.ACTIVE_WAVEFORMVIEW) WaveformViewer waveformViewerPart) { if(this.waveformViewerPart!=null) this.waveformViewerPart.storeDesignBrowerState(new DBState()); this.waveformViewerPart=waveformViewerPart; @@ -328,6 +373,12 @@ public class DesignBrowser { database.addPropertyChangeListener(treeViewerPCL); } + /** + * Sets the selection. + * + * @param selection the selection + * @param partService the part service + */ @Inject public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){ MPart part = partService.getActivePart(); @@ -342,6 +393,9 @@ public class DesignBrowser { updateButtons(); } + /** + * Update buttons. + */ private void updateButtons() { if(txTableViewer!=null && !insertItem.isDisposed() && !appendItem.isDisposed() && !appendAllItem.isDisposed() && !insertAllItem.isDisposed()){ @@ -357,14 +411,26 @@ public class DesignBrowser { } } + /** + * The Class WaveformAttributeFilter. + */ public class WaveformAttributeFilter extends ViewerFilter { + /** The search string. */ private String searchString; + /** + * Sets the search text. + * + * @param s the new search text + */ public void setSearchText(String s) { this.searchString = ".*" + s + ".*"; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (searchString == null || searchString.length() == 0) { @@ -378,6 +444,12 @@ public class DesignBrowser { } } + /** + * Gets the filtered children. + * + * @param viewer the viewer + * @return the filtered children + */ protected Object[] getFilteredChildren(TableViewer viewer){ Object parent = viewer.getInput(); if(parent==null) return new Object[0]; @@ -402,32 +474,60 @@ public class DesignBrowser { return result; } + /** + * Run command. + * + * @param handler the handler + * @param annotation the annotation + * @param where the where + * @param all the all + * @return the object + */ protected Object runCommand(AddWaveformHandler handler, Class annotation, String where, Boolean all) { ContextInjectionFactory.inject(handler, eclipseCtx); eclipseCtx.set(AddWaveformHandler.PARAM_WHERE_ID, where); eclipseCtx.set(AddWaveformHandler.PARAM_ALL_ID, all.toString()); eclipseCtx.set(DesignBrowser.class, this); - eclipseCtx.set(WaveformViewerPart.class, waveformViewerPart); + eclipseCtx.set(WaveformViewer.class, waveformViewerPart); Object result = ContextInjectionFactory.invoke(handler, annotation, eclipseCtx); return result; } + /** + * Gets the filtered children. + * + * @return the filtered children + */ public Object[] getFilteredChildren() { return getFilteredChildren(txTableViewer); } - public WaveformViewerPart getActiveWaveformViewerPart() { + /** + * Gets the active waveform viewer part. + * + * @return the active waveform viewer part + */ + public WaveformViewer getActiveWaveformViewerPart() { return waveformViewerPart; } + /** + * The Class DBState. + */ class DBState { + /** + * Instantiates a new DB state. + */ public DBState() { this.expandedElements=treeViewer.getExpandedElements(); this.treeSelection=treeViewer.getSelection(); this.tableSelection=txTableViewer.getSelection(); } + /** + * Apply. + */ public void apply() { treeViewer.setExpandedElements(expandedElements); treeViewer.setSelection(treeSelection, true); @@ -435,8 +535,13 @@ public class DesignBrowser { } + /** The expanded elements. */ private Object[] expandedElements; + + /** The tree selection. */ private ISelection treeSelection; + + /** The table selection. */ private ISelection tableSelection; } }; \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/PartListener.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/PartListener.java index e12f76e..9f6b7d3 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/PartListener.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/PartListener.java @@ -13,19 +13,46 @@ package com.minres.scviewer.e4.application.parts; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.e4.ui.workbench.modeling.IPartListener; +/** + * The default implementation of a {@link IPartListener}. + * The class that is interested in processing a part + * event extends this class overriding the respective method, and the object created + * with that class is registered with a component using the + * component's addPartListener method. When + * the part event occurs, that object's appropriate + * method is invoked. + * + * @see PartEvent + */ public class PartListener implements IPartListener { + + /* (non-Javadoc) + * @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partBroughtToTop(org.eclipse.e4.ui.model.application.ui.basic.MPart) + */ @Override public void partBroughtToTop(MPart part) {} + /* (non-Javadoc) + * @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partActivated(org.eclipse.e4.ui.model.application.ui.basic.MPart) + */ @Override public void partActivated(MPart part) {} + /* (non-Javadoc) + * @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partDeactivated(org.eclipse.e4.ui.model.application.ui.basic.MPart) + */ @Override public void partDeactivated(MPart part) {} + /* (non-Javadoc) + * @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partHidden(org.eclipse.e4.ui.model.application.ui.basic.MPart) + */ @Override public void partHidden(MPart part) {} + /* (non-Javadoc) + * @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partVisible(org.eclipse.e4.ui.model.application.ui.basic.MPart) + */ @Override public void partVisible(MPart part) {} } \ No newline at end of file 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 e6b89c6..9adeebe 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 @@ -57,32 +57,51 @@ import com.minres.scviewer.database.ITxAttribute; import com.minres.scviewer.database.ITxRelation; import com.minres.scviewer.e4.application.provider.TxPropertiesLabelProvider; +/** + * The Class TransactionDetails shows the details of a selected transaction. + */ public class TransactionDetails { + /** The Constant COLUMN_FIRST. */ // Column constants public static final int COLUMN_FIRST = 0; + /** The Constant COLUMN_SECOND. */ public static final int COLUMN_SECOND = 1; + /** The Constant COLUMN_THIRD. */ public static final int COLUMN_THIRD = 2; + /** The event broker. */ @Inject IEventBroker eventBroker; + /** The selection service. */ @Inject ESelectionService selectionService; + /** The name filter. */ private Text nameFilter; + /** The tree viewer. */ private TreeViewer treeViewer; + /** The col3. */ private TreeViewerColumn col1, col2, col3; + /** The attribute filter. */ TxAttributeFilter attributeFilter; + /** The view sorter. */ TxAttributeViewerSorter viewSorter; - private WaveformViewerPart waveformViewerPart; + /** The waveform viewer part. */ + private WaveformViewer waveformViewerPart; + /** + * Creates the composite. + * + * @param parent the parent + */ @PostConstruct public void createComposite(final Composite parent) { parent.setLayout(new GridLayout(1, false)); @@ -207,16 +226,30 @@ public class TransactionDetails { }); } + /** + * Sets the focus. + */ @Focus public void setFocus() { treeViewer.getTree().setFocus(); } + /** + * Gets the status event. + * + * @param part the part + * @return the status event + */ @Inject @Optional - public void getStatusEvent(@UIEventTopic(WaveformViewerPart.ACTIVE_WAVEFORMVIEW) WaveformViewerPart part) { + public void getStatusEvent(@UIEventTopic(WaveformViewer.ACTIVE_WAVEFORMVIEW) WaveformViewer part) { this.waveformViewerPart=part; } + /** + * Sets the selection. + * + * @param selection the new selection + */ @Inject public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection){ if(treeViewer!=null && selection!=null && !treeViewer.getTree().isDisposed()){ @@ -231,10 +264,22 @@ public class TransactionDetails { } } + /** + * Time to string. + * + * @param time the time + * @return the string + */ String timeToString(Long time){ return waveformViewerPart.getScaledTime(time); } + /** + * Tx to string. + * + * @param tx the tx + * @return the string + */ String txToString(ITx tx){ StringBuilder sb = new StringBuilder(); sb.append("tx#").append(tx.getId()).append("[").append(timeToString(tx.getBeginTime())). @@ -242,21 +287,29 @@ public class TransactionDetails { return sb.toString(); } + /** + * The Class TxAttributeViewerSorter. + */ class TxAttributeViewerSorter extends ViewerSorter { + + /** The Constant ASCENDING. */ private static final int ASCENDING = 0; + /** The Constant DESCENDING. */ private static final int DESCENDING = 1; + /** The column. */ private int column; + /** The direction. */ private int direction; /** * Does the sort. If it's a different column from the previous sort, do an * ascending sort. If it's the same column as the last sort, toggle the sort * direction. - * - * @param column + * + * @param column the column */ public void doSort(int column) { if (column == this.column) { @@ -270,7 +323,12 @@ public class TransactionDetails { } /** - * Compares the object for sorting + * Compares the object for sorting. + * + * @param viewer the viewer + * @param e1 the e1 + * @param e2 the e2 + * @return the int */ @SuppressWarnings("unchecked") public int compare(Viewer viewer, Object e1, Object e2) { @@ -297,14 +355,26 @@ public class TransactionDetails { } } + /** + * The Class TxAttributeFilter. + */ class TxAttributeFilter extends ViewerFilter { + /** The search string. */ private String searchString; + /** + * Sets the search text. + * + * @param s the new search text + */ public void setSearchText(String s) { this.searchString = ".*" + s + ".*"; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (searchString == null || searchString.length() == 0) { @@ -321,17 +391,40 @@ public class TransactionDetails { } } - enum Type {PROPS, ATTRS, IN_REL, OUT_REL} + /** + * The Enum Type. + */ + enum Type {/** The props. */ +PROPS, /** The attrs. */ + ATTRS, /** The in rel. */ + IN_REL, /** The out rel. */ + OUT_REL} + /** + * The Class TreeNode. + */ class TreeNode{ + + /** The type. */ public Type type; + + /** The element. */ public ITx element; + /** + * Instantiates a new tree node. + * + * @param element the element + * @param type the type + */ public TreeNode(ITx element, Type type){ this.element=element; this.type=type; } + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ public String toString(){ switch(type){ case PROPS: return "Properties"; @@ -343,15 +436,27 @@ public class TransactionDetails { } } + /** + * The Class TransactionTreeContentProvider. + */ class TransactionTreeContentProvider implements ITreeContentProvider { + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ @Override public void dispose() { } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object) + */ @Override public Object[] getElements(Object element) { return new Object[]{ @@ -362,6 +467,9 @@ public class TransactionDetails { }; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) + */ @Override public Object[] getChildren(Object element) { if(element instanceof TreeNode){ @@ -398,11 +506,17 @@ public class TransactionDetails { return null; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) + */ @Override public Object getParent(Object element) { return null; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) + */ @Override public boolean hasChildren(Object element) { return getChildren(element)!=null; @@ -410,16 +524,35 @@ public class TransactionDetails { } + /** + * The Class AttributeLabelProvider. + */ class AttributeLabelProvider extends LabelProvider implements IStyledLabelProvider { + + /** The field. */ final int field; + + /** The Constant NAME. */ public static final int NAME=0; + + /** The Constant TYPE. */ public static final int TYPE=1; + + /** The Constant VALUE. */ public static final int VALUE=2; + /** + * Instantiates a new attribute label provider. + * + * @param field the field + */ public AttributeLabelProvider(int field) { this.field=field; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object) + */ @Override public StyledString getStyledText(Object element) { switch(field){ 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 8ac919d..b7a7c20 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 @@ -76,7 +76,6 @@ 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; -// TODO: Auto-generated Javadoc /** * The Class WaveformViewerPart. */ 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 5fe7302..9bea8a5 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 @@ -21,10 +21,17 @@ import org.eclipse.wb.swt.SWTResourceManager; import com.minres.scviewer.database.ui.WaveformColors; import com.opcoach.e4.preferences.ScopedPreferenceStore; +/** + * The Class DefaultValuesInitializer. + */ public class DefaultValuesInitializer extends AbstractPreferenceInitializer { + /** The default colors. */ public final Color[] colors = new Color[WaveformColors.values().length]; + /** + * Instantiates a new default values initializer. + */ public DefaultValuesInitializer() { colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN); @@ -48,6 +55,9 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer { colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255); } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ @Override public void initializeDefaultPreferences() { IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java index 92c42dc..e0b83b3 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java @@ -10,27 +10,69 @@ *******************************************************************************/ package com.minres.scviewer.e4.application.preferences; +/** + * The Class PreferenceConstants for the preferences dialog & setting. + */ public class PreferenceConstants { + /** The Constant PREFERENCES_SCOPE. */ public static final String PREFERENCES_SCOPE="com.minres.scviewer.e4.application"; + + /** The Constant DATABASE_RELOAD. */ public static final String DATABASE_RELOAD="databaseReload"; + + /** The Constant LINE_COLOR. */ public static final String LINE_COLOR="LINE_COLOR"; + + /** The Constant LINE_HIGHLITE_COLOR. */ public static final String LINE_HIGHLITE_COLOR="LINE_HIGHLITE_COLOR"; + + /** The Constant TRACK_BG_EVEN_COLOR. */ public static final String TRACK_BG_EVEN_COLOR="TRACK_BG_EVEN_COLOR"; + + /** The Constant TRACK_BG_ODD_COLOR. */ public static final String TRACK_BG_ODD_COLOR="TRACK_BG_ODD_COLOR"; + + /** The Constant TRACK_BG_HIGHLITE_COLOR. */ public static final String TRACK_BG_HIGHLITE_COLOR="TRACK_BG_HIGHLITE_COLOR"; + + /** The Constant TX_BG_COLOR. */ public static final String TX_BG_COLOR="TX_BG_COLOR"; + + /** The Constant TX_BG_HIGHLITE_COLOR. */ public static final String TX_BG_HIGHLITE_COLOR="TX_BG_HIGHLITE_COLOR"; + + /** The Constant TX_BORDER_COLOR. */ public static final String TX_BORDER_COLOR="TX_BORDER_COLOR"; + + /** The Constant SIGNAL0_COLOR. */ public static final String SIGNAL0_COLOR="SIGNAL0_COLOR"; + + /** The Constant SIGNAL1_COLOR. */ public static final String SIGNAL1_COLOR="SIGNAL1_COLOR"; + + /** The Constant SIGNALZ_COLOR. */ public static final String SIGNALZ_COLOR="SIGNALZ_COLOR"; + + /** The Constant SIGNALX_COLOR. */ public static final String SIGNALX_COLOR="SIGNALX_COLOR"; + + /** The Constant SIGNAL_TEXT_COLOR. */ public static final String SIGNAL_TEXT_COLOR="SIGNAL_TEXT_COLOR"; + + /** The Constant CURSOR_COLOR. */ public static final String CURSOR_COLOR="CURSOR_COLOR"; + + /** The Constant CURSOR_DRAG_COLOR. */ public static final String CURSOR_DRAG_COLOR="CURSOR_DRAG_COLOR"; + + /** The Constant CURSOR_TEXT_COLOR. */ public static final String CURSOR_TEXT_COLOR="CURSOR_TEXT_COLOR"; + + /** The Constant MARKER_COLOR. */ public static final String MARKER_COLOR="MARKER_COLOR"; + + /** The Constant MARKER_TEXT_COLOR. */ public static final String MARKER_TEXT_COLOR="MARKER_TEXT_COLOR"; diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/SCViewerPreferencesPage.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/SCViewerPreferencesPage.java index c175829..e559d2a 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/SCViewerPreferencesPage.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/SCViewerPreferencesPage.java @@ -13,13 +13,22 @@ package com.minres.scviewer.e4.application.preferences; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; -/** A sample preference page to show how it works */ + +/** + * The Class SCViewerPreferencesPage showing the SCViewer top preferences. + */ public class SCViewerPreferencesPage extends FieldEditorPreferencePage { + /** + * Instantiates a new SC viewer preferences page. + */ public SCViewerPreferencesPage() { super(GRID); } + /* (non-Javadoc) + * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() + */ @Override protected void createFieldEditors() { diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/WaveformPreferencesPage.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/WaveformPreferencesPage.java index 207a25b..56d45d8 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/WaveformPreferencesPage.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/WaveformPreferencesPage.java @@ -15,13 +15,21 @@ import org.eclipse.jface.preference.FieldEditorPreferencePage; import com.minres.scviewer.database.ui.WaveformColors; -/** A sample preference page to show how it works */ +/** + * The WaveformView preference page to show the colors to use. + */ public class WaveformPreferencesPage extends FieldEditorPreferencePage { + /** + * Instantiates a new waveform preferences page. + */ public WaveformPreferencesPage() { super(GRID); } + /* (non-Javadoc) + * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() + */ @Override protected void createFieldEditors() { diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbContentProvider.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbContentProvider.java index 62ccd8a..f2c2d11 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbContentProvider.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbContentProvider.java @@ -21,29 +21,50 @@ import com.google.common.collect.Collections2; import com.minres.scviewer.database.IHierNode; import com.minres.scviewer.database.IWaveform; +/** + * The Class TxDbContentProvider providing the tree content of a database for the respective viewer. + */ public class TxDbContentProvider implements ITreeContentProvider { + /** The show nodes. */ // private List nodes; private boolean showNodes; + /** + * Instantiates a new tx db content provider. + */ public TxDbContentProvider() { super(); this.showNodes = false; } + /** + * Instantiates a new tx db content provider. + * + * @param showNodes the show nodes + */ public TxDbContentProvider(boolean showNodes) { super(); this.showNodes = showNodes; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ @Override public void dispose() { } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // showNodes=!(newInput instanceof IHierNode); } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object) + */ @Override public Object[] getElements(Object inputElement) { if(inputElement instanceof IHierNode){ @@ -64,16 +85,25 @@ public class TxDbContentProvider implements ITreeContentProvider { return null; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) + */ @Override public Object[] getChildren(Object parentElement) { return getElements(parentElement); } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) + */ @Override public Object getParent(Object element) { return null; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) + */ @Override public boolean hasChildren(Object element) { Object[] obj = getElements(element); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbLabelProvider.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbLabelProvider.java index 3011853..9968cdc 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbLabelProvider.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbLabelProvider.java @@ -24,13 +24,21 @@ import com.minres.scviewer.database.ISignalChangeMulti; import com.minres.scviewer.database.ITxStream; import com.minres.scviewer.database.IWaveformDb; +/** + * The Class TxDbLabelProvider providing the labels for the respective viewers. + */ public class TxDbLabelProvider implements ILabelProvider { + /** The listeners. */ private List listeners = new ArrayList(); + /** The wave. */ private Image database, stream, signal, folder, wave; + /** + * Instantiates a new tx db label provider. + */ public TxDbLabelProvider() { super(); database=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database.png"); @@ -40,11 +48,17 @@ public class TxDbLabelProvider implements ILabelProvider { wave=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/wave.png"); } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) + */ @Override public void addListener(ILabelProviderListener listener) { listeners.add(listener); } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() + */ @Override public void dispose() { if(database!=null) database.dispose(); @@ -54,16 +68,25 @@ public class TxDbLabelProvider implements ILabelProvider { if(wave!=null) wave.dispose(); } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) + */ @Override public boolean isLabelProperty(Object element, String property) { return false; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) + */ @Override public void removeListener(ILabelProviderListener listener) { listeners.remove(listener); } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) + */ @Override public Image getImage(Object element) { if(element instanceof IWaveformDb){ @@ -82,6 +105,9 @@ public class TxDbLabelProvider implements ILabelProvider { return null; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) + */ @Override public String getText(Object element) { return ((IHierNode)element).getName(); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxPropertiesContentProvider.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxPropertiesContentProvider.java index 4cd094b..a04cf8c 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxPropertiesContentProvider.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxPropertiesContentProvider.java @@ -21,19 +21,32 @@ import com.minres.scviewer.database.IHierNode; import com.minres.scviewer.database.ITx; import com.minres.scviewer.database.ITxAttribute; +/** + * The Class TxPropertiesContentProvider. Not used atm + */ public class TxPropertiesContentProvider implements IStructuredContentProvider { + /** The show nodes. */ // private List nodes; private boolean showNodes=false; + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ @Override public void dispose() { } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { showNodes=!(newInput instanceof IHierNode); } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ @Override public Object[] getElements(Object inputElement) { if(inputElement instanceof ITx){ diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxPropertiesLabelProvider.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxPropertiesLabelProvider.java index 0e5307b..ecf7533 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxPropertiesLabelProvider.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxPropertiesLabelProvider.java @@ -20,38 +20,63 @@ import org.eclipse.swt.graphics.Image; import com.minres.scviewer.database.ITxAttribute; import com.minres.scviewer.e4.application.parts.TransactionDetails; +/** + * The Class TxPropertiesLabelProvider providing the labels of a property to the respective viewer. + */ public class TxPropertiesLabelProvider implements ITableLabelProvider { + /** The listeners. */ private List listeners = new ArrayList(); + /** + * Instantiates a new tx properties label provider. + */ public TxPropertiesLabelProvider() { super(); } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() + */ @Override public void dispose() { } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) + */ @Override public void addListener(ILabelProviderListener listener) { listeners.add(listener); } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) + */ @Override public void removeListener(ILabelProviderListener listener) { listeners.remove(listener); } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) + */ @Override public boolean isLabelProperty(Object element, String property) { return false; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) + */ @Override public Image getColumnImage(Object element, int columnIndex) { return null; } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) + */ @Override public String getColumnText(Object element, int columnIndex) { ITxAttribute attribute = (ITxAttribute) element; diff --git a/com.minres.scviewer.e4.product/SCViewer.launch b/com.minres.scviewer.e4.product/SCViewer.launch deleted file mode 100644 index cb90612..0000000 --- a/com.minres.scviewer.e4.product/SCViewer.launch +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 0007ab932290a6a4f2dd85d37298a9df2351bddb Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 22 Nov 2015 14:29:55 +0100 Subject: [PATCH 5/8] 4: It shoudl be possible to start SCViewer several times in parallel Task-Url: https://github.com/eyck/txviewer/issues/issue/4 --- com.minres.scviewer.e4.product/scviewer.product | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.minres.scviewer.e4.product/scviewer.product b/com.minres.scviewer.e4.product/scviewer.product index dce1dd6..5e42d46 100644 --- a/com.minres.scviewer.e4.product/scviewer.product +++ b/com.minres.scviewer.e4.product/scviewer.product @@ -7,7 +7,7 @@ - -clearPersistedState + -clearPersistedState -data @none -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts From 31ed3e4858572b8317e9c5fc9a01470966f54381 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 22 Nov 2015 16:38:00 +0100 Subject: [PATCH 6/8] 5: DesignBrowser should indicate loading of database Task-Url: https://github.com/eyck/txviewer/issues/issue/5 --- .../icons/database_go.png | Bin 0 -> 698 bytes .../e4/application/parts/DesignBrowser.java | 2 +- .../application/parts/LoadingWaveformDb.java | 88 ++++++++++++++++++ .../e4/application/parts/WaveformViewer.java | 9 +- .../provider/TxDbContentProvider.java | 7 +- .../provider/TxDbLabelProvider.java | 10 +- 6 files changed, 106 insertions(+), 10 deletions(-) create mode 100644 com.minres.scviewer.e4.application/icons/database_go.png create mode 100644 com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/LoadingWaveformDb.java diff --git a/com.minres.scviewer.e4.application/icons/database_go.png b/com.minres.scviewer.e4.application/icons/database_go.png new file mode 100644 index 0000000000000000000000000000000000000000..61a8556c403a1b56cb7719f4916d07ed82cd55ff GIT binary patch literal 698 zcmV;r0!96aP)U4c>+hFP*|&0tGt{!YG|5fRw@-UpUxK})gOY{KjH!sGG4?RHzSe!mY<6j86&kw_%0+>rt+UvTG zPNxG!QLHl_`>TN6lhf(69Pnfg>e~`ot!6OL_K}%<0mC@>2*2;ZcEFQ4iGwF{@R*{j z7!M|qd3hZgQye2(un7;}EWl(MRHj3v{mH--l93DO%KKRTaX^3MX`58z^<+{ z6<23&!!Q{PW`ItyBW>gC_$Bnz0p8cvrP&8U;E(_Zug)QpWlpZPzmjE&ksHm>&{4WL zcWMqjtuMUYDzy&;xOM)i=ubqW(I5dCx}hU{e1gb^CAKTo5EzT#!}bO?zL#36j`?8+ z3*~b8c`}*w$6_%IbOkHrWx4~^auW|u<6?Xs@2VxNZ5G?Ij>|hs<|oJSYs}?xlO%MH zkQM~t1b+*>9q#P0c*i_HG3Qv{e6_1E^9qr_9C}QDj%+r2jL4@6j4t)_BWY1InA104 gM*QcJxn<}50%n)c1HutrKL7v#07*qoM6N<$f)5Qpt^fc4 literal 0 HcmV?d00001 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 84598c1..1c8cd09 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 @@ -363,7 +363,7 @@ public class DesignBrowser { if(db==database) return; // do nothing if old and new daabase is the same ((List)input).get(0).removePropertyChangeListener(treeViewerPCL); } - treeViewer.setInput(database.isLoaded()?Arrays.asList(new IWaveformDb[]{database}):null); + treeViewer.setInput(Arrays.asList(database.isLoaded()?new IWaveformDb[]{database}:new IWaveformDb[]{new LoadingWaveformDb()})); Object state=this.waveformViewerPart.retrieveDesignBrowerState(); if(state!=null && state instanceof DBState) ((DBState)state).apply(); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/LoadingWaveformDb.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/LoadingWaveformDb.java new file mode 100644 index 0000000..3893d08 --- /dev/null +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/LoadingWaveformDb.java @@ -0,0 +1,88 @@ +package com.minres.scviewer.e4.application.parts; + +import java.beans.PropertyChangeListener; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import com.minres.scviewer.database.IHierNode; +import com.minres.scviewer.database.IWaveform; +import com.minres.scviewer.database.IWaveformDb; +import com.minres.scviewer.database.IWaveformEvent; +import com.minres.scviewer.database.RelationType; + +public class LoadingWaveformDb implements IWaveformDb { + + private final String label = "Database loading..."; + + @Override + public void addPropertyChangeListener(PropertyChangeListener l) { + } + + @Override + public void removePropertyChangeListener(PropertyChangeListener l) { + } + + @Override + public String getFullName() { + return label; + } + + @Override + public String getName() { + return label; + } + + @Override + public void setName(String name) { + } + + @Override + public void setParentName(String name) { + } + + @Override + public List getChildNodes() { + return new ArrayList(); + } + + @Override + public int compareTo(IHierNode o) { + return 0; + } + + @Override + public Long getMaxTime() { + return new Long(0); + } + + @Override + public IWaveform getStreamByName(String name) { + return null; + } + + @Override + public List> getAllWaves() { + return new ArrayList>(); + } + + @Override + public List getAllRelationTypes() { + return new ArrayList(); + } + + @Override + public boolean load(File inp) throws Exception { + return false; + } + + @Override + public boolean isLoaded() { + return false; + } + + @Override + public void clear() { + } + +} 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 b7a7c20..9a42746 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 @@ -297,22 +297,21 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis */ protected void loadDatabase(final Map state) { fileMonitor.removeFileChangeListener(this); - Job job = new Job(" My Job") { + Job job = new Job("Database Load Job") { @Override protected IStatus run(IProgressMonitor monitor) { // convert to SubMonitor and set total number of work units - SubMonitor subMonitor = SubMonitor.convert(monitor, filesToLoad.size()); - subMonitor.setTaskName("Loading database"); + SubMonitor subMonitor = SubMonitor.convert(monitor, filesToLoad.size()+1); try { + subMonitor.worked(1); for (File file : filesToLoad) { - // TimeUnit.SECONDS.sleep(2); + subMonitor.setTaskName("Loading "+file.getName()); database.load(file); database.addPropertyChangeListener(waveformPane); subMonitor.worked(1); if (monitor.isCanceled()) return Status.CANCEL_STATUS; } - // sleep a second } catch (Exception e) { database = null; e.printStackTrace(); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbContentProvider.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbContentProvider.java index f2c2d11..2cb0db0 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbContentProvider.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbContentProvider.java @@ -20,6 +20,7 @@ import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.minres.scviewer.database.IHierNode; import com.minres.scviewer.database.IWaveform; +import com.minres.scviewer.database.IWaveformDb; /** * The Class TxDbContentProvider providing the tree content of a database for the respective viewer. @@ -79,9 +80,11 @@ public class TxDbContentProvider implements ITreeContentProvider { } }); return res.toArray(); - }else if(inputElement instanceof List) + }else if(inputElement instanceof List){ return ((List)inputElement).toArray(); - else + }else if(inputElement instanceof IWaveformDb){ + return new Object[]{}; + } else return null; } diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbLabelProvider.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbLabelProvider.java index 9968cdc..349d9d5 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbLabelProvider.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbLabelProvider.java @@ -23,6 +23,7 @@ import com.minres.scviewer.database.ISignal; import com.minres.scviewer.database.ISignalChangeMulti; import com.minres.scviewer.database.ITxStream; import com.minres.scviewer.database.IWaveformDb; +import com.minres.scviewer.e4.application.parts.LoadingWaveformDb; /** * The Class TxDbLabelProvider providing the labels for the respective viewers. @@ -33,7 +34,7 @@ public class TxDbLabelProvider implements ILabelProvider { private List listeners = new ArrayList(); /** The wave. */ - private Image database, stream, signal, folder, wave; + private Image loadinDatabase, database, stream, signal, folder, wave; /** @@ -41,6 +42,7 @@ public class TxDbLabelProvider implements ILabelProvider { */ public TxDbLabelProvider() { super(); + loadinDatabase=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database_go.png"); database=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database.png"); stream=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/stream.png"); folder=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/folder.png"); @@ -61,6 +63,7 @@ public class TxDbLabelProvider implements ILabelProvider { */ @Override public void dispose() { + if(loadinDatabase!=null) database.dispose(); if(database!=null) database.dispose(); if(stream!=null) stream.dispose(); if(folder!=null) folder.dispose(); @@ -90,7 +93,10 @@ public class TxDbLabelProvider implements ILabelProvider { @Override public Image getImage(Object element) { if(element instanceof IWaveformDb){ - return database; + if(element instanceof LoadingWaveformDb) + return loadinDatabase; + else + return database; }else if(element instanceof ITxStream){ return stream; }else if(element instanceof ISignal){ From ff4cb91aed4f6736ae2b1f20dfa6819a4842da3b Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 30 Nov 2015 22:16:29 +0100 Subject: [PATCH 7/8] 6: Add Load/Save state functionality Task-Url: https://github.com/eyck/txviewer/issues/issue/6 --- .../database/swt/internal/WaveformViewer.java | 85 +++++++++--------- .../Application.e4xmi | 16 +++- .../icons/folder_page.png | Bin 0 -> 688 bytes .../icons/script_save.png | Bin 0 -> 804 bytes .../handlers/LoadStoreSettingsHandler.java | 57 ++++++++++++ .../e4/application/handlers/OpenHandler.java | 8 +- .../e4/application/parts/WaveformViewer.java | 39 ++++++++ 7 files changed, 159 insertions(+), 46 deletions(-) create mode 100644 com.minres.scviewer.e4.application/icons/folder_page.png create mode 100644 com.minres.scviewer.e4.application/icons/script_save.png create mode 100644 com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/LoadStoreSettingsHandler.java diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java index d6f365f..9565c14 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java @@ -20,6 +20,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map.Entry; import java.util.NavigableMap; +import java.util.NoSuchElementException; import java.util.TreeMap; import org.eclipse.core.runtime.ListenerList; @@ -772,52 +773,56 @@ public class WaveformViewer implements IWaveformViewer { protected void paintNames(GC gc, Rectangle rect) { if (streams.size() > 0) { - Integer firstKey = trackVerticalOffset.floorKey(rect.y); - if (firstKey == null) - firstKey = trackVerticalOffset.firstKey(); - Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height); - Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight()); - if (lastKey == firstKey) { - TrackEntry trackEntry=trackVerticalOffset.get(firstKey); - IWaveform w = trackEntry.waveform; - if (w instanceof ITxStream) - subArea.height *= ((ITxStream) w).getMaxConcurrency(); - drawTextFormat(gc, subArea, firstKey, w.getFullName(), trackEntry.selected); - } else { - for (Entry entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()) { - IWaveform w = entry.getValue().waveform; - subArea.height = waveformCanvas.getTrackHeight(); + try { + Integer firstKey = trackVerticalOffset.floorKey(rect.y); + if (firstKey == null) + firstKey = trackVerticalOffset.firstKey(); + Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height); + Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight()); + if (lastKey == firstKey) { + TrackEntry trackEntry=trackVerticalOffset.get(firstKey); + IWaveform w = trackEntry.waveform; if (w instanceof ITxStream) subArea.height *= ((ITxStream) w).getMaxConcurrency(); - drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), entry.getValue().selected); + drawTextFormat(gc, subArea, firstKey, w.getFullName(), trackEntry.selected); + } else { + for (Entry entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()) { + IWaveform w = entry.getValue().waveform; + subArea.height = waveformCanvas.getTrackHeight(); + if (w instanceof ITxStream) + subArea.height *= ((ITxStream) w).getMaxConcurrency(); + drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), entry.getValue().selected); + } } - } + }catch(NoSuchElementException e){} } } protected void paintValues(GC gc, Rectangle rect) { if (streams.size() > 0) { - Integer firstKey = trackVerticalOffset.floorKey(rect.y); - if (firstKey == null) - firstKey = trackVerticalOffset.firstKey(); - Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height); - Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight()); - if (lastKey == firstKey) { - TrackEntry trackEntry=trackVerticalOffset.get(firstKey); - IWaveform w = trackEntry.waveform; - if (w instanceof ITxStream) - subArea.height *= ((ITxStream) w).getMaxConcurrency(); - drawValue(gc, subArea, firstKey, actualValues.get(w), trackEntry.selected); - } else { - for (Entry entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true) - .entrySet()) { - IWaveform w = entry.getValue().waveform; - subArea.height = waveformCanvas.getTrackHeight(); + try { + Integer firstKey = trackVerticalOffset.floorKey(rect.y); + if (firstKey == null) + firstKey = trackVerticalOffset.firstKey(); + Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height); + Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight()); + if (lastKey == firstKey) { + TrackEntry trackEntry=trackVerticalOffset.get(firstKey); + IWaveform w = trackEntry.waveform; if (w instanceof ITxStream) subArea.height *= ((ITxStream) w).getMaxConcurrency(); - drawValue(gc, subArea, entry.getKey(), actualValues.get(w), entry.getValue().selected); + drawValue(gc, subArea, firstKey, actualValues.get(w), trackEntry.selected); + } else { + for (Entry entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true) + .entrySet()) { + IWaveform w = entry.getValue().waveform; + subArea.height = waveformCanvas.getTrackHeight(); + if (w instanceof ITxStream) + subArea.height *= ((ITxStream) w).getMaxConcurrency(); + drawValue(gc, subArea, entry.getKey(), actualValues.get(w), entry.getValue().selected); + } } - } + }catch(NoSuchElementException e){} } } @@ -846,11 +851,11 @@ public class WaveformViewer implements IWaveformViewer { gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (waveformCanvas.getTrackHeight() - size.y) / 2, true); } - - public void setHighliteRelation(RelationType relationType){ - this.waveformCanvas.setHighliteRelation(relationType); - } - + + public void setHighliteRelation(RelationType relationType){ + this.waveformCanvas.setHighliteRelation(relationType); + } + /* (non-Javadoc) * @see com.minres.scviewer.database.swt.IWaveformPanel#getMaxTime() */ diff --git a/com.minres.scviewer.e4.application/Application.e4xmi b/com.minres.scviewer.e4.application/Application.e4xmi index 55e48fa..35149e6 100644 --- a/com.minres.scviewer.e4.application/Application.e4xmi +++ b/com.minres.scviewer.e4.application/Application.e4xmi @@ -34,8 +34,13 @@
- - + + + + + + + @@ -77,6 +82,9 @@ + + + @@ -145,6 +153,7 @@ + @@ -226,6 +235,9 @@ + + + diff --git a/com.minres.scviewer.e4.application/icons/folder_page.png b/com.minres.scviewer.e4.application/icons/folder_page.png new file mode 100644 index 0000000000000000000000000000000000000000..1ef6e11438f3226f88bdc457f55d677d1f2f8409 GIT binary patch literal 688 zcmV;h0#E&kP)CVGc zN?Hxg{(SJp>2>GN9JetoZ(aZH;Ije%0FdZ{S!LRVX%}YG;=d8L^N!mJkCd*SBx($jgG)S}+Le)f;q=GIn30YFNh3ZW|nh}2rL)`=3ju9K*d z<&~Gte>sT=5|RjR+}A(|O&3gS5t&*G5h0Um$c5IgEgxJl_8nzY#B+YU^|Fhvzo-^U z6fNn3(lBMcl9{Silx)4RpURdFw}1BZ?>}8S&h8fk5`hjKW@sP$LJL*otPOMf+jp$? zcC^*PiL>vkTOZln=wuc^%A^$j`TU&aa3ETVYE{(r=bgN835`stIePGw{uwD`7K9Y) z=4)VDHnkl3YL%JeLce6>Uubzae&kQ4(W!a4mwm4 z9lAtNv=ALSSd<+NDwVaw^{3sLb!X=Ld%vD1v~3H{e06ITmmVL?oETThxJs&&OzJem zHtwUrCLZ83e4hiPx_{6!^k(M?jGkMpCU#xpD+L1R^b^O%J&(6Mk`UL>+ z=KDX%bR-j>Tz%V8|BxWMH@@Yq=Prq6jEhpgV{ iMhatptY3F`RQVr(hfH%Uc-uk%0000 persistedState = new HashMap<>(); + persistedState.put(DATABASE_FILE + "S", Integer.toString(filesToLoad.size())); + Integer index = 0; + for (File file : filesToLoad) { + persistedState.put(DATABASE_FILE + index, file.getAbsolutePath()); + index++; + } + saveWaveformViewerState(persistedState); + Properties props = new Properties(); + props.putAll(persistedState); + try { + FileOutputStream out = new FileOutputStream(fileName); + props.store(out, "Written by SCViewer"); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void loadState(String fileName){ + Properties props = new Properties(); + try { + FileInputStream in = new FileInputStream(fileName); + props.load(in); + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + HashMap propMap = new HashMap((Map) props); + restoreWaveformViewerState(propMap); + } + /** * Save waveform viewer state. * From 5c784af74ff5d3c439c2d56eff523f621c942f95 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 30 Nov 2015 22:55:03 +0100 Subject: [PATCH 8/8] 6: Add Load/Save state functionality Task-Url: https://github.com/eyck/txviewer/issues/issue/6 --- .../database/swt/internal/WaveformViewer.java | 16 +++++++++++-- .../scviewer/database/ui/IWaveformViewer.java | 6 ++++- .../e4/application/parts/WaveformViewer.java | 24 +++++++++++++------ 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java index 9565c14..3b88ad1 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java @@ -923,8 +923,8 @@ public class WaveformViewer implements IWaveformViewer { * @see com.minres.scviewer.database.swt.IWaveformPanel#getActMarkerTime() */ @Override - public long getSelectedMarkerTime(){ - return getMarkerTime(selectedMarker); + public int getSelectedMarkerId(){ + return selectedMarker; } @Override @@ -1168,4 +1168,16 @@ public class WaveformViewer implements IWaveformViewer { public void setColors(HashMap colourMap) { waveformCanvas.initColors(colourMap); } + + @Override + public long getBaselineTime() { + return -waveformCanvas.getScaleFactorPow10()*waveformCanvas.getOrigin().x; + } + + @Override + public void setBaselineTime(Long time) { + Point origin = waveformCanvas.getOrigin(); + origin.x=(int) (-time/waveformCanvas.getScaleFactorPow10()); + waveformCanvas.setOrigin(origin); + } } diff --git a/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/IWaveformViewer.java b/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/IWaveformViewer.java index 75dc95b..cac7994 100644 --- a/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/IWaveformViewer.java +++ b/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/IWaveformViewer.java @@ -77,7 +77,7 @@ public interface IWaveformViewer extends PropertyChangeListener, ISelectionProvi public long getCursorTime(); - public long getSelectedMarkerTime(); + public int getSelectedMarkerId(); public long getMarkerTime(int index); @@ -96,4 +96,8 @@ public interface IWaveformViewer extends PropertyChangeListener, ISelectionProvi public List getCursorList(); public void setColors(HashMap colourMap); + + public long getBaselineTime(); + + public void setBaselineTime(Long scale); } \ No newline at end of file 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 907a404..94408db 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 @@ -105,6 +105,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis /** The Constant ZOOM_LEVEL. */ protected static final String ZOOM_LEVEL = "ZOOM_LEVEL"; + /** The Constant BASE_LINE_TIME. */ + protected static final String BASE_LINE_TIME = "BASE_LINE_TIME"; + /** The Constant FILE_CHECK_INTERVAL. */ protected static final long FILE_CHECK_INTERVAL = 60000; @@ -209,7 +212,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis public void propertyChange(PropertyChangeEvent evt) { Long time = (Long) evt.getNewValue(); eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(time)); - long marker = waveformPane.getSelectedMarkerTime(); + long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarkerId()); eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(time - marker)); } @@ -486,6 +489,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis index++; } persistedState.put(ZOOM_LEVEL, Integer.toString(waveformPane.getZoomLevel())); + persistedState.put(BASE_LINE_TIME, Long.toString(waveformPane.getBaselineTime())); } /** @@ -494,8 +498,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis * @param state the state */ protected void restoreWaveformViewerState(Map state) { - updateAll(); - Integer waves = state.containsKey(SHOWN_WAVEFORM + "S") ? Integer.parseInt(state.get(SHOWN_WAVEFORM + "S")) : 0; + Integer waves = state.containsKey(SHOWN_WAVEFORM+"S") ? Integer.parseInt(state.get(SHOWN_WAVEFORM + "S")):0; List res = new LinkedList<>(); for (int i = 0; i < waves; i++) { IWaveform waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i)); @@ -504,8 +507,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis } if (res.size() > 0) waveformPane.getStreamList().addAll(res); - Integer cursorLength = state.containsKey(SHOWN_CURSOR + "S") ? Integer.parseInt(state.get(SHOWN_CURSOR + "S")) - : 0; + Integer cursorLength = state.containsKey(SHOWN_CURSOR+"S")?Integer.parseInt(state.get(SHOWN_CURSOR + "S")):0; List cursors = waveformPane.getCursorList(); if (cursorLength == cursors.size()) { for (int i = 0; i < cursorLength; i++) { @@ -520,16 +522,24 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis } catch (NumberFormatException e) { } } + if (state.containsKey(BASE_LINE_TIME)) { + try { + Long scale = Long.parseLong(state.get(BASE_LINE_TIME)); + waveformPane.setBaselineTime(scale); + } catch (NumberFormatException e) { + } + } + updateAll(); } /** - * Update all. + * Update all status elements by posting respective events. */ private void updateAll() { eventBroker.post(ACTIVE_WAVEFORMVIEW, this); eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]); long cursor = waveformPane.getCursorTime(); - long marker = waveformPane.getSelectedMarkerTime(); + long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarkerId()); eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(cursor)); eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getScaledTime(marker)); eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - marker));