/* (non-Javadoc)
   * @see au.gov.ansto.bragg.kakadu.ui.views.AnalysisParametersView#createPartControl(org.eclipse.swt.widgets.Composite)
   */
  @Override
  public void createPartControl(Composite composite) {
    super.createPartControl(composite);

    setVisibility();
  }
  @Override
  protected void initListeners() {
    super.initListeners();

    AlgorithmTask task = getAlgorithmTask();
    OperationManager oMgr = task.getOperationManager(0);
    final Operation opSource = oMgr.getOperation(SOURCE_PROCESSOR_NAME);
    final Operation opTrans = oMgr.getOperation(TRANS_PROCESSOR_NAME);
    final Operation opPlot = oMgr.getOperation(PLOT_PROCESSOR_NAME);

    // final Operation operation =
    // task.getOperationManager(0).getOperation(NAVIGATION_PROCESSOR_NAME);
    // final OperationParameter parameter = operation.getOperationParameter(SCAN_VARIABLE_NAME);
    // final Operation plotOperation =
    // task.getOperationManager(0).getOperation(ONEDPLOT_PROCESSOR_NAME);

    //		final KurandaMouseListener doubleClickListener = new KurandaMouseListener()
    //		{
    //			public void mouseDoubleClick(EventData eventData) {
    //				double x = eventData.getX();
    //				//eventData.
    //			}
    //
    ////				List<OperationParameterEditor> editors = parameterEditorsMap.get(operation.getName());
    ////				for (OperationParameterEditor editor : editors){
    ////					if (editor.getOperationParameter() == parameter){
    ////						if (editor instanceof OptionOperationParameterEditor)
    ////							((OptionOperationParameterEditor) editor).setSelection(
    ////									new Double(eventData.getX()));
    ////					}
    ////				}
    ////				applyParameters();
    ////			}
    //
    //			public void mouseDown(EventData eventData) {}
    //
    //			public void mouseUp(EventData eventData) {}
    //
    //		};
    //
    //		PlotManager.addOpenNewPlotListener(
    //			new PlotManager.OpenNewPlotListener(){
    //				public void newPlotOpened(Plot plot) {
    //					if (plot.getOperaton() == opPlot)
    //						plot.getCurrentPlotWidget().addMouseEventListener(doubleClickListener);
    //				}
    //			}
    //		);

    plotListener =
        new PlotManager.OpenNewPlotListener() {

          public void newPlotOpened(final au.gov.ansto.bragg.kakadu.ui.plot.Plot plot) {
            if (plot != null && plot.getOperaton().getName().equals("plotter.op")) {
              ToolBar verticalBar = plot.getVerticalToolbar();
              ToolItem transferToolItem = new ToolItem(verticalBar, SWT.NONE);
              //				copyToolItem.setToolTipText("Copy");
              transferToolItem.setImage(
                  Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/needle_16x16.png")
                      .createImage());
              plot.setQuickRemoveEnabled(true);
              transferToolItem.addSelectionListener(
                  new SelectionListener() {

                    public void widgetSelected(SelectionEvent arg0) {
                      List<PlotDataItem> dataItems =
                          plot.getMultiPlotDataManager().getPlotDataItems();
                      if (dataItems != null && dataItems.size() > 0) {
                        try {
                          PlotDataItem newDataItem = dataItems.get(0).clone();
                          //									newDataItem.setColor(AbstractDataSource.getNextColor());
                          newDataItem.setLinked(false);
                          plot.getMultiPlotDataManager().addPlotDataItem(newDataItem);
                        } catch (PlotException e) {
                          e.printStackTrace();
                        }
                      }
                    }

                    public void widgetDefaultSelected(SelectionEvent arg0) {}
                  });
            }
          }
        };
    PlotManager.addOpenNewPlotListener(plotListener);
  }
 @Override
 public void dispose() {
   super.dispose();
   PlotManager.removeOpenNewPlotListener(plotListener);
 }