diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/ConstantSelectionPropertyEditor.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/ConstantSelectionPropertyEditor.java index d66154fd1..096ab73b7 100644 --- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/ConstantSelectionPropertyEditor.java +++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/ConstantSelectionPropertyEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -35,6 +35,7 @@ import org.eclipse.wb.internal.core.utils.ui.GridLayoutFactory; import org.eclipse.wb.internal.core.utils.ui.dialogs.ResizableDialog; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IJavaProject; @@ -65,7 +66,6 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/DisplayExpressionPropertyEditor.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/DisplayExpressionPropertyEditor.java index 8aa7af15b..39a51e139 100644 --- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/DisplayExpressionPropertyEditor.java +++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/DisplayExpressionPropertyEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -15,8 +15,8 @@ import org.eclipse.wb.internal.core.model.property.table.PropertyTable; import org.eclipse.wb.internal.core.utils.ast.AstEditor; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.swt.graphics.Point; /** * {@link PropertyEditor} that displays source of {@link Expression} from {@link GenericProperty}. diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/InnerClassPropertyEditor.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/InnerClassPropertyEditor.java index a24da607b..19fff92d9 100644 --- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/InnerClassPropertyEditor.java +++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/InnerClassPropertyEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. 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 @@ -30,13 +30,13 @@ import org.eclipse.wb.internal.core.utils.state.EditorState; import org.eclipse.wb.internal.core.utils.ui.UiUtils; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.dom.ClassInstanceCreation; import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.TypeDeclaration; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Shell; import org.apache.commons.lang3.StringUtils; diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/complex/InstanceObjectPropertyEditor.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/complex/InstanceObjectPropertyEditor.java index ba6f1980e..c0285643c 100644 --- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/complex/InstanceObjectPropertyEditor.java +++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/complex/InstanceObjectPropertyEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -37,6 +37,7 @@ import org.eclipse.wb.internal.core.utils.execution.RunnableEx; import org.eclipse.wb.internal.core.utils.state.EditorState; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.dom.ClassInstanceCreation; @@ -48,7 +49,6 @@ import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.window.Window; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.dialogs.SelectionDialog; diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/string/StringPropertyEditor.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/string/StringPropertyEditor.java index dd847227f..0133a604b 100644 --- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/string/StringPropertyEditor.java +++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/string/StringPropertyEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -92,7 +92,7 @@ protected boolean setEditorText(Property property, String text) throws Exception * Opens editing dialog. */ private void openDialog(PropertyTable propertyTable, Property property) throws Exception { - StringPropertyDialog dialog = new StringPropertyDialog(propertyTable.getShell(), property); + StringPropertyDialog dialog = new StringPropertyDialog(propertyTable.getControl().getShell(), property); if (dialog.open() == Window.OK) { } } diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/event/ListenerMethodPropertyEditor.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/event/ListenerMethodPropertyEditor.java index 8c42c7aee..660e91e41 100644 --- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/event/ListenerMethodPropertyEditor.java +++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/event/ListenerMethodPropertyEditor.java @@ -18,7 +18,7 @@ import org.eclipse.wb.internal.core.utils.execution.ExecutionUtils; import org.eclipse.wb.internal.core.utils.execution.RunnableEx; -import org.eclipse.swt.graphics.Point; +import org.eclipse.draw2d.geometry.Point; /** * Implementation of {@link PropertyEditor} for {@link ListenerMethodProperty}. diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/util/ImportantPropertiesDialog.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/util/ImportantPropertiesDialog.java index 2198d92c6..34dab5fe9 100644 --- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/util/ImportantPropertiesDialog.java +++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/util/ImportantPropertiesDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -92,7 +92,7 @@ private ImportantPropertiesDialog(Shell parentShell, JavaInfo javaInfo) { private final ObjectEventListener m_refreshListener = new ObjectEventListener() { @Override public void refreshed() throws Exception { - m_propertyTable.redraw(); + m_propertyTable.getControl().redraw(); } }; @@ -102,7 +102,7 @@ protected Control createDialogArea(Composite parent) { area.setLayout(new GridLayout()); // m_propertyTable = new PropertyTable(area, SWT.BORDER); - GridDataFactory.create(m_propertyTable).grab().fill().hintC(55, 20); + GridDataFactory.create(m_propertyTable.getControl()).grab().fill().hintC(55, 20); // install refresh listener m_javaInfo.addBroadcastListener(m_refreshListener); // show important properties diff --git a/org.eclipse.wb.core/src-draw2d/org/eclipse/wb/internal/draw2d/FigureCanvas.java b/org.eclipse.wb.core/src-draw2d/org/eclipse/wb/internal/draw2d/FigureCanvas.java index 60492d45b..bd19f2832 100644 --- a/org.eclipse.wb.core/src-draw2d/org/eclipse/wb/internal/draw2d/FigureCanvas.java +++ b/org.eclipse.wb.core/src-draw2d/org/eclipse/wb/internal/draw2d/FigureCanvas.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2023 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. 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 @@ -11,10 +11,9 @@ package org.eclipse.wb.internal.draw2d; import org.eclipse.wb.draw2d.Figure; -import org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils; +import org.eclipse.draw2d.DeferredUpdateManager; import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.LightweightSystem; import org.eclipse.draw2d.SWTGraphics; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Rectangle; @@ -23,8 +22,6 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; /** * A Canvas that contains {@link Figure Figures}. @@ -35,11 +32,7 @@ public class FigureCanvas extends org.eclipse.draw2d.FigureCanvas { private RootFigure m_rootFigure; private final Dimension m_rootPreferredSize = new Dimension(); - // TODO ptziegler: Painting the figures on the canvas is the responsibility of - // the UpdateManager, not the FigureCanvas. - @Deprecated - private Image m_bufferedImage; - private boolean m_drawCached; + private CachedUpdateManager m_updateManager; //////////////////////////////////////////////////////////////////////////// // @@ -47,9 +40,7 @@ public class FigureCanvas extends org.eclipse.draw2d.FigureCanvas { // //////////////////////////////////////////////////////////////////////////// public FigureCanvas(Composite parent, int style) { - super(parent, style | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE, createLightweightSystem()); - // add all listeners - hookControlEvents(); + super(parent, style | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE); // create root figure createRootFigure(); } @@ -66,38 +57,17 @@ private void createRootFigure() { m_rootFigure.setForegroundColor(getForeground()); m_rootFigure.setFont(getFont()); setDefaultEventManager(); + setDefaultUpdateManager(); setContents(m_rootFigure); } - private static LightweightSystem createLightweightSystem() { - return new LightweightSystem() { - private FigureCanvas getFigureCanvas() { - return (FigureCanvas) ReflectionUtils.getFieldObject(this, "canvas"); - } - - @Override - protected void controlResized() { - getFigureCanvas().disposeBufferedImage(); - super.controlResized(); - } - - @Override - public void paint(GC gc) { - org.eclipse.swt.graphics.Rectangle bounds = gc.getClipping(); - getFigureCanvas().handlePaint(gc, bounds.x, bounds.y, bounds.width, bounds.height); - } - }; - } - protected void setDefaultEventManager() { m_rootFigure.getFigureCanvas().getLightweightSystem().setEventDispatcher(new EventManager(this)); } - private void disposeBufferedImage() { - if (m_bufferedImage != null) { - m_bufferedImage.dispose(); - m_bufferedImage = null; - } + protected void setDefaultUpdateManager() { + m_updateManager = new CachedUpdateManager(this); + m_rootFigure.getFigureCanvas().getLightweightSystem().setUpdateManager(m_updateManager); } //////////////////////////////////////////////////////////////////////////// @@ -117,7 +87,7 @@ public RootFigure getRootFigure() { * Sets draw cached mode. */ public void setDrawCached(boolean value) { - m_drawCached = value; + m_updateManager.m_drawCached = value; } //////////////////////////////////////////////////////////////////////////// @@ -136,52 +106,6 @@ public Point computeSize(int wHint, int hHint, boolean changed) { // Handle events // //////////////////////////////////////////////////////////////////////////// - private void hookControlEvents() { - addListener(SWT.Dispose, new Listener() { - @Override - public void handleEvent(Event event) { - disposeBufferedImage(); - } - }); - } - - private void handlePaint(GC paintGC, int x, int y, int width, int height) { - // check draw cached mode - if (m_drawCached) { - if (m_bufferedImage == null) { - paintGC.fillRectangle(x, y, width, height); - } else { - paintGC.drawImage(m_bufferedImage, 0, 0); - } - return; - } - // check double buffered image - if (m_bufferedImage == null) { - Point size = getSize(); - m_bufferedImage = new Image(null, size.x, size.y); - } - // prepare double buffered Graphics - GC bufferedGC = new GC(m_bufferedImage); - try { - bufferedGC.setClipping(x, y, width, height); - bufferedGC.setBackground(paintGC.getBackground()); - bufferedGC.setForeground(paintGC.getForeground()); - bufferedGC.setFont(paintGC.getFont()); - bufferedGC.setLineStyle(paintGC.getLineStyle()); - bufferedGC.setLineWidth(paintGC.getLineWidth()); - bufferedGC.setXORMode(paintGC.getXORMode()); - // draw content - Graphics graphics = new SWTGraphics(bufferedGC); - int dx = -getViewport().getHorizontalRangeModel().getValue(); - int dy = -getViewport().getVerticalRangeModel().getValue(); - graphics.translate(dx, dy); - m_rootFigure.paint(graphics); - } finally { - bufferedGC.dispose(); - } - // flush painting - paintGC.drawImage(m_bufferedImage, 0, 0); - } /** * Check bounds and reconfigure scroll bar's if needed and repaint client area. @@ -204,4 +128,62 @@ public void handleRefresh(int x, int y, int width, int height) { redraw(); } } + + private static class CachedUpdateManager extends DeferredUpdateManager { + private FigureCanvas m_canvas; + private Image m_bufferedImage; + private boolean m_drawCached; + + public CachedUpdateManager(FigureCanvas canvas) { + m_canvas = canvas; + } + + @Override + protected void paint(GC paintGC) { + org.eclipse.swt.graphics.Rectangle bounds = paintGC.getClipping(); + // check draw cached mode + if (m_drawCached) { + if (m_bufferedImage == null) { + paintGC.fillRectangle(bounds); + } else { + paintGC.drawImage(m_bufferedImage, 0, 0); + } + return; + } + // check double buffered image + if (m_bufferedImage == null) { + Point size = m_canvas.getSize(); + m_bufferedImage = new Image(null, size.x, size.y); + } + // prepare double buffered Graphics + GC bufferedGC = new GC(m_bufferedImage); + try { + bufferedGC.setClipping(bounds); + bufferedGC.setBackground(paintGC.getBackground()); + bufferedGC.setForeground(paintGC.getForeground()); + bufferedGC.setFont(paintGC.getFont()); + bufferedGC.setLineStyle(paintGC.getLineStyle()); + bufferedGC.setLineWidth(paintGC.getLineWidth()); + bufferedGC.setXORMode(paintGC.getXORMode()); + // draw content + Graphics graphics = new SWTGraphics(bufferedGC); + int dx = -m_canvas.getViewport().getHorizontalRangeModel().getValue(); + int dy = -m_canvas.getViewport().getVerticalRangeModel().getValue(); + graphics.translate(dx, dy); + m_canvas.getRootFigure().paint(graphics); + } finally { + bufferedGC.dispose(); + } + // flush painting + paintGC.drawImage(m_bufferedImage, 0, 0); + } + + @Override + public void dispose() { + if (m_bufferedImage != null) { + m_bufferedImage.dispose(); + m_bufferedImage = null; + } + } + } } \ No newline at end of file diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/editor/structure/property/ComponentsPropertiesPage.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/editor/structure/property/ComponentsPropertiesPage.java index 26ef39d21..224573375 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/editor/structure/property/ComponentsPropertiesPage.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/editor/structure/property/ComponentsPropertiesPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -111,7 +111,7 @@ public void createControl(Composite parent) { } // show "properties" table { - m_stackLayout.topControl = m_propertyTable; + m_stackLayout.topControl = m_propertyTable.getControl(); m_container.layout(); } // actions @@ -237,7 +237,7 @@ private void fillContextMenu() { } } }); - m_propertyTable.setMenu(manager.createContextMenu(m_propertyTable)); + m_propertyTable.getControl().setMenu(manager.createContextMenu(m_propertyTable.getControl())); } /** @@ -419,7 +419,7 @@ public SetCategoryAction(String text, PropertyCategory category) { @Override public void run() { PropertyManager.setCategory(m_activeProperty, m_category); - m_propertyTable.redraw(); + m_propertyTable.getControl().redraw(); } private void update() { @@ -482,9 +482,9 @@ public void run() { refreshProperties(); // set focus if (m_showEvents) { - m_eventsTable.setFocus(); + m_eventsTable.getControl().setFocus(); } else { - m_propertyTable.setFocus(); + m_propertyTable.getControl().setFocus(); } } }; @@ -534,7 +534,7 @@ private void showEvents() throws Exception { m_eventsTable.setInput(properties); // show "events" table { - m_stackLayout.topControl = m_eventsTable; + m_stackLayout.topControl = m_eventsTable.getControl(); m_container.layout(); } } @@ -553,7 +553,7 @@ private void showProperties() throws Exception { } // show "property" table { - m_stackLayout.topControl = m_propertyTable; + m_stackLayout.topControl = m_propertyTable.getControl(); m_container.layout(); } } diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/ComplexProperty.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/ComplexProperty.java index b9d12792e..fc11faa44 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/ComplexProperty.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/ComplexProperty.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -17,7 +17,7 @@ import org.eclipse.wb.internal.core.model.property.table.PropertyTooltipProvider; import org.eclipse.wb.internal.core.model.property.table.PropertyTooltipTextProvider; -import org.eclipse.swt.graphics.Point; +import org.eclipse.draw2d.geometry.Point; import java.util.List; diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/AbstractComboBoxPropertyEditor.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/AbstractComboBoxPropertyEditor.java index 6cf2141cc..d97d6f4c5 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/AbstractComboBoxPropertyEditor.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/AbstractComboBoxPropertyEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -15,8 +15,8 @@ import org.eclipse.wb.internal.core.model.property.Property; import org.eclipse.wb.internal.core.model.property.table.PropertyTable; import org.eclipse.wb.internal.core.utils.execution.ExecutionUtils; -import org.eclipse.wb.internal.core.utils.execution.RunnableEx; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusEvent; @@ -24,7 +24,6 @@ import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; /** @@ -49,7 +48,7 @@ public abstract class AbstractComboBoxPropertyEditor extends TextDisplayProperty public final boolean activate(final PropertyTable propertyTable, final Property property, Point location) throws Exception { - m_combo = new CComboBox(propertyTable, SWT.NONE); + m_combo = new CComboBox(propertyTable.getControl(), SWT.NONE); // initialize addItems(property, m_combo); selectItem(property, m_combo); @@ -74,15 +73,12 @@ public void widgetSelected(SelectionEvent e) { }); m_combo.setFocus(); // schedule showing drop-down, because we don't have bounds yet - ExecutionUtils.runAsync(new RunnableEx() { - @Override - public void run() throws Exception { - m_combo.comboDropDown(true); - if (m_dropDelayedText != null) { - m_combo.setEditText(m_dropDelayedText); - m_combo.setEditSelection(m_dropDelayedText.length(), m_dropDelayedText.length()); - m_dropDelayedText = null; - } + ExecutionUtils.runAsync(() -> { + m_combo.comboDropDown(true); + if (m_dropDelayedText != null) { + m_combo.setEditText(m_dropDelayedText); + m_combo.setEditSelection(m_dropDelayedText.length(), m_dropDelayedText.length()); + m_dropDelayedText = null; } }); // keep editor active @@ -95,7 +91,7 @@ private void handleKeyPressed(PropertyTable propertyTable, Property property, Ke } else if (e.keyCode == SWT.ARROW_UP || e.keyCode == SWT.ARROW_DOWN) { e.doit = false; propertyTable.deactivateEditor(true); - propertyTable.navigate(e); + propertyTable.getEditDomain().navigate(e); } } diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/AbstractComboPropertyEditor.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/AbstractComboPropertyEditor.java index c72bef8ae..270ad254e 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/AbstractComboPropertyEditor.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/AbstractComboPropertyEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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,7 @@ import org.eclipse.wb.internal.core.model.property.Property; import org.eclipse.wb.internal.core.model.property.table.PropertyTable; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusEvent; @@ -21,7 +22,6 @@ import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; @@ -46,7 +46,7 @@ public boolean activate(final PropertyTable propertyTable, final Property proper throws Exception { // create combo { - m_combo = new CCombo3(propertyTable, SWT.NONE); + m_combo = new CCombo3(propertyTable.getControl(), SWT.NONE); m_doDropDown = true; // add items addItems(property, m_combo); diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/AbstractTextPropertyEditor.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/AbstractTextPropertyEditor.java index c45a90a0a..3698342c7 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/AbstractTextPropertyEditor.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/AbstractTextPropertyEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -13,11 +13,11 @@ import org.eclipse.wb.internal.core.model.property.Property; import org.eclipse.wb.internal.core.model.property.table.PropertyTable; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; @@ -44,7 +44,7 @@ public boolean activate(final PropertyTable propertyTable, Point location) throws Exception { // create Text { - m_textControl = new Text(propertyTable, SWT.NONE); + m_textControl = new Text(propertyTable.getControl(), SWT.NONE); new TextControlActionsManager(m_textControl); m_textControl.setEditable(isEditable()); m_textControl.setFocus(); @@ -143,7 +143,7 @@ private void handleKeyPressed(PropertyTable propertyTable, Property property, Ke } // OK, deactivate and navigate propertyTable.deactivateEditor(true); - propertyTable.navigate(e); + propertyTable.getEditDomain().navigate(e); } } diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/BooleanObjectPropertyEditor.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/BooleanObjectPropertyEditor.java index 70efe5275..7d6a72582 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/BooleanObjectPropertyEditor.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/BooleanObjectPropertyEditor.java @@ -16,8 +16,8 @@ import org.eclipse.wb.internal.core.utils.ui.DrawUtils; import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; /** * The {@link PropertyEditor} for Boolean. diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/BooleanPropertyEditor.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/BooleanPropertyEditor.java index fd335734f..3f163022f 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/BooleanPropertyEditor.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/BooleanPropertyEditor.java @@ -16,8 +16,8 @@ import org.eclipse.wb.internal.core.utils.ui.DrawUtils; import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; /** * The {@link PropertyEditor} for boolean. diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/PropertyEditor.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/PropertyEditor.java index 7430700c2..051ce48b1 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/PropertyEditor.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/PropertyEditor.java @@ -16,10 +16,10 @@ import org.eclipse.wb.internal.core.utils.IAdaptable; import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/TextDialogPropertyEditor.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/TextDialogPropertyEditor.java index 59f98368e..d0bb86341 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/TextDialogPropertyEditor.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/TextDialogPropertyEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -15,7 +15,7 @@ import org.eclipse.wb.internal.core.model.property.editor.presentation.PropertyEditorPresentation; import org.eclipse.wb.internal.core.model.property.table.PropertyTable; -import org.eclipse.swt.graphics.Point; +import org.eclipse.draw2d.geometry.Point; /** * Abstract {@link PropertyEditor} that displays text and button to open dialog. diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/presentation/ButtonPropertyEditorPresentationImpl.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/presentation/ButtonPropertyEditorPresentationImpl.java index 14b15677a..e3897b514 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/presentation/ButtonPropertyEditorPresentationImpl.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/presentation/ButtonPropertyEditorPresentationImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -15,6 +15,7 @@ import org.eclipse.wb.internal.core.utils.Pair; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Control; @@ -103,7 +104,7 @@ private Control createControl(final PropertyTable propertyTable, final Property propertyTable.setActiveProperty(property); }); // return focus on propertyTable after click - control.addListener(SWT.MouseUp, event -> propertyTable.forceFocus()); + control.addListener(SWT.MouseUp, event -> propertyTable.getControl().forceFocus()); // handle selection control.addListener(SWT.Selection, event -> { try { @@ -120,7 +121,7 @@ private Control createControl(final PropertyTable propertyTable, final Property * Creates the {@link Control} instance. By default, {@link Button} instance created. */ protected Control createControlImpl(final PropertyTable propertyTable, final Property property) { - Button button = new Button(propertyTable, getPresentation().getStyle()); + Button button = new Button(propertyTable.getControl(), getPresentation().getStyle()); button.setImage(getPresentation().getImage()); button.setToolTipText(getPresentation().getTooltip()); return button; @@ -171,11 +172,14 @@ private static void setBounds(Control control, int newX, int newY, int newWidth, control.setData("oldWidth", newWidth); control.setData("oldHeight", newHeight); // check, may be same size - if (oldWidthObject != null) { + if (oldWidthObject != null && oldHeightObject != null) { int oldWidth = oldWidthObject.intValue(); int oldHeight = oldHeightObject.intValue(); if (oldWidth == newWidth && oldHeight == newHeight) { - control.setLocation(newX, newY); + Point newLocation = new Point(newX, newY); + if (!newLocation.equals(control.getLocation())) { + control.setLocation(newLocation); + } return; } } diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/presentation/ButtonPropertyEditorPresentationImplMac.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/presentation/ButtonPropertyEditorPresentationImplMac.java index 4c0188bf3..c2b0b0091 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/presentation/ButtonPropertyEditorPresentationImplMac.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/editor/presentation/ButtonPropertyEditorPresentationImplMac.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -41,7 +41,7 @@ public ButtonPropertyEditorPresentationImplMac(ButtonPropertyEditorPresentation //////////////////////////////////////////////////////////////////////////// @Override protected final Control createControlImpl(final PropertyTable propertyTable, Property property) { - CFlatButton button = new CFlatButton(propertyTable, SWT.NONE); + CFlatButton button = new CFlatButton(propertyTable.getControl(), SWT.NONE); button.setImage(getPresentation().getImage()); button.setToolTipText(getPresentation().getTooltip()); return button; diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/PropertyTable.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/PropertyTable.java index 347173d78..1a7dbfc74 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/PropertyTable.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/PropertyTable.java @@ -25,33 +25,44 @@ import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Cursors; import org.eclipse.draw2d.Figure; +import org.eclipse.draw2d.FigureCanvas; +import org.eclipse.draw2d.FigureUtilities; import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.SWTGraphics; +import org.eclipse.draw2d.GridData; +import org.eclipse.draw2d.GridLayout; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.LineBorder; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.SeparatorBorder; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Insets; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.EditDomain; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPartFactory; +import org.eclipse.gef.EditPartViewer; +import org.eclipse.gef.editparts.AbstractGraphicalEditPart; +import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.ScrollBar; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.NotImplementedException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Set; import java.util.TreeSet; @@ -64,7 +75,7 @@ * @author lobas_av * @coverage core.model.property.table */ -public class PropertyTable extends Canvas implements ISelectionProvider { +public class PropertyTable extends ScrollingGraphicalViewer { //////////////////////////////////////////////////////////////////////////// // // Colors @@ -91,6 +102,7 @@ public class PropertyTable extends Canvas implements ISelectionProvider { private static final int MIN_COLUMN_WIDTH = 75; private static final int MARGIN_LEFT = 2; private static final int MARGIN_RIGHT = 1; + private static final int MARGIN_BOTTOM = 1; private static final int STATE_IMAGE_MARGIN_RIGHT = 4; //////////////////////////////////////////////////////////////////////////// // @@ -105,16 +117,15 @@ public class PropertyTable extends Canvas implements ISelectionProvider { // Instance fields // //////////////////////////////////////////////////////////////////////////// - private final PropertyTableTooltipHelper m_tooltipHelper; private boolean m_showAdvancedProperties; private Property[] m_rawProperties; private List m_properties; private final Set m_expandedIds = new TreeSet<>(); - private Image m_bufferedImage; private int m_rowHeight; - private int m_selection; - private int m_page; private int m_splitter = -1; + private Font m_baseFont; + private Font m_boldFont; + private Font m_italicFont; //////////////////////////////////////////////////////////////////////////// // @@ -122,59 +133,33 @@ public class PropertyTable extends Canvas implements ISelectionProvider { // //////////////////////////////////////////////////////////////////////////// public PropertyTable(Composite parent, int style) { - super(parent, style | SWT.V_SCROLL | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE); - hookControlEvents(); + createControl(parent); + setEditPartFactory(new PropertyEditPartFactory()); + setEditDomain(new PropertyEditDomain()); + getControl().addListener(SWT.Resize, event -> handleResize()); // calculate sizes - { - GC gc = new GC(this); - try { - m_rowHeight = 1 + gc.getFontMetrics().getHeight() + 1; - } finally { - gc.dispose(); - } - } - // install tooltip helper - m_tooltipHelper = new PropertyTableTooltipHelper(this); + m_rowHeight = 1 + FigureUtilities.getFontMetrics(getControl().getFont()).getHeight() + 1; + m_baseFont = parent.getFont(); + m_boldFont = DrawUtils.getBoldFont(m_baseFont); + m_italicFont = DrawUtils.getItalicFont(m_baseFont); + // Initialize with + setInput(null); } - //////////////////////////////////////////////////////////////////////////// - // - // Events - // - //////////////////////////////////////////////////////////////////////////// - /** - * Adds listeners for events. - */ - private void hookControlEvents() { - addListener(SWT.Dispose, event -> disposeBufferedImage()); - addListener(SWT.Resize, event -> handleResize()); - addListener(SWT.Paint, event -> handlePaint(event.gc, event.x, event.y, event.width, event.height)); - getVerticalBar().addListener(SWT.Selection, event -> handleVerticalScrolling()); - addMouseListener(new MouseAdapter() { - @Override - public void mouseDown(MouseEvent event) { - forceFocus(); - handleMouseDown(event); - } + @Override + protected void handleDispose(DisposeEvent e) { + m_boldFont.dispose(); + m_italicFont.dispose(); + } - @Override - public void mouseUp(MouseEvent event) { - handleMouseUp(event); - } + @Override + public FigureCanvas getControl() { + return (FigureCanvas) super.getControl(); + } - @Override - public void mouseDoubleClick(MouseEvent event) { - handleMouseDoubleClick(event); - } - }); - addMouseMoveListener(event -> handleMouseMove(event)); - // keyboard - addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - handleKeyDown(e); - } - }); + @Override + public PropertyEditDomain getEditDomain() { + return (PropertyEditDomain) super.getEditDomain(); } //////////////////////////////////////////////////////////////////////////// @@ -182,297 +167,21 @@ public void keyPressed(KeyEvent e) { // Events: dispose, resize, scroll // //////////////////////////////////////////////////////////////////////////// - /** - * Disposes image used for double buffered painting. - */ - private void disposeBufferedImage() { - if (m_bufferedImage != null) { - m_bufferedImage.dispose(); - m_bufferedImage = null; - } - } /** * Handles {@link SWT#Resize} event. */ private void handleResize() { - disposeBufferedImage(); - configureScrolling(); // splitter { // set default value for splitter if (m_splitter <= MIN_COLUMN_WIDTH) { - m_splitter = Math.max((int) (getClientArea().width * 0.4), MIN_COLUMN_WIDTH); + m_splitter = Math.max((int) (getControl().getClientArea().width * 0.4), MIN_COLUMN_WIDTH); } configureSplitter(); } } - /** - * Handles {@link SWT#Selection} event for vertical {@link ScrollBar}. - */ - private void handleVerticalScrolling() { - ScrollBar verticalBar = getVerticalBar(); - if (verticalBar.getEnabled()) { - // update selection - m_selection = verticalBar.getSelection(); - // redraw (but not include vertical bar to avoid flashing) - { - org.eclipse.swt.graphics.Rectangle clientArea = getClientArea(); - redraw(clientArea.x, clientArea.y, clientArea.width, clientArea.height, false); - } - } - } - - //////////////////////////////////////////////////////////////////////////// - // - // Keyboard - // - //////////////////////////////////////////////////////////////////////////// - /** - * Handles {@link SWT#KeyDown} event. - */ - private void handleKeyDown(KeyEvent e) { - if (m_activePropertyInfo != null) { - try { - Property property = m_activePropertyInfo.getProperty(); - // expand/collapse - if (m_activePropertyInfo.isComplex()) { - if (!m_activePropertyInfo.isExpanded() && (e.character == '+' || e.keyCode == SWT.ARROW_RIGHT)) { - m_activePropertyInfo.expand(); - configureScrolling(); - return; - } - if (m_activePropertyInfo.isExpanded() && (e.character == '-' || e.keyCode == SWT.ARROW_LEFT)) { - m_activePropertyInfo.collapse(); - configureScrolling(); - return; - } - } - // navigation - if (navigate(e)) { - return; - } - // editor activation - if (e.character == ' ' || e.character == SWT.CR) { - activateEditor(property, null); - return; - } - // DEL - if (e.keyCode == SWT.DEL) { - e.doit = false; - property.setValue(Property.UNKNOWN_VALUE); - return; - } - // send to editor - property.getEditor().keyDown(this, property, e); - } catch (Throwable ex) { - DesignerPlugin.log(ex); - } - } - } - - /** - * @return true if given {@link KeyEvent} was navigation event, so - * new {@link PropertyInfo} was selected. - */ - public boolean navigate(KeyEvent e) { - int index = m_properties.indexOf(m_activePropertyInfo); - org.eclipse.swt.graphics.Rectangle clientArea = getClientArea(); - // - int newIndex = index; - if (e.keyCode == SWT.HOME) { - newIndex = 0; - } else if (e.keyCode == SWT.END) { - newIndex = m_properties.size() - 1; - } else if (e.keyCode == SWT.PAGE_UP) { - newIndex = Math.max(index - m_page + 1, 0); - } else if (e.keyCode == SWT.PAGE_DOWN) { - newIndex = Math.min(index + m_page - 1, m_properties.size() - 1); - } else if (e.keyCode == SWT.ARROW_UP) { - newIndex = Math.max(index - 1, 0); - } else if (e.keyCode == SWT.ARROW_DOWN) { - newIndex = Math.min(index + 1, m_properties.size() - 1); - } - // activate new property - if (newIndex != index && newIndex < m_properties.size()) { - setActivePropertyInfo(m_properties.get(newIndex)); - // check for scrolling - int y = m_rowHeight * (newIndex - m_selection); - if (y < 0) { - m_selection = newIndex; - configureScrolling(); - } else if (y + m_rowHeight > clientArea.height) { - m_selection = newIndex - m_page + 1; - configureScrolling(); - } - // repaint - redraw(); - return true; - } - // no navigation change - return false; - } - - //////////////////////////////////////////////////////////////////////////// - // - // Events: mouse - // - //////////////////////////////////////////////////////////////////////////// - private boolean m_splitterResizing; - /** - * We do expand/collapse on to events: click on state sign and on double click. - * But when we double click on state sign, we will have two events, so - * we should ignore double click. - */ - private long m_lastExpandCollapseTime; - - /** - * Handles {@link SWT#MouseDown} event. - */ - private void handleMouseDown(MouseEvent event) { - m_splitterResizing = event.button == 1 && m_properties != null && isLocationSplitter(event.x); - // click in property - if (!m_splitterResizing && m_properties != null) { - int propertyIndex = getPropertyIndex(event.y); - if (propertyIndex >= m_properties.size()) { - return; - } - // prepare property - setActivePropertyInfo(m_properties.get(propertyIndex)); - Property property = m_activePropertyInfo.getProperty(); - // de-activate current editor - deactivateEditor(true); - redraw(); - // activate editor - if (isLocationValue(event.x)) { - activateEditor(property, getValueRelativeLocation(event.x, event.y)); - } - } - } - - /** - * Handles {@link SWT#MouseUp} event. - */ - private void handleMouseUp(MouseEvent event) { - if (event.button == 1) { - // resize splitter - if (m_splitterResizing) { - m_splitterResizing = false; - return; - } - // if out of bounds, then ignore - if (!getClientArea().contains(event.x, event.y)) { - return; - } - // update - if (m_properties != null) { - int index = getPropertyIndex(event.y); - if (index < m_properties.size()) { - PropertyInfo propertyInfo = m_properties.get(index); - // check for expand/collapse - if (isLocationState(propertyInfo, event.x)) { - try { - m_lastExpandCollapseTime = System.currentTimeMillis(); - propertyInfo.flip(); - configureScrolling(); - } catch (Throwable e) { - DesignerPlugin.log(e); - } - } - } - } - } - } - - /** - * Handles {@link SWT#MouseDoubleClick} event. - */ - private void handleMouseDoubleClick(MouseEvent event) { - if (System.currentTimeMillis() - m_lastExpandCollapseTime > getDisplay().getDoubleClickTime()) { - try { - if (m_activePropertyInfo != null) { - if (m_activePropertyInfo.isComplex()) { - m_activePropertyInfo.flip(); - configureScrolling(); - } else { - Property property = m_activePropertyInfo.getProperty(); - property.getEditor().doubleClick(property, getValueRelativeLocation(event.x, event.y)); - } - } - } catch (Throwable e) { - handleException(e); - } - } - } - - /** - * Handles {@link SWT#MouseMove} event. - */ - private void handleMouseMove(MouseEvent event) { - int x = event.x; - // resize splitter - if (m_splitterResizing) { - m_splitter = x; - configureSplitter(); - redraw(); - return; - } - // if out of bounds, then ignore - if (!getClientArea().contains(event.x, event.y)) { - return; - } - // update - if (m_properties != null) { - // update cursor - if (isLocationSplitter(x)) { - setCursor(Cursors.SIZEWE); - } else { - setCursor(null); - } - // update tooltip helper - updateTooltip(event); - } else { - updateTooltipNoProperty(); - } - } - - /** - * Updates {@link PropertyTableTooltipHelper}. - */ - private void updateTooltip(MouseEvent event) { - int x = event.x; - int propertyIndex = getPropertyIndex(event.y); - // - if (propertyIndex < m_properties.size()) { - PropertyInfo propertyInfo = m_properties.get(propertyIndex); - Property property = propertyInfo.getProperty(); - int y = (propertyIndex - m_selection) * m_rowHeight; - // check for title - { - int titleX = getTitleTextX(propertyInfo); - int titleRight = m_splitter - 2; - if (titleX <= x && x < titleRight) { - m_tooltipHelper.update(property, true, false, titleX, titleRight, y, m_rowHeight); - return; - } - } - // check for value - { - int valueX = m_splitter + 3; - if (x > valueX) { - m_tooltipHelper.update(property, false, true, valueX, getClientArea().width, y, m_rowHeight); - } - } - } else { - updateTooltipNoProperty(); - } - } - - private void updateTooltipNoProperty() { - m_tooltipHelper.update(null, false, false, 0, 0, 0, 0); - } - //////////////////////////////////////////////////////////////////////////// // // Editor @@ -536,11 +245,12 @@ private void setActiveEditorBounds() { // prepare bounds for editor org.eclipse.swt.graphics.Rectangle bounds; { - org.eclipse.swt.graphics.Rectangle clientArea = getClientArea(); + PropertyEditPart editPart = (PropertyEditPart) getEditPartRegistry().get(m_activePropertyInfo); + Rectangle figureBounds = getAbsoluteBounds(editPart); int x = m_splitter + 1; - int width = clientArea.width - x - MARGIN_RIGHT; - int y = m_rowHeight * (index - m_selection) + 1; - int height = m_rowHeight - 1; + int y = figureBounds.top(); + int width = getControl().getClientArea().width - x - MARGIN_RIGHT; + int height = figureBounds.height() - MARGIN_BOTTOM; bounds = new org.eclipse.swt.graphics.Rectangle(x, y, width, height); } // update bounds using presentation @@ -580,34 +290,6 @@ public void handleException(Throwable e) { m_exceptionHandler.handle(e); } - //////////////////////////////////////////////////////////////////////////// - // - // Scrolling - // - //////////////////////////////////////////////////////////////////////////// - /** - * Configures vertical {@link ScrollBar}. - */ - private void configureScrolling() { - ScrollBar verticalBar = getVerticalBar(); - if (m_properties == null) { - verticalBar.setEnabled(false); - } else { - m_page = getClientArea().height / m_rowHeight; - m_selection = Math.max(0, Math.min(m_properties.size() - m_page, m_selection)); - verticalBar.setValues(m_selection, 0, m_properties.size(), m_page, 1, m_page); - // enable/disable scrolling - if (m_properties.size() <= m_page) { - verticalBar.setEnabled(false); - } else { - verticalBar.setEnabled(true); - } - } - // redraw, we reconfigure scrolling only if list of properties was changed, so - // we should redraw - redraw(); - } - //////////////////////////////////////////////////////////////////////////// // // Location/size utils @@ -629,6 +311,17 @@ private int getTitleTextX(PropertyInfo propertyInfo) { return getTitleX(propertyInfo) + getLevelIndent(); } + /** + * @return the bounds of the given edit part relative to the top right corner of + * the viewport. + */ + private static Rectangle getAbsoluteBounds(PropertyEditPart editPart) { + IFigure figure = editPart.getFigure(); + Rectangle bounds = figure.getBounds().getCopy(); + figure.translateToAbsolute(bounds); + return bounds; + } + /** * @return the indentation for single level. */ @@ -640,7 +333,7 @@ private int getLevelIndent() { * Checks horizontal splitter value to boundary values. */ private void configureSplitter() { - org.eclipse.swt.graphics.Rectangle clientArea = getClientArea(); + org.eclipse.swt.graphics.Rectangle clientArea = getControl().getClientArea(); // check title width if (m_splitter < MIN_COLUMN_WIDTH) { m_splitter = MIN_COLUMN_WIDTH; @@ -651,14 +344,6 @@ private void configureSplitter() { } } - /** - * @return the index in {@link #m_properties} corresponding given y - * location. - */ - private int getPropertyIndex(int y) { - return m_selection + y / m_rowHeight; - } - /** * @return true if given x coordinate is on state * (plus/minus) image. @@ -690,7 +375,8 @@ private boolean isLocationValue(int x) { * @return the location relative to the value part of property. */ private Point getValueRelativeLocation(int x, int y) { - return new Point(x - (m_splitter + 2), y - m_rowHeight * getPropertyIndex(y)); + PropertyEditPart editPart = (PropertyEditPart) findObjectAt(new Point(x, y)); + return new Point(x - (m_splitter + 2), getAbsoluteBounds(editPart).top()); } //////////////////////////////////////////////////////////////////////////// @@ -773,8 +459,7 @@ private void setInput0() { // set new PropertyInfo setActivePropertyInfo(newActivePropertyInfo); } - // update scroll bar - configureScrolling(); + setContents(m_properties); } /** @@ -847,13 +532,13 @@ public int forTests_getSplitter() { /** * @return the location of state image (plus/minus) for given {@link Property}. */ - public Point forTests_getStateLocation(Property property) { + public org.eclipse.swt.graphics.Point forTests_getStateLocation(Property property) { PropertyInfo propertyInfo = getPropertyInfo(property); if (propertyInfo != null) { - int index = m_properties.indexOf(propertyInfo); + PropertyEditPart editPart = (PropertyEditPart) getEditPartRegistry().get(propertyInfo); int x = getTitleX(propertyInfo); - int y = m_rowHeight * (index - m_selection) + 1; - return new Point(x, y); + int y = getAbsoluteBounds(editPart).y(); + return new org.eclipse.swt.graphics.Point(x, y); } return null; } @@ -861,13 +546,13 @@ public Point forTests_getStateLocation(Property property) { /** * @return the location of state image (plus/minus) for given {@link Property}. */ - public Point forTests_getValueLocation(Property property) { + public org.eclipse.swt.graphics.Point forTests_getValueLocation(Property property) { PropertyInfo propertyInfo = getPropertyInfo(property); if (propertyInfo != null) { - int index = m_properties.indexOf(propertyInfo); + PropertyEditPart editPart = (PropertyEditPart) getEditPartRegistry().get(propertyInfo); int x = m_splitter + 5; - int y = m_rowHeight * (index - m_selection) + 1; - return new Point(x, y); + int y = getAbsoluteBounds(editPart).y(); + return new org.eclipse.swt.graphics.Point(x, y); } return null; } @@ -904,19 +589,6 @@ private PropertyInfo getPropertyInfo(Property property) { // ISelectionProvider // //////////////////////////////////////////////////////////////////////////// - private final List m_selectionListeners = new ArrayList<>(); - - @Override - public void addSelectionChangedListener(ISelectionChangedListener listener) { - if (!m_selectionListeners.contains(listener)) { - m_selectionListeners.add(listener); - } - } - - @Override - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - m_selectionListeners.add(listener); - } @Override public ISelection getSelection() { @@ -947,252 +619,434 @@ private void setActivePropertyInfo(PropertyInfo activePropertyInfo) { m_activePropertyId = m_activePropertyInfo.m_id; } // make sure that active property is visible - if (m_activePropertyInfo != null) { - int row = m_properties.indexOf(m_activePropertyInfo); - if (m_selection <= row && row < m_selection + m_page) { - } else { - m_selection = row; - configureScrolling(); - } + if (getEditPartRegistry().get(m_activePropertyInfo) instanceof PropertyEditPart editPart) { + reveal(editPart); } // send events - SelectionChangedEvent selectionEvent = new SelectionChangedEvent(this, getSelection()); - for (ISelectionChangedListener listener : m_selectionListeners) { - listener.selectionChanged(selectionEvent); - } + fireSelectionChanged(); // re-draw - redraw(); + getControl().redraw(); } //////////////////////////////////////////////////////////////////////////// // - // Painting + // PropertyCategory // //////////////////////////////////////////////////////////////////////////// - private boolean m_painting; - private Font m_baseFont; - private Font m_boldFont; - private Font m_italicFont; + private PropertyCategoryProvider m_propertyCategoryProvider = PropertyCategoryProviders.fromProperty(); + + /** + * Sets the {@link PropertyCategoryProvider} that can be used to tweak usual + * {@link PropertyCategory}. + */ + public void setPropertyCategoryProvider(PropertyCategoryProvider propertyCategoryProvider) { + m_propertyCategoryProvider = propertyCategoryProvider; + } /** - * Handles {@link SWT#Paint} event. + * @return the {@link PropertyCategory} that is used by this + * {@link PropertyTable} to display. */ - private void handlePaint(GC gc, int x, int y, int width, int height) { - // sometimes we disable Eclipse Shell to prevent user actions, but we do this - // for short time - if (!isEnabled()) { - return; - } - // prevent recursion - if (m_painting) { - return; - } - m_painting = true; + private PropertyCategory getCategory(Property property) { + return m_propertyCategoryProvider.getCategory(property); + } + + //////////////////////////////////////////////////////////////////////////// + // + // Events + // + //////////////////////////////////////////////////////////////////////////// + + public class PropertyEditDomain extends EditDomain { + private final PropertyTableTooltipHelper m_tooltipHelper = new PropertyTableTooltipHelper(PropertyTable.this); + private boolean m_splitterResizing; + /** + * We do expand/collapse on to events: click on state sign and on double click. + * But when we double click on state sign, we will have two events, so + * we should ignore double click. + */ + private long m_lastExpandCollapseTime; + + //////////////////////////////////////////////////////////////////////////// // - try { - setActiveEditorBounds(); - // prepare buffered image - if (m_bufferedImage == null || m_bufferedImage.isDisposed()) { - Point size = getSize(); - m_bufferedImage = new Image(DesignerPlugin.getStandardDisplay(), size.x, size.y); + // Events: mouse + // + //////////////////////////////////////////////////////////////////////////// + + @Override + public void mouseDown(MouseEvent event, EditPartViewer viewer) { + m_splitterResizing = event.button == 1 && m_properties != null && isLocationSplitter(event.x); + // click in property + if (!m_splitterResizing && findObjectAt(new Point(event.x, event.y)) instanceof PropertyEditPart editPart) { + // prepare property + setActivePropertyInfo(editPart.getModel()); + Property property = m_activePropertyInfo.getProperty(); + // de-activate current editor + deactivateEditor(true); + getControl().redraw(); + // activate editor + if (isLocationValue(event.x)) { + activateEditor(property, getValueRelativeLocation(event.x, event.y)); + } } - // prepare buffered GC - GC bufferedGC = null; - try { - // perform some drawing - { - bufferedGC = new GC(m_bufferedImage); - bufferedGC.setClipping(x, y, width, height); - bufferedGC.setBackground(gc.getBackground()); - bufferedGC.setForeground(gc.getForeground()); - bufferedGC.setFont(gc.getFont()); - bufferedGC.setLineStyle(gc.getLineStyle()); - bufferedGC.setLineWidth(gc.getLineWidth()); + } + + @Override + public void mouseUp(MouseEvent event, EditPartViewer viewer) { + if (event.button == 1) { + // resize splitter + if (m_splitterResizing) { + m_splitterResizing = false; + return; } - // fill client area - { - org.eclipse.swt.graphics.Rectangle clientArea = getClientArea(); - bufferedGC.setBackground(COLOR_BACKGROUND); - bufferedGC.fillRectangle(clientArea); + // if out of bounds, then ignore + if (!getControl().getClientArea().contains(event.x, event.y)) { + return; } - // draw content - if (m_properties == null) { - drawEmptyContent(bufferedGC); - } else { - Graphics graphics = new SWTGraphics(bufferedGC); - try { - drawContent(graphics); - } catch (Exception e) { - DesignerPlugin.log(e); - } finally { - graphics.dispose(); + // update + if (findObjectAt(new Point(event.x, event.y)) instanceof PropertyEditPart editPart) { + PropertyInfo propertyInfo = editPart.getModel(); + // check for expand/collapse + if (isLocationState(propertyInfo, event.x)) { + try { + m_lastExpandCollapseTime = System.currentTimeMillis(); + propertyInfo.flip(); + } catch (Throwable e) { + DesignerPlugin.log(e); + } } } - } finally { - // flush image - if (bufferedGC != null) { - bufferedGC.dispose(); - } } - gc.drawImage(m_bufferedImage, 0, 0); - } finally { - m_painting = false; } - } - /** - * Draws content when there are no properties. - */ - private void drawEmptyContent(GC gc) { - org.eclipse.swt.graphics.Rectangle area = getClientArea(); - // draw message - gc.setForeground(COLOR_NO_PROPERTIES); - DrawUtils.drawStringCHCV(gc, ModelMessages.PropertyTable_noProperties, 0, 0, area.width, area.height); - } + @Override + public void mouseDoubleClick(MouseEvent event, EditPartViewer viewer) { + if (System.currentTimeMillis() - m_lastExpandCollapseTime > getControl().getDisplay() + .getDoubleClickTime()) { + try { + if (m_activePropertyInfo != null) { + if (m_activePropertyInfo.isComplex()) { + m_activePropertyInfo.flip(); + } else { + Property property = m_activePropertyInfo.getProperty(); + property.getEditor().doubleClick(property, getValueRelativeLocation(event.x, event.y)); + } + } + } catch (Throwable e) { + handleException(e); + } + } + } - /** - * Draws all {@link PropertyInfo}'s, separators, etc. - */ - private void drawContent(Graphics graphics) { - org.eclipse.swt.graphics.Rectangle clientArea = getClientArea(); - // prepare fonts - m_baseFont = graphics.getFont(); - m_boldFont = DrawUtils.getBoldFont(m_baseFont); - m_italicFont = DrawUtils.getItalicFont(m_baseFont); - // show presentations - int[] presentationsWidth = showPresentations(clientArea); - // draw properties - { - int y = clientArea.y - m_rowHeight * m_selection; - for (int i = 0; i < m_properties.size(); i++) { - // skip, if not visible yet - if (y + m_rowHeight < 0) { - y += m_rowHeight; - continue; + @Override + public void mouseMove(MouseEvent event, EditPartViewer viewer) { + // if out of bounds, then ignore + if (!getControl().getClientArea().contains(event.x, event.y)) { + return; + } + // update + if (findObjectAt(new Point(event.x, event.y)) instanceof PropertyEditPart) { + // update cursor + if (isLocationSplitter(event.x)) { + getControl().setCursor(Cursors.SIZEWE); + } else { + getControl().setCursor(null); } - // stop, if already invisible - if (y > clientArea.height) { - break; + // update tooltip helper + updateTooltip(event); + } else { + updateTooltipNoProperty(); + } + } + + @Override + public void mouseDrag(MouseEvent event, EditPartViewer viewer) { + // resize splitter + if (m_splitterResizing) { + m_splitter = event.x; + configureSplitter(); + getControl().redraw(); + } + } + + /** + * Updates {@link PropertyTableTooltipHelper}. + */ + private void updateTooltip(MouseEvent event) { + int x = event.x; + // + if (findObjectAt(new Point(x, event.y)) instanceof PropertyEditPart editPart) { + PropertyInfo propertyInfo = editPart.getModel(); + Property property = propertyInfo.getProperty(); + int y = getAbsoluteBounds(editPart).bottom(); + // check for title + { + int titleX = getTitleTextX(propertyInfo); + int titleRight = m_splitter - 2; + if (titleX <= x && x < titleRight) { + m_tooltipHelper.update(property, true, false, titleX, titleRight, y, m_rowHeight); + return; + } } - // draw single property + // check for value { - PropertyInfo propertyInfo = m_properties.get(i); - PropertyFigure propertyFigure = new PropertyFigure(propertyInfo); - propertyFigure.setBounds(new Rectangle(0, y + 1, clientArea.width - presentationsWidth[i], m_rowHeight - 1)); - propertyFigure.paint(graphics); - y += m_rowHeight; + int valueX = m_splitter + 3; + if (x > valueX) { + m_tooltipHelper.update(property, false, true, valueX, getControl().getClientArea().width, y, + m_rowHeight); + } } - // draw row separator - graphics.setForegroundColor(COLOR_LINE); - graphics.drawLine(0, y, clientArea.width, y); + } else { + updateTooltipNoProperty(); } } - // draw expand line - drawExpandLines(graphics, clientArea); - // draw rectangle around table - graphics.setForegroundColor(COLOR_LINE); - graphics.drawRectangle(0, 0, clientArea.width - 1, clientArea.height - 1); - // draw splitter - graphics.setForegroundColor(COLOR_LINE); - graphics.drawLine(m_splitter, 0, m_splitter, clientArea.height); - // dispose font - m_boldFont.dispose(); - m_italicFont.dispose(); - } - /** - * Shows {@link PropertyEditorPresentation}'s for all {@link Property}'s, i.e. - * updates also their bounds. So, some {@link PropertyEditorPresentation}'s - * become invisible because they are moved above or below visible client area. - * - * @return the array of width for each {@link PropertyEditorPresentation}'s, - * consumed on the right. - */ - private int[] showPresentations(org.eclipse.swt.graphics.Rectangle clientArea) { - int[] presentationsWidth = new int[m_properties.size()]; - // prepare value rectangle - int x = m_splitter + 4; - int w = clientArea.width - x - MARGIN_RIGHT; - // show presentation's for all properties - int y = clientArea.y - m_rowHeight * m_selection; - for (int i = 0; i < m_properties.size(); i++) { - PropertyInfo propertyInfo = m_properties.get(i); - Property property = propertyInfo.getProperty(); - PropertyEditorPresentation presentation = property.getEditor().getPresentation(); - if (presentation != null) { - presentationsWidth[i] = presentation.show(this, property, x, y + 1, w, m_rowHeight - 1); - } - y += m_rowHeight; + private void updateTooltipNoProperty() { + m_tooltipHelper.update(null, false, false, 0, 0, 0, 0); } - return presentationsWidth; - } - /** - * Draws lines from expanded complex property to its last sub-property. - */ - private void drawExpandLines(Graphics graphics, org.eclipse.swt.graphics.Rectangle clientArea) { - int height = m_rowHeight - 1; - int xOffset = m_plusImage.getBounds().width / 2; - int yOffset = (height - m_plusImage.getBounds().width) / 2; + //////////////////////////////////////////////////////////////////////////// // - int y = clientArea.y - m_selection * m_rowHeight; - graphics.setForegroundColor(COLOR_COMPLEX_LINE); - for (int i = 0; i < m_properties.size(); i++) { - PropertyInfo propertyInfo = m_properties.get(i); - // - if (propertyInfo.isExpanded()) { - int index = m_properties.indexOf(propertyInfo); - // prepare index of last sub-property - int index2 = index; - for (; index2 < m_properties.size(); index2++) { - PropertyInfo nextPropertyInfo = m_properties.get(index2); - if (nextPropertyInfo != propertyInfo && nextPropertyInfo.getLevel() <= propertyInfo.getLevel()) { - break; + // Keyboard + // + //////////////////////////////////////////////////////////////////////////// + + @Override + public void keyDown(KeyEvent e, EditPartViewer viewer) { + if (m_activePropertyInfo != null) { + try { + Property property = m_activePropertyInfo.getProperty(); + // expand/collapse + if (m_activePropertyInfo.isComplex()) { + if (!m_activePropertyInfo.isExpanded() + && (e.character == '+' || e.keyCode == SWT.ARROW_RIGHT)) { + m_activePropertyInfo.expand(); + return; + } + if (m_activePropertyInfo.isExpanded() && (e.character == '-' || e.keyCode == SWT.ARROW_LEFT)) { + m_activePropertyInfo.collapse(); + return; + } } - } - index2--; - // draw line if there are children - if (index2 > index) { - int x = getTitleX(propertyInfo) + xOffset; - int y1 = y + height - yOffset; - int y2 = y + m_rowHeight * (index2 - index) + m_rowHeight / 2; - graphics.drawLine(x, y1, x, y2); - graphics.drawLine(x, y2, x + m_rowHeight / 3, y2); + // navigation + if (navigate(e)) { + return; + } + // editor activation + if (e.character == ' ' || e.character == SWT.CR) { + activateEditor(property, null); + return; + } + // DEL + if (e.keyCode == SWT.DEL) { + e.doit = false; + property.setValue(Property.UNKNOWN_VALUE); + return; + } + // send to editor + property.getEditor().keyDown(PropertyTable.this, property, e); + } catch (Throwable ex) { + DesignerPlugin.log(ex); } } + } + + /** + * @return true if given {@link KeyEvent} was navigation event, so + * new {@link PropertyInfo} was selected. + */ + public boolean navigate(KeyEvent e) { + int index = m_properties.indexOf(m_activePropertyInfo); + int page = getControl().getClientArea().height / m_rowHeight; // - y += m_rowHeight; + int newIndex = index; + if (e.keyCode == SWT.HOME) { + newIndex = 0; + } else if (e.keyCode == SWT.END) { + newIndex = m_properties.size() - 1; + } else if (e.keyCode == SWT.PAGE_UP) { + newIndex = Math.max(index - page + 1, 0); + } else if (e.keyCode == SWT.PAGE_DOWN) { + newIndex = Math.min(index + page - 1, m_properties.size() - 1); + } else if (e.keyCode == SWT.ARROW_UP) { + newIndex = Math.max(index - 1, 0); + } else if (e.keyCode == SWT.ARROW_DOWN) { + newIndex = Math.min(index + 1, m_properties.size() - 1); + } + // activate new property + if (newIndex != index && newIndex < m_properties.size()) { + setActivePropertyInfo(m_properties.get(newIndex)); + return true; + } + // no navigation change + return false; } } //////////////////////////////////////////////////////////////////////////// // - // PropertyCategory + // PropertyFigure // //////////////////////////////////////////////////////////////////////////// - private PropertyCategoryProvider m_propertyCategoryProvider = PropertyCategoryProviders.fromProperty(); - /** - * Sets the {@link PropertyCategoryProvider} that can be used to tweak usual - * {@link PropertyCategory}. - */ - public void setPropertyCategoryProvider(PropertyCategoryProvider propertyCategoryProvider) { - m_propertyCategoryProvider = propertyCategoryProvider; + public class PropertyEditPartFactory implements EditPartFactory { + @Override + @SuppressWarnings("unchecked") + public EditPart createEditPart(EditPart context, Object model) { + if (model instanceof List properties) { + if (properties.isEmpty()) { + return new NoPropertyEditPart(); + } + return new PropertyRootEditPart((List) model); + } + return new PropertyEditPart((PropertyInfo) model); + } } - /** - * @return the {@link PropertyCategory} that is used by this - * {@link PropertyTable} to display. - */ - private PropertyCategory getCategory(Property property) { - return m_propertyCategoryProvider.getCategory(property); + private static class NoPropertyEditPart extends AbstractGraphicalEditPart { + + @Override + protected IFigure createFigure() { + Label label = new Label(); + label.setBackgroundColor(COLOR_BACKGROUND); + label.setForegroundColor(COLOR_NO_PROPERTIES); + label.setText(ModelMessages.PropertyTable_noProperties); + label.setOpaque(true); + return label; + } + + @Override + protected void createEditPolicies() { + // Nothing to do + } + } - //////////////////////////////////////////////////////////////////////////// - // - // PropertyFigure - // - //////////////////////////////////////////////////////////////////////////// + private final class PropertyRootEditPart extends AbstractGraphicalEditPart { + public PropertyRootEditPart(List model) { + setModel(model); + } + + @Override + protected IFigure createFigure() { + GridLayout gridLayout = new GridLayout(); + gridLayout.marginHeight = 0; + gridLayout.marginWidth = 0; + gridLayout.horizontalSpacing = 0; + gridLayout.verticalSpacing = 0; + + LineBorder border = new LineBorder(COLOR_LINE) { + @Override + public void paint(IFigure f, Graphics g, Insets i) { + // draw rectangle around figure + super.paint(f, g, i); + // draw expand line + tempRect = getPaintRectangle(f, i); + drawExpandLines(g, tempRect); + // draw splitter + tempRect = getPaintRectangle(f, i); + g.drawLine(m_splitter, 0, m_splitter, tempRect.height); + } + + //////////////////////////////////////////////////////////////////////////// + // + // Painting + // + //////////////////////////////////////////////////////////////////////////// + + /** + * Draws lines from expanded complex property to its last sub-property. + */ + private void drawExpandLines(Graphics graphics, Rectangle clientArea) { + int height = m_rowHeight - MARGIN_BOTTOM; + int xOffset = m_plusImage.getBounds().width / 2; + int yOffset = (height - m_plusImage.getBounds().width) / 2; + // + graphics.setForegroundColor(COLOR_COMPLEX_LINE); + for (int i = 0; i < m_properties.size(); i++) { + PropertyInfo propertyInfo = m_properties.get(i); + // + if (propertyInfo.isExpanded()) { + int index = m_properties.indexOf(propertyInfo); + // prepare index of last sub-property + int index2 = index; + for (; index2 < m_properties.size(); index2++) { + PropertyInfo nextPropertyInfo = m_properties.get(index2); + if (nextPropertyInfo != propertyInfo + && nextPropertyInfo.getLevel() <= propertyInfo.getLevel()) { + break; + } + } + index2--; + // draw line if there are children + if (index2 > index + && getEditPartRegistry().get(propertyInfo) instanceof PropertyEditPart editPart) { + int y = editPart.getFigure().getBounds().top(); + int x = getTitleX(propertyInfo) + xOffset; + int y1 = y + height - yOffset; + int y2 = y + m_rowHeight * (index2 - index) + m_rowHeight / 2; + graphics.drawLine(x, y1, x, y2); + graphics.drawLine(x, y2, x + m_rowHeight / 3, y2); + } + } + // + } + } + }; + // + figure = new Figure(); + figure.setBorder(border); + figure.setBackgroundColor(COLOR_BACKGROUND); + figure.setLayoutManager(gridLayout); + figure.setOpaque(true); + return figure; + } + + @Override + protected void createEditPolicies() { + // Nothing to do + } + + @Override + @SuppressWarnings("unchecked") + public List getModel() { + return (List) super.getModel(); + } + + @Override + protected List getModelChildren() { + List model = getModel(); + if (model == null) { + return Collections.emptyList(); + } + return Collections.unmodifiableList(model); + } + } + + private final class PropertyEditPart extends AbstractGraphicalEditPart { + public PropertyEditPart(PropertyInfo propertyInfo) { + setModel(propertyInfo); + } + + @Override + public PropertyInfo getModel() { + return (PropertyInfo) super.getModel(); + } + + @Override + protected IFigure createFigure() { + SeparatorBorder border = new SeparatorBorder(new Insets(0, 0, MARGIN_BOTTOM, 1), PositionConstants.BOTTOM); + border.setColor(COLOR_LINE); + figure = new PropertyFigure(getModel()); + figure.setBorder(border); + return figure; + } + + @Override + protected void createEditPolicies() { + // Nothing to do + } + } private final class PropertyFigure extends Figure { private final PropertyInfo m_propertyInfo; @@ -1201,6 +1055,19 @@ public PropertyFigure(PropertyInfo propertyInfo) { m_propertyInfo = propertyInfo; } + @Override + public void setParent(IFigure parent) { + super.setParent(parent); + if (parent != null) { + parent.setConstraint(this, new GridData(SWT.FILL, SWT.FILL, true, false)); + } + } + + @Override + public Dimension getPreferredSize(int wHint, int hHint) { + return new Dimension(wHint, m_rowHeight); + } + @Override protected void paintFigure(Graphics graphics) { int width = bounds.width(); @@ -1210,10 +1077,23 @@ protected void paintFigure(Graphics graphics) { try { Property property = m_propertyInfo.getProperty(); boolean isActiveProperty = m_activePropertyInfo != null && m_activePropertyInfo.getProperty() == property; + int presentationWidth = 0; + PropertyEditorPresentation presentation = property.getEditor().getPresentation(); + if (presentation != null) { + Point p = new Point(m_splitter + 4, y); + translateToAbsolute(p); + // + int w = width - p.x() - MARGIN_RIGHT; + int h = height - MARGIN_BOTTOM; + // + presentationWidth = presentation.show(PropertyTable.this, property, p.x(), p.y(), w, h); + } // set background { if (isActiveProperty) { graphics.setBackgroundColor(COLOR_PROPERTY_BG_SELECTED); + // Might've been moved due to resizing the table + setActiveEditorBounds(); } else { if (property.isModified()) { graphics.setBackgroundColor(COLOR_PROPERTY_BG_MODIFIED); @@ -1221,7 +1101,7 @@ protected void paintFigure(Graphics graphics) { graphics.setBackgroundColor(COLOR_PROPERTY_BG); } } - graphics.fillRectangle(0, y, width, height); + graphics.fillRectangle(0, y, width - presentationWidth, height); } // draw state image if (m_propertyInfo.isShowComplex()) { @@ -1258,14 +1138,24 @@ protected void paintFigure(Graphics graphics) { } // prepare value rectangle int x = m_splitter + 4; - int w = width - x - MARGIN_RIGHT; + int w = getControl().getClientArea().width - x - MARGIN_RIGHT; // paint value - property.getEditor().paint(property, graphics, x, y, w, height); + property.getEditor().paint(property, graphics, x, y, w - presentationWidth, height); } } catch (Throwable e) { DesignerPlugin.log(e); } } + + @Override + public void erase() { + Property property = m_propertyInfo.getProperty(); + PropertyEditorPresentation presentation = property.getEditor().getPresentation(); + if (presentation != null) { + presentation.hide(PropertyTable.this, property); + } + super.erase(); + } } //////////////////////////////////////////////////////////////////////////// @@ -1374,6 +1264,7 @@ public void expand() throws Exception { // int index = m_properties.indexOf(this); addChildren(index + 1); + setContents(m_properties); } /** @@ -1389,6 +1280,7 @@ public void collapse() throws Exception { // int index = m_properties.indexOf(this); removeChildren(index + 1); + setContents(m_properties); } //////////////////////////////////////////////////////////////////////////// diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/PropertyTableTooltipHelper.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/PropertyTableTooltipHelper.java index 625bd109e..9f941270d 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/PropertyTableTooltipHelper.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/PropertyTableTooltipHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -40,7 +40,7 @@ class PropertyTableTooltipHelper implements IPropertyTooltipSite { //////////////////////////////////////////////////////////////////////////// public PropertyTableTooltipHelper(PropertyTable table) { m_table = table; - m_table.addListener(SWT.MouseHover, new Listener() { + m_table.getControl().addListener(SWT.MouseHover, new Listener() { @Override public void handleEvent(Event event) { if (event.stateMask == 0) { @@ -48,7 +48,7 @@ public void handleEvent(Event event) { } } }); - m_table.addListener(SWT.MouseExit, new Listener() { + m_table.getControl().addListener(SWT.MouseExit, new Listener() { @Override public void handleEvent(Event event) { // check, may be cursor is now on tooltip, so ignore this MouseExit @@ -148,7 +148,7 @@ private void showTooltip(IAdaptable adaptable, int startX, int endX) { } // create Shell { - m_tooltip = new Shell(m_table.getShell(), SWT.NO_FOCUS | SWT.ON_TOP | SWT.TOOL | SWT.SINGLE); + m_tooltip = new Shell(m_table.getControl().getShell(), SWT.NO_FOCUS | SWT.ON_TOP | SWT.TOOL | SWT.SINGLE); configureColors(m_tooltip); GridLayoutFactory.create(m_tooltip).noMargins(); } @@ -163,9 +163,9 @@ private void showTooltip(IAdaptable adaptable, int startX, int endX) { // prepare tooltip location Point tooltipLocation; if (provider.getTooltipPosition() == PropertyTooltipProvider.ON) { - tooltipLocation = m_table.toDisplay(new Point(startX, m_y)); + tooltipLocation = m_table.getControl().toDisplay(new Point(startX, m_y)); } else { - tooltipLocation = m_table.toDisplay(new Point(startX, m_y + m_rowHeight)); + tooltipLocation = m_table.getControl().toDisplay(new Point(startX, m_y + m_rowHeight)); } // set location/size and open m_tooltip.setLocation(tooltipLocation.x, tooltipLocation.y); diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/PropertyTooltipProvider.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/PropertyTooltipProvider.java index ad9e8fcc2..487a78948 100644 --- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/PropertyTooltipProvider.java +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/PropertyTooltipProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -99,12 +99,12 @@ public void handleEvent(Event event) { // convert location from tooltip to table Point p = new Point(event.x, event.y); p = tooltipControl.toDisplay(p); - p = table.toControl(p); + p = table.getControl().toControl(p); // send MouseDown to table Event newEvent = new Event(); newEvent.x = p.x; newEvent.y = p.y; - table.notifyListeners(SWT.MouseDown, newEvent); + table.getControl().notifyListeners(SWT.MouseDown, newEvent); // hide tooltip m_site.hideTooltip(); break; diff --git a/org.eclipse.wb.layout.group/META-INF/MANIFEST.MF b/org.eclipse.wb.layout.group/META-INF/MANIFEST.MF index 6bae2a70c..f11a10cf8 100644 --- a/org.eclipse.wb.layout.group/META-INF/MANIFEST.MF +++ b/org.eclipse.wb.layout.group/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.wb.layout.group;singleton:=true -Bundle-Version: 1.9.500.qualifier +Bundle-Version: 1.9.600.qualifier Bundle-Vendor: %providerName Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ActivationPolicy: lazy diff --git a/org.eclipse.wb.layout.group/src/org/eclipse/wb/internal/layout/group/model/assistant/LayoutAssistantSupport.java b/org.eclipse.wb.layout.group/src/org/eclipse/wb/internal/layout/group/model/assistant/LayoutAssistantSupport.java index 6bc0f1b51..f3ee16042 100644 --- a/org.eclipse.wb.layout.group/src/org/eclipse/wb/internal/layout/group/model/assistant/LayoutAssistantSupport.java +++ b/org.eclipse.wb.layout.group/src/org/eclipse/wb/internal/layout/group/model/assistant/LayoutAssistantSupport.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -108,7 +108,7 @@ public boolean isModified() throws Exception { constraintsProperty.setEditorPresentation(new ButtonPropertyEditorPresentation() { @Override protected void onClick(PropertyTable propertyTable, Property property) throws Exception { - m_constraintsDialog = new ConstraintsDialog(propertyTable.getShell(), m_layout, component); + m_constraintsDialog = new ConstraintsDialog(propertyTable.getControl().getShell(), m_layout, component); m_constraintsDialog.create(); m_constraintsDialog.getShell().addDisposeListener(new DisposeListener() { @Override diff --git a/org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/jface/viewers/TableViewerColumnSorterPropertyEditor.java b/org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/jface/viewers/TableViewerColumnSorterPropertyEditor.java index 34fc9e9ce..053d3c997 100644 --- a/org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/jface/viewers/TableViewerColumnSorterPropertyEditor.java +++ b/org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/jface/viewers/TableViewerColumnSorterPropertyEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -24,9 +24,9 @@ import org.eclipse.wb.internal.core.utils.jdt.core.ProjectUtils; import org.eclipse.wb.internal.rcp.Activator; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.graphics.Point; /** * {@link PropertyEditor} for installing sorter of {@link TableViewer} by column. diff --git a/org.eclipse.wb.swing.MigLayout/src/org/eclipse/wb/internal/swing/MigLayout/model/CellConstraintsSupport.java b/org.eclipse.wb.swing.MigLayout/src/org/eclipse/wb/internal/swing/MigLayout/model/CellConstraintsSupport.java index ae477dab8..5659de5a8 100644 --- a/org.eclipse.wb.swing.MigLayout/src/org/eclipse/wb/internal/swing/MigLayout/model/CellConstraintsSupport.java +++ b/org.eclipse.wb.swing.MigLayout/src/org/eclipse/wb/internal/swing/MigLayout/model/CellConstraintsSupport.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2023 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -529,7 +529,7 @@ public ComplexProperty getCellProperty() throws Exception { m_complexProperty.setEditorPresentation(new ButtonPropertyEditorPresentation() { @Override protected void onClick(PropertyTable propertyTable, Property property) throws Exception { - new CellEditDialog(propertyTable.getShell(), m_layout, m_this).open(); + new CellEditDialog(propertyTable.getControl().getShell(), m_layout, m_this).open(); } }); // grid properties diff --git a/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/model/layout/LayoutInfo.java b/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/model/layout/LayoutInfo.java index f6cf2354a..3fdc16c57 100644 --- a/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/model/layout/LayoutInfo.java +++ b/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/model/layout/LayoutInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2021 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -276,7 +276,7 @@ protected void onClick(PropertyTable propertyTable, Property property) throws Exception { MenuManager manager = new MenuManager(); getContainer().fillLayoutsManager(manager); - Menu menu = manager.createContextMenu(propertyTable); + Menu menu = manager.createContextMenu(propertyTable.getControl()); UiUtils.showAndDisposeOnHide(menu); } }); diff --git a/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/model/property/editor/beans/TextPropertyEditor.java b/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/model/property/editor/beans/TextPropertyEditor.java index edfe19ce1..3abceb3a6 100644 --- a/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/model/property/editor/beans/TextPropertyEditor.java +++ b/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/model/property/editor/beans/TextPropertyEditor.java @@ -20,7 +20,7 @@ import org.eclipse.wb.internal.core.model.property.table.PropertyTable; import org.eclipse.draw2d.Graphics; -import org.eclipse.swt.graphics.Point; +import org.eclipse.draw2d.geometry.Point; /** * The {@link PropertyEditor} wrapper for text based AWT {@link java.beans.PropertyEditor}. diff --git a/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/model/property/editor/color/ColorPropertyEditor.java b/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/model/property/editor/color/ColorPropertyEditor.java index 6284e93ae..4b3fca98e 100644 --- a/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/model/property/editor/color/ColorPropertyEditor.java +++ b/org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/model/property/editor/color/ColorPropertyEditor.java @@ -34,6 +34,7 @@ import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.QualifiedName; @@ -44,7 +45,6 @@ import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; diff --git a/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/layout/LayoutInfo.java b/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/layout/LayoutInfo.java index 20bce89d8..28fac61f2 100644 --- a/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/layout/LayoutInfo.java +++ b/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/layout/LayoutInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -380,7 +380,7 @@ protected Image getImage() { protected void onClick(PropertyTable propertyTable, Property property) throws Exception { MenuManager manager = new MenuManager(); getComposite().fillLayoutsManager(manager); - Menu menu = manager.createContextMenu(propertyTable); + Menu menu = manager.createContextMenu(propertyTable.getControl()); UiUtils.showAndDisposeOnHide(menu); } }); diff --git a/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/property/editor/color/ColorPropertyEditor.java b/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/property/editor/color/ColorPropertyEditor.java index 8ba37867a..1c353be88 100644 --- a/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/property/editor/color/ColorPropertyEditor.java +++ b/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/property/editor/color/ColorPropertyEditor.java @@ -45,6 +45,7 @@ import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.QualifiedName; @@ -55,7 +56,6 @@ import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Composite; diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/EventsPropertyTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/EventsPropertyTest.java index 8bca84161..3513ed358 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/EventsPropertyTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/EventsPropertyTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2023 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. 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 @@ -2285,9 +2285,7 @@ public void test_ListenerMethodPropertyEditor_doubleClick() throws Exception { // open "keyPressed" method { PropertyEditor keyPressedEditor = keyPressedProperty.getEditor(); - ReflectionUtils.invokeMethod(keyPressedEditor, "doubleClick(" - + Property.class.getName() - + ",org.eclipse.swt.graphics.Point)", new Object[]{keyPressedProperty, null}); + keyPressedEditor.doubleClick(keyPressedProperty, null); assertEditor( "class Test extends JPanel {", " Test() {", @@ -2305,7 +2303,7 @@ public void test_ListenerMethodPropertyEditor_doubleClick() throws Exception { /** * Create listener method using - * {@link PropertyEditor#activate(PropertyTable, Property, org.eclipse.swt.graphics.Point)}. + * {@link PropertyEditor#activate(PropertyTable, Property, org.eclipse.draw2d.geometry.Point)}. */ @Test public void test_ListenerMethodPropertyEditor_activate() throws Exception { @@ -2324,11 +2322,7 @@ public void test_ListenerMethodPropertyEditor_activate() throws Exception { // open "keyPressed" method { PropertyEditor keyPressedEditor = keyPressedProperty.getEditor(); - ReflectionUtils.invokeMethod(keyPressedEditor, "activate(" - + PropertyTable.class.getName() - + "," - + Property.class.getName() - + ",org.eclipse.swt.graphics.Point)", new Object[]{null, keyPressedProperty, null}); + keyPressedEditor.activate(null, keyPressedProperty, null); assertEditor( "class Test extends JPanel {", " Test() {", diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/BooleanObjectPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/BooleanObjectPropertyEditorTest.java index 60246740f..8b30bb4e9 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/BooleanObjectPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/BooleanObjectPropertyEditorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. 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 @@ -16,7 +16,7 @@ import org.eclipse.wb.internal.core.model.property.table.PropertyTable; import org.eclipse.wb.internal.swing.model.component.ContainerInfo; -import org.eclipse.swt.graphics.Point; +import org.eclipse.draw2d.geometry.Point; import org.junit.Test; diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/BooleanPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/BooleanPropertyEditorTest.java index d5daf228c..3e575a3b3 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/BooleanPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/BooleanPropertyEditorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. 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 @@ -15,7 +15,7 @@ import org.eclipse.wb.internal.core.model.property.table.PropertyTable; import org.eclipse.wb.internal.swing.model.component.ContainerInfo; -import org.eclipse.swt.graphics.Point; +import org.eclipse.draw2d.geometry.Point; import org.junit.Test; diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/AbstractPropertyTableTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/AbstractPropertyTableTest.java index 6cbb740f8..5d2caf98d 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/AbstractPropertyTableTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/AbstractPropertyTableTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -47,7 +47,7 @@ public void setUp() throws Exception { m_shell.setBounds(10000, 0, 300, 500); // m_propertyTable = new PropertyTable(m_shell, SWT.NONE); - m_sender = new EventSender(m_propertyTable); + m_sender = new EventSender(m_propertyTable.getControl()); // m_shell.setVisible(true); waitEventLoop(1); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/PropertyTableTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/PropertyTableTest.java index b9e07d6d1..89af7b294 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/PropertyTableTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/PropertyTableTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2023 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -100,16 +100,16 @@ public void test_setInput_null() throws Exception { @Test public void test_cursor() throws Exception { m_sender.moveTo(10, 10); - assertNull(m_propertyTable.getCursor()); + assertNull(m_propertyTable.getControl().getCursor()); // int splitter = m_propertyTable.forTests_getSplitter(); for (int x = splitter - 1; x <= splitter + 1; x++) { m_sender.moveTo(x, 10); - assertSame(Cursors.SIZEWE, m_propertyTable.getCursor()); + assertSame(Cursors.SIZEWE, m_propertyTable.getControl().getCursor()); } // m_sender.moveTo(splitter + 2, 10); - assertNull(m_propertyTable.getCursor()); + assertNull(m_propertyTable.getControl().getCursor()); } /** @@ -117,7 +117,7 @@ public void test_cursor() throws Exception { */ @Test public void test_splitter() throws Exception { - int width = m_propertyTable.getClientArea().width; + int width = m_propertyTable.getControl().getClientArea().width; // check initial position int splitter = (int) (width * 0.4); assertEquals(splitter, m_propertyTable.forTests_getSplitter()); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/TableTest1.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/TableTest1.java index 916aba406..1fe8b0cd3 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/TableTest1.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/TableTest1.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -85,7 +85,7 @@ public static void main(String[] args) { PropertyTable table = new PropertyTable(shell, SWT.NONE); //PropertyTable2 table = new PropertyTable2(shell, SWT.NONE); //table.setFont(new Font(null, "", 12, SWT.NONE)); - table.setLayoutData(new GridData(GridData.FILL_BOTH)); + table.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); //table.setInput(null); if (true) { table.setInput(new Property[]{ diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/DesignerEditorTestCase.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/DesignerEditorTestCase.java index 98206d4f8..036edbe34 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/DesignerEditorTestCase.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/DesignerEditorTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2023 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. * 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 @@ -24,6 +24,7 @@ import org.eclipse.wb.internal.core.editor.actions.DesignPageActions; import org.eclipse.wb.internal.core.editor.multi.DesignerEditor; import org.eclipse.wb.internal.core.editor.palette.DesignerPalette; +import org.eclipse.wb.internal.core.editor.structure.DesignComponentsComposite; import org.eclipse.wb.internal.core.editor.structure.components.IComponentsTree; import org.eclipse.wb.internal.core.gef.part.DesignRootEditPart; import org.eclipse.wb.internal.core.model.JavaInfoUtils; @@ -257,7 +258,9 @@ protected void fetchContentFields() { { UiContext uiContext = new UiContext(); uiContext.useShell(DesignerPlugin.getShell().getText()); - m_propertyTable = uiContext.findFirstWidget(PropertyTable.class); + Object componentComposite = uiContext.findFirstWidget(DesignComponentsComposite.class); + Object componentPropertyPage = ReflectionUtils.getFieldObject(componentComposite, "m_propertiesPage"); + m_propertyTable = (PropertyTable) ReflectionUtils.getFieldObject(componentPropertyPage, "m_propertyTable"); } // DesignPageSite { diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/gef/EventSender.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/gef/EventSender.java index 55f611ebd..5bbfb3646 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/gef/EventSender.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/gef/EventSender.java @@ -130,7 +130,7 @@ public EventSender moveTo(int x, int y) { Event event = createEvent(x, y, 0); m_control.notifyListeners(SWT.MouseMove, event); // process "async" runnables - waitEventLoop(0); + waitEventLoop(10); return this; } diff --git a/target-platform/wb.target b/target-platform/wb.target index 65f6ee38b..a36f54d42 100644 --- a/target-platform/wb.target +++ b/target-platform/wb.target @@ -4,6 +4,7 @@ +