You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2008/11/13 23:12:22 UTC
svn commit: r713840 - in
/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse:
cpcontainer/ ui/ ui/wizards/
Author: hibou
Date: Thu Nov 13 14:12:21 2008
New Revision: 713840
URL: http://svn.apache.org/viewvc?rev=713840&view=rev
Log:
IVYDE-120:
- only use Eclipse 3.2 API, even if it doesn't work as well as the 3.3 API
Added:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/DecorationOverlayIcon.java (with props)
Modified:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvyFilePathText.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsPathText.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/wizards/IvyNewWizard.java
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java?rev=713840&r1=713839&r2=713840&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java Thu Nov 13 14:12:21 2008
@@ -18,12 +18,12 @@
package org.apache.ivyde.eclipse.cpcontainer;
import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.ui.DecorationOverlayIcon;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.packageview.ClassPathContainer;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.DecorationOverlayIcon;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ILabelProviderListener;
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/DecorationOverlayIcon.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/DecorationOverlayIcon.java?rev=713840&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/DecorationOverlayIcon.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/DecorationOverlayIcon.java Thu Nov 13 14:12:21 2008
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivyde.eclipse.ui;
+
+import org.eclipse.jface.resource.CompositeImageDescriptor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ * extracted from org.eclipse.jface.viewers.DecorationOverlayIcon of Eclipse 3.3
+ */
+public class DecorationOverlayIcon extends CompositeImageDescriptor {
+
+ private Image baseImage;
+
+ private Point size;
+
+ private final ImageDescriptor overlayImage;
+
+ public DecorationOverlayIcon(Image baseImage, ImageDescriptor overlayImage, int quadrant) {
+ this.baseImage = baseImage;
+ this.overlayImage = overlayImage;
+ this.size = new Point(baseImage.getBounds().width, baseImage.getBounds().height);
+ }
+
+ protected void drawCompositeImage(int width, int height) {
+ drawImage(baseImage.getImageData(), 0, 0);
+ ImageData overlayData = overlayImage.getImageData();
+ // Use the missing descriptor if it is not there.
+ if (overlayData == null) {
+ overlayData = ImageDescriptor.getMissingImageDescriptor().getImageData();
+ }
+ drawImage(overlayData, 0, size.y - overlayData.height);
+ }
+
+ protected Point getSize() {
+ return size;
+ }
+
+ protected int getTransparentPixel() {
+ return baseImage.getImageData().transparentPixel;
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/DecorationOverlayIcon.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/DecorationOverlayIcon.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/DecorationOverlayIcon.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvyFilePathText.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvyFilePathText.java?rev=713840&r1=713839&r2=713840&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvyFilePathText.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvyFilePathText.java Thu Nov 13 14:12:21 2008
@@ -28,19 +28,23 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.DecoratedField;
+import org.eclipse.jface.fieldassist.FieldDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.fieldassist.IControlCreator;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Text;
@@ -54,7 +58,7 @@
private Text ivyFilePathText;
- private ControlDecoration ivyFilePathTextDeco;
+ private DecoratedField ivyFilePathTextDeco;
private IvyDEException ivyXmlError;
@@ -64,6 +68,8 @@
private Button browseButton;
+ private FieldDecoration errorDecoration;
+
public IvyFilePathText(Composite parent, int style, IJavaProject project) {
super(parent, style);
GridLayout layout = new GridLayout(2, false);
@@ -72,27 +78,34 @@
setLayout(layout);
this.project = project;
- Image errorDecoImage = FieldDecorationRegistry.getDefault().getFieldDecoration(
- FieldDecorationRegistry.DEC_ERROR).getImage();
+ errorDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(
+ FieldDecorationRegistry.DEC_ERROR);
- ivyFilePathText = new Text(this, SWT.SINGLE | SWT.BORDER);
- ivyFilePathText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+ ivyFilePathTextDeco = new DecoratedField(this, SWT.LEFT | SWT.TOP, new IControlCreator() {
+ public Control createControl(Composite parent, int style) {
+ return new Text(parent, SWT.SINGLE | SWT.BORDER);
+ }
+ });
+ ivyFilePathTextDeco.addFieldDecoration(errorDecoration, SWT.TOP | SWT.LEFT, false);
+ ivyFilePathTextDeco.hideDecoration(errorDecoration);
+ // this doesn't work well: we want the decoration image to be clickable, but it actually
+ // hides the clickable area
+ // ivyFilePathTextDeco.getLayoutControl().addMouseListener(new MouseAdapter() {
+ // public void mouseDown(MouseEvent e) {
+ // if (ivyXmlError != null) {
+ // ivyXmlError.show(IStatus.ERROR, "IvyDE configuration problem", null);
+ // }
+ // }
+ // });
+
+ ivyFilePathText = (Text) ivyFilePathTextDeco.getControl();
+ ivyFilePathTextDeco.getLayoutControl().setLayoutData(
+ new GridData(GridData.FILL, GridData.FILL, true, false));
ivyFilePathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent ev) {
ivyXmlPathUpdated();
}
});
- ivyFilePathTextDeco = new ControlDecoration(ivyFilePathText, SWT.LEFT | SWT.TOP);
- ivyFilePathTextDeco.setMarginWidth(2);
- ivyFilePathTextDeco.setImage(errorDecoImage);
- ivyFilePathTextDeco.hide();
- ivyFilePathTextDeco.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (ivyXmlError != null) {
- ivyXmlError.show(IStatus.ERROR, "IvyDE configuration problem", null);
- }
- }
- });
browseButton = new Button(this, SWT.NONE);
browseButton.setText("Browse");
@@ -131,12 +144,13 @@
public void setIvyXmlError(IvyDEException error) {
if (error == null) {
ivyXmlError = null;
- ivyFilePathTextDeco.hide();
+ ivyFilePathTextDeco.hideDecoration(errorDecoration);
ivyFilePathTextDeco.hideHover();
} else if (!error.equals(ivyXmlError)) {
ivyXmlError = error;
- ivyFilePathTextDeco.show();
+ ivyFilePathTextDeco.showDecoration(errorDecoration);
if (ivyFilePathText.isVisible()) {
+ errorDecoration.setDescription(error.getShortMsg());
ivyFilePathTextDeco.showHoverText(error.getShortMsg());
}
}
@@ -144,6 +158,7 @@
public void updateErrorMarker() {
if (isVisible() && ivyXmlError != null) {
+ errorDecoration.setDescription(ivyXmlError.getShortMsg());
ivyFilePathTextDeco.showHoverText(ivyXmlError.getShortMsg());
} else {
ivyFilePathTextDeco.hideHover();
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsPathText.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsPathText.java?rev=713840&r1=713839&r2=713840&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsPathText.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsPathText.java Thu Nov 13 14:12:21 2008
@@ -26,18 +26,22 @@
import org.apache.ivyde.eclipse.IvyDEException;
import org.apache.ivyde.eclipse.IvyPlugin;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.DecoratedField;
+import org.eclipse.jface.fieldassist.FieldDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.fieldassist.IControlCreator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Text;
@@ -50,12 +54,14 @@
private Text settingsText;
- private ControlDecoration settingsTextDeco;
+ private DecoratedField settingsTextDeco;
private final List listeners = new ArrayList();
private IvyDEException settingsError;
+ private FieldDecoration errorDecoration;
+
public SettingsPathText(Composite parent, int style) {
super(parent, style);
GridLayout layout = new GridLayout(2, false);
@@ -63,28 +69,39 @@
layout.marginWidth = 0;
setLayout(layout);
- Image errorDecoImage = FieldDecorationRegistry.getDefault().getFieldDecoration(
- FieldDecorationRegistry.DEC_ERROR).getImage();
+ errorDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(
+ FieldDecorationRegistry.DEC_ERROR);
+
+ settingsTextDeco = new DecoratedField(this, SWT.LEFT | SWT.TOP, new IControlCreator() {
+ public Control createControl(Composite parent, int style) {
+ return new Text(parent, SWT.SINGLE | SWT.BORDER);
+ }
+ });
+ settingsTextDeco.addFieldDecoration(errorDecoration, SWT.TOP | SWT.LEFT, false);
+ // settingsTextDeco.setMarginWidth(2);
+ settingsTextDeco.hideDecoration(errorDecoration);
+ // this doesn't work well: we want the decoration image to be clickable, but it actually
+ // hides the clickable area
+ // settingsTextDeco.getLayoutControl().addMouseListener(new MouseAdapter() {
+ // public void mouseDoubleClick(MouseEvent e) {
+ // super.mouseDoubleClick(e);
+ // }
+ // public void mouseDown(MouseEvent e) {
+ // if (settingsError != null) {
+ // settingsError.show(IStatus.ERROR, "IvyDE configuration problem", null);
+ // }
+ // }
+ // });
- settingsText = new Text(this, SWT.SINGLE | SWT.BORDER);
+ settingsText = (Text) settingsTextDeco.getControl();
settingsText.setToolTipText(TOOLTIP_SETTINGS);
- settingsText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+ settingsTextDeco.getLayoutControl().setLayoutData(
+ new GridData(GridData.FILL, GridData.FILL, true, false));
settingsText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
settingsPathUpdated();
}
});
- settingsTextDeco = new ControlDecoration(settingsText, SWT.LEFT | SWT.TOP);
- settingsTextDeco.setMarginWidth(2);
- settingsTextDeco.setImage(errorDecoImage);
- settingsTextDeco.hide();
- settingsTextDeco.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (settingsError != null) {
- settingsError.show(IStatus.ERROR, "IvyDE configuration problem", null);
- }
- }
- });
Button browse = new Button(this, SWT.NONE);
browse.setText("Browse");
@@ -137,12 +154,13 @@
public void setSettingsError(IvyDEException error) {
if (error == null) {
settingsError = null;
- settingsTextDeco.hide();
+ settingsTextDeco.hideDecoration(errorDecoration);
settingsTextDeco.hideHover();
} else if (!error.equals(settingsError)) {
settingsError = error;
- settingsTextDeco.show();
+ settingsTextDeco.showDecoration(errorDecoration);
if (settingsText.isVisible()) {
+ errorDecoration.setDescription(error.getShortMsg());
settingsTextDeco.showHoverText(error.getShortMsg());
}
}
@@ -150,6 +168,7 @@
public void updateErrorMarker() {
if (isVisible() && settingsError != null) {
+ errorDecoration.setDescription(settingsError.getShortMsg());
settingsTextDeco.showHoverText(settingsError.getShortMsg());
} else {
settingsTextDeco.hideHover();
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/wizards/IvyNewWizard.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/wizards/IvyNewWizard.java?rev=713840&r1=713839&r2=713840&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/wizards/IvyNewWizard.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/wizards/IvyNewWizard.java Thu Nov 13 14:12:21 2008
@@ -146,7 +146,7 @@
}
stream.close();
} catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, IvyPlugin.ID,
+ throw new CoreException(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
"The ivy.xml could not be created", e));
}
monitor.worked(1);