org.geneweaver.query.ui.QueryGeneratePage Maven / Gradle / Ivy
package org.geneweaver.query.ui;
import java.nio.file.Path;
import java.util.function.Consumer;
import org.eclipse.jface.resource.ImageDescriptor;
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;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;
import org.geneweaver.query.dao.QueryBuildRequest;
class QueryGeneratePage extends WizardPage {
private QueryBuildRequest request;
private Path dir;
private PathChoice dchoice;
private Text console;
protected QueryGeneratePage(QueryBuildRequest request, String pageName) {
super(pageName);
this.request = request;
setPageComplete(false);
setTitle("Generate");
setImageDescriptor(ImageDescriptor.createFromURL(getClass().getClassLoader().getResource("GW2-logo-blue.png")));
setMessage("Create the directory structure and files required to run the query on a cluster with sbatch.");
}
@Override
public void createControl(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(new GridLayout(1, false));
main.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true, true));
Consumer consumer = path->{
this.dir=path;
setPageComplete(true);
this.dchoice.setFileText(""); // We do not require the text here.
};
this.dchoice = new PathChoice(main, SWT.NONE, consumer, PathChoice.Type.Directory);
dchoice.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
dchoice.setFileLabelText("Output Directory ");
dchoice.createControls();
this.console = new Text(main, SWT.BORDER | SWT.MULTI|SWT.READ_ONLY|SWT.V_SCROLL|SWT.H_SCROLL);
this.console.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
this.console.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
console.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true, true));
setPageComplete(false);
setControl(main);
}
/**
* @return the dir
*/
public Path getDir() {
return dir;
}
/**
* @param dir the dir to set
*/
public void setDir(Path dir) {
this.dir = dir;
}
Consumer createMessageConsumer() {
return line->{
console.append("> ");
console.append(line);
console.append(System.lineSeparator());
};
}
}