From: p.ciardelli Date: Thu, 30 Aug 2007 09:03:33 +0000 (+0000) Subject: Mockup with Master-Details page. X-Git-Tag: rcp.ss-first-working-version~1302 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/94f6ce6d358ef9bd77f176fd252b71626f4325c8 Mockup with Master-Details page. --- diff --git a/.gitattributes b/.gitattributes index a18d3dd4e..682479c31 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,17 +8,35 @@ icons/sample.gif -text icons/sample.icns -text icons/sample2.gif -text icons/sample3.gif -text +/plugin.properties -text /plugin.xml -text +/plugin_customization.ini -text /product_lg.gif -text /splash.bmp -text src/eu/etaxonomy/taxeditor/Activator.java -text src/eu/etaxonomy/taxeditor/ApplicationActionBarAdvisor.java -text src/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java -text src/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java -text +src/eu/etaxonomy/taxeditor/FormEditorInput.java -text +src/eu/etaxonomy/taxeditor/FormView.java -text src/eu/etaxonomy/taxeditor/ICommandIds.java -text +src/eu/etaxonomy/taxeditor/IModelListener.java -text +src/eu/etaxonomy/taxeditor/MasterDetailsPage.java -text src/eu/etaxonomy/taxeditor/MessagePopupAction.java -text +src/eu/etaxonomy/taxeditor/Messages.java -text +src/eu/etaxonomy/taxeditor/Name.java -text +src/eu/etaxonomy/taxeditor/NameDetailsPage.java -text +src/eu/etaxonomy/taxeditor/NamedObject.java -text src/eu/etaxonomy/taxeditor/NavigationView.java -text +src/eu/etaxonomy/taxeditor/OpenFormEditorAction.java -text +src/eu/etaxonomy/taxeditor/OpenSimpleFormEditorAction.java -text src/eu/etaxonomy/taxeditor/OpenViewAction.java -text src/eu/etaxonomy/taxeditor/Perspective.java -text +src/eu/etaxonomy/taxeditor/ScrolledPropertiesBlock.java -text +src/eu/etaxonomy/taxeditor/SimpleFormEditor.java -text +src/eu/etaxonomy/taxeditor/SimpleFormEditorInput.java -text +src/eu/etaxonomy/taxeditor/SimpleModel.java -text src/eu/etaxonomy/taxeditor/TaxEditorApplication.java -text src/eu/etaxonomy/taxeditor/View.java -text +src/eu/etaxonomy/taxeditor/messages.properties -text +/taxeditor.product -text diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index 85be423f0..a3fb886c5 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -5,5 +5,6 @@ Bundle-SymbolicName: eu.etaxonomy.taxeditor; singleton:=true Bundle-Version: 1.0.0 Bundle-Activator: eu.etaxonomy.taxeditor.Activator Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime + org.eclipse.core.runtime, + org.eclipse.ui.forms Eclipse-LazyStart: true diff --git a/plugin.properties b/plugin.properties new file mode 100644 index 000000000..86039f9a6 --- /dev/null +++ b/plugin.properties @@ -0,0 +1,18 @@ +############################################################################### +# Copyright (c) 2003, 2004 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Common Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/cpl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### +pluginName = Eclipse Forms Article Source Code +providerName = Eclipse.org +actionSetName = Eclipse Forms Article +menuLabel = Form Article Editors +actionLabel = Simple Form Editor +categoryName = Eclipse Forms Article Examples +viewName = Eclipse Form +baseEditor = Simple Form (RCP) Editor \ No newline at end of file diff --git a/plugin.xml b/plugin.xml index 4b3648ba6..e9016db68 100644 --- a/plugin.xml +++ b/plugin.xml @@ -19,6 +19,38 @@ id="eu.etaxonomy.taxeditor.perspective"> + + + + + + + + + + + + + + + + + + @@ -81,15 +120,31 @@ name="Taxonomic Editor"> + value="Taxonomic Editor (c) 2007 European Distributed Institute of Taxonomy Thanks to our worldwide fan community and Jesus."> + value="icons/edit_16x16.gif"> + value="logo_edit.gif"> + + + + + + + + diff --git a/plugin_customization.ini b/plugin_customization.ini new file mode 100644 index 000000000..ecdf68e87 --- /dev/null +++ b/plugin_customization.ini @@ -0,0 +1 @@ +org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP = true diff --git a/splash.bmp b/splash.bmp index d7d2e3032..74c122595 100644 Binary files a/splash.bmp and b/splash.bmp differ diff --git a/src/eu/etaxonomy/taxeditor/Activator.java b/src/eu/etaxonomy/taxeditor/Activator.java index 883be1548..3df3ff645 100644 --- a/src/eu/etaxonomy/taxeditor/Activator.java +++ b/src/eu/etaxonomy/taxeditor/Activator.java @@ -1,6 +1,16 @@ package eu.etaxonomy.taxeditor; +import java.net.URL; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.forms.FormColors; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -34,10 +44,10 @@ public class Activator extends AbstractUIPlugin { * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ - public void stop(BundleContext context) throws Exception { + /*public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); - } + }*/ /** * Returns the shared instance @@ -55,7 +65,98 @@ public class Activator extends AbstractUIPlugin { * @param path the path * @return the image descriptor */ - public static ImageDescriptor getImageDescriptor(String path) { + public static ImageDescriptor getImageDescriptorOrig(String path) { return imageDescriptorFromPlugin(PLUGIN_ID, path); } + + /** + * EVERYTHING BELOW HERE WAS PASTED FROM FORMARTICLEPLUGIN.JAVA + **/ + //Resource bundle. + private ResourceBundle resourceBundle; + private FormColors formColors; + public static final String IMG_FORM_BG = "formBg"; //$NON-NLS-1$ + public static final String IMG_LARGE = "large"; //$NON-NLS-1$ + public static final String IMG_HORIZONTAL = "horizontal"; //$NON-NLS-1$ + public static final String IMG_VERTICAL = "vertical"; //$NON-NLS-1$ + public static final String IMG_SAMPLE = "sample"; //$NON-NLS-1$ + public static final String IMG_WIZBAN = "wizban"; //$NON-NLS-1$ + public static final String IMG_LINKTO_HELP = "linkto_help"; //$NON-NLS-1$ + public static final String IMG_HELP_TOPIC = "help_topic"; //$NON-NLS-1$ + public static final String IMG_CLOSE = "close"; //$NON-NLS-1$ + + protected void initializeImageRegistry(ImageRegistry registry) { + registerImage(registry, IMG_FORM_BG, "form_banner.gif"); //$NON-NLS-1$ + registerImage(registry, IMG_LARGE, "large_image.gif"); //$NON-NLS-1$ + registerImage(registry, IMG_HORIZONTAL, "th_horizontal.gif"); //$NON-NLS-1$ + registerImage(registry, IMG_VERTICAL, "th_vertical.gif"); //$NON-NLS-1$ + registerImage(registry, IMG_SAMPLE, "sample.gif"); //$NON-NLS-1$ + registerImage(registry, IMG_WIZBAN, "newprj_wiz.gif"); //$NON-NLS-1$ + registerImage(registry, IMG_LINKTO_HELP, "linkto_help.gif"); //$NON-NLS-1$ + registerImage(registry, IMG_HELP_TOPIC, "help_topic.gif"); //$NON-NLS-1$ + registerImage(registry, IMG_CLOSE, "close_view.gif"); //$NON-NLS-1$ + } + + private void registerImage(ImageRegistry registry, String key, + String fileName) { + try { + IPath path = new Path("icons/" + fileName); //$NON-NLS-1$ + URL url = find(path); + if (url!=null) { + ImageDescriptor desc = ImageDescriptor.createFromURL(url); + registry.put(key, desc); + } + } catch (Exception e) { + } + } + + public FormColors getFormColors(Display display) { + if (formColors == null) { + formColors = new FormColors(display); + formColors.markShared(); + } + return formColors; + } + /** + * Returns the workspace instance. + */ +/* public static IWorkspace getWorkspace() { + return ResourcesPlugin.getWorkspace(); + }*/ + /** + * Returns the string from the plugin's resource bundle, or 'key' if not + * found. + */ + public static String getResourceString(String key) { + ResourceBundle bundle = Activator.getDefault().getResourceBundle(); + try { + return (bundle != null ? bundle.getString(key) : key); + } catch (MissingResourceException e) { + return key; + } + } + /** + * Returns the plugin's resource bundle, + */ + public ResourceBundle getResourceBundle() { + return resourceBundle; + } + public void stop(BundleContext context) throws Exception { + plugin = null; + try { + if (formColors != null) { + formColors.dispose(); + formColors = null; + } + } finally { + super.stop(context); + } + } + public Image getImage(String key) { + return getImageRegistry().get(key); + } + public ImageDescriptor getImageDescriptor(String key) { + return getImageRegistry().getDescriptor(key); + } + } diff --git a/src/eu/etaxonomy/taxeditor/ApplicationActionBarAdvisor.java b/src/eu/etaxonomy/taxeditor/ApplicationActionBarAdvisor.java index 74358060e..c551a82db 100644 --- a/src/eu/etaxonomy/taxeditor/ApplicationActionBarAdvisor.java +++ b/src/eu/etaxonomy/taxeditor/ApplicationActionBarAdvisor.java @@ -2,6 +2,7 @@ package eu.etaxonomy.taxeditor; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.GroupMarker; +import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.ICoolBarManager; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; @@ -54,9 +55,13 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor { newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window); register(newWindowAction); + // model on this one openViewAction = new OpenViewAction(window, "Open Another Message View", View.ID); register(openViewAction); + /*IAction newMasterDetailEditorAction = new IAction(window, "Testy Poo", "eu.etaxonomy.taxeditor.simple"); + register(newMasterDetailEditorAction);*/ + messagePopupAction = new MessagePopupAction("Open Message", window); register(messagePopupAction); } @@ -65,16 +70,20 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor { MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP); + MenuManager testMenu = new MenuManager("&Names Demo", IWorkbenchActionConstants.M_HELP); + menuBar.add(fileMenu); // Add a group marker indicating where action set menus will appear. menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); menuBar.add(helpMenu); + //menuBar.add(testMenu); // File fileMenu.add(newWindowAction); fileMenu.add(new Separator()); fileMenu.add(messagePopupAction); fileMenu.add(openViewAction); + //testMenu.add(openViewAction); fileMenu.add(new Separator()); fileMenu.add(exitAction); diff --git a/src/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java b/src/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java index 87f6a8cea..5f1aea3b7 100644 --- a/src/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java +++ b/src/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java @@ -18,8 +18,9 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { public void preWindowOpen() { IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); - configurer.setInitialSize(new Point(600, 400)); + configurer.setInitialSize(new Point(800, 600)); configurer.setShowCoolBar(true); + //configurer.setShowCoolBar(false); configurer.setShowStatusLine(false); } diff --git a/src/eu/etaxonomy/taxeditor/FormEditorInput.java b/src/eu/etaxonomy/taxeditor/FormEditorInput.java new file mode 100644 index 000000000..42f679b16 --- /dev/null +++ b/src/eu/etaxonomy/taxeditor/FormEditorInput.java @@ -0,0 +1,63 @@ +package eu.etaxonomy.taxeditor; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IPersistableElement; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +public class FormEditorInput implements IEditorInput { + private String name; + public FormEditorInput(String name) { + this.name = name; + } + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IEditorInput#exists() + */ + public boolean exists() { + return true; + } + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IEditorInput#getImageDescriptor() + */ + public ImageDescriptor getImageDescriptor() { + return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( + ISharedImages.IMG_OBJ_ELEMENT); + } + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IEditorInput#getName() + */ + public String getName() { + return name; + } + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IEditorInput#getPersistable() + */ + public IPersistableElement getPersistable() { + return null; + } + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IEditorInput#getToolTipText() + */ + public String getToolTipText() { + return getName(); + } + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + public Object getAdapter(Class adapter) { + return null; + } +} \ No newline at end of file diff --git a/src/eu/etaxonomy/taxeditor/FormView.java b/src/eu/etaxonomy/taxeditor/FormView.java new file mode 100644 index 000000000..b783459a7 --- /dev/null +++ b/src/eu/etaxonomy/taxeditor/FormView.java @@ -0,0 +1,317 @@ +package eu.etaxonomy.taxeditor; + +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +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.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.FormColors; +import org.eclipse.ui.forms.ManagedForm; +import org.eclipse.ui.forms.events.ExpansionAdapter; +import org.eclipse.ui.forms.events.ExpansionEvent; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; +import org.eclipse.ui.forms.widgets.ExpandableComposite; +import org.eclipse.ui.forms.widgets.Form; +import org.eclipse.ui.forms.widgets.FormText; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Hyperlink; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.forms.widgets.Section; +import org.eclipse.ui.forms.widgets.TableWrapData; +import org.eclipse.ui.forms.widgets.TableWrapLayout; +import org.eclipse.ui.part.ViewPart; + +public class FormView extends ViewPart { + private FormToolkit toolkit; + // private Form form; + private ScrolledForm form; + private ScrolledPropertiesBlock block; + + public static final String ID = "eu.etaxonomy.taxeditor.formview"; + + /** + * The constructor. + */ + public FormView() { + /*block = new ScrolledPropertiesBlock();*/ + } + + /** + * This is a callback that will allow us to create the viewer and initialize + * it. + */ + public void createPartControl(Composite parent) { + + toolkit = new FormToolkit(parent.getDisplay()); + Composite container = toolkit.createComposite(parent, SWT.NONE); + container.setLayout(new FillLayout()); + toolkit.paintBordersFor(container); + + ScrolledForm form = toolkit.createScrolledForm(container); + form.getBody().setLayout(new FillLayout()); + form.setText("MasterDetailsBlock example form"); + + ManagedForm mform = new ManagedForm(toolkit, form) ; + + /*ScrolledPropertiesBlock block = new ScrolledPropertiesBlock(); + block.createContent(mform);*/ + + // + /*createActions(); + initializeToolBar(); + initializeMenu();*/ + + + /*toolkit = new FormToolkit(parent.getDisplay()); + form = toolkit.createScrolledForm(parent);*/ + +/* TableWrapData td = new TableWrapData(); + Section section = toolkit.createSection(form.getBody(), + Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE + | Section.EXPANDED); + td = new TableWrapData(TableWrapData.FILL); + td.colspan = 2; + section.setLayoutData(td); + section.addExpansionListener(new ExpansionAdapter() { + public void expansionStateChanged(ExpansionEvent e) { + form.reflow(true); + } + }); + section.setText("Section title"); + section.setDescription("This is the description that goes " + + "below the title"); + Composite sectionClient = toolkit.createComposite(section); + sectionClient.setLayout(new GridLayout()); + section.setClient(sectionClient); + */ + + /*Label label = toolkit.createLabel(form.getBody(), "Text field label:"); + final Text text = toolkit.createText(form.getBody(), ""); + text.setText("value");*/ + /* + final String[] names = new String[6]; + names[0] = "Pilosella piloselloides (Vill.) Soják subsp. piloselloides"; + names[1] = "Pilosella piloselloides subsp. bauhinii (Schult.) S. Bräut. & Greuter"; + names[2] = "Pilosella piloselloides subsp. floccosa (Nägeli & Peter) S. Bräut. & Greuter"; + names[3] = "Pilosella piloselloides subsp. magyarica (Peter) S. Bräut. & Greuter"; + names[4] = "Pilosella piloselloides subsp. praealta (Gochnat) S. Bräut. & Greuter"; + names[5] = "Pilosella piloselloides subsp. rubrobauhinii (Schelk. & Zahn) S. Bräut. & Greuter"; + + TableWrapLayout layout = new TableWrapLayout(); + form.getBody().setLayout(layout); + final Integer j = 1; + for (int i = 0; i < 5; i++) { + Hyperlink link = toolkit.createHyperlink(form.getBody(), names[i], + SWT.WRAP); + /*j = (Integer)i; + link.addHyperlinkListener(new HyperlinkAdapter() { + + public void linkActivated(HyperlinkEvent e) { + text.setText(Integer.toString(j)); + } + }); + }*/ + + /* + + + final Hyperlink link = toolkit.createHyperlink(form.getBody(), "Click here.", + SWT.WRAP); + + layout.numColumns = 2; + TableWrapData td = new TableWrapData(); + td.colspan = 2; + link.setLayoutData(td); + Label label = toolkit.createLabel(form.getBody(), "Text field label:"); + final Text text = toolkit.createText(form.getBody(), ""); + text.setText("value"); + + final int tester = 2; + + link.addHyperlinkListener(new HyperlinkAdapter() { + + public void linkActivated(HyperlinkEvent e) { + text.setText(Integer.toString(tester)); + } + }); + */ + /* + toolkit = new FormToolkit(parent.getDisplay()); + form = toolkit.createScrolledForm(parent); // .createForm(parent); // + // alternate: + // createScrolledForm + form.setText("Hello, Eclipse Forms"); + TableWrapLayout layout = new TableWrapLayout(); + // GridLayout layout = new GridLayout(); + form.getBody().setLayout(layout); + Hyperlink link = toolkit.createHyperlink(form.getBody(), "Click here.", + SWT.WRAP); + link.addHyperlinkListener(new HyperlinkAdapter() { + public void linkActivated(HyperlinkEvent e) { + System.out.println("Link activated!"); + } + }); + link.setText("This is an example of a form that is much longer " + + "and will need to wrap."); + + layout.numColumns = 2; + TableWrapData td = new TableWrapData(); + td.colspan = 2; + link.setLayoutData(td); + + Label label = toolkit.createLabel(form.getBody(), "Text field label:"); + Text text = toolkit.createText(form.getBody(), ""); + + td = new TableWrapData(TableWrapData.FILL_GRAB); + text.setLayoutData(td); + + Button button = toolkit.createButton(form.getBody(), + "A checkbox in a form", SWT.CHECK); + td = new TableWrapData(); + td.colspan = 2; + button.setLayoutData(td); + + ExpandableComposite ec = toolkit.createExpandableComposite(form + .getBody(), ExpandableComposite.TREE_NODE + | ExpandableComposite.CLIENT_INDENT); + ec.setText("Expandable Composite title"); + String ctext = "We will now create a somewhat long text so that " + + "we can use it as content for the expandable composite. " + + "Expandable composite is used to hide or show the text using the " + + "toggle control"; + Label client = toolkit.createLabel(ec, ctext, SWT.WRAP); + ec.setClient(client); + td = new TableWrapData(); + td.colspan = 2; + ec.setLayoutData(td); + ec.addExpansionListener(new ExpansionAdapter() { + public void expansionStateChanged(ExpansionEvent e) { + form.reflow(true); + } + }); + + Section section = toolkit.createSection(form.getBody(), + Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE + | Section.EXPANDED); + td = new TableWrapData(TableWrapData.FILL); + td.colspan = 2; + section.setLayoutData(td); + section.addExpansionListener(new ExpansionAdapter() { + public void expansionStateChanged(ExpansionEvent e) { + form.reflow(true); + } + }); + section.setText("Section title"); + section.setDescription("This is the description that goes " + + "below the title"); + Composite sectionClient = toolkit.createComposite(section); + sectionClient.setLayout(new GridLayout()); + button = toolkit.createButton(sectionClient, "Radio 1", SWT.RADIO); + button = toolkit.createButton(sectionClient, "Radio 2", SWT.RADIO); + section.setClient(sectionClient); + + StringBuffer buf = new StringBuffer(); + buf.append("
"); + buf.append("

"); + buf.append("Here is some plain text for the text to render; "); + buf.append("this text is at http://www.eclipse.org web site."); + buf.append("

"); + buf.append("

"); + buf.append("" + + "This text is in header font and color."); + buf.append("

"); + buf.append("

This line will contain some bold and " + + "some source text. "); + buf.append("We can also add an image. "); + buf.append("

"); + buf.append("
  • A default (bulleted) list item.
  • "); + buf.append("
  • Another bullet list item.
  • "); + buf + .append("
  • A list item with text.
  • "); + buf.append("
  • Another list " + + "item with text
  • "); + buf.append("
  • List item with " + + "an image bullet
  • "); + buf + .append("
  • " + + "A list item with text.
  • "); + buf + .append("
  • " + + "A list item with text.
  • "); + buf.append("

    leading blanks; more white \n\n new " + + "lines
    \n more bb white .

    "); + buf.append("
    "); + FormText formText = toolkit.createFormText(form.getBody(), true); + formText.setWhitespaceNormalized(true); + td = new TableWrapData(TableWrapData.FILL); + td.colspan = 2; + formText.setLayoutData(td); + + formText.setColor("header", toolkit.getColors().getColor( + FormColors.TITLE)); + formText.setFont("header", JFaceResources.getHeaderFont()); + formText.setFont("code", JFaceResources.getTextFont()); + formText.setText(buf.toString(), true, false); + formText.addHyperlinkListener(new HyperlinkAdapter() { + public void linkActivated(HyperlinkEvent e) { + System.out.println("Link active: " + e.getHref()); + } + }); + */ + + /* colspan, rowspan demo */ + /* + * TableWrapLayout layout = new TableWrapLayout(); toolkit = new + * FormToolkit(parent.getDisplay()); form = toolkit.createForm(parent); // + * alternate: createScrolledForm form.getBody().setLayout(layout); + * + * layout.numColumns = 3; Label label; TableWrapData td; + * + * label = toolkit.createLabel(form.getBody(), "Some text to put in the + * first column", SWT.WRAP); label = toolkit.createLabel(form.getBody(), + * "Some text to put in the second column and make it a bit "+ "longer + * so that we can see what happens with column "+ "distribution. This + * text must be the longest so that it can "+ "get more space allocated + * to the columns it belongs to.", SWT.WRAP); td = new TableWrapData(); + * td.colspan = 2; label.setLayoutData(td); label = + * toolkit.createLabel(form.getBody(), "This text will span two rows and + * should not grow the column.", SWT.WRAP); td = new TableWrapData(); + * td.rowspan = 2; label.setLayoutData(td); label = + * toolkit.createLabel(form.getBody(), "This text goes into column 2 and + * consumes only one cell", SWT.WRAP); label.setLayoutData(new + * TableWrapData(TableWrapData.FILL_GRAB)); label = + * toolkit.createLabel(form.getBody(), "This text goes into column 3 and + * consumes only one cell too", SWT.WRAP); label.setLayoutData(new + * TableWrapData(TableWrapData.FILL)); label = + * toolkit.createLabel(form.getBody(), "This text goes into column 2 and + * consumes only one cell", SWT.WRAP); label.setLayoutData(new + * TableWrapData(TableWrapData.FILL_GRAB)); label = + * toolkit.createLabel(form.getBody(), "This text goes into column 3 and + * consumes only one cell too", SWT.WRAP); label.setLayoutData(new + * TableWrapData(TableWrapData.FILL)); + * form.getBody().setBackground(form.getBody().getDisplay(). + * getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); + */ + } + + /** + * Passing the focus request to the form. + */ + public void setFocus() { + form.setFocus(); + } + + /** + * Disposes the toolkit + */ + public void dispose() { + toolkit.dispose(); + super.dispose(); + } +} diff --git a/src/eu/etaxonomy/taxeditor/ICommandIds.java b/src/eu/etaxonomy/taxeditor/ICommandIds.java index 349d94c2b..c405b99c3 100644 --- a/src/eu/etaxonomy/taxeditor/ICommandIds.java +++ b/src/eu/etaxonomy/taxeditor/ICommandIds.java @@ -11,5 +11,6 @@ public interface ICommandIds { public static final String CMD_OPEN = "eu.etaxonomy.taxeditor.open"; public static final String CMD_OPEN_MESSAGE = "eu.etaxonomy.taxeditor.openMessage"; + public static final String CMD_OPEN_EDITOR = "eu.etaxonomy.taxeditor.openMessage"; } diff --git a/src/eu/etaxonomy/taxeditor/IModelListener.java b/src/eu/etaxonomy/taxeditor/IModelListener.java new file mode 100644 index 000000000..8295b0865 --- /dev/null +++ b/src/eu/etaxonomy/taxeditor/IModelListener.java @@ -0,0 +1,8 @@ +package eu.etaxonomy.taxeditor; + +public interface IModelListener { + String ADDED="__added"; //$NON-NLS-1$ + String REMOVED="__removed"; //$NON-NLS-1$ + String CHANGED = "__changed"; //$NON-NLS-1$ + void modelChanged(Object[] objects, String type, String property); +} \ No newline at end of file diff --git a/src/eu/etaxonomy/taxeditor/MasterDetailsPage.java b/src/eu/etaxonomy/taxeditor/MasterDetailsPage.java new file mode 100644 index 000000000..24efd34c7 --- /dev/null +++ b/src/eu/etaxonomy/taxeditor/MasterDetailsPage.java @@ -0,0 +1,22 @@ +package eu.etaxonomy.taxeditor; + +import org.eclipse.ui.forms.IManagedForm; +import org.eclipse.ui.forms.editor.FormEditor; +import org.eclipse.ui.forms.editor.FormPage; +import org.eclipse.ui.forms.widgets.ScrolledForm; + +public class MasterDetailsPage extends FormPage { + private ScrolledPropertiesBlock block; + public MasterDetailsPage(FormEditor editor) { + super(editor, "fourth", Messages.getString("MasterDetailsPage.label")); //$NON-NLS-1$ //$NON-NLS-2$ + block = new ScrolledPropertiesBlock(this); + } + protected void createFormContent(final IManagedForm managedForm) { + final ScrolledForm form = managedForm.getForm(); + //FormToolkit toolkit = managedForm.getToolkit(); + form.setText(Messages.getString("MasterDetailsPage.title")); //$NON-NLS-1$ + form.setBackgroundImage(Activator.getDefault().getImage( + Activator.IMG_FORM_BG)); + block.createContent(managedForm); + } +} \ No newline at end of file diff --git a/src/eu/etaxonomy/taxeditor/MessagePopupAction.java b/src/eu/etaxonomy/taxeditor/MessagePopupAction.java index f662e06e0..54245b80d 100644 --- a/src/eu/etaxonomy/taxeditor/MessagePopupAction.java +++ b/src/eu/etaxonomy/taxeditor/MessagePopupAction.java @@ -16,7 +16,7 @@ public class MessagePopupAction extends Action { setId(ICommandIds.CMD_OPEN_MESSAGE); // Associate the action with a pre-defined command, to allow key bindings. setActionDefinitionId(ICommandIds.CMD_OPEN_MESSAGE); - setImageDescriptor(eu.etaxonomy.taxeditor.Activator.getImageDescriptor("/icons/sample3.gif")); + setImageDescriptor(Activator.getImageDescriptorOrig("/icons/sample3.gif")); } public void run() { diff --git a/src/eu/etaxonomy/taxeditor/Messages.java b/src/eu/etaxonomy/taxeditor/Messages.java new file mode 100644 index 000000000..4cf03cd2c --- /dev/null +++ b/src/eu/etaxonomy/taxeditor/Messages.java @@ -0,0 +1,23 @@ +package eu.etaxonomy.taxeditor; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "eu.etaxonomy.taxeditor.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + // TODO Auto-generated method stub + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} \ No newline at end of file diff --git a/src/eu/etaxonomy/taxeditor/Name.java b/src/eu/etaxonomy/taxeditor/Name.java new file mode 100644 index 000000000..2ef1f54e9 --- /dev/null +++ b/src/eu/etaxonomy/taxeditor/Name.java @@ -0,0 +1,64 @@ +package eu.etaxonomy.taxeditor; + +public class Name extends NamedObject { + public static final String P_CHOICE="choice"; //$NON-NLS-1$ + public static final String P_FLAG="flag"; //$NON-NLS-1$ + public static final String P_TEXT="text"; //$NON-NLS-1$ + public static final String P_GENUSNAME="genusname"; //$NON-NLS-1$ + public static final String P_SPECIESEPITHET="speciesepithet"; //$NON-NLS-1$ + public static final String [] CHOICES = { + Messages.getString("TypeOne.c1"), Messages.getString("TypeOne.c2"), Messages.getString("TypeOne.c3"), Messages.getString("TypeOne.c4") }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private int choice=0; + private String text; + private String genusName; + private String speciesEpithet; + private boolean flag; + + /** + * @param name + */ + public Name(String name, String genusName, String speciesEpithet) { + super(name); + this.genusName = genusName; + this.speciesEpithet = speciesEpithet; + this.text = name; + + this.flag = true; + this.choice = 2; + } + public int getChoice() { + return choice; + } + public void setChoice(int choice) { + this.choice = choice; + model.fireModelChanged(new Object[] {this}, IModelListener.CHANGED, P_CHOICE); + } + public boolean getFlag() { + return flag; + } + public void setFlag(boolean flag) { + this.flag = flag; + model.fireModelChanged(new Object[] {this}, IModelListener.CHANGED, P_FLAG); + } + public String getText() { + return text; + } + public void setText(String text) { + this.text = text; + model.fireModelChanged(new Object[] {this}, IModelListener.CHANGED, P_TEXT); + } + public String getGenusName() { + return genusName; + } + public void setGenusName(String genusName) { + this.genusName = genusName; + model.fireModelChanged(new Object[] {this}, IModelListener.CHANGED, P_GENUSNAME); + } + public String getSpeciesEpithet() { + return speciesEpithet; + } + public void setSpeciesEpithet(String speciesEpithet) { + this.speciesEpithet = speciesEpithet; + model.fireModelChanged(new Object[] {this}, IModelListener.CHANGED, P_SPECIESEPITHET); + } +} diff --git a/src/eu/etaxonomy/taxeditor/NameDetailsPage.java b/src/eu/etaxonomy/taxeditor/NameDetailsPage.java new file mode 100644 index 000000000..222a7e395 --- /dev/null +++ b/src/eu/etaxonomy/taxeditor/NameDetailsPage.java @@ -0,0 +1,215 @@ +package eu.etaxonomy.taxeditor; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +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.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.IDetailsPage; +import org.eclipse.ui.forms.IFormPart; +import org.eclipse.ui.forms.IManagedForm; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Section; +import org.eclipse.ui.forms.widgets.TableWrapData; +import org.eclipse.ui.forms.widgets.TableWrapLayout; + +public class NameDetailsPage implements IDetailsPage { + private IManagedForm mform; + private Name input; + //private TaxonName input; + private Button [] choices; + private Button flag; + private Text text; + private Text genusName; + private Text speciesEpithet; + private Section s1; + private static final String RTEXT_DATA = + "

    An example of a free-form text that should be "+ //$NON-NLS-1$ + "wrapped below the section with widgets.

    "+ //$NON-NLS-1$ + "

    It can contain simple tags like links and bold text.

    "; //$NON-NLS-1$ + + public NameDetailsPage() { + } + /* (non-Javadoc) + * @see org.eclipse.ui.forms.IDetailsPage#initialize(org.eclipse.ui.forms.IManagedForm) + */ + public void initialize(IManagedForm mform) { + this.mform = mform; + } + /* (non-Javadoc) + * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite) + */ + public void createContents(Composite parent) { + TableWrapLayout layout = new TableWrapLayout(); + layout.topMargin = 5; + layout.leftMargin = 5; + layout.rightMargin = 2; + layout.bottomMargin = 2; + parent.setLayout(layout); + + FormToolkit toolkit = mform.getToolkit(); + //s1 = toolkit.createSection(parent, Section.DESCRIPTION|Section.TITLE_BAR); + s1 = toolkit.createSection(parent, Section.TITLE_BAR); + s1.marginWidth = 10; + s1.setText("Type One Details"); //$NON-NLS-1$ + //s1.setDescription(Messages.getString("TypeOneDetailsPage.name")); //$NON-NLS-1$ + TableWrapData td = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP); + td.grabHorizontal = true; + s1.setLayoutData(td); + Composite client = toolkit.createComposite(s1); + GridLayout glayout = new GridLayout(); + glayout.marginWidth = glayout.marginHeight = 0; + glayout.numColumns = 2; + client.setLayout(glayout); + GridData gd; + + /*SelectionListener choiceListener = new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + Integer value = (Integer)e.widget.getData(); + if (input!=null) { + input.setChoice(value.intValue()); + } + } + }; */ + + /* + NOTE: this can only be commented out when CHOICES part of update() below is also commented out + choices = new Button[TypeOne.CHOICES.length]; + for (int i=0; i(); + TaxonName tn = new TaxonName(); + NameService ns = new NameService(); + objects.add(ns.getTaxonNameById(1)); + objects.add(ns.getTaxonNameById(5)); + objects.add(ns.getTaxonNameById(28));*/ + + objects = new ArrayList(); + NamedObject[] objects = { + new Name("Pilosella piloselloides (Vill.) Soják", "Pilosella", "piloselloides"), + new Name("Pilosella pavichii (Heuff.) Arv.-Touv.", "Pilosella", "pavichii"), + new Name("Pilosella vahlii (Froel.) F. W. Schultz & Sch. Bip.", "Pilosella", "vahlii") + /*new TypeOne(Messages.getString("SimpleModel.t1_i1"), 2, true, Messages.getString("SimpleModel.text1")), //$NON-NLS-1$ //$NON-NLS-2$ + new TypeOne(Messages.getString("SimpleModel.t1_i2"), 1, false, Messages.getString("SimpleModel.text2")), //$NON-NLS-1$ //$NON-NLS-2$ + new TypeOne(Messages.getString("SimpleModel.t1_i3"), 3, true, Messages.getString("SimpleModel.text3")), //$NON-NLS-1$ //$NON-NLS-2$ + new TypeOne(Messages.getString("SimpleModel.t1_i4"), 0, false, Messages.getString("SimpleModel.text4")), //$NON-NLS-1$ //$NON-NLS-2$ + new TypeOne(Messages.getString("SimpleModel.t1_i5"), 1, true, Messages.getString("SimpleModel.text5")), //$NON-NLS-1$ //$NON-NLS-2$ + new TypeTwo(Messages.getString("SimpleModel.t2_i1"), false, true), //$NON-NLS-1$ + new TypeTwo(Messages.getString("SimpleModel.t2_i2"), true, false)*/}; //$NON-NLS-1$ + add(objects, false); + } + public void add(NamedObject[] objs, boolean notify) { + for (int i = 0; i < objs.length; i++) { + objects.add(objs[i]); + objs[i].setModel(this); + } + if (notify) + fireModelChanged(objs, IModelListener.ADDED, ""); //$NON-NLS-1$ + } + +// public void add(ArrayList tns, boolean notify) { +// for (int i = 0; i < tns.size(); i++) { +// objects.add(tns.get(i)); +// //tns[i].setModel(this); +// } +// //if (notify) +// //fireModelChanged(tns, IModelListener.ADDED, ""); //$NON-NLS-1$ +// } + + public void remove(NamedObject[] objs, boolean notify) { + for (int i = 0; i < objs.length; i++) { + objects.remove(objs[i]); + objs[i].setModel(null); + } + if (notify) + fireModelChanged(objs, IModelListener.REMOVED, ""); //$NON-NLS-1$ + } +} diff --git a/src/eu/etaxonomy/taxeditor/View.java b/src/eu/etaxonomy/taxeditor/View.java index 20d052703..2b798c050 100644 --- a/src/eu/etaxonomy/taxeditor/View.java +++ b/src/eu/etaxonomy/taxeditor/View.java @@ -21,8 +21,8 @@ public class View extends ViewPart { public void createPartControl(Composite parent) { Composite top = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; + layout.marginHeight = 10; + layout.marginWidth = 10; top.setLayout(layout); // top banner Composite banner = new Composite(top, SWT.NONE); diff --git a/src/eu/etaxonomy/taxeditor/messages.properties b/src/eu/etaxonomy/taxeditor/messages.properties new file mode 100644 index 000000000..af10879a5 --- /dev/null +++ b/src/eu/etaxonomy/taxeditor/messages.properties @@ -0,0 +1,125 @@ +FormView.title=Hello, Eclipse Forms +FormView.link=Click here. +FormView.linkMessage=Link activated\! +FormView.longLink=This is an example of a form that is much longer and will need to wrap. +FormView.textLabel=Text field label: +FormView.checkbox=A checkbox in a form +FormView.expandable=Expandable Composite title +FormView.expandableText=We will now create a somewhat long text so that +FormView.expandablText2=we can use it as content for the expandable composite. +FormView.expandableText3=Expandable composite is used to hide or show the text using the +FormView.expandableText4=toggle control +FormView.stitle=Section title +FormView.sdesc=This is the description that goes below the title +FormView.radio1=Radio 1 +FormView.radio2=Radio 2 +FormView.ftext1=Here is some plain text for the text to render; +FormView.ftext2=this text is at http://www.eclipse.org web site. +FormView.ftext3=This text is in header font and color. +FormView.ftext4=

    This line will contain some bold and some source text. +FormView.ftext5=We can also add an image. +FormView.ftext6=

  • A default (bulleted) list item.
  • +FormView.ftext7=
  • Another bullet list item.
  • +FormView.ftext8=
  • A list item with text.
  • +FormView.ftext9=
  • Another list item with text
  • +FormView.ftext10=
  • List item with an image bullet
  • +FormView.ftext11=
  • A list item with text.
  • +FormView.ftext12=
  • A list item with text.
  • +FormView.ftext13=

    leading blanks; more white \n\n new lines
    \n more bb white .

    +FormView.lmessage=Link active: +FreeFormPage.label=First Page +FreeFormPage.title=Free-form text with links +FreeFormPage.link=Sample hyperlink with longer text. +FreeFormPage.button=Button +FreeFormPage.sectionTitle1=Expandable Section with a longer title +FreeFormPage.sectionTitle2=Section title +FreeFormPage.sectionDescription=This is a section description that should be rendered below the separator. +FreeFormPage.mtitle=Eclipse Forms +FreeFormPage.mtext=Link activated: href= +SecondPage.label=Section Page +SecondPage.title=Title for the second page +SecondPage.firstSection=First Table Section +SecondPage.secondSection=Second Table Section +SecondPage.add=Add... +SecondPage.desc=This section has a tree and a button. +ScrolledPropertiesBlock.sname=Names +ScrolledPropertiesBlock.sdesc=Click on a name to edit its fields in the detail view. +ScrolledPropertiesBlock.add=Add... +ScrolledPropertiesBlock.horizontal=Horizontal orientation +ScrolledPropertiesBlock.vertical=Vertical orientation +TypeOneDetailsPage.name=Set the properties of the selected TypeOne object. +TypeTwoDetailsPage.name=Type Two Details +TypeTwoDetailsPage.desc=Set the properties of the selected TypeTwo object. +TypeOneDetailsPage.check=Value of the flag property +TypeOneDetailsPage.label=Text property: +TypeTwoDetailsPage.flag1=Value of the flag1 property +TypeTwoDetailsPage.flag2=Value of the flag2 property +OpenSimpleFormEditorAction.name=Simple Editor +SimpleModel.t1_i1=TypeOne instance 1 +SimpleModel.text1=Some text +SimpleModel.t1_i2=TypeOne instance 2 +SimpleModel.text2=Different text +SimpleModel.t1_i3=TypeOne instance 3 +SimpleModel.text3=Text +SimpleModel.t1_i4=TypeOne instance 4 +SimpleModel.text4=Longer text +SimpleModel.t1_i5=TypeOne instance 5 +SimpleModel.text5=Sample +SimpleModel.t2_i1=TypeTwo instance 1 +SimpleModel.t2_i2=TypeTwo instance 2 +MasterDetailsPage.label=Master Details +MasterDetailsPage.title=Edit Name Demo +ThirdPage.label=Flow Page +ThirdPage.title=Form with wrapped controls +ThirdPage.ls1.name=Link Section +ThirdPage.ls1.desc=An example of a section with links +ThirdPage.ls2.name=Link Section +ThirdPage.ls2.desc=An example of a section with links +ThirdPage.ms1.name=Mixed Section +ThirdPage.ms1.desc=An example of a section with both links and form controls +ThirdPage.ls3.name=Link Section +ThirdPage.ls3.desc=An example of a section with links +ThirdPage.cs1.name=Control Section +ThirdPage.cs1.desc=An example of a section with form controls +ThirdPage.ls4.name=Sample Section +ThirdPage.ls4.desc=An example of a section with links +ThirdPage.ls5.name=Sample Section +ThirdPage.ls5.desc=An example of a section with links +ThirdPage.ms2.name=Mixed Section +ThirdPage.ms2.desc=An example of a section with both links and form controls +ThirdPage.l6.name=Sample Section +ThirdPage.l6.desc=An example of a section with links +ThirdPage.cs2.name=Control Section +ThirdPage.cs2.desc=An example of a section with links +ThirdPage.l7.name=Sample Section +ThirdPage.l7.desc=An example of a section with links +ThirdPage.l8.name=Sample Section +ThirdPage.l8.desc=An example of a section with links +ThirdPage.m3.name=Mixed Section +ThirdPage.m3.desc=An example of a section with both links and form controls +ThirdPage.l9.name=Sample Section +ThirdPage.l9.desc=An example of a section with links +ThirdPage.c3.name=Control Section +ThirdPage.c3.desc=An example of a section with form controls +ThirdPage.link=Hyperlink text +ThirdPage.button1=A radio button 1 +ThirdPage.button2=A radio button 2 +ThirdPage.button3=A radio button with a longer text +ThirdPage.checkbox=A checkbox button +ThirdPage.longlink=A longer hyperlink text example +ThirdPage.link2=Another hyperlink text +ThirdPage.textLabel=A text label: +PageWithSubPages.label=Composite Page +PageWithSubPages.title=Form with subpages +PageWithSubPages.copyright.tab=Copyright +PageWithSubPages.copyright.text=Copyright 2004 IBM and others. +PageWithSubPages.license.tab=License Agreement +PageWithSubPages.license.text=LICENSE AGREEMENT\n\nUse this feature any way you want. +PageWithSubPages.desc.tab=Description +PageWithSubPages.desc.text=A simple description of the feature +PageWithSubPages.apply=Apply +PageWithSubPages.reset=Reset +TypeOne.c1=Choice 1 +TypeOne.c2=Choice 2 +TypeOne.c3=Choice 3 +TypeOne.c4=Choice 4 diff --git a/taxeditor.product b/taxeditor.product new file mode 100644 index 000000000..56c930373 --- /dev/null +++ b/taxeditor.product @@ -0,0 +1,68 @@ + + + + + + + + + Taxonomic Editor +(c) 2007 European Distributed Institute of Taxonomy + +Thanks to our worldwide fan community and Jesus. + + + + + + + -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +