CPD Results

The following document contains the results of PMD's CPD 5.3.5.

Duplications

File Line
info/limpet/ui/data_provider/data/DataManagerDropAdapter.java 40
info/limpet/ui/editors/dnd/DataManagerDropAdapter.java 40
public class DataManagerDropAdapter extends ViewerDropAdapter
{

  private IStoreGroup _store;

  public DataManagerDropAdapter(Viewer viewer, IStoreGroup store)
  {
    super(viewer);
    this._store = store;
  }

  @Override
  public boolean performDrop(Object data)
  {
    if (!(data instanceof String[]) && !(data instanceof List[])
        && !(data instanceof String))
    {
      return false;
    }
    if (data instanceof String[])
    {
      String[] fileNames = (String[]) data;
      return filesDropped(fileNames);
    }
    if (data instanceof String)
    {
      // ok, it's some data from the control itself.

      final boolean validTarget;
      final Object target = getCurrentTarget();
      if (target == getSelectedObject())
      {
        return false;
      }
      if (target == null)
      {
        validTarget = true;
      }
      else if (target instanceof GroupWrapper)
      {
        validTarget = true;
      }
      else
      {
        validTarget = false;
      }

      if (!validTarget)
      {
        return false;
      }
      else
      {
        String str = (String) data;
        String[] items = str.split(LimpetDragListener.SEPARATOR);
        for (int i = 0; i < items.length; i++)
        {
          String thisS = items[i];

          // find the item
          IStoreItem item = _store.get(UUID.fromString(thisS));

          if (item == null)
          {
            Activator.logError(Status.ERROR,
File Line
info/limpet/ui/heatmap/Helper2D.java 123
info/limpet/ui/heatmap/Helper2D.java 278
  public static HContainer convert(final DoubleDataset dataset)
  {
    final HContainer res = new HContainer();

    // ok, start by changing the table columns to the correct size
    // sort out the axes
    List<AxesMetadata> amList;
    try
    {
      amList = dataset.getMetadata(AxesMetadata.class);
      final AxesMetadata am = amList.get(0);
      final ILazyDataset[] axes = am.getAxes();
      if (axes.length != 2)
      {
        return null;
      }
      final DoubleDataset aOne = (DoubleDataset) axes[0];
      final DoubleDataset aTwo = (DoubleDataset) axes[1];

      final double[] aIndices = aOne.getData();
      res.rowTitles = aIndices;
      final double[] bIndices = aTwo.getData();
      res.colTitles = bIndices;

      res.values = new double[aIndices.length][bIndices.length];
      for (int i = 0; i < aIndices.length; i++)
      {
        for (int j = 0; j < bIndices.length; j++)
        {
File Line
info/limpet/ui/propertyeditors/SliderCellEditor.java 42
info/limpet/ui/propertyeditors/SliderCellEditorExt.java 31
  public SliderCellEditor(final Composite parent, int minValue, int maxValue)
  {
    super(parent, SWT.NONE);
    this.minValue = minValue;
    this.maxValue = maxValue;
  }

  /**
   * @return
   */
  public LayoutData getLayoutData()
  {
    final CellEditor.LayoutData res = super.getLayoutData();
    res.grabHorizontal = true;
    return res;
  }

  protected Control createControl(final Composite parent)
  {
    final Font font = parent.getFont();
    final Color bg = parent.getBackground();

    _myControl = new Composite(parent, getStyle());
    _myControl.setFont(font);
    _myControl.setBackground(bg);

    final GridLayout rl = new GridLayout();
    rl.marginWidth = 0;
    rl.marginHeight = 0;
    rl.numColumns = 8;

    _myControl.setLayout(rl);
    _myLabel = new Label(_myControl, SWT.NONE);
    _myLabel.setText("000");
    _myLabel.pack();
File Line
info/limpet/ui/data_provider/data/DataManagerDropAdapter.java 119
info/limpet/ui/editors/dnd/DataManagerDropAdapter.java 119
              IStoreGroup mem = (IStoreGroup) _store;
              mem.remove(item);
            }
          }

          // sort out the object
          if (target instanceof GroupWrapper)
          {
            GroupWrapper group = (GroupWrapper) target;
            // and add to the new one
            group.getGroup().add(item);
          }
          else
          {
            // ok, put it at the top level
            _store.add(item);
          }
        }
        changed();
        return true;
      }

    }
    // else if (data instanceof List[])
    // {
    // Object target = getCurrentTarget();
    // if (target == getSelectedObject())
    // {
    // return false;
    // }
    // if (target instanceof GroupWrapper)
    // {
    // for (@SuppressWarnings("rawtypes")
    // List list : (List[]) data)
    // {
    // for (Object object : list)
    // {
    // if (object instanceof GroupWrapper)
    // {
    // GroupWrapper groupWrapper = (GroupWrapper) object;
    // List<IStoreItem> l = new ArrayList<IStoreItem>();
    // StoreGroup storeGroup = new StoreGroup(groupWrapper.toString());
    // l.add(storeGroup);
    // storeGroup.addAll(groupWrapper.getGroup());
    // ((GroupWrapper) target).getGroup().addAll(l);
    // }
    // else if (object instanceof CollectionWrapper)
    // {
    // CollectionWrapper collectionWrapper = (CollectionWrapper) object;
    // ((GroupWrapper) target).getGroup().add(
    // collectionWrapper.getCollection());
    // }
    // }
    // }
    // changed();
    // return true;
    // }
    // }
    return false;
  }

  @Override
  public boolean validateDrop(Object target, int operation,
      TransferData transferType)
  {
    boolean validTarget = target == null || target instanceof GroupWrapper;

    return FileTransfer.getInstance().isSupportedType(transferType)
        || TextTransfer.getInstance().isSupportedType(transferType)
        || validTarget;
  }

  private boolean filesDropped(String[] fileNames)
  {
    if (fileNames != null)
    {
      for (int i = 0; i < fileNames.length; i++)
      {
        String fileName = fileNames[i];
        if (fileName != null && fileName.toLowerCase().endsWith(".csv"))
File Line
info/limpet/ui/data_provider/data/OperationWrapper.java 28
info/limpet/ui/editors/OperationWrapper.java 28
public class OperationWrapper extends Action
{
	private final IOperation limpetAction;
	private final IContext context;
	private final IStoreGroup store;
	private final ISelectionProvider provider;

	public OperationWrapper(IOperation limpetAction, String title,
			ImageDescriptor imageDescriptor, IContext context, IStoreGroup store,
			ISelectionProvider provider)
	{
		this.limpetAction = limpetAction;
		this.context = context;
		this.store = store;
		this.provider = provider;
		setText(title);
		setImageDescriptor(imageDescriptor);
	}

	@Override
	public void run()
	{
		Collection<ICommand> ops = limpetAction.actionsFor(
				provider.getSelection(), store, context);
		if (ops != null && ops.size() == 1)
		{
			ICommand first = ops.iterator().next();
			first.execute();
		}
		else
		{
			context.openWarning("Error",
					"Cannot run the action for current selection");
		}
	}
}
File Line
info/limpet/ui/heatmap/Helper2D.java 166
info/limpet/ui/heatmap/Helper2D.java 405
  public static HContainer convertToMean(final List<IStoreItem> items)
  {
    // sort out the helper
    final ListConverterHelper helper;
    final IStoreItem first = items.get(0);
    if (first instanceof NumberDocument)
    {
      helper = new ListConverterHelper()
      {

        @Override
        public HContainer convertMe(final IStoreItem item)
        {
          final NumberDocument nd = (NumberDocument) item;
          final DoubleDataset ds = (DoubleDataset) nd.getDataset();
          return convert(ds);
        }
      };
    }
    else if (first instanceof DoubleListDocument)
    {
      helper = new ListConverterHelper()
      {

        @Override
        public HContainer convertMe(final IStoreItem item)
        {
          final DoubleListDocument nd = (DoubleListDocument) item;
          final ObjectDataset ds = (ObjectDataset) nd.getDataset();
          return convert(ds, false);
File Line
info/limpet/ui/data_frequency/DataFrequencyView.java 216
info/limpet/ui/time_frequency/TimeFrequencyView.java 152
        newSeries.setYSeries(yData);

        // adjust the axis range
        chart.getAxisSet().adjustRange();
        IAxis xAxis = chart.getAxisSet().getXAxis(0);
        xAxis.enableCategory(false);

        // set the y axis min to be zero
        Range yRange = chart.getAxisSet().getYAxis(0).getRange();
        chart.getAxisSet().getYAxis(0).setRange(new Range(0, yRange.upper));

        chart.redraw();
      }
    }
  }

  @Override
  public void setFocus()
  {
    chart.setFocus();
  }

  @Override
  protected boolean appliesToMe(List<IStoreItem> selection,
      CollectionComplianceTests tests)
  {
    final boolean res;
    if(!tests.allOneDim(selection))
File Line
info/limpet/ui/propertyeditors/SliderCellEditor.java 79
info/limpet/ui/propertyeditors/SliderCellEditorExt.java 69
    _myLabel.setLayoutData(gd1);

    _theSlider = new Slider(_myControl, SWT.HORIZONTAL);
    final GridData gd2 = new GridData(GridData.FILL_HORIZONTAL);
    gd2.horizontalSpan = 7;
    _theSlider.setLayoutData(gd2);
    _theSlider.addSelectionListener(new SelectionListener()
    {

      public void widgetSelected(final SelectionEvent e)
      {
        _myLabel.setText(formatMe(_theSlider.getSelection()));
        _myLabel.update();
      }

      public void widgetDefaultSelected(final SelectionEvent e)
      {

      }
    });

    return _myControl;
  }

  protected Object doGetValue()
  {
    Object res = null;
    if (_theSlider != null)
    {