@Override public void update(IProgressMonitor monitor) { List<String> scopes = null; SPELLmessage msg = new SPELLmessageGetSharedVariableScopes(); SPELLmessage response; try { response = s_proxy.sendRequest(msg); if (response != null) { scopes = SPELLmessageGetSharedVariableScopes.getScopes(response); } if (scopes != null) { scopes.add(GLOBAL_SCOPE); // Create local model scope tables if needed for (String scope : scopes) { if (!m_tables.containsKey(scope)) { SharedScope table = new SharedScope(scope, s_proxy); m_tables.put(scope, table); Logger.debug("Added new scope during update: " + scope, Level.PROC, this); } if (monitor.isCanceled()) return; } // Clean local model scope tables if needed List<String> toRemove = new LinkedList<String>(); for (String scope : m_tables.keySet()) { if (!scopes.contains(scope)) { toRemove.add(scope); Logger.debug("Remove scope during update: " + scope, Level.PROC, this); } if (monitor.isCanceled()) return; } for (String scope : toRemove) { m_tables.remove(scope); if (monitor.isCanceled()) return; } } // Once the set of scopes is aligned, update the tables for (ISharedScope table : m_tables.values()) { Logger.debug("Updating scope: " + table.getScopeName(), Level.PROC, this); table.update(monitor); if (monitor.isCanceled()) return; } } catch (Exception e) { e.printStackTrace(); } }
/** * ************************************************************************* * * <p>************************************************************************ */ @Override public void removeSharedScope(String scope) { if (scope.equals(GLOBAL_SCOPE)) return; if (m_tables.containsKey(scope)) { SPELLmessage msg = new SPELLmessageRemoveSharedVariableScope(s_proxy.getClientKey(), scope); SPELLmessage response; try { response = s_proxy.sendRequest(msg); if (response != null) { if (SPELLmessageRemoveSharedVariableScope.isSuccess(response)) { Logger.info("Remove shared scope " + scope, Level.PROC, this); m_tables.remove(scope); } } } catch (Exception ex) { ex.printStackTrace(); } } }