/******************************************************************************* * Copyright (c) 2000, 2007 IBM Corporation 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.ui.forms.examples.internal.rcp; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.*; import org.eclipse.ui.forms.editor.FormEditor; import org.eclipse.ui.forms.editor.FormPage; import org.eclipse.ui.forms.events.*; import org.eclipse.ui.forms.examples.internal.ExamplesPlugin; import org.eclipse.ui.forms.widgets.*; /** * @author dejan * * To change the template for this generated type comment go to Window - * Preferences - Java - Code Generation - Code and Comments */ public class FreeFormPage extends FormPage { /** * @param id * @param title */ public FreeFormPage(FormEditor editor) { super(editor, "first", "First Page"); } public static final void createSharedFormContent(IManagedForm managedForm) { ScrolledForm form = managedForm.getForm(); FormToolkit toolkit = managedForm.getToolkit(); toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_HOVER); form.setText("Free-form text with links"); form.setBackgroundImage(ExamplesPlugin.getDefault().getImage(ExamplesPlugin.IMG_FORM_BG)); TableWrapLayout layout = new TableWrapLayout(); layout.leftMargin = 10; layout.rightMargin = 10; form.getBody().setLayout(layout); TableWrapData td; Hyperlink link = toolkit.createHyperlink(form.getBody(), "Sample hyperlink with longer text.", SWT.WRAP); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { try { Thread.sleep(1000); } catch (InterruptedException ex) { } } }); td = new TableWrapData(); td.align = TableWrapData.LEFT; link.setLayoutData(td); createExpandable(form, toolkit); } protected void createFormContent(IManagedForm managedForm) { createSharedFormContent(managedForm); } private static void createExpandable(final ScrolledForm form, final FormToolkit toolkit) { final ExpandableComposite exp = toolkit.createExpandableComposite(form .getBody(), ExpandableComposite.TREE_NODE // ExpandableComposite.NONE ); exp.setActiveToggleColor(toolkit.getHyperlinkGroup() .getActiveForeground()); exp.setToggleColor(toolkit.getColors().getColor(IFormColors.SEPARATOR)); Composite client = toolkit.createComposite(exp); exp.setClient(client); TableWrapLayout elayout = new TableWrapLayout(); client.setLayout(elayout); elayout.leftMargin = elayout.rightMargin = 0; final Button button = toolkit.createButton(client, "Button", SWT.PUSH); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { //openFormWizard(button.getShell(), toolkit.getColors()); } }); exp.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); exp.setText("Expandable Section with a longer title"); TableWrapData td = new TableWrapData(); //td.colspan = 2; td.align = TableWrapData.LEFT; //td.align = TableWrapData.FILL; exp.setLayoutData(td); } }