+
+ Vector<AlignmentViewPanelListener> view_listeners = new Vector<>();
+
+ public synchronized void sendViewPosition(
+ jalview.api.AlignmentViewPanel source, int startRes, int endRes,
+ int startSeq, int endSeq)
+ {
+
+ if (view_listeners != null && view_listeners.size() > 0)
+ {
+ Enumeration<AlignmentViewPanelListener> listeners = view_listeners
+ .elements();
+ while (listeners.hasMoreElements())
+ {
+ AlignmentViewPanelListener slis = listeners.nextElement();
+ if (slis != source)
+ {
+ slis.viewPosition(startRes, endRes, startSeq, endSeq, source);
+ }
+ ;
+ }
+ }
+ }
+
+ public void registerPDBEntry(PDBEntry pdbentry)
+ {
+ if (pdbentry.getFile() != null
+ && pdbentry.getFile().trim().length() > 0)
+ {
+ registerPDBFile(pdbentry.getId(), pdbentry.getFile());
+ }
+ }
+
+ public void addCommandListener(CommandListener cl)
+ {
+ if (!commandListeners.contains(cl))
+ {
+ commandListeners.add(cl);
+ }
+ }
+
+ public boolean hasCommandListener(CommandListener cl)
+ {
+ return this.commandListeners.contains(cl);
+ }
+
+ public boolean removeCommandListener(CommandListener l)
+ {
+ return commandListeners.remove(l);
+ }
+
+ /**
+ * Forward a command to any command listeners (except for the command's
+ * source).
+ *
+ * @param command
+ * the command to be broadcast (in its form after being performed)
+ * @param undo
+ * if true, the command was being 'undone'
+ * @param source
+ */
+ public void commandPerformed(CommandI command, boolean undo,
+ VamsasSource source)
+ {
+ for (CommandListener listener : commandListeners)
+ {
+ listener.mirrorCommand(command, undo, this, source);
+ }
+ }
+
+ /**
+ * Returns a new CommandI representing the given command as mapped to the
+ * given sequences. If no mapping could be made, or the command is not of a
+ * mappable kind, returns null.
+ *
+ * @param command
+ * @param undo
+ * @param mapTo
+ * @param gapChar
+ * @return
+ */
+ public CommandI mapCommand(CommandI command, boolean undo,
+ final AlignmentI mapTo, char gapChar)
+ {
+ if (command instanceof EditCommand)
+ {
+ return MappingUtils.mapEditCommand((EditCommand) command, undo, mapTo,
+ gapChar, seqmappings);
+ }
+ else if (command instanceof OrderCommand)
+ {
+ return MappingUtils.mapOrderCommand((OrderCommand) command, undo,
+ mapTo, seqmappings);
+ }
+ return null;
+ }
+
+ public List<AlignedCodonFrame> getSequenceMappings()
+ {
+ return seqmappings;
+ }
+
+ public static StructureSelectionManager getStructureSelectionManager(
+ StructureSelectionManagerProvider context)
+ {
+ IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> map = Instance
+ .getInstance().structureSelections;
+
+ if (map == null)
+ {
+ map = Instance
+ .getInstance().structureSelections = new IdentityHashMap<>();
+ }
+ StructureSelectionManager instance = map.get(context);
+ if (instance == null)
+ {
+ // BH: actually, not possible except for coding error; this is an attempt
+ // to discover that.
+ if (context == null && !map.isEmpty())
+ {
+ throw new Error(MessageManager.getString(
+ "error.implementation_error_structure_selection_manager_null"),
+ new NullPointerException(MessageManager
+ .getString("exception.ssm_context_is_null")));
+ }
+ map.put(context,
+ instance = new StructureSelectionManager());
+ }
+ return instance;
+ }
+
+ /**
+ * release all references associated with this manager provider
+ *
+ * @param provider
+ */
+
+ public static void release(StructureSelectionManagerProvider provider)
+ {
+ IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> map = Instance
+ .getInstance().structureSelections;
+ if (map != null)
+ {
+ map.remove(provider);
+ }
+ }
+