Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 136132 Details for
Bug 64786
(Test)Provide context menu when right clicking on variable column header
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch.
Bugzilla_64786_Patch.txt (text/plain), 15.54 KB, created by
Paul Slauenwhite
on 2009-05-17 18:06:05 EDT
(
hide
)
Description:
Patch.
Filename:
MIME Type:
Creator:
Paul Slauenwhite
Created:
2009-05-17 18:06:05 EDT
Size:
15.54 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.hyades.test.ui >Index: src/org/eclipse/hyades/test/ui/datapool/internal/control/DatapoolMenuManager.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/datapool/internal/control/DatapoolMenuManager.java,v >retrieving revision 1.17 >diff -u -r1.17 DatapoolMenuManager.java >--- src/org/eclipse/hyades/test/ui/datapool/internal/control/DatapoolMenuManager.java 12 May 2009 18:30:00 -0000 1.17 >+++ src/org/eclipse/hyades/test/ui/datapool/internal/control/DatapoolMenuManager.java 17 May 2009 22:06:54 -0000 >@@ -41,7 +41,7 @@ > * > * @author Peter Sun > * @author Paul E. Slauenwhite >- * @version May 12, 2009 >+ * @version May 17, 2009 > * @since January 27, 2005 > */ > public class DatapoolMenuManager { >@@ -94,20 +94,25 @@ > public static final int EDIT_COLUMN_ACTION_ENABLED = 1 << 6; > > /** >- * Display mode constant for enabling the cut {@link EditAction} (value is 1<<7). >+ * Display mode constant for enabling the cut {@link CutAction} (value is 1<<7). > */ > public static final int CUT_ACTION_ENABLED = 1 << 7; > > /** >- * Display mode constant for enabling the copy {@link EditAction} (value is 1<<8). >+ * Display mode constant for enabling the copy {@link CopyAction} (value is 1<<8). > */ > public static final int COPY_ACTION_ENABLED = 1 << 8; > > /** >- * Display mode constant for enabling the paste {@link EditAction} (value is 1<<9). >+ * Display mode constant for enabling the paste {@link PasteAction} (value is 1<<9). > */ > public static final int PASTE_ACTION_ENABLED = 1 << 9; > >+ /** >+ * Display mode constant for enabling the find and replace {@link FindReplaceAction} (value is 1<<10). >+ */ >+ public static final int FIND_REPLACE_ACTION_ENABLED = 1 << 10; >+ > public DatapoolMenuManager(DatapoolTable table, String vendorID, boolean showEquivalenceClassActions, boolean showVariableActions, boolean showRecordActions) { > if (table == null) return; > this.customActions = new Vector(); >@@ -218,14 +223,7 @@ > } > > public void setDisplayMode(int displayMode) { >- >- //Enable find/replace action: >- FindReplaceAction findReplaceAction = DatapoolActionHandlerListener.INSTANCE.getFindReplaceAction(); >- >- if (findReplaceAction != null) { >- findReplaceAction.setEnabled(true); >- } >- >+ > //Set the display modes for the row actions: > insertRowAction.aboutToShow((displayMode & INSERT_ROW_ACTION_ENABLED) != 0); > deleteRowAction.aboutToShow((displayMode & DELETE_ROW_ACTION_ENABLED) != 0); >@@ -240,5 +238,11 @@ > cutAction.setEnabled((displayMode & CUT_ACTION_ENABLED) != 0); > copyAction.setEnabled((displayMode & COPY_ACTION_ENABLED) != 0); > pasteAction.setEnabled((displayMode & PASTE_ACTION_ENABLED) != 0); >+ >+ FindReplaceAction findReplaceAction = DatapoolActionHandlerListener.INSTANCE.getFindReplaceAction(); >+ >+ if (findReplaceAction != null) { >+ findReplaceAction.setEnabled((displayMode & FIND_REPLACE_ACTION_ENABLED) != 0); >+ } > } > } >Index: src/org/eclipse/hyades/test/ui/datapool/internal/control/DatapoolTable.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/datapool/internal/control/DatapoolTable.java,v >retrieving revision 1.70 >diff -u -r1.70 DatapoolTable.java >--- src/org/eclipse/hyades/test/ui/datapool/internal/control/DatapoolTable.java 15 May 2009 16:12:08 -0000 1.70 >+++ src/org/eclipse/hyades/test/ui/datapool/internal/control/DatapoolTable.java 17 May 2009 22:06:56 -0000 >@@ -74,8 +74,6 @@ > import org.eclipse.swt.events.KeyListener; > import org.eclipse.swt.events.MenuDetectEvent; > import org.eclipse.swt.events.MenuDetectListener; >-import org.eclipse.swt.events.MenuEvent; >-import org.eclipse.swt.events.MenuListener; > import org.eclipse.swt.events.MouseAdapter; > import org.eclipse.swt.events.MouseEvent; > import org.eclipse.swt.events.PaintEvent; >@@ -94,6 +92,8 @@ > import org.eclipse.swt.widgets.Combo; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Menu; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.swt.widgets.Table; >@@ -116,10 +116,10 @@ > * > * @author Peter Sun > * @author Paul E. Slauenwhite >- * @version May 15, 2009 >+ * @version May 17, 2009 > * @since January 27, 2005 > */ >-public class DatapoolTable implements IMenuListener, MenuListener, SelectionListener, IDatapoolListener { >+public class DatapoolTable implements SelectionListener, IDatapoolListener { > > private static final int MAX_TABLE_WIDTH = 60; > private static final int MAX_TABLE_HEIGHT = 60; >@@ -146,6 +146,7 @@ > private boolean showRecords = true; > private boolean isF2Mode = false; > private int previousMultiRowSelectionIndex = -1; // only used for deselecting when multi-selection in place. >+ private int headerSelectionIndex = -1; > private String cellkey; > private boolean passwordExist = false; > private String password = null; >@@ -756,6 +757,8 @@ > //Open the context menu: > contextMenu.setEnabled(true); > contextMenu.setVisible(true); >+ >+ headerSelectionIndex = -1; > } > } > } >@@ -1198,16 +1201,165 @@ > } > > /** >- * >+ * Creates the context menu. > */ > private void createMenu() { >- MenuManager menuMgr= new MenuManager("#DatapoolEditor"); //$NON-NLS-1$ >- menuMgr.setRemoveAllWhenShown(true); >- menuMgr.addMenuListener(this); >- contextMenu = menuMgr.createContextMenu(table); >+ >+ MenuManager menuManager = new MenuManager("#DatapoolEditor"); //$NON-NLS-1$ >+ menuManager.setRemoveAllWhenShown(true); >+ menuManager.addMenuListener(new IMenuListener(){ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) >+ */ >+ public void menuAboutToShow(IMenuManager menuManager) { >+ >+ datapoolMenuManager.addActions(menuManager); >+ >+ if(headerSelectionIndex != -1){ >+ setHeaderMenuMode(datapoolMenuManager); >+ } >+ else{ >+ setMenuMode(datapoolMenuManager); >+ } >+ } >+ }); >+ >+ contextMenu = menuManager.createContextMenu(table); >+ > table.setMenu(contextMenu); >+ table.addListener(SWT.MenuDetect, new Listener(){ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) >+ */ >+ public void handleEvent(Event event) { >+ >+ Point point = Display.getCurrent().map(null, table, new Point(event.x, event.y)); >+ Rectangle clientArea = table.getClientArea(); >+ >+ //Header context menu: >+ if((point.y >= clientArea.y) && (point.y < (clientArea.y + table.getHeaderHeight()))){ >+ headerSelectionIndex = getColumnIndex(point); >+ } >+ >+ //Cell context menu: >+ else{ >+ headerSelectionIndex = -1; >+ } >+ } >+ }); >+ } >+ >+ /** >+ * Resolves the column index of the selection{@link Point}. >+ * >+ * @param point The section point. >+ * @return The column index of the selection{@link Point}. >+ */ >+ private int getColumnIndex(Point point){ >+ >+ //Resolve the first row: >+ TableItem tableItem = table.getItem(0); >+ >+ for (int counter = 0; counter < table.getColumnCount(); counter++) { >+ >+ Rectangle clientArea = tableItem.getBounds(counter); >+ >+ if((point.x >= clientArea.x) && (point.x <= (clientArea.x + clientArea.width))){ >+ return counter; >+ } >+ } >+ >+ return -1; > } > >+ /** >+ * Sets the mode for the context menu. >+ * >+ * @param datapoolMenuManager Datapool menu manager. >+ */ >+ private void setMenuMode(DatapoolMenuManager datapoolMenuManager){ >+ >+ if(datapoolMenuManager != null){ >+ >+ int displayMode = 0; >+ int recordCount = equivalenceClass.getRecordCount(); >+ >+ if((!datapoolEditorPart.isReadOnly()) && (equivalenceClass != null)){ >+ >+ //Set the display modes for the row actions: >+ displayMode |= DatapoolMenuManager.INSERT_ROW_ACTION_ENABLED; >+ >+ if(recordCount > 0){ >+ >+ displayMode |= DatapoolMenuManager.EDIT_ROW_ACTION_ENABLED; >+ >+ if(recordCount > 1){ >+ displayMode |= DatapoolMenuManager.DELETE_ROW_ACTION_ENABLED; >+ } >+ } >+ >+ //Set the display modes for the columns actions: >+ displayMode |= DatapoolMenuManager.INSERT_COLUMN_ACTION_ENABLED; >+ >+ if (((tableCursor != null) && (!tableCursor.isDisposed()) && (tableCursor.getColumn() > 0)) && (table.getSelectionIndex() > -1)) { >+ >+ displayMode |= DatapoolMenuManager.EDIT_COLUMN_ACTION_ENABLED; >+ >+ if(getDatapool().getVariableCount() > 1){ >+ displayMode |= DatapoolMenuManager.DELETE_COLUMN_ACTION_ENABLED; >+ } >+ } >+ } >+ >+ //Set the display modes for the copy edit action: >+ if((!table.isDisposed()) && (table.getSelectionCount() > 0) && (tableUtil.getColumnCount() > 1) && (recordCount > 0)){ >+ >+ displayMode |= DatapoolMenuManager.CUT_ACTION_ENABLED; >+ displayMode |= DatapoolMenuManager.COPY_ACTION_ENABLED; >+ >+ if(!DatapoolClipboard.getInstance().isEmpty()){ >+ displayMode |= DatapoolMenuManager.PASTE_ACTION_ENABLED; >+ } >+ >+ displayMode |= DatapoolMenuManager.FIND_REPLACE_ACTION_ENABLED; >+ } >+ >+ datapoolMenuManager.setDisplayMode(displayMode); >+ } >+ } >+ >+ /** >+ * Sets the mode for the header context menu. >+ * >+ * @param datapoolMenuManager Datapool menu manager. >+ */ >+ private void setHeaderMenuMode(DatapoolMenuManager datapoolMenuManager){ >+ >+ if(datapoolMenuManager != null){ >+ >+ int displayMode = 0; >+ >+ if((!datapoolEditorPart.isReadOnly()) && (equivalenceClass != null)){ >+ >+ //Set the display modes for the columns actions: >+ displayMode |= DatapoolMenuManager.INSERT_COLUMN_ACTION_ENABLED; >+ >+ if (headerSelectionIndex > 0) { >+ >+ displayMode |= DatapoolMenuManager.EDIT_COLUMN_ACTION_ENABLED; >+ >+ if(getDatapool().getVariableCount() > 1){ >+ displayMode |= DatapoolMenuManager.DELETE_COLUMN_ACTION_ENABLED; >+ } >+ } >+ } >+ >+ datapoolMenuManager.setDisplayMode(displayMode); >+ } >+ } >+ > /* > * Creates the table widget and viewer. Populates the table from the datapool. > */ >@@ -1800,76 +1952,10 @@ > /** > * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) > */ >- public void widgetDefaultSelected(SelectionEvent e) >- { >- } >- >- >- // IMenuListener >- >- /** >- * see menuAboutToShow(org.eclipse.jface.action.IMenuManager) in org.eclipse.jface.action.IMenuListener >- */ >- public void menuAboutToShow(IMenuManager imenuMgr) >- { >- datapoolMenuManager.addActions(imenuMgr); >- setMenuMode(datapoolMenuManager); >+ public void widgetDefaultSelected(SelectionEvent e){ >+ //No-operation. > } >- >- // Action handlers >- >- /** >- * @param dpMenuManager >- */ >- private void setMenuMode(DatapoolMenuManager dpMenuManager) >- { >- if(dpMenuManager != null){ >- >- int displayMode = 0; >- int recordCount = equivalenceClass.getRecordCount(); >- >- if((!datapoolEditorPart.isReadOnly()) && (equivalenceClass != null)){ >- >- //Set the display modes for the row actions: >- displayMode |= DatapoolMenuManager.INSERT_ROW_ACTION_ENABLED; >- >- if(recordCount > 0){ >- >- displayMode |= DatapoolMenuManager.DELETE_ROW_ACTION_ENABLED; >- >- if(recordCount > 1){ >- displayMode |= DatapoolMenuManager.EDIT_ROW_ACTION_ENABLED; >- } >- } >- >- //Set the display modes for the columns actions: >- displayMode |= DatapoolMenuManager.INSERT_COLUMN_ACTION_ENABLED; >- >- if (((tableCursor != null) && (!tableCursor.isDisposed()) && (tableCursor.getColumn() > 0)) && (table.getSelectionIndex() > -1)) { >- >- if(getDatapool().getVariableCount() > 1){ >- displayMode |= DatapoolMenuManager.DELETE_COLUMN_ACTION_ENABLED; >- } >- >- displayMode |= DatapoolMenuManager.EDIT_COLUMN_ACTION_ENABLED; >- } >- } >- >- //Set the display modes for the copy edit action: >- if((!table.isDisposed()) && (table.getSelectionCount() > 0) && (tableUtil.getColumnCount() > 1) && (recordCount > 0)){ >- >- displayMode |= DatapoolMenuManager.CUT_ACTION_ENABLED; >- displayMode |= DatapoolMenuManager.COPY_ACTION_ENABLED; > >- if(!DatapoolClipboard.getInstance().isEmpty()){ >- displayMode |= DatapoolMenuManager.PASTE_ACTION_ENABLED; >- } >- } >- >- dpMenuManager.setDisplayMode(displayMode); >- } >- } >- > /** > * Inserts a new record/row to the table before the current record. > */ >@@ -2011,11 +2097,22 @@ > */ > public void insertColumn() > { >- if(showVariables == false) >+ if(showVariables == false){ > return; >+ } >+ > int selectedColumnIndex = -1; >- if(tableCursor != null && !tableCursor.isDisposed()) >+ >+ if(headerSelectionIndex != -1){ >+ >+ selectedColumnIndex = headerSelectionIndex; >+ >+ headerSelectionIndex = -1; >+ } >+ else if(tableCursor != null && !tableCursor.isDisposed()){ > selectedColumnIndex = tableCursor.getColumn(); >+ } >+ > TableColumn previousTableColumn = null; > if(selectedColumnIndex > 0) > previousTableColumn = table.getColumn(selectedColumnIndex - 1); >@@ -2129,7 +2226,7 @@ > > /* > * Deletes the currently selected variable/column. Removes the column and >- * all assocaited cells from the datapool object. Removes the column from >+ * all associated cells from the datapool object. Removes the column from > * the table. > */ > public void deleteColumn() >@@ -2155,9 +2252,19 @@ > else > return; > } >- else >- { >- int selectedColumnIndex = tableCursor.getColumn(); >+ else{ >+ >+ int selectedColumnIndex = -1; >+ >+ if(headerSelectionIndex != -1){ >+ >+ selectedColumnIndex = headerSelectionIndex; >+ >+ headerSelectionIndex = -1; >+ } >+ else if(tableCursor != null && !tableCursor.isDisposed()){ >+ selectedColumnIndex = tableCursor.getColumn(); >+ } > > // Don't delete the row name column. > if (selectedColumnIndex < 1) >@@ -2186,11 +2293,21 @@ > * variable in the datapool object. Updates the table to reflect the edit > * and/or move. > */ >- public void editColumn() >- { >- int selectedColumnIndex = tableCursor.getColumn(); >- TableColumn tableColumn = (TableColumn) table.getColumn(selectedColumnIndex); >- editColumnAux(tableColumn); >+ public void editColumn(){ >+ >+ int selectedColumnIndex = -1; >+ >+ if(headerSelectionIndex != -1){ >+ >+ selectedColumnIndex = headerSelectionIndex; >+ >+ headerSelectionIndex = -1; >+ } >+ else if(tableCursor != null && !tableCursor.isDisposed()){ >+ selectedColumnIndex = tableCursor.getColumn(); >+ } >+ >+ editColumnAux(((TableColumn)(table.getColumn(selectedColumnIndex)))); > } > > /* >@@ -3611,19 +3728,6 @@ > return this.equivalenceClass; > } > >- /** >- * @see org.eclipse.swt.events.MenuListener#menuHidden(org.eclipse.swt.events.MenuEvent) >- */ >- public void menuHidden(MenuEvent e) { >- } >- >- /** >- * @see org.eclipse.swt.events.MenuListener#menuShown(org.eclipse.swt.events.MenuEvent) >- */ >- public void menuShown(MenuEvent e) { >- setMenuMode(datapoolMenuManager); >- } >- > public void setPassword(String password){ > this.password = password; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 64786
: 136132