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 195970 Details for
Bug 321294
[Compatibility] Ctrl+E is unimplemented
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]
Ctrl+E implementation patch v1
bug321294-patch-v1.txt (text/plain), 26.76 KB, created by
Remy Suen
on 2011-05-18 09:16:24 EDT
(
hide
)
Description:
Ctrl+E implementation patch v1
Filename:
MIME Type:
Creator:
Remy Suen
Created:
2011-05-18 09:16:24 EDT
Size:
26.76 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/AbstractTableInformationControl.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/AbstractTableInformationControl.java >diff -N Eclipse UI/org/eclipse/ui/internal/AbstractTableInformationControl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/AbstractTableInformationControl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,534 @@ >+/******************************************************************************* >+ * Copyright (c) 2003, 2011 IBM Corporation and others. >+ * 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: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal; >+ >+import org.eclipse.jface.util.Util; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerFilter; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.KeyEvent; >+import org.eclipse.swt.events.KeyListener; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.MouseAdapter; >+import org.eclipse.swt.events.MouseEvent; >+import org.eclipse.swt.events.MouseMoveListener; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.events.TraverseEvent; >+import org.eclipse.swt.events.TraverseListener; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.FontMetrics; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.layout.FillLayout; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Item; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.MenuItem; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Table; >+import org.eclipse.swt.widgets.TableItem; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.ui.internal.misc.StringMatcher; >+ >+/** >+ * @since 3.0 >+ */ >+public abstract class AbstractTableInformationControl { >+ >+ /** >+ * The NamePatternFilter selects the elements which match the given string >+ * patterns. >+ */ >+ protected class NamePatternFilter extends ViewerFilter { >+ >+ /* >+ * (non-Javadoc) Method declared on ViewerFilter. >+ */ >+ public boolean select(Viewer viewer, Object parentElement, Object element) { >+ StringMatcher matcher = getMatcher(); >+ if (matcher == null || !(viewer instanceof TableViewer)) { >+ return true; >+ } >+ TableViewer tableViewer = (TableViewer) viewer; >+ >+ String matchName = ((ILabelProvider) tableViewer.getLabelProvider()).getText(element); >+ >+ if (matchName == null) { >+ return false; >+ } >+ // A dirty editor's label will start with dirty prefix, this prefix >+ // should not be taken in consideration when matching with a pattern >+ if (matchName.startsWith("*")) { //$NON-NLS-1$ >+ matchName = matchName.substring(1); >+ } >+ return matcher.match(matchName); >+ } >+ } >+ >+ /** The control's shell */ >+ private Shell fShell; >+ >+ /** The composite */ >+ private Composite fComposite; >+ >+ /** The control's text widget */ >+ private Text fFilterText; >+ >+ /** The control's table widget */ >+ private TableViewer fTableViewer; >+ >+ /** The current string matcher */ >+ private StringMatcher fStringMatcher; >+ >+ /** >+ * Creates an information control with the given shell as parent. The given >+ * styles are applied to the shell and the table widget. >+ * >+ * @param parent >+ * the parent shell >+ * @param shellStyle >+ * the additional styles for the shell >+ * @param controlStyle >+ * the additional styles for the control >+ */ >+ public AbstractTableInformationControl(Shell parent, int shellStyle, int controlStyle) { >+ fShell = new Shell(parent, shellStyle); >+ fShell.setLayout(new FillLayout()); >+ >+ // Composite for filter text and viewer >+ fComposite = new Composite(fShell, SWT.RESIZE); >+ GridLayout layout = new GridLayout(1, false); >+ fComposite.setLayout(layout); >+ createFilterText(fComposite); >+ >+ fTableViewer = createTableViewer(fComposite, controlStyle); >+ >+ final Table table = fTableViewer.getTable(); >+ table.addKeyListener(new KeyListener() { >+ public void keyPressed(KeyEvent e) { >+ switch (e.keyCode) { >+ case SWT.ESC: >+ dispose(); >+ break; >+ case SWT.DEL: >+ removeSelectedItems(); >+ e.character = SWT.NONE; >+ e.doit = false; >+ break; >+ case SWT.ARROW_UP: >+ if (table.getSelectionIndex() == 0) { >+ // on the first item, going up should grant focus to >+ // text field >+ fFilterText.setFocus(); >+ } >+ break; >+ case SWT.ARROW_DOWN: >+ if (table.getSelectionIndex() == table.getItemCount() - 1) { >+ // on the last item, going down should grant focus to >+ // the text field >+ fFilterText.setFocus(); >+ } >+ break; >+ } >+ } >+ >+ public void keyReleased(KeyEvent e) { >+ // do nothing >+ } >+ }); >+ >+ table.addSelectionListener(new SelectionListener() { >+ public void widgetSelected(SelectionEvent e) { >+ // do nothing; >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ gotoSelectedElement(); >+ } >+ }); >+ >+ /* >+ * Bug in GTK, see SWT bug: 62405 Editor drop down performance slow on >+ * Linux-GTK on mouse move. Rather then removing the support altogether >+ * this feature has been worked around for GTK only as we expect that >+ * newer versions of GTK will no longer exhibit this quality and we will >+ * be able to have the desired support running on all platforms. See >+ * comment https://bugs.eclipse.org/bugs/show_bug.cgi?id=62405#c22 TODO: >+ * remove this code once bug 62405 is fixed for the mainstream GTK >+ * version >+ */ >+ final int ignoreEventCount = Util.isGtk() ? 4 : 1; >+ >+ table.addMouseMoveListener(new MouseMoveListener() { >+ TableItem fLastItem = null; >+ int lastY = 0; >+ int itemHeightdiv4 = table.getItemHeight() / 4; >+ int tableHeight = table.getBounds().height; >+ Point tableLoc = table.toDisplay(0, 0); >+ int divCount = 0; >+ >+ public void mouseMove(MouseEvent e) { >+ if (divCount == ignoreEventCount) { >+ divCount = 0; >+ } >+ if (table.equals(e.getSource()) & ++divCount == ignoreEventCount) { >+ Object o = table.getItem(new Point(e.x, e.y)); >+ if (fLastItem == null ^ o == null) { >+ table.setCursor(o == null ? null : table.getDisplay().getSystemCursor( >+ SWT.CURSOR_HAND)); >+ } >+ if (o instanceof TableItem && lastY != e.y) { >+ lastY = e.y; >+ if (!o.equals(fLastItem)) { >+ fLastItem = (TableItem) o; >+ table.setSelection(new TableItem[] { fLastItem }); >+ } else if (e.y < itemHeightdiv4) { >+ // Scroll up >+ Item item = fTableViewer.scrollUp(e.x + tableLoc.x, e.y + tableLoc.y); >+ if (item instanceof TableItem) { >+ fLastItem = (TableItem) item; >+ table.setSelection(new TableItem[] { fLastItem }); >+ } >+ } else if (e.y > tableHeight - itemHeightdiv4) { >+ // Scroll down >+ Item item = fTableViewer.scrollDown(e.x + tableLoc.x, e.y + tableLoc.y); >+ if (item instanceof TableItem) { >+ fLastItem = (TableItem) item; >+ table.setSelection(new TableItem[] { fLastItem }); >+ } >+ } >+ } else if (o == null) { >+ fLastItem = null; >+ } >+ } >+ } >+ }); >+ >+ table.addMouseListener(new MouseAdapter() { >+ public void mouseUp(MouseEvent e) { >+ if (table.getSelectionCount() < 1) { >+ return; >+ } >+ >+ if (e.button == 1) { >+ if (table.equals(e.getSource())) { >+ Object o = table.getItem(new Point(e.x, e.y)); >+ TableItem selection = table.getSelection()[0]; >+ if (selection.equals(o)) { >+ gotoSelectedElement(); >+ } >+ } >+ } >+ if (e.button == 3) { >+ TableItem tItem = fTableViewer.getTable().getItem(new Point(e.x, e.y)); >+ if (tItem != null) { >+ Menu menu = new Menu(fTableViewer.getTable()); >+ MenuItem mItem = new MenuItem(menu, SWT.NONE); >+ mItem.setText(WorkbenchMessages.PartPane_close); >+ mItem.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent selectionEvent) { >+ removeSelectedItems(); >+ } >+ }); >+ menu.setVisible(true); >+ } >+ } >+ } >+ }); >+ >+ fShell.addTraverseListener(new TraverseListener() { >+ public void keyTraversed(TraverseEvent e) { >+ switch (e.detail) { >+ case SWT.TRAVERSE_PAGE_NEXT: >+ e.detail = SWT.TRAVERSE_NONE; >+ e.doit = true; >+ { >+ int n = table.getItemCount(); >+ if (n == 0) >+ return; >+ >+ int i = table.getSelectionIndex() + 1; >+ if (i >= n) >+ i = 0; >+ table.setSelection(i); >+ } >+ break; >+ >+ case SWT.TRAVERSE_PAGE_PREVIOUS: >+ e.detail = SWT.TRAVERSE_NONE; >+ e.doit = true; >+ { >+ int n = table.getItemCount(); >+ if (n == 0) >+ return; >+ >+ int i = table.getSelectionIndex() - 1; >+ if (i < 0) >+ i = n - 1; >+ table.setSelection(i); >+ } >+ break; >+ } >+ } >+ }); >+ >+ setInfoSystemColor(); >+ installFilter(); >+ } >+ >+ /** >+ * Removes the selected items from the list and closes their corresponding >+ * tabs Selects the next item in the list or disposes it if its presentation >+ * is disposed >+ */ >+ protected void removeSelectedItems() { >+ int selInd = fTableViewer.getTable().getSelectionIndex(); >+ if (deleteSelectedElements()) { >+ return; >+ } >+ fTableViewer.refresh(); >+ if (selInd >= fTableViewer.getTable().getItemCount()) { >+ selInd = fTableViewer.getTable().getItemCount() - 1; >+ } >+ if (selInd >= 0) { >+ fTableViewer.getTable().setSelection(selInd); >+ } >+ } >+ >+ protected abstract TableViewer createTableViewer(Composite parent, int style); >+ >+ public TableViewer getTableViewer() { >+ return fTableViewer; >+ } >+ >+ protected Text createFilterText(Composite parent) { >+ fFilterText = new Text(parent, SWT.NONE); >+ >+ GridData data = new GridData(); >+ GC gc = new GC(parent); >+ gc.setFont(parent.getFont()); >+ FontMetrics fontMetrics = gc.getFontMetrics(); >+ gc.dispose(); >+ >+ data.heightHint = org.eclipse.jface.dialogs.Dialog.convertHeightInCharsToPixels( >+ fontMetrics, 1); >+ data.horizontalAlignment = GridData.FILL; >+ data.verticalAlignment = GridData.BEGINNING; >+ fFilterText.setLayoutData(data); >+ >+ fFilterText.addKeyListener(new KeyListener() { >+ public void keyPressed(KeyEvent e) { >+ switch (e.keyCode) { >+ case SWT.CR: >+ case SWT.KEYPAD_CR: >+ gotoSelectedElement(); >+ break; >+ case SWT.ARROW_DOWN: >+ fTableViewer.getTable().setFocus(); >+ fTableViewer.getTable().setSelection(0); >+ break; >+ case SWT.ARROW_UP: >+ fTableViewer.getTable().setFocus(); >+ fTableViewer.getTable() >+ .setSelection(fTableViewer.getTable().getItemCount() - 1); >+ break; >+ case SWT.ESC: >+ dispose(); >+ break; >+ } >+ } >+ >+ public void keyReleased(KeyEvent e) { >+ // do nothing >+ } >+ }); >+ >+ // Horizontal separator line >+ Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT); >+ separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ >+ return fFilterText; >+ } >+ >+ private void setInfoSystemColor() { >+ Display display = fShell.getDisplay(); >+ setForegroundColor(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); >+ setBackgroundColor(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); >+ } >+ >+ private void installFilter() { >+ fFilterText.setText(""); //$NON-NLS-1$ >+ >+ fFilterText.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ String text = ((Text) e.widget).getText(); >+ int length = text.length(); >+ if (length > 0 && text.charAt(length - 1) != '*') { >+ text = text + '*'; >+ } >+ setMatcherString(text); >+ } >+ }); >+ } >+ >+ /** >+ * The string matcher has been modified. The default implementation >+ * refreshes the view and selects the first macthed element >+ */ >+ private void stringMatcherUpdated() { >+ // refresh viewer to refilter >+ fTableViewer.getControl().setRedraw(false); >+ fTableViewer.refresh(); >+ selectFirstMatch(); >+ fTableViewer.getControl().setRedraw(true); >+ } >+ >+ /** >+ * Sets the patterns to filter out for the receiver. >+ * <p> >+ * The following characters have special meaning: ? => any character * => >+ * any string >+ * </p> >+ */ >+ private void setMatcherString(String pattern) { >+ if (pattern.length() == 0) { >+ fStringMatcher = null; >+ } else { >+ boolean ignoreCase = pattern.toLowerCase().equals(pattern); >+ fStringMatcher = new StringMatcher(pattern, ignoreCase, false); >+ } >+ stringMatcherUpdated(); >+ } >+ >+ private StringMatcher getMatcher() { >+ return fStringMatcher; >+ } >+ >+ /** >+ * Implementers can modify >+ */ >+ protected Object getSelectedElement() { >+ return ((IStructuredSelection) fTableViewer.getSelection()).getFirstElement(); >+ } >+ >+ protected abstract void gotoSelectedElement(); >+ >+ /** >+ * Delete all selected elements. >+ * >+ * @return <code>true</code> if there are no elements left after deletion. >+ */ >+ protected abstract boolean deleteSelectedElements(); >+ >+ /** >+ * Selects the first element in the table which matches the current filter >+ * pattern. >+ */ >+ protected void selectFirstMatch() { >+ Table table = fTableViewer.getTable(); >+ Object element = findElement(table.getItems()); >+ if (element != null) { >+ fTableViewer.setSelection(new StructuredSelection(element), true); >+ } else { >+ fTableViewer.setSelection(StructuredSelection.EMPTY); >+ } >+ } >+ >+ private Object findElement(TableItem[] items) { >+ ILabelProvider labelProvider = (ILabelProvider) fTableViewer.getLabelProvider(); >+ for (int i = 0; i < items.length; i++) { >+ Object element = items[i].getData(); >+ if (fStringMatcher == null) { >+ return element; >+ } >+ >+ if (element != null) { >+ String label = labelProvider.getText(element); >+ if (label == null) { >+ return null; >+ } >+ // remove the dirty prefix from the editor's label >+ if (label.startsWith("*")) { //$NON-NLS-1$ >+ label = label.substring(1); >+ } >+ if (fStringMatcher.match(label)) { >+ return element; >+ } >+ } >+ } >+ return null; >+ } >+ >+ public void setVisible(boolean visible) { >+ fShell.setVisible(visible); >+ } >+ >+ public void dispose() { >+ if (fShell != null) { >+ if (!fShell.isDisposed()) { >+ fShell.dispose(); >+ } >+ fShell = null; >+ fTableViewer = null; >+ fComposite = null; >+ fFilterText = null; >+ } >+ } >+ >+ public Point computeSizeHint() { >+ return fShell.computeSize(SWT.DEFAULT, SWT.DEFAULT); >+ } >+ >+ public void setLocation(Point location) { >+ Rectangle trim = fShell.computeTrim(0, 0, 0, 0); >+ Point textLocation = fComposite.getLocation(); >+ location.x += trim.x - textLocation.x; >+ location.y += trim.y - textLocation.y; >+ fShell.setLocation(location); >+ } >+ >+ public void setSize(int width, int height) { >+ fShell.setSize(width, height); >+ } >+ >+ public Shell getShell() { >+ return fShell; >+ } >+ >+ private void setForegroundColor(Color foreground) { >+ fTableViewer.getTable().setForeground(foreground); >+ fFilterText.setForeground(foreground); >+ fComposite.setForeground(foreground); >+ } >+ >+ private void setBackgroundColor(Color background) { >+ fTableViewer.getTable().setBackground(background); >+ fFilterText.setBackground(background); >+ fComposite.setBackground(background); >+ } >+ >+ public void setFocus() { >+ fShell.forceFocus(); >+ fFilterText.setFocus(); >+ } >+} >Index: Eclipse UI/org/eclipse/ui/internal/BasicPartList.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/BasicPartList.java >diff -N Eclipse UI/org/eclipse/ui/internal/BasicPartList.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/BasicPartList.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,149 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * 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: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ui.internal; >+ >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.List; >+import java.util.Map; >+import org.eclipse.e4.ui.model.application.ui.MUIElement; >+import org.eclipse.e4.ui.model.application.ui.MUILabel; >+import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder; >+import org.eclipse.e4.ui.model.application.ui.basic.MPart; >+import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; >+import org.eclipse.e4.ui.workbench.modeling.EPartService; >+import org.eclipse.e4.ui.workbench.swt.util.ISWTResourceUtilities; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.viewers.ArrayContentProvider; >+import org.eclipse.jface.viewers.ColumnLabelProvider; >+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Listener; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Table; >+ >+public class BasicPartList extends AbstractTableInformationControl { >+ >+ private class BasicStackListLabelProvider extends ColumnLabelProvider { >+ >+ public String getText(Object element) { >+ return ((MUILabel) element).getLabel(); >+ } >+ >+ public Image getImage(Object element) { >+ return getLabelImage(((MUILabel) element).getIconURI()); >+ } >+ >+ public String getToolTipText(Object element) { >+ return ((MUILabel) element).getTooltip(); >+ } >+ >+ public boolean useNativeToolTip(Object object) { >+ return true; >+ } >+ } >+ >+ private Map<String, Image> images = new HashMap<String, Image>(); >+ >+ private ISWTResourceUtilities utils; >+ >+ private MPartStack input; >+ >+ private EPartService partService; >+ >+ public BasicPartList(Shell parent, int shellStyle, int treeStyler, EPartService partService, >+ MPartStack input, ISWTResourceUtilities utils) { >+ super(parent, shellStyle, treeStyler); >+ this.partService = partService; >+ this.input = input; >+ this.utils = utils; >+ } >+ >+ private Image getLabelImage(String iconURI) { >+ Image image = images.get(iconURI); >+ if (image == null) { >+ ImageDescriptor descriptor = utils.imageDescriptorFromURI(URI.createURI(iconURI)); >+ image = descriptor.createImage(); >+ images.put(iconURI, image); >+ } >+ return image; >+ } >+ >+ protected TableViewer createTableViewer(Composite parent, int style) { >+ Table table = new Table(parent, SWT.SINGLE | (style & ~SWT.MULTI)); >+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ TableViewer tableViewer = new TableViewer(table); >+ tableViewer.addFilter(new NamePatternFilter()); >+ tableViewer.setContentProvider(ArrayContentProvider.getInstance()); >+ tableViewer.setLabelProvider(new BasicStackListLabelProvider()); >+ >+ ColumnViewerToolTipSupport.enableFor(tableViewer); >+ table.addListener(SWT.Dispose, new Listener() { >+ public void handleEvent(Event event) { >+ for (Image image : images.values()) { >+ image.dispose(); >+ } >+ } >+ }); >+ return tableViewer; >+ } >+ >+ private List<Object> getInput() { >+ List<Object> list = new ArrayList<Object>(); >+ for (MUIElement element : input.getChildren()) { >+ if (element instanceof MPlaceholder) { >+ element = ((MPlaceholder) element).getRef(); >+ } >+ >+ if (element.isToBeRendered() && element.isVisible() && element instanceof MPart) { >+ list.add(element); >+ } >+ } >+ return list; >+ } >+ >+ public void setInput() { >+ getTableViewer().setInput(getInput()); >+ selectFirstMatch(); >+ } >+ >+ protected void gotoSelectedElement() { >+ Object selectedElement = getSelectedElement(); >+ >+ // close the shell >+ dispose(); >+ >+ if (selectedElement instanceof MPart) { >+ partService.activate((MPart) selectedElement); >+ } >+ } >+ >+ protected boolean deleteSelectedElements() { >+ Object selectedElement = getSelectedElement(); >+ if (selectedElement != null) { >+ partService.hidePart((MPart) selectedElement); >+ >+ if (getInput().isEmpty()) { >+ getShell().dispose(); >+ return true; >+ } >+ } >+ return false; >+ >+ } >+} >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.compatibility/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java,v >retrieving revision 1.179 >diff -u -r1.179 WorkbenchPage.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 9 May 2011 16:55:07 -0000 1.179 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 18 May 2011 13:16:07 -0000 >@@ -2497,7 +2497,7 @@ > return mpart == null ? false : partService.isPartVisible(mpart); > } > >- private MUIElement findSharedArea() { >+ public MUIElement findSharedArea() { > MPerspective perspective = getPerspectiveStack().getSelectedElement(); > return perspective == null ? null : modelService.find(IPageLayout.ID_EDITOR_AREA, > perspective); >Index: Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.compatibility/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java,v >retrieving revision 1.1 >diff -u -r1.1 WorkbookEditorsHandler.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java 2 Mar 2010 20:11:48 -0000 1.1 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java 18 May 2011 13:16:07 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2011 IBM Corporation and others. > * 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 >@@ -14,6 +14,18 @@ > import org.eclipse.core.commands.AbstractHandler; > import org.eclipse.core.commands.ExecutionEvent; > import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.e4.ui.model.application.ui.MElementContainer; >+import org.eclipse.e4.ui.model.application.ui.MUIElement; >+import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder; >+import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; >+import org.eclipse.e4.ui.workbench.IResourceUtilities; >+import org.eclipse.e4.ui.workbench.modeling.EPartService; >+import org.eclipse.e4.ui.workbench.swt.util.ISWTResourceUtilities; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Listener; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.handlers.HandlerUtil; > >@@ -31,13 +43,56 @@ > * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) > */ > public Object execute(ExecutionEvent event) throws ExecutionException { >- IWorkbenchWindow workbenchWindow = HandlerUtil >- .getActiveWorkbenchWindow(event); >- if (workbenchWindow == null) { >- // action has been disposed >- return null; >+ IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindowChecked(event); >+ WorkbenchPage page = (WorkbenchPage) workbenchWindow.getActivePage(); >+ if (page != null) { >+ MUIElement area = page.findSharedArea(); >+ if (area instanceof MPlaceholder) { >+ area = ((MPlaceholder) area).getRef(); >+ } >+ >+ MPartStack activeStack = getActiveStack(area); >+ if (activeStack != null) { >+ ISWTResourceUtilities utils = (ISWTResourceUtilities) HandlerUtil >+ .getVariableChecked(event, IResourceUtilities.class.getName()); >+ EPartService partService = (EPartService) HandlerUtil.getVariableChecked(event, >+ EPartService.class.getName()); >+ final BasicPartList editorList = new BasicPartList(workbenchWindow.getShell(), >+ SWT.ON_TOP, SWT.V_SCROLL | SWT.H_SCROLL, partService, activeStack, utils); >+ editorList.setInput(); >+ >+ Point size = editorList.computeSizeHint(); >+ editorList.setSize(size.x, size.y); >+ >+ Rectangle bounds = workbenchWindow.getShell().getBounds(); >+ int x = (bounds.width / 2) + bounds.x; >+ int y = (bounds.height / 2) + bounds.y; >+ x = x - (size.x / 2); >+ y = y - (size.y / 2); >+ >+ editorList.setLocation(new Point(x, y)); >+ editorList.setVisible(true); >+ editorList.setFocus(); >+ editorList.getShell().addListener(SWT.Deactivate, new Listener() { >+ public void handleEvent(Event event) { >+ editorList.getShell().getDisplay().asyncExec(new Runnable() { >+ public void run() { >+ editorList.dispose(); >+ } >+ }); >+ } >+ }); >+ } >+ } >+ return null; >+ } >+ >+ private MPartStack getActiveStack(Object element) { >+ if (element instanceof MPartStack) { >+ return (MPartStack) element; >+ } else if (element instanceof MElementContainer<?>) { >+ return getActiveStack(((MElementContainer<?>) element).getSelectedElement()); > } >- // TODO show the list of editors in the editor area > return null; > } >
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 321294
: 195970