|
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2005, 2007 IBM Corporation and others. |
2 |
* Copyright (c) 2005, 2008 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Link Here
|
| 20 |
import org.eclipse.hyades.test.ui.datapool.internal.action.DeleteColumnAction; |
20 |
import org.eclipse.hyades.test.ui.datapool.internal.action.DeleteColumnAction; |
| 21 |
import org.eclipse.hyades.test.ui.datapool.internal.action.DeleteRowAction; |
21 |
import org.eclipse.hyades.test.ui.datapool.internal.action.DeleteRowAction; |
| 22 |
import org.eclipse.hyades.test.ui.datapool.internal.action.EditColumnAction; |
22 |
import org.eclipse.hyades.test.ui.datapool.internal.action.EditColumnAction; |
|
|
23 |
import org.eclipse.hyades.test.ui.datapool.internal.action.EditRowAction; |
| 23 |
import org.eclipse.hyades.test.ui.datapool.internal.action.FindReplaceAction; |
24 |
import org.eclipse.hyades.test.ui.datapool.internal.action.FindReplaceAction; |
| 24 |
import org.eclipse.hyades.test.ui.datapool.internal.action.InsertColumnAction; |
25 |
import org.eclipse.hyades.test.ui.datapool.internal.action.InsertColumnAction; |
| 25 |
import org.eclipse.hyades.test.ui.datapool.internal.action.InsertRowAction; |
26 |
import org.eclipse.hyades.test.ui.datapool.internal.action.InsertRowAction; |
|
Link Here
|
| 32 |
import org.eclipse.jface.viewers.ISelectionProvider; |
33 |
import org.eclipse.jface.viewers.ISelectionProvider; |
| 33 |
|
34 |
|
| 34 |
/** |
35 |
/** |
| 35 |
* @author psun |
36 |
* DatapoolMenuManager.java |
| 36 |
* |
37 |
* <p/> |
|
|
38 |
* |
| 39 |
* |
| 40 |
* @author Peter Sun |
| 41 |
* @author Paul E. Slauenwhite |
| 42 |
* @version April 13, 2008 |
| 43 |
* @since January 27, 2005 |
| 37 |
*/ |
44 |
*/ |
| 38 |
public class DatapoolMenuManager { |
45 |
public class DatapoolMenuManager { |
| 39 |
private InsertRowAction insertRowAction = null; |
46 |
|
|
|
47 |
private InsertRowAction insertRowAction = null; |
| 40 |
private DeleteRowAction deleteRowAction = null; |
48 |
private DeleteRowAction deleteRowAction = null; |
|
|
49 |
private EditRowAction editRowAction = null; |
| 41 |
private InsertColumnAction insertColumnAction = null; |
50 |
private InsertColumnAction insertColumnAction = null; |
| 42 |
private DeleteColumnAction deleteColumnAction = null; |
51 |
private DeleteColumnAction deleteColumnAction = null; |
| 43 |
private EditColumnAction editColumnAction = null; |
52 |
private EditColumnAction editColumnAction = null; |
|
Link Here
|
| 51 |
private boolean showColumnActions = true; |
60 |
private boolean showColumnActions = true; |
| 52 |
private boolean showRowActions = true; |
61 |
private boolean showRowActions = true; |
| 53 |
private boolean showEditActions = true; |
62 |
private boolean showEditActions = true; |
|
|
63 |
|
| 64 |
/** |
| 65 |
* Display mode Display mode constant for enabling the {@link InsertRowAction} (value is 1<<1). |
| 66 |
*/ |
| 67 |
public static final int INSERT_ROW_ACTION_ENABLED = 1 << 1; |
| 68 |
|
| 69 |
/** |
| 70 |
* Display mode constant for enabling the {@link DeleteRowAction} (value is 1<<2). |
| 71 |
*/ |
| 72 |
public static final int DELETE_ROW_ACTION_ENABLED = 1 << 2; |
| 73 |
|
| 74 |
/** |
| 75 |
* Display mode constant for enabling the {@link EditRowAction} (value is 1<<3). |
| 76 |
*/ |
| 77 |
public static final int EDIT_ROW_ACTION_ENABLED = 1 << 3; |
| 78 |
|
| 79 |
/** |
| 80 |
* Display mode constant for enabling the {@link InsertColumnAction} (value is 1<<4). |
| 81 |
*/ |
| 82 |
public static final int INSERT_COLUMN_ACTION_ENABLED = 1 << 4; |
| 83 |
|
| 84 |
/** |
| 85 |
* Display mode constant for enabling the {@link DeleteColumnAction} (value is 1<<5). |
| 86 |
*/ |
| 87 |
public static final int DELETE_COLUMN_ACTION_ENABLED = 1 << 5; |
| 88 |
|
| 89 |
/** |
| 90 |
* Display mode constant for enabling the {@link EditColumnAction} (value is 1<<6). |
| 91 |
*/ |
| 92 |
public static final int EDIT_COLUMN_ACTION_ENABLED = 1 << 6; |
| 93 |
|
| 94 |
/** |
| 95 |
* Display mode constant for enabling the cut {@link EditAction} (value is 1<<7). |
| 96 |
*/ |
| 97 |
public static final int CUT_ACTION_ENABLED = 1 << 7; |
| 98 |
|
| 99 |
/** |
| 100 |
* Display mode constant for enabling the copy {@link EditAction} (value is 1<<8). |
| 101 |
*/ |
| 102 |
public static final int COPY_ACTION_ENABLED = 1 << 8; |
| 103 |
|
| 104 |
/** |
| 105 |
* Display mode constant for enabling the paste {@link EditAction} (value is 1<<9). |
| 106 |
*/ |
| 107 |
public static final int PASTE_ACTION_ENABLED = 1 << 9; |
| 54 |
|
108 |
|
| 55 |
public DatapoolMenuManager(DatapoolTable table, String vendorID, boolean showEquivalenceClassActions, boolean showVariableActions, boolean showRecordActions) { |
109 |
public DatapoolMenuManager(DatapoolTable table, String vendorID, boolean showEquivalenceClassActions, boolean showVariableActions, boolean showRecordActions) { |
| 56 |
if (table == null) return; |
110 |
if (table == null) return; |
|
Link Here
|
| 70 |
|
124 |
|
| 71 |
insertRowAction = new InsertRowAction(provider, table); |
125 |
insertRowAction = new InsertRowAction(provider, table); |
| 72 |
deleteRowAction = new DeleteRowAction(provider, table); |
126 |
deleteRowAction = new DeleteRowAction(provider, table); |
| 73 |
//editRowAction = new EditRowAction(provider, table); |
127 |
editRowAction = new EditRowAction(provider, table); |
| 74 |
insertColumnAction = new InsertColumnAction(provider, table); |
128 |
insertColumnAction = new InsertColumnAction(provider, table); |
| 75 |
deleteColumnAction = new DeleteColumnAction(provider, table); |
129 |
deleteColumnAction = new DeleteColumnAction(provider, table); |
| 76 |
editColumnAction = new EditColumnAction(provider, table); |
130 |
editColumnAction = new EditColumnAction(provider, table); |
|
Link Here
|
| 102 |
if (showRowActions) { |
156 |
if (showRowActions) { |
| 103 |
menuMgr.add(insertRowAction); |
157 |
menuMgr.add(insertRowAction); |
| 104 |
menuMgr.add(deleteRowAction); |
158 |
menuMgr.add(deleteRowAction); |
| 105 |
//menuMgr.add(editRowAction); |
159 |
menuMgr.add(editRowAction); |
| 106 |
menuMgr.add(new Separator()); |
160 |
menuMgr.add(new Separator()); |
| 107 |
} |
161 |
} |
| 108 |
if (showColumnActions) { |
162 |
if (showColumnActions) { |
|
Link Here
|
| 125 |
} |
179 |
} |
| 126 |
} |
180 |
} |
| 127 |
|
181 |
|
| 128 |
public void setDisplayMode(int mode, boolean isCutCopyPasteable) { |
182 |
public void setDisplayMode(int displayMode) { |
| 129 |
//- Enable find/replace action |
183 |
|
| 130 |
FindReplaceAction frAction = DatapoolActionHandlerListener.INSTANCE.getFindReplaceAction(); |
184 |
//Enable find/replace action: |
| 131 |
if (frAction != null) { |
185 |
FindReplaceAction findReplaceAction = DatapoolActionHandlerListener.INSTANCE.getFindReplaceAction(); |
| 132 |
frAction.setEnabled(true); |
186 |
|
| 133 |
} |
187 |
if (findReplaceAction != null) { |
| 134 |
boolean showPaste = !DatapoolClipboard.getInstance().isEmpty(); |
188 |
findReplaceAction.setEnabled(true); |
| 135 |
// Based on the mode, enable certain menu items. |
189 |
} |
| 136 |
switch (mode) { |
190 |
|
| 137 |
case 0: |
191 |
//Set the display modes for the row actions: |
| 138 |
insertRowAction.aboutToShow(true); |
192 |
insertRowAction.aboutToShow((displayMode & INSERT_ROW_ACTION_ENABLED) != 0); |
| 139 |
deleteRowAction.aboutToShow(true); |
193 |
deleteRowAction.aboutToShow((displayMode & DELETE_ROW_ACTION_ENABLED) != 0); |
| 140 |
insertColumnAction.aboutToShow(true); |
194 |
editRowAction.aboutToShow((displayMode & EDIT_ROW_ACTION_ENABLED) != 0); |
| 141 |
deleteColumnAction.aboutToShow(false); |
195 |
|
| 142 |
editColumnAction.aboutToShow(false); |
196 |
//Set the display modes for the columns actions: |
| 143 |
cutAction.setEnabled(isCutCopyPasteable); |
197 |
insertColumnAction.aboutToShow((displayMode & INSERT_COLUMN_ACTION_ENABLED) != 0); |
| 144 |
copyAction.setEnabled(isCutCopyPasteable); |
198 |
deleteColumnAction.aboutToShow((displayMode & DELETE_COLUMN_ACTION_ENABLED) != 0); |
| 145 |
pasteAction.setEnabled(showPaste && isCutCopyPasteable); |
199 |
editColumnAction.aboutToShow((displayMode & EDIT_COLUMN_ACTION_ENABLED) != 0); |
| 146 |
break; |
200 |
|
| 147 |
case 1: |
201 |
//Set the display modes for the edit actions: |
| 148 |
insertRowAction.aboutToShow(true); |
202 |
cutAction.setEnabled((displayMode & CUT_ACTION_ENABLED) != 0); |
| 149 |
deleteRowAction.aboutToShow(true); |
203 |
copyAction.setEnabled((displayMode & COPY_ACTION_ENABLED) != 0); |
| 150 |
insertColumnAction.aboutToShow(true); |
204 |
pasteAction.setEnabled((displayMode & PASTE_ACTION_ENABLED) != 0); |
| 151 |
deleteColumnAction.aboutToShow(true); |
|
|
| 152 |
editColumnAction.aboutToShow(true); |
| 153 |
cutAction.setEnabled(true && isCutCopyPasteable); |
| 154 |
copyAction.setEnabled(true && isCutCopyPasteable); |
| 155 |
pasteAction.setEnabled(showPaste && isCutCopyPasteable); |
| 156 |
break; |
| 157 |
case 2: |
| 158 |
case 4: |
| 159 |
insertRowAction.aboutToShow(true); |
| 160 |
deleteRowAction.aboutToShow(false); |
| 161 |
insertColumnAction.aboutToShow(true); |
| 162 |
deleteColumnAction.aboutToShow(false); |
| 163 |
editColumnAction.aboutToShow(false); |
| 164 |
cutAction.setEnabled(false && isCutCopyPasteable); |
| 165 |
copyAction.setEnabled(false && isCutCopyPasteable); |
| 166 |
pasteAction.setEnabled(false && isCutCopyPasteable); |
| 167 |
break; |
| 168 |
case 3: |
| 169 |
insertRowAction.aboutToShow(true); |
| 170 |
deleteRowAction.aboutToShow(false); |
| 171 |
insertColumnAction.aboutToShow(true); |
| 172 |
deleteColumnAction.aboutToShow(true); |
| 173 |
editColumnAction.aboutToShow(false); |
| 174 |
cutAction.setEnabled(false && isCutCopyPasteable); |
| 175 |
copyAction.setEnabled(false && isCutCopyPasteable); |
| 176 |
pasteAction.setEnabled(false && isCutCopyPasteable); |
| 177 |
break; |
| 178 |
case 5: |
| 179 |
insertRowAction.aboutToShow(false); |
| 180 |
deleteRowAction.aboutToShow(false); |
| 181 |
insertColumnAction.aboutToShow(false); |
| 182 |
deleteColumnAction.aboutToShow(false); |
| 183 |
editColumnAction.aboutToShow(false); |
| 184 |
cutAction.setEnabled(false && isCutCopyPasteable); |
| 185 |
copyAction.setEnabled(true && isCutCopyPasteable); |
| 186 |
pasteAction.setEnabled(false && isCutCopyPasteable); |
| 187 |
break; |
| 188 |
case 6: |
| 189 |
//- Case of only one variable left in the equivalence class |
| 190 |
insertRowAction.aboutToShow(true); |
| 191 |
deleteRowAction.aboutToShow(true); |
| 192 |
insertColumnAction.aboutToShow(true); |
| 193 |
deleteColumnAction.aboutToShow(false); |
| 194 |
editColumnAction.aboutToShow(true); |
| 195 |
cutAction.setEnabled(true && isCutCopyPasteable); |
| 196 |
copyAction.setEnabled(true && isCutCopyPasteable); |
| 197 |
pasteAction.setEnabled(showPaste && isCutCopyPasteable); |
| 198 |
break; |
| 199 |
default: |
| 200 |
insertRowAction.aboutToShow(true); |
| 201 |
deleteRowAction.aboutToShow(true); |
| 202 |
insertColumnAction.aboutToShow(true); |
| 203 |
deleteColumnAction.aboutToShow(true); |
| 204 |
editColumnAction.aboutToShow(true); |
| 205 |
cutAction.setEnabled(true && isCutCopyPasteable); |
| 206 |
copyAction.setEnabled(true && isCutCopyPasteable); |
| 207 |
pasteAction.setEnabled(false && isCutCopyPasteable); |
| 208 |
break; |
| 209 |
} |
| 210 |
} |
205 |
} |
| 211 |
} |
206 |
} |