Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e3cd487c2cd55bc846c7ba675adf739c0d83eab6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*****************************************************************************
 * Copyright (c) 2014 CEA LIST.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *		
 *		 Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.infra.nattable.utils;

import org.eclipse.core.runtime.MultiStatus;

/**
 * 
 * This class is used to store the tests about the paste capability of the table
 * 
 */
public class PasteEnablementStatus {

	/**
	 * the result of the tests to paste rows in the table
	 */
	private MultiStatus rowStatus;

	/**
	 * the result of the test to paste columns in the table
	 */
	private MultiStatus columnStatus;


	/**
	 * 
	 * Constructor.
	 * 
	 * @param columnStatus
	 *        the paste column status
	 * @param rowStatus
	 *        the paste row status
	 */
	public PasteEnablementStatus(final MultiStatus columnStatus, final MultiStatus rowStatus) {
		this.rowStatus = rowStatus;
		this.columnStatus = columnStatus;
	}

	/**
	 * 
	 * @return
	 *         the paste mode according to the row and column status
	 */
	public PasteModeEnumeration getPasteMode() {
		if(this.rowStatus == null && this.columnStatus == null) {
			return PasteModeEnumeration.PASTE_NO_CONFIGURATION;
		}
		if(this.rowStatus != null && this.columnStatus != null) {
			if(this.columnStatus.isOK() && this.rowStatus.isOK()) {
				return PasteModeEnumeration.PASTE_EOBJECT_ROW_OR_COLUMN;
			}
			if(this.columnStatus.isOK() && !this.rowStatus.isOK()) {
				return PasteModeEnumeration.PASTE_EOBJECT_COLUMN;
			}
			if(!this.columnStatus.isOK() && this.rowStatus.isOK()) {
				return PasteModeEnumeration.PASTE_EOBJECT_ROW;
			}
		}
		if(this.rowStatus != null && this.rowStatus.isOK() && this.columnStatus == null) {
			return PasteModeEnumeration.PASTE_EOBJECT_ROW;
		}
		if(this.columnStatus != null && this.rowStatus == null && this.columnStatus.isOK()) {
			return PasteModeEnumeration.PASTE_EOBJECT_COLUMN;
		}
		return PasteModeEnumeration.CANT_PASTE;
	}

	/**
	 * 
	 * @return
	 *         the column status
	 */
	public MultiStatus getColumnStatus() {
		return this.columnStatus;
	}

	/**
	 * 
	 * @return
	 *         the row status
	 */
	public MultiStatus getRowStatus() {
		return this.rowStatus;
	}


}

Back to the top