X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fproconf%2Fg3d%2Fviews%2FSinglePageResourceView.java;fp=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fproconf%2Fg3d%2Fviews%2FSinglePageResourceView.java;h=0000000000000000000000000000000000000000;hb=6b6fcff5d6c326feef07ccf8401f97911778fffe;hp=7935bb589d8d3208049a7011d5dc5b11c02f0097;hpb=504c111db40d78f4913badddd126b283b5504dbb;p=simantics%2F3d.git diff --git a/org.simantics.g3d/src/org/simantics/proconf/g3d/views/SinglePageResourceView.java b/org.simantics.g3d/src/org/simantics/proconf/g3d/views/SinglePageResourceView.java deleted file mode 100644 index 7935bb58..00000000 --- a/org.simantics.g3d/src/org/simantics/proconf/g3d/views/SinglePageResourceView.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007- VTT Technical Research Centre of Finland. - * 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: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.proconf.g3d.views; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.forms.events.ExpansionAdapter; -import org.eclipse.ui.forms.events.ExpansionEvent; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.forms.widgets.Section; -import org.simantics.proconf.ui.workbench.GraphAccessViewPart; -import org.simantics.utils.ui.jface.BaseSelectionProvider; - -public abstract class SinglePageResourceView extends GraphAccessViewPart{ - protected Composite parent; - private ScrolledForm form; - private BaseSelectionProvider defaultInputSelectionProvider = new BaseSelectionProvider(); - protected FormToolkit toolkit; - protected ISelectionListener pageSelectionListener; - - @Override - public void createPartControl(Composite parent) { - super.createPartControl(parent); - this.parent = parent; - - toolkit = new FormToolkit(parent.getDisplay()); - form = getToolkit().createScrolledForm(parent); - - GridLayout layout = new GridLayout(2, false); - form.getBody().setLayout(layout); - form.getBody().setLayoutData( - new GridData(GridData.FILL, GridData.FILL, true, true)); - - getViewSite().setSelectionProvider(defaultInputSelectionProvider); - - // createWidgets(); - - form.setText(getFormText()); - - hookPageSelection(); - - } - - - /** - * Receives selection changes - * - * @param part - * @param selection - */ - protected void pageSelectionChanged(IWorkbenchPart part, ISelection selection) { - - } - - - - - - protected abstract String getFormText(); - - protected abstract void createWidgets(); - - @Override - public void setFocus() { - //System.out.println("FormTypeEditorBase.setFocus(): Input = " + getInput()); - ScrolledForm form = getActiveForm(); - if (form != null) { - form.setFocus(); - } - } - - public FormToolkit getToolkit() { - return toolkit; - } - - public ScrolledForm getActiveForm() { - return form; - } - - public void clearForm() { - for (Control c : form.getBody().getChildren()) - c.dispose(); - - } - - protected Composite getBody() { - return form.getBody(); - } - - public Composite newGridSection( - int formColumns, - int childColumns, - boolean equalWidth, - boolean grabVertical, - String text, - String description) - { - return newGridSection(getBody(), formColumns, childColumns, equalWidth, grabVertical, text, description); - } - - public Composite newGridSection( - Composite parent, - int formColumns, - int childColumns, - boolean equalWidth, - boolean grabVertical, - String text, - String description) - { - FormToolkit toolkit = getToolkit(); - - Section section = toolkit.createSection(parent, - Section.DESCRIPTION | Section.TWISTIE | Section.TITLE_BAR | Section.EXPANDED); - section.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, grabVertical, formColumns, 1)); - section.addExpansionListener(new ExpansionAdapter() { - public void expansionStateChanged(ExpansionEvent e) { - //System.out.println("SinglePageTypeEditor: expansionStateChanged " + e); - //reflow(true); - } - }); - section.setText(text); - section.setDescription(description); - Composite sectionClient = toolkit.createComposite(section); - sectionClient.setLayout(new GridLayout(childColumns, equalWidth)); - sectionClient.setLayoutData(new GridData()); - section.setClient(sectionClient); - return sectionClient; - } - - public void dispose() { - if (pageSelectionListener != null) - getSite().getPage().removePostSelectionListener(pageSelectionListener); - - super.dispose(); - } - - private void hookPageSelection() { - pageSelectionListener = new ISelectionListener() { - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - if (part == SinglePageResourceView.this) - return; - pageSelectionChanged(part, selection); - } - }; - getSite().getPage().addPostSelectionListener(pageSelectionListener); - ISelection sel = getSite().getPage().getSelection(); - IWorkbenchPart wb = getSite().getPage().getActivePart(); - pageSelectionChanged(wb, sel); - } - -}