package de.afbb.bibo.ui.view;

import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.part.EditorPart;

abstract class AbstractEditView extends EditorPart {

	protected static final String EMPTY_STRING = "";//$NON-NLS-1$

	private Image imageValidation;
	private Label lblValidationImage;
	private Label lblValidationMessage;
	protected final DataBindingContext bindingContext = new DataBindingContext();
	protected FormToolkit toolkit = new FormToolkit(Display.getCurrent());

	@Override
	public void createPartControl(final Composite parent) {
//		final ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
//		scrolledComposite.setLayout(new GridLayout(1, false));
//
//		final Composite wrapperComposite = new Composite(scrolledComposite, SWT.NONE);
//		wrapperComposite.setLayout(new GridLayout(2, false));
//		wrapperComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
//		GridDataFactory.fillDefaults().grab(true, true).applyTo(wrapperComposite);
//
//		lblValidationImage = new Label(wrapperComposite, SWT.NONE);
//		lblValidationMessage = new Label(wrapperComposite, SWT.NONE);
//		lblValidationImage.setText("image");
//		lblValidationMessage.setText("text");
//
//		final Composite content = new Composite(wrapperComposite, SWT.NONE);
//		GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(content);
//
//		initUi(content);
//
//		scrolledComposite.setContent(wrapperComposite);
//		wrapperComposite.setSize(wrapperComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
//		scrolledComposite.setMinSize(wrapperComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
//		scrolledComposite.setExpandHorizontal(true);
//		scrolledComposite.setExpandVertical(true);
		initUi(parent);
		initBinding();
	}

	/**
	 * initializes the UX of the editor
	 */
	protected abstract void initUi(final Composite parent);

	/**
	 * initializes the databinding for the editor
	 */
	protected abstract void initBinding();

	@Override
	public void doSave(final IProgressMonitor monitor) {
	}

	@Override
	public void doSaveAs() {
	}

	@Override
	public boolean isDirty() {
		return false;
	}

	@Override
	public boolean isSaveAsAllowed() {
		return false;
	}
}

@@ -26,16 +26,53 @@
 iew;%0D%0A%0D%0A
+import java.net.ConnectException;%0D%0A%0D%0A
 import o
@@ -116,24 +116,24 @@
 ngContext;%0D%0A
-
 import org.e
@@ -171,16 +171,65 @@
 nitor;%0D%0A
+import org.eclipse.jface.dialogs.MessageDialog;%0D%0A
 import o
@@ -344,16 +344,16 @@
 splay;%0D%0A
-
 import o
@@ -383,16 +383,51 @@
 Label;%0D%0A
+import org.eclipse.ui.PlatformUI;%0D%0A
 import o
@@ -2443,24 +2443,597 @@
 nding();%0D%0A%0D%0A
+%09/**%0D%0A%09 * handles an connect exception by displaying an info dialog to the user and closing the view afterwards%0D%0A%09 * %0D%0A%09 * @param e%0D%0A%09 */%0D%0A%09protected void handle(final ConnectException e) %7B%0D%0A%09%09Display.getDefault().asyncExec(new Runnable() %7B%0D%0A%0D%0A%09%09%09@Override%0D%0A%09%09%09public void run() %7B%0D%0A%09%09%09%09MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), %22Fehler%22,%0D%0A%09%09%09%09%09%09%22Es besteht ein Verbindungsfehler mit dem Server.%5CnDiese Ansicht wird sich nun schlie%C3%9Fen.%22);%0D%0A%09%09%09%09getSite().getPage().closeEditor(AbstractEditView.this, false);%0D%0A%09%09%09%7D%0D%0A%09%09%7D);%0D%0A%09%7D%0D%0A%0D%0A
 %09@Override%0D%0A

implement a simple way for editors to handle connection exceptions