*/\r
package eu.etaxonomy.taxeditor.editor.descriptiontree;\r
\r
-import java.net.URI;\r
-import java.net.URISyntaxException;\r
-\r
import org.eclipse.jface.viewers.ISelection;\r
import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.browser.Browser;\r
import org.eclipse.swt.events.ModifyEvent;\r
import org.eclipse.swt.events.ModifyListener;\r
import org.eclipse.swt.events.MouseAdapter;\r
import org.eclipse.swt.events.MouseEvent;\r
-import org.eclipse.swt.events.PaintEvent;\r
-import org.eclipse.swt.events.PaintListener;\r
-import org.eclipse.swt.graphics.Image;\r
import org.eclipse.swt.layout.GridData;\r
import org.eclipse.swt.layout.GridLayout;\r
import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Canvas;\r
import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
import org.eclipse.swt.widgets.Text;\r
import org.eclipse.ui.forms.IFormPart;\r
\r
import eu.etaxonomy.cdm.common.CdmUtils;\r
import eu.etaxonomy.cdm.model.media.ImageFile;\r
-import eu.etaxonomy.taxeditor.model.ImageResources;\r
\r
/**\r
* @author p.ciardelli\r
public class ImageDetailsPage extends AbstractDescriptionDetailsPage implements ModifyListener{\r
\r
private Text text;\r
- private Canvas canvas;\r
- private Image image;\r
+ private Browser browser;\r
\r
/* (non-Javadoc)\r
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)\r
client.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
\r
section.setText("Image Details"); //$NON-NLS-1$\r
- \r
- createLabel("Image URL:", client, parent);\r
+\r
+// // Create composite for moving image up and down in list\r
+// final Composite moveComposite = new Composite(client, SWT.NONE);\r
+// moveComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
+// final GridLayout gridLayout1 = new GridLayout();\r
+// gridLayout1.numColumns = 3;\r
+// moveComposite.setLayout(gridLayout1);\r
+// \r
+// // Create label\r
+// Label moveLabel = toolkit.createLabel(moveComposite, "Move image in list:", SWT.NONE);\r
+// moveLabel.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false)); \r
+// \r
+// // Create "Up" button\r
+// final Button upButton = toolkit.createButton(moveComposite, "Up", SWT.PUSH);\r
+// upButton.setLayoutData(new GridData());\r
+// upButton.addMouseListener(new MouseAdapter() {\r
+// public void mouseUp(MouseEvent e) {\r
+// showImage();\r
+// }\r
+// }); \r
+//\r
+// // Create "Down" button\r
+// final Button downButton = toolkit.createButton(moveComposite, "Down", SWT.PUSH);\r
+// downButton.setLayoutData(new GridData());\r
+// downButton.addMouseListener(new MouseAdapter() {\r
+// public void mouseUp(MouseEvent e) {\r
+// showImage();\r
+// }\r
+// }); \r
\r
// Create composite for search text, search term input, and "Search" button\r
final Composite urlComposite = new Composite(client, SWT.NONE);\r
urlComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
final GridLayout gridLayout = new GridLayout();\r
- gridLayout.numColumns = 2;\r
+ gridLayout.numColumns = 3;\r
urlComposite.setLayout(gridLayout);\r
\r
- // Create input field for search term\r
- text = new Text(urlComposite, SWT.BORDER | SWT.SINGLE);\r
+ // Create label\r
+ Label urlLabel = toolkit.createLabel(urlComposite, "Image URL:", SWT.NONE);\r
+ urlLabel.setLayoutData(new GridData());\r
+ \r
+ // Create input field for URL\r
+ text = toolkit.createText(urlComposite, "", SWT.BORDER | SWT.SINGLE);\r
final GridData gd_text = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
text.setLayoutData(gd_text);\r
\r
- // Create "Search" button\r
- final Button showButton = mform.getToolkit().createButton(urlComposite, "Show", SWT.PUSH);\r
-// final Button showButton = new Button(urlComposite, SWT.NONE);\r
+ // Create "Show" button\r
+ final Button showButton = toolkit.createButton(urlComposite, "Show", SWT.PUSH);\r
showButton.setLayoutData(new GridData());\r
-// showButton.setText("Show");\r
showButton.addMouseListener(new MouseAdapter() {\r
- \r
// Populate search results resultsTable after clicking button\r
public void mouseUp(MouseEvent e) {\r
showImage();\r
}\r
}); \r
-\r
- createCitationControls();\r
- \r
- // Create composite for search text, search term input, and "Search" button\r
- final Composite imageComposite = new Composite(client, SWT.NONE);\r
- imageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
- imageComposite.setLayout(new GridLayout());\r
- \r
- canvas = new Canvas(imageComposite, SWT.NO_REDRAW_RESIZE);\r
-// canvas = new Canvas(imageComposite, SWT.BORDER);\r
+ \r
+ browser = new Browser(client, SWT.NONE);\r
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r
- \r
// TODO this is a quick fix, couldnt figure out how to get the window to resize for new images\r
gd.heightHint = 1000;\r
- canvas.setLayoutData(gd); \r
+ browser.setLayoutData(gd);\r
\r
- canvas.addPaintListener (new PaintListener () {\r
- public void paintControl (PaintEvent e) {\r
- if (image != null) {\r
- e.gc.drawImage (image, 0, 0);\r
- }\r
- }\r
- });\r
}\r
\r
/**\r
*/\r
private void showImage() {\r
String uriString = ((ImageFile) input).getUri();\r
- if (uriString == null || uriString.length() == 0) {\r
- // TODO draw empty image\r
- showImageNotFound();\r
- return;\r
- }\r
- try {\r
- URI uri = new URI (uriString);\r
- image = ImageResources.getImage(uri);\r
- mform.reflow(true);\r
- } catch (URISyntaxException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- showImageNotFound();\r
- }\r
- }\r
- \r
- private void showImageNotFound() {\r
- image = ImageResources.getImageNotFound();\r
- image = ImageResources.getImage(ImageResources.IMG_NOT_FOUND);\r
- canvas.setBounds(image.getBounds());\r
+ String html = "<HTML><HEAD><TITLE>HTML Test</TITLE></HEAD><BODY marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>";\r
+ html += "<img src=\"" + uriString + "\" />";\r
+ html += "</BODY></HTML>";\r
+ browser.setText(html);\r
}\r
\r
+ private void moveImage(int direction) {\r
+ \r
+// IUndoableOperation operation = null;\r
+// try {\r
+// // TODO use undo context specific to editor\r
+// operation = new RemoveImageFromDescriptionElementOperation(event.getCommand().getName(), \r
+// EditorUtil.getUndoContext(), taxon, image, element, (IPostOperationEnabled) editor);\r
+// EditorUtil.executeOperation(operation);\r
+// } catch (NotDefinedException e) {\r
+// logger.warn("Command name not set");\r
+// }\r
+ \r
+ \r
+ \r
+// ImagesHelper.moveImage((DescriptionElementBase) input, getSelectedImage(), direction);\r
+// imageViewer.refresh();\r
+// fireStateChanged();\r
+ }\r
+ \r
/* (non-Javadoc)\r
* @see eu.etaxonomy.taxeditor.editor.descriptionnew.AbstractDescriptionDetailsPage#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection)\r
*/\r