All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.geneweaver.query.ui.QueryEngineWizard Maven / Gradle / Ivy

package org.geneweaver.query.ui;

import java.io.IOException;
import java.nio.file.Path;

import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.widgets.Display;
import org.geneweaver.query.dao.QueryBuildRequest;
import org.geneweaver.query.service.QueryGeneratorService;

class QueryEngineWizard extends Wizard {
	
	private QueryBuildRequest request = new QueryBuildRequest();
	private QueryGeneratePage qpage;
	private NoDefaultButtonWizardDialog dialog;

	QueryEngineWizard() {
		setNeedsProgressMonitor(true);
	}
	@Override
	public void addPages() {
		
		setWindowTitle("Variant Orthology Graph Query Engine - "+QueryEngineEntry.getVersion());
		addPage(new WelcomePage(request, "Welcome"));
		addPage(new InputFilePage(request, "Inputs"));
		addPage(new RouteChoicePage(request, "Routes"));
		addPage(new InputMapPage(request, "Map to Graph"));
		addPage(new FilterChoicePage(request, "Filter"));
		
		this.qpage = new QueryGeneratePage(request, "Generate");
		addPage(qpage);

	}

	@Override
	public boolean performFinish() {
		
		try {
			QueryGeneratorService service = new QueryGeneratorService(QueryEngineEntry.getVersion());
			
			Path dir = qpage.getDir();
			service.write(request, dir, qpage.createMessageConsumer());
			qpage.setMessage("Wrote files to "+dir);
			qpage.setErrorMessage(null);
			dialog.setCancelButtonText("Close");
			dialog.setFinishButtonEnabled(false);
			return false; // true closes the wizard, which we do not want.
			
		} catch (IOException e) {
			qpage.setErrorMessage("Error writing query files: "+e.getMessage());
			e.printStackTrace();
			return false;
		} finally {
			getShell().setVisible(true);
		}
	}
	
	@Override
	public boolean performCancel() {
		Display.getDefault().close();
		return false;
	}
	public void setDialog(NoDefaultButtonWizardDialog dialog) {
		this.dialog = dialog;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy