package de.gps.log.db.ui.views;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
public class LogView {
public static String ID = "de.gps.log.db.ui.LogView";
private final Composite parent;
// e4 will inject the composite "parent" into the view
@Inject
public LogView(Composite parent) {
// the following is standard SWT Stuff
this.parent = parent;
}
@Focus
void setFocus() {
System.out.println("DBLogView -- setFocus");
}
// PostConstruct ensures that the dependency injection has been finished
// when this method is called
@PostConstruct
public void buildUI() {
System.out.println("DBLogView -- buildUI");
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginWidth = 0;
layout.marginHeight = 0;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
createViewer(composite);
}
@PreDestroy
public void dispose() {
// this is necessary
System.out.println("DBLogView -- dispose");
}
private void createViewer(Composite parent) {
Button button = new Button(parent, SWT.NONE);
button.addSelectionListener(new SelectionListener(){
@Override
public void widgetSelected(SelectionEvent e) {
System.out.println("Button pressed");
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
System.out.println("Button pressed");
}
});
}
}