| /*=============================================================================# |
| # Copyright (c) 2010, 2019 Stephan Wahlbrink and others. |
| # |
| # This program and the accompanying materials are made available under the |
| # terms of the Eclipse Public License 2.0 which is available at |
| # https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 |
| # which is available at https://www.apache.org/licenses/LICENSE-2.0. |
| # |
| # SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 |
| # |
| # Contributors: |
| # Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation |
| #=============================================================================*/ |
| |
| package org.eclipse.statet.r.ui.dataeditor; |
| |
| import org.eclipse.jface.viewers.ISelection; |
| |
| |
| public class RDataTableSelection implements ISelection { |
| |
| |
| private final String fAnchorRowLabel; |
| private final String fAnchorColumnLabel; |
| |
| private final String fLastSelectedCellRowLabel; |
| private final String fLastSelectedCellColumnLabel; |
| |
| |
| public RDataTableSelection( |
| final String anchorRowLabel, final String anchorColumnLabel, |
| final String lastSelectedCellRowLabel, final String lastSelectedCellColumnLabel) { |
| this.fAnchorRowLabel= anchorRowLabel; |
| this.fAnchorColumnLabel= anchorColumnLabel; |
| this.fLastSelectedCellRowLabel= lastSelectedCellRowLabel; |
| this.fLastSelectedCellColumnLabel= lastSelectedCellColumnLabel; |
| } |
| |
| |
| @Override |
| public boolean isEmpty() { |
| return (this.fAnchorRowLabel == null); |
| } |
| |
| |
| public String getAnchorRowLabel() { |
| return this.fAnchorRowLabel; |
| } |
| |
| public String getAnchorColumnLabel() { |
| return this.fAnchorColumnLabel; |
| } |
| |
| public String getLastSelectedCellRowLabel() { |
| return this.fLastSelectedCellRowLabel; |
| } |
| |
| public String getLastSelectedCellColumnLabel() { |
| return this.fLastSelectedCellColumnLabel; |
| } |
| |
| |
| @Override |
| public int hashCode() { |
| int h= ((this.fAnchorRowLabel != null) ? this.fAnchorRowLabel.hashCode() : 0); |
| h= h * 3 + ((this.fAnchorColumnLabel != null) ? this.fAnchorColumnLabel.hashCode() : 0); |
| h= h * 17 + ((this.fLastSelectedCellRowLabel != null) ? this.fLastSelectedCellRowLabel.hashCode() : 0); |
| h= h * 99 + ((this.fLastSelectedCellColumnLabel != null) ? this.fLastSelectedCellColumnLabel.hashCode() : 0); |
| return h; |
| } |
| |
| @Override |
| public boolean equals(final Object obj) { |
| if (!(obj instanceof RDataTableSelection)) { |
| return false; |
| } |
| final RDataTableSelection other= (RDataTableSelection) obj; |
| return (((this.fAnchorRowLabel != null) ? |
| this.fAnchorRowLabel.equals(other.fAnchorRowLabel) : null == other.fAnchorRowLabel ) |
| && ((this.fAnchorColumnLabel != null) ? |
| this.fAnchorColumnLabel.equals(other.fAnchorColumnLabel) : null == other.fAnchorColumnLabel ) |
| && ((this.fLastSelectedCellRowLabel != null) ? |
| this.fLastSelectedCellRowLabel.equals(other.fLastSelectedCellRowLabel) : null == other.fLastSelectedCellRowLabel ) |
| && ((this.fLastSelectedCellColumnLabel != null) ? |
| this.fLastSelectedCellColumnLabel.equals(other.fLastSelectedCellColumnLabel) : null == other.fLastSelectedCellColumnLabel ) |
| ); |
| } |
| |
| } |