Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix freeze at starting, Default model for opening files

  • Loading branch information...
commit 8c0fa4dab794dfa432b105a6783b2f3766af7d1c 1 parent 5af0b6d
@nroduit authored
View
2  weasis-base/weasis-base-ui/src/main/java/org/weasis/base/ui/gui/WeasisWin.java
@@ -263,7 +263,7 @@ else if (source instanceof MediaSeriesGroup) {
List<MediaSeries> series = builder.getSeries();
if (series != null && builder.isCompareEntryToBuildNewViewer()
- && model.getTreeModelNodeForNewPlugin() != null) {
+ && model.getTreeModelNodeForNewPlugin() != null && model instanceof TreeModel) {
TreeModel treeModel = (TreeModel) model;
if (series.size() == 1) {
MediaSeries s = series.get(0);
View
229 weasis-core/weasis-core-api/src/main/java/org/weasis/core/api/explorer/model/AbstractFileModel.java
@@ -0,0 +1,229 @@
+package org.weasis.core.api.explorer.model;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.SwingUtilities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.weasis.core.api.command.Option;
+import org.weasis.core.api.command.Options;
+import org.weasis.core.api.explorer.ObservableEvent;
+import org.weasis.core.api.gui.util.GuiExecutor;
+import org.weasis.core.api.media.data.Codec;
+import org.weasis.core.api.media.data.MediaElement;
+import org.weasis.core.api.media.data.MediaSeriesGroup;
+import org.weasis.core.api.media.data.Series;
+import org.weasis.core.api.media.data.TagW;
+import org.weasis.core.api.service.BundleTools;
+
+public class AbstractFileModel implements TreeModel, DataExplorerModel {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AbstractFileModel.class);
+
+ public static final String[] functions = { "get", "close" }; //$NON-NLS-1$ //$NON-NLS-2$
+ public static final String NAME = "All Files"; //$NON-NLS-1$
+ public static final TreeModelNode series = new TreeModelNode(1, 0, TagW.SubseriesInstanceUID);
+ public static final TreeModelNode file = new TreeModelNode(2, 0, TagW.SubseriesInstanceUID);
+
+ public static final ArrayList<TreeModelNode> modelStrucure = new ArrayList<TreeModelNode>(5);
+ static {
+ modelStrucure.add(root);
+ modelStrucure.add(series);
+ modelStrucure.add(file);
+ }
+
+ private final Tree<MediaSeriesGroup> model;
+ private PropertyChangeSupport propertyChange = null;
+
+ public AbstractFileModel() {
+ model = new Tree<MediaSeriesGroup>(rootNode);
+ }
+
+ @Override
+ public synchronized List<Codec> getCodecPlugins() {
+ return BundleTools.CODEC_PLUGINS;
+ }
+
+ @Override
+ public Collection<MediaSeriesGroup> getChildren(MediaSeriesGroup node) {
+ return model.getSuccessors(node);
+ }
+
+ @Override
+ public MediaSeriesGroup getHierarchyNode(MediaSeriesGroup parent, Object value) {
+ if (parent != null || value != null) {
+ synchronized (model) {
+ for (MediaSeriesGroup node : model.getSuccessors(parent)) {
+ if (node.equals(value)) {
+ return node;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void addHierarchyNode(MediaSeriesGroup root, MediaSeriesGroup leaf) {
+ synchronized (model) {
+ model.addLeaf(root, leaf);
+ }
+ }
+
+ @Override
+ public void removeHierarchyNode(MediaSeriesGroup root, MediaSeriesGroup leaf) {
+ synchronized (model) {
+ Tree<MediaSeriesGroup> tree = model.getTree(root);
+ if (tree != null) {
+ tree.removeLeaf(leaf);
+ }
+ }
+ }
+
+ @Override
+ public MediaSeriesGroup getParent(MediaSeriesGroup node, TreeModelNode modelNode) {
+ if (null != node && modelNode != null) {
+ // synchronized (model) {
+ // Tree<MediaSeriesGroup> tree = model.getTree(node);
+ // if (tree != null) {
+ // Tree<MediaSeriesGroup> parent = null;
+ // while ((parent = tree.getParent()) != null) {
+ // if (parent.getHead().getTagID().equals(modelNode.getTagElement())) {
+ // return parent.getHead();
+ // }
+ // tree = parent;
+ // }
+ // }
+ // }
+ }
+ return null;
+ }
+
+ public void dispose() {
+ synchronized (model) {
+ for (Iterator<MediaSeriesGroup> iterator = this.getChildren(TreeModel.rootNode).iterator(); iterator
+ .hasNext();) {
+ MediaSeriesGroup s = iterator.next();
+ if (s instanceof Series) {
+ ((Series) s).dispose();
+ }
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return NAME;
+ }
+
+ @Override
+ public List<TreeModelNode> getModelStructure() {
+ return modelStrucure;
+ }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener propertychangelistener) {
+ if (propertyChange == null) {
+ propertyChange = new PropertyChangeSupport(this);
+ }
+ propertyChange.addPropertyChangeListener(propertychangelistener);
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener propertychangelistener) {
+ if (propertyChange != null) {
+ propertyChange.removePropertyChangeListener(propertychangelistener);
+ }
+
+ }
+
+ @Override
+ public void firePropertyChange(final ObservableEvent event) {
+ if (propertyChange != null) {
+ if (event == null) {
+ throw new NullPointerException();
+ }
+ if (SwingUtilities.isEventDispatchThread()) {
+ propertyChange.firePropertyChange(event);
+ } else {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ propertyChange.firePropertyChange(event);
+ }
+ });
+ }
+ }
+ }
+
+ public void removeSeries(MediaSeriesGroup dicomSeries) {
+ if (dicomSeries != null) {
+ // remove first series in UI (Dicom Explorer, Viewer using this series)
+ firePropertyChange(new ObservableEvent(ObservableEvent.BasicAction.Remove, AbstractFileModel.this, null,
+ dicomSeries));
+ // remove in the data model
+ MediaSeriesGroup studyGroup = getParent(dicomSeries, AbstractFileModel.root);
+ removeHierarchyNode(studyGroup, dicomSeries);
+ LOGGER.info("Remove Series: {}", dicomSeries); //$NON-NLS-1$
+ dicomSeries.dispose();
+ }
+ }
+
+ @Override
+ public boolean applySplittingRules(Series original, MediaElement media) {
+ return false;
+ }
+
+ public void get(String[] argv) throws IOException {
+
+ }
+
+ public void close(String[] argv) throws IOException {
+ final String[] usage = { "Remove DICOM files in Dicom Explorer", //$NON-NLS-1$
+ "Usage: dicom:close [series] [ARGS]", //$NON-NLS-1$
+ " -a --all Close all series", //$NON-NLS-1$
+ " -s --series <args> Close series, [arg] is Series UID", " -? --help show help" }; //$NON-NLS-1$ //$NON-NLS-2$
+ final Option opt = Options.compile(usage).parse(argv);
+ final List<String> args = opt.args();
+
+ if (opt.isSet("help") || (args.isEmpty() && !opt.isSet("all"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ opt.usage();
+ return;
+ }
+
+ GuiExecutor.instance().execute(new Runnable() {
+
+ @Override
+ public void run() {
+ firePropertyChange(new ObservableEvent(ObservableEvent.BasicAction.Select, AbstractFileModel.this,
+ null, AbstractFileModel.this));
+ if (opt.isSet("all")) { //$NON-NLS-1$
+ for (MediaSeriesGroup seriesGroup : model.getSuccessors(rootNode)) {
+ removeSeries(seriesGroup);
+ }
+ } else if (opt.isSet("series")) { //$NON-NLS-1$
+ for (String seriesUID : args) {
+ MediaSeriesGroup series = getHierarchyNode(rootNode, seriesUID);
+ if (series instanceof Series) {
+ removeSeries(series);
+ break;
+ }
+ }
+ }
+ }
+ });
+ }
+
+ @Override
+ public TreeModelNode getTreeModelNodeForNewPlugin() {
+ return file;
+ }
+
+}
View
69 weasis-core/weasis-core-ui/src/main/java/org/weasis/core/ui/editor/ViewerPluginBuilder.java
@@ -10,82 +10,23 @@
******************************************************************************/
package org.weasis.core.ui.editor;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import javax.swing.SwingUtilities;
-
import org.weasis.core.api.explorer.ObservableEvent;
+import org.weasis.core.api.explorer.model.AbstractFileModel;
import org.weasis.core.api.explorer.model.DataExplorerModel;
-import org.weasis.core.api.explorer.model.TreeModelNode;
import org.weasis.core.api.media.MimeInspector;
import org.weasis.core.api.media.data.Codec;
import org.weasis.core.api.media.data.MediaElement;
import org.weasis.core.api.media.data.MediaReader;
import org.weasis.core.api.media.data.MediaSeries;
-import org.weasis.core.api.media.data.Series;
import org.weasis.core.api.service.BundleTools;
import org.weasis.core.ui.docking.UIManager;
public class ViewerPluginBuilder {
- public static final DataExplorerModel DefaultDataModel = new DataExplorerModel() {
- private PropertyChangeSupport propertyChange = null;
-
- @Override
- public void addPropertyChangeListener(PropertyChangeListener propertychangelistener) {
- if (propertyChange == null) {
- propertyChange = new PropertyChangeSupport(this);
- }
- propertyChange.addPropertyChangeListener(propertychangelistener);
- }
-
- @Override
- public void removePropertyChangeListener(PropertyChangeListener propertychangelistener) {
- if (propertyChange != null) {
- propertyChange.removePropertyChangeListener(propertychangelistener);
- }
- }
-
- @Override
- public void firePropertyChange(final ObservableEvent event) {
- if (propertyChange != null) {
- if (event == null) {
- throw new NullPointerException();
- }
- if (SwingUtilities.isEventDispatchThread()) {
- propertyChange.firePropertyChange(event);
- } else {
- SwingUtilities.invokeLater(new Runnable() {
-
- @Override
- public void run() {
- propertyChange.firePropertyChange(event);
- }
- });
- }
- }
- }
-
- @Override
- public TreeModelNode getTreeModelNodeForNewPlugin() {
- return null;
- }
-
- @Override
- public List<Codec> getCodecPlugins() {
- return BundleTools.CODEC_PLUGINS;
- }
-
- @Override
- public boolean applySplittingRules(Series original, MediaElement media) {
- return false;
- }
-
- };
-
+ public static final AbstractFileModel DefaultDataModel = new AbstractFileModel();
private final SeriesViewerFactory factory;
private final List<MediaSeries> series;
private final DataExplorerModel model;
@@ -202,7 +143,11 @@ public static void openSequenceInDefaultPlugin(MediaElement media, DataExplorerM
public static void openSequenceInDefaultPlugin(File file) {
MediaReader reader = getMedia(file);
if (reader != null) {
- openSequenceInDefaultPlugin(reader.getMediaSeries(), null, true, true);
+ MediaSeries s = reader.getMediaSeries();
+ if (!(reader instanceof DefaultMimeIO)) {
+ DefaultDataModel.addHierarchyNode(DefaultDataModel.rootNode, s);
+ }
+ openSequenceInDefaultPlugin(s, DefaultDataModel, true, true);
}
}
View
4 weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/MimeSystemAppFactory.java
@@ -20,7 +20,6 @@
import org.weasis.core.api.gui.util.AbstractProperties;
import org.weasis.core.api.media.MimeInspector;
import org.weasis.core.api.media.data.MediaSeries;
-import org.weasis.core.ui.docking.UIManager;
import org.weasis.core.ui.editor.MimeSystemAppViewer;
import org.weasis.core.ui.editor.SeriesViewer;
import org.weasis.core.ui.editor.SeriesViewerFactory;
@@ -34,7 +33,6 @@
public static final String NAME = "default system application"; //$NON-NLS-1$
public static final Icon ICON = new ImageIcon(MimeInspector.class.getResource("/icon/16x16/apps-system.png")); //$NON-NLS-1$
public static final MimeSystemAppViewer mimeSystemViewer = new MimeSystemAppViewer() {
- private final String dockableUID = "" + UIManager.dockableUIGenerator.getAndIncrement(); //$NON-NLS-1$;
@Override
public String getPluginName() {
@@ -68,7 +66,7 @@ public void addSeries(MediaSeries series) {
@Override
public String getDockableUID() {
- return dockableUID;
+ return null;
}
};
View
6 weasis-launcher/conf/config.properties
@@ -146,8 +146,10 @@ felix.auto.start.70= \
file:${maven.localRepository}/org/weasis/dicom/weasis-dicom-viewer2d/${weasis.dicom.version}/weasis-dicom-viewer2d-${weasis.dicom.version}.jar \
felix.auto.start.100= \
-file:${maven.localRepository}/org/weasis/base/weasis-base-explorer/${weasis.core.version}/weasis-base-explorer-${weasis.core.version}.jar \
- file:${maven.localRepository}/org/weasis/base/weasis-base-viewer2d/${weasis.core.version}/weasis-base-viewer2d-${weasis.core.version}.jar
+ file:${maven.localRepository}/org/weasis/base/weasis-base-viewer2d/${weasis.core.version}/weasis-base-viewer2d-${weasis.core.version}.jar \
+
+felix.auto.start.110= \
+ file:${maven.localRepository}/org/weasis/base/weasis-base-explorer/${weasis.core.version}/weasis-base-explorer-${weasis.core.version}.jar \
# Set the logging levels for OSGI framework 0=None / 1(default)=Error / 2=Warning / 3=Information / 4=Debug
felix.log.level=1
Please sign in to comment.
Something went wrong with that request. Please try again.