Skip to content

Commit

Permalink
Adapt PropertyEditor interface to work with Draw2D points
Browse files Browse the repository at this point in the history
Follow-up to fe14a8a. By using Draw2D
points instead of SWT points, we don't have to use the fully qualified
name.
  • Loading branch information
ptziegler committed Apr 30, 2024
1 parent fe14a8a commit 53affba
Show file tree
Hide file tree
Showing 21 changed files with 54 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -52,24 +52,24 @@
* instance of selected external {@link Class}. Source for class generated class is configured as
* template.
*
* <pre><xmp>
<property id="setLabelProvider(org.eclipse.jface.viewers.IBaseLabelProvider)">
<editor id="innerClass">
<parameter name="mode">inner</parameter>
<parameter name="name">TableLabelProvider</parameter>
<parameter name="class">org.eclipse.jface.viewers.ITableLabelProvider</parameter>
<parameter name="source"><![CDATA[
private class ${name} extends org.eclipse.jface.viewers.LabelProvider implements org.eclipse.jface.viewers.ITableLabelProvider {
public org.eclipse.swt.graphics.Image getColumnImage(Object element, int columnIndex) {
return null;
}
public String getColumnText(Object element, int columnIndex) {
return element.toString();
}
}
]]></parameter>
</editor>
</property>
* <pre><xmp>
<property id="setLabelProvider(org.eclipse.jface.viewers.IBaseLabelProvider)">
<editor id="innerClass">
<parameter name="mode">inner</parameter>
<parameter name="name">TableLabelProvider</parameter>
<parameter name="class">org.eclipse.jface.viewers.ITableLabelProvider</parameter>
<parameter name="source"><![CDATA[
private class ${name} extends org.eclipse.jface.viewers.LabelProvider implements org.eclipse.jface.viewers.ITableLabelProvider {
public org.eclipse.swt.graphics.Image getColumnImage(Object element, int columnIndex) {
return null;
}
public String getColumnText(Object element, int columnIndex) {
return element.toString();
}
}
]]></parameter>
</editor>
</property>
* </xmp></pre>
*
* @author scheglov_ke
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
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;
import org.eclipse.swt.events.KeyAdapter;
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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
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;
import org.eclipse.swt.events.MouseAdapter;
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>Boolean</code>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>boolean</code>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.draw2d.FigureUtilities;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.SWTGraphics;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.ui.parts.GraphicalViewerImpl;
import org.eclipse.jface.viewers.ISelection;
Expand Down Expand Up @@ -499,7 +500,7 @@ private void updateTooltipNoProperty() {
* @param location the mouse location, if editor is activated using mouse click,
* or <code>null</code> if it is activated using keyboard.
*/
public void activateEditor(Property property, org.eclipse.swt.graphics.Point location) {
public void activateEditor(Property property, Point location) {
try {
// de-activate old editor
deactivateEditor(true);
Expand Down Expand Up @@ -700,8 +701,8 @@ private boolean isLocationValue(int x) {
*
* @return the location relative to the value part of property.
*/
private org.eclipse.swt.graphics.Point getValueRelativeLocation(int x, int y) {
return new org.eclipse.swt.graphics.Point(x - (m_splitter + 2), y - m_rowHeight * getPropertyIndex(y));
private Point getValueRelativeLocation(int x, int y) {
return new Point(x - (m_splitter + 2), y - m_rowHeight * getPropertyIndex(y));
}

////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2023 Google, Inc.
* Copyright (c) 2011, 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
Expand Down Expand Up @@ -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(keyReleasedProperty, null);
assertEditor(
"class Test extends JPanel {",
" Test() {",
Expand All @@ -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 {
Expand All @@ -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() {",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;

Expand Down
Loading

0 comments on commit 53affba

Please sign in to comment.