Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ protected void setDefaultEventManager() {

protected GraphicalViewer(FigureCanvas canvas) {
m_canvas = canvas;
m_rootEditPart = new RootEditPart(this, getRootFigure());
m_rootEditPart = new RootEditPart(getRootFigure());
m_rootEditPart.setViewer(this);
m_rootEditPart.activate();
setRootEditPart(m_rootEditPart);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2023 Google, Inc.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -21,8 +21,10 @@
import org.eclipse.wb.gef.graphical.tools.MarqueeSelectionTool;
import org.eclipse.wb.internal.draw2d.IRootFigure;

import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.Request;
import org.eclipse.gef.editparts.LayerManager;

/**
* A {@link RootEditPart} is the <i>root</i> of an {@link IEditPartViewer}. It bridges the gap
Expand All @@ -33,7 +35,7 @@
* @author lobas_av
* @coverage gef.graphical
*/
public class RootEditPart extends GraphicalEditPart implements org.eclipse.gef.RootEditPart {
public class RootEditPart extends GraphicalEditPart implements org.eclipse.gef.RootEditPart, LayerManager {
private IEditPartViewer m_viewer;
private final IRootFigure m_rootFigure;
private EditPart m_contentEditPart;
Expand All @@ -43,8 +45,7 @@ public class RootEditPart extends GraphicalEditPart implements org.eclipse.gef.R
// Constructor
//
////////////////////////////////////////////////////////////////////////////
public RootEditPart(IEditPartViewer viewer, IRootFigure rootFigure) {
m_viewer = viewer;
public RootEditPart(IRootFigure rootFigure) {
m_rootFigure = rootFigure;
createLayers();
}
Expand Down Expand Up @@ -88,7 +89,16 @@ public IEditPartViewer getViewer() {

@Override
public void setViewer(EditPartViewer viewer) {
if (m_viewer == viewer) {
return;
}
if (m_viewer != null) {
unregister();
}
m_viewer = (IEditPartViewer) viewer;
if (m_viewer != null) {
register();
}
}

/**
Expand All @@ -107,6 +117,11 @@ protected Figure createFigure() {
return null;
}

@Override
public Object getModel() {
return LayerManager.ID;
}

////////////////////////////////////////////////////////////////////////////
//
// IRootEditPart
Expand Down Expand Up @@ -152,4 +167,12 @@ public void setContents(org.eclipse.gef.EditPart contentEditPart) {
public Tool getDragTracker(Request request) {
return new MarqueeSelectionTool();
}

@Override
public IFigure getLayer(Object key) {
if (key instanceof String name) {
return m_rootFigure.getLayer(name);
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2023 Google, Inc.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -30,15 +30,6 @@ public class RootEditPart extends TreeEditPart implements org.eclipse.gef.RootEd
private IEditPartViewer m_viewer;
private TreeEditPart m_contentEditPart;

////////////////////////////////////////////////////////////////////////////
//
// Constructor
//
////////////////////////////////////////////////////////////////////////////
public RootEditPart(IEditPartViewer viewer) {
m_viewer = viewer;
}

////////////////////////////////////////////////////////////////////////////
//
// EditPart
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2024 Google, Inc. and others.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -61,7 +61,8 @@ public TreeViewer(Tree tree) {
// handle SWT events
m_eventManager = new TreeEventManager(m_tree, this);
// create root EditPart
m_rootEditPart = new RootEditPart(this);
m_rootEditPart = new RootEditPart();
m_rootEditPart.setViewer(this);
m_rootEditPart.activate();
setRootEditPart(m_rootEditPart);
// handle selection events
Expand Down
Loading