Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Commit

Permalink
Initial wizard commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasmuelder committed Jul 4, 2016
1 parent 4601744 commit a280cda
Show file tree
Hide file tree
Showing 15 changed files with 354 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/org.yakindu.sct.examples.ui/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions examples/org.yakindu.sct.examples.ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
28 changes: 28 additions & 0 deletions examples/org.yakindu.sct.examples.ui/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.yakindu.sct.examples.ui</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
14 changes: 14 additions & 0 deletions examples/org.yakindu.sct.examples.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Example Wizard
Bundle-SymbolicName: org.yakindu.sct.examples.ui;singleton:=true
Bundle-Version: 2.6.1.qualifier
Bundle-Activator: org.yakindu.sct.examples.ui.ExampleActivator
Bundle-Vendor: statecharts.org
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.jface,
org.eclipse.core.resources,
org.eclipse.ui,
org.eclipse.ui.ide
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
5 changes: 5 additions & 0 deletions examples/org.yakindu.sct.examples.ui/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions examples/org.yakindu.sct.examples.ui/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.newWizards">
<category
id="org.yakindu.sct.examples.ui"
name="YAKINDU SCT">
</category>
<wizard
category="org.yakindu.sct.examples.ui"
class="org.yakindu.sct.examples.ui.wizards.ExamplesWizard"
icon="icons/sample.gif"
id="org.yakindu.sct.examples.ui.wizards.ExamplesWizard"
name="YAKINDU Examples">
</wizard>
</extension>

</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.yakindu.sct.examples.ui;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class ExampleActivator implements BundleActivator {

private static BundleContext context;

static BundleContext getContext() {
return context;
}

/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext bundleContext) throws Exception {
ExampleActivator.context = bundleContext;
}

/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {
ExampleActivator.context = null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.yakindu.sct.examples.ui.service;

import java.util.List;

public interface IExampleService {

List<ExampleData> getAllExamples();

public static class ExampleData {

private String id;
private String title;
private String description;

public ExampleData(String id, String title, String description) {
super();
this.id = id;
this.title = title;
this.description = description;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.yakindu.sct.examples.ui.service;

import java.util.ArrayList;
import java.util.List;

//TODO Delete me
public class MockExampleService implements IExampleService {

@Override
public List<ExampleData> getAllExamples() {
List<ExampleData> result = new ArrayList<>();
result.add(new ExampleData("my.id", "title", "description"));
result.add(new ExampleData("my.id2", "title2", "description2"));
result.add(new ExampleData("my.id3", "title3", "description3"));

return result;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.yakindu.sct.examples.ui.wizards;

import org.eclipse.jface.viewers.ArrayContentProvider;

public class ExampleContentProvider extends ArrayContentProvider {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.yakindu.sct.examples.ui.wizards;

import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;
import org.yakindu.sct.examples.ui.service.IExampleService.ExampleData;

public class ExampleLabelProvider implements ITableLabelProvider {

@Override
public void addListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub

}

@Override
public void dispose() {
// TODO Auto-generated method stub

}

@Override
public boolean isLabelProperty(Object element, String property) {
// TODO Auto-generated method stub
return false;
}

@Override
public void removeListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub

}

@Override
public Image getColumnImage(Object element, int columnIndex) {
return null;
}

@Override
public String getColumnText(Object element, int columnIndex) {
return ((ExampleData)element).getTitle();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.yakindu.sct.examples.ui.wizards;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;

public class ExamplesWizard extends Wizard implements INewWizard {
private ExamplesWizardPage page;
private ISelection selection;

public ExamplesWizard() {
super();
setNeedsProgressMonitor(true);
}

public void addPages() {
page = new ExamplesWizardPage(selection);
addPage(page);
}

public boolean performFinish() {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
doFinish(monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
};
try {
getContainer().run(true, false, op);
} catch (InterruptedException e) {
return false;
} catch (InvocationTargetException e) {
Throwable realException = e.getTargetException();
MessageDialog.openError(getShell(), "Error", realException.getMessage());
return false;
}
return true;
}

protected void doFinish(IProgressMonitor monitor)
throws CoreException {
//TODO: Import selected project
monitor.worked(1);
}

public void init(IWorkbench workbench, IStructuredSelection selection) {
this.selection = selection;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.yakindu.sct.examples.ui.wizards;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.yakindu.sct.examples.ui.service.IExampleService;
import org.yakindu.sct.examples.ui.service.MockExampleService;

public class ExamplesWizardPage extends WizardPage {

// TODO guice
private IExampleService exampleService = new MockExampleService();

public ExamplesWizardPage(ISelection selection) {
super("wizardPage");
setTitle("Select an example");
setDescription("This wizard creates statechart examples.");
}

public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
container.setLayout(layout);
createExamplesViewer(container);
createDetailsPane(container);
setControl(container);
}

protected void createDetailsPane(Composite container) {
Composite details = new Composite(container, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
details.setLayout(layout);

// TODO: Show Image
Label title = new Label(container, SWT.NONE);
title.setText("Example Title here...");

GridDataFactory.fillDefaults().applyTo(title);

Label description = new Label(container, SWT.NONE);
description.setText("Description here...");
GridDataFactory.fillDefaults().applyTo(description);

}

protected void createExamplesViewer(Composite container) {
TableViewer viewer = new TableViewer(container);
GridDataFactory.fillDefaults().applyTo(viewer.getControl());
viewer.setContentProvider(new ExampleContentProvider());
viewer.setLabelProvider(new ExampleLabelProvider());
viewer.setInput(exampleService.getAllExamples());

}
}

0 comments on commit a280cda

Please sign in to comment.