Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Started preference wizard for selecting models

  • Loading branch information...
commit e50888e3ab5d14d2bc75365512f4eb3b14143c77 1 parent ed042ab
Ola Spjuth olas authored
61 plugins/net.bioclipse.opentox.ds/src/net/bioclipse/opentox/ds/wizards/AddModelsWizard.java
View
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Ola Spjuth.
+ * 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:
+ * Ola Spjuth - initial API and implementation
+ ******************************************************************************/
+package net.bioclipse.opentox.ds.wizards;
+
+import java.util.List;
+import java.util.Map;
+
+import net.bioclipse.opentox.ds.OpenToxModel;
+
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+
+/**
+ * A wizard to select molecules and optionally a property that is used
+ * as reponse value.
+ *
+ * @author ola
+ *
+ */
+public class AddModelsWizard extends Wizard{
+
+ private SelectModelsPage selectModelsPage;
+
+ private List<OpenToxModel> models;
+
+ public List<OpenToxModel> getModels() {
+ return models;
+ }
+
+ public void setModels(List<OpenToxModel> models) {
+ this.models = models;
+ }
+
+ @Override
+ public void addPages() {
+
+ //Page 1: Select molecular files
+ selectModelsPage=new SelectModelsPage("Select models to add " +
+ "to Decision Support");
+ addPage(selectModelsPage);
+
+
+ }
+
+ @Override
+ public boolean performFinish() {
+
+ //Do something here?
+
+ return true;
+ }
+
+}
95 plugins/net.bioclipse.opentox.ds/src/net/bioclipse/opentox/ds/wizards/SelectModelsPage.java
View
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ola Spjuth.
+ * 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:
+ * Ola Spjuth - initial API and implementation
+ ******************************************************************************/
+package net.bioclipse.opentox.ds.wizards;
+
+
+import net.bioclipse.opentox.ds.Activator;
+import net.bioclipse.opentox.ds.prefs.OpenToxModelsPrefsPage;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * A Wizard page to select one or many opentox services
+ *
+ * @author ola
+ *
+ */
+public class SelectModelsPage extends WizardPage {
+
+ private CheckboxTreeViewer viewer;
+ private AddModelsWizard wizard;
+
+ // private ArrayList<IFile> selectedFiles;
+
+
+ protected SelectModelsPage(String pageName) {
+ super( pageName );
+ }
+
+ public void createControl( Composite parent ) {
+
+ wizard=(AddModelsWizard) getWizard();
+
+ setTitle( "Select Models" );
+ setDescription( "Select OpenTox models to include in the " +
+ "Decision Support. " );
+ // setImageDescriptor( Activator.getImageDescriptor( "wizban/wiz_imp_mol.gif" ) );
+
+ Composite comp = new Composite(parent, SWT.NONE);
+ GridLayout layout=new GridLayout();
+ comp.setLayout( layout );
+
+ viewer = new CheckboxTreeViewer(
+ parent, SWT.CHECK | SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.BORDER);
+
+ viewer.setUseHashlookup(true);
+ viewer.setContentProvider(new ServicesContentProvider());
+ viewer.setLabelProvider( new ServicesLabelProvider());
+
+ //Get services from prefs and set as input
+ IPreferenceStore store =
+ Activator.getDefault().getPreferenceStore();
+
+ String servicePrefs = store.getString(OpenToxModelsPrefsPage.OT_MODELS_PREFS);
+ String[] serviceStrings = OpenToxModelsPrefsPage.parsePreferenceString(servicePrefs);
+ viewer.setInput(serviceStrings);
+ viewer.expandToLevel(2);
+
+
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.grabExcessHorizontalSpace=true;
+ data.grabExcessVerticalSpace=true;
+ data.heightHint = 400;
+ data.widthHint = 300;
+ viewer.getControl().setLayoutData(data);
+ viewer.addCheckStateListener(new ICheckStateListener() {
+
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ System.out.println("Changed in viewer: " + event.getElement()
+ + " - " + event.getChecked());
+ //TODO: Act on this!
+ }
+ });
+
+ setControl( comp );
+ }
+
+}
45 plugins/net.bioclipse.opentox.ds/src/net/bioclipse/opentox/ds/wizards/ServicesContentProvider.java
View
@@ -0,0 +1,45 @@
+package net.bioclipse.opentox.ds.wizards;
+
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class ServicesContentProvider implements ITreeContentProvider {
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
46 plugins/net.bioclipse.opentox.ds/src/net/bioclipse/opentox/ds/wizards/ServicesLabelProvider.java
View
@@ -0,0 +1,46 @@
+package net.bioclipse.opentox.ds.wizards;
+
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+
+public class ServicesLabelProvider implements ILabelProvider {
+
+ @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 getImage(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.