Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2018 IBM Corporation and others.
* Copyright (c) 2003, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.e4.ui.internal.workbench.renderers.swt;

import java.util.List;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.swt.internal.copy.SearchPattern;
import org.eclipse.e4.ui.workbench.swt.internal.copy.WorkbenchSWTMessages;
import org.eclipse.jface.preference.JFacePreferences;
Expand All @@ -23,6 +25,7 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyListener;
Expand All @@ -33,13 +36,15 @@
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
Expand All @@ -48,11 +53,16 @@
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

/**
* @since 3.0
*/
public abstract class AbstractTableInformationControl {
private ViewerComparator originalComparatorOrder;
private Object originalInputOrder;
private boolean reversed = false;

/**
* The NamePatternFilter selects the elements which match the given string
Expand Down Expand Up @@ -313,18 +323,25 @@ public TableViewer getTableViewer() {
}

protected Text createFilterText(Composite parent) {
fFilterText = new Text(parent, SWT.NONE);
Composite c = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
c.setLayout(layout);
c.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

GridData data = new GridData();
fFilterText = new Text(c, SWT.NONE);

GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
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);
.convertHeightInCharsToPixels(fontMetrics, 1);
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.BEGINNING;
data.verticalAlignment = GridData.CENTER;
fFilterText.setLayoutData(data);

fFilterText.addKeyListener(KeyListener.keyPressedAdapter(e -> {
Expand All @@ -347,6 +364,46 @@ protected Text createFilterText(Composite parent) {
}
}));

ToolBar toolBar = new ToolBar(c, SWT.FLAT | SWT.NO_FOCUS);
GridData tbData = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
toolBar.setLayoutData(tbData);

ToolItem reverseItem = new ToolItem(toolBar, SWT.CHECK);
Image image = new Image(Display.getCurrent(),
getClass().getClassLoader().getResourceAsStream("icons/full/elcl16/view_recent_editor.svg"));//$NON-NLS-1$
reverseItem.setImage(image);
reverseItem.setToolTipText(SWTRenderersMessages.mostRecentHiddenEditor);
reverseItem.addDisposeListener(e -> {
if (image != null && !image.isDisposed()) {
image.dispose();
}
});

reverseItem.addListener(SWT.Selection, e -> {
if (this instanceof BasicPartList bpl) {

if (!reversed) {
if (originalComparatorOrder == null) {
originalComparatorOrder = fTableViewer.getComparator();
originalInputOrder = fTableViewer.getInput();
}
List<MPart> showEditors = bpl.getEditorsReversed();
fTableViewer.setComparator(null);
fTableViewer.setInput(showEditors);
reversed = true;

} else {
fTableViewer.setComparator(originalComparatorOrder);
fTableViewer.setInput(originalInputOrder);
reversed = false;
}
computeSizeHint();
fComposite.layout(true, true);
fComposite.getShell().pack(true);
fTableViewer.refresh();
}
});

// Horizontal separator line
Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2015 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -16,6 +16,7 @@
package org.eclipse.e4.ui.internal.workbench.renderers.swt;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
Expand Down Expand Up @@ -162,6 +163,20 @@ private List<Object> getInput() {
return list;
}

public List<MPart> getEditorsReversed() {
List<MPart> showEditors = new ArrayList<>();
for (Object obj : getInput()) {
if (obj instanceof MPart part) {
CTabItem item = renderer.findItemForPart(part);
if (item != null && !item.isShowing()) {
showEditors.add(part);
}
}
}
Collections.reverse(showEditors);
return showEditors;
}

public void setInput() {
getTableViewer().setInput(getInput());
selectFirstMatch();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2015 IBM Corporation and others.
* Copyright (c) 2010, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -35,6 +35,7 @@ public class SWTRenderersMessages extends NLS {
public static String menuCloseRight;
public static String menuCloseLeft;
public static String menuDetach;
public static String mostRecentHiddenEditor;

public static String viewMenu;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2010, 2015 IBM Corporation and others.
# Copyright (c) 2010, 2025 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -26,4 +26,5 @@ menuCloseAll = Close &All
menuCloseRight = Close Tabs to the &Right
menuCloseLeft = Close Tabs to the &Left
menuDetach= &Detach
mostRecentHiddenEditor=Show editors by most recently moved to the chevron
viewMenu = View Menu
Loading