/** * Returns a list of all legal parameter values for {@link ShowPlotViewHandler}. The key is the * display name and the value is the parameter value to {@link * ShowPlotViewHandler#VIEW_NAME_PARAM}. * * <p>The list of legal values is made up of the following sources: * * <ul> * <li>All of the Plot Views that have been activated and registered themselves * PlotWindowManager * <li>All views in the view registry whose ID starts with {@link IPlotWindowManager#ID} * <li>All the view references whose primary ID is {@link * IPlotWindowManager#PLOT_VIEW_MULTIPLE_ID} * <li>All Gui Names from {@link PlotService#getGuiNames()}. These are suffixed with {@link * ShowPlotViewHandler#IN_PLOT_SERVER_SUFFIX} * <li>A <code>null</code> value for a option to open a new unique view name. * </ul> */ @Override public Map<String, String> getParameterValues() { PlotWindowManager manager = PlotWindowManager.getPrivateManager(); String[] views = manager.getAllPossibleViews(null, false); Set<String> guiNamesWithData = Collections.emptySet(); try { String[] names = PlotServerProvider.getPlotServer().getGuiNames(); if (names != null) guiNamesWithData = new HashSet<String>(Arrays.asList(names)); } catch (Exception e) { // non-fatal, just means no IN_PLOT_SERVER_SUFFIX next to view name, still shouldn't happen logger.debug("Failed to get list of Gui Names from Plot Server", e); } Map<String, String> values = new HashMap<String, String>(); for (String view : views) { String viewDisplay = view; DATA_BLOCK: if (guiNamesWithData.contains(view)) { try { DataBean db = PlotServerProvider.getPlotServer().getData(view); if (db == null || db.getData() == null || db.getData().isEmpty()) break DATA_BLOCK; viewDisplay = view + IN_PLOT_SERVER_SUFFIX; } catch (Exception ne) { break DATA_BLOCK; } } values.put(viewDisplay, view); } // null is a legal argument, means open a new view values.put(NEW_PLOT_VIEW, null); return values; }
/** Default Constructor of the plot view */ public PlotServerConnection(final String plotName) { this.plotName = plotName; this.plotId = UUID.randomUUID(); plotServer = PlotServerProvider.getPlotServer(); plotServer.addIObserver(this); execSvc = Executors.newFixedThreadPool(2); plotConsumer = new PlotConsumer(plotServer, plotName); plotConsumer.addIObserver(this); execSvc.execute(plotConsumer); plotConsumer.addJob(new PlotJob(PlotJobType.Data)); }
public ImageExplorerView() { plotServer = PlotServerProvider.getPlotServer(); plotID = UUID.randomUUID(); logger.info("Image explorer view uuid: {}", plotID); execSvc = Executors.newFixedThreadPool(2); // initialise job updateDirectory = new Job("Update directory") { @Override protected IStatus run(IProgressMonitor monitor) { ImageExplorerDirectoryChooseAction.setImageFolder(dirPath, filter); return Status.OK_STATUS; } }; }