X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Fwizards%2FnewWizards%2FMograsimSettingsPage.java;fp=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Fwizards%2FnewWizards%2FMograsimSettingsPage.java;h=390cefbac01940c807b9d0c65131ee4f31c368a8;hb=804d41d604dfe055fc9ab2d311e0a30188db21e1;hp=0000000000000000000000000000000000000000;hpb=dbaa5d3ce959374d39d95889d008106b3e135b63;p=Mograsim.git diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/MograsimSettingsPage.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/MograsimSettingsPage.java new file mode 100644 index 00000000..390cefba --- /dev/null +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/MograsimSettingsPage.java @@ -0,0 +1,132 @@ +package net.mograsim.plugin.wizards.newWizards; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.IStructuredSelection; +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.Label; + +import net.mograsim.plugin.nature.MachineContextSwtTools; +import net.mograsim.plugin.nature.MachineContextSwtTools.MachineCombo; + +public class MograsimSettingsPage extends WizardPage +{ + private MachineCombo machineSelect; + + public MograsimSettingsPage(IStructuredSelection selection) + { + this(); + } + + public MograsimSettingsPage() + { + super("Mograsim Project Settings"); + setPageComplete(false); + } + + @Override + public void createControl(Composite parent) + { + Composite composite = new Composite(parent, SWT.NULL); + initializeDialogUnits(parent); + + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + addFirstSection(composite); + addSeparator(composite); + addSecondSection(composite); + + // Show description on opening + setErrorMessage(null); + setMessage(null); + setControl(composite); + Dialog.applyDialogFont(composite); + } + + private void addFirstSection(Composite parent) + { + Composite composite = createDefaultComposite(parent); + + // Label for path field + Label pathLabel = new Label(composite, SWT.NONE); + pathLabel.setText("Please configure the machine that Mograsim should use:"); + } + + private void addSeparator(Composite parent) + { + Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); + GridData gridData = new GridData(); + gridData.horizontalAlignment = GridData.FILL; + gridData.grabExcessHorizontalSpace = true; + separator.setLayoutData(gridData); + } + + private Composite createDefaultComposite(Composite parent) + { + Composite composite = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + composite.setLayout(layout); + + GridData data = new GridData(); + data.verticalAlignment = GridData.FILL; + data.horizontalAlignment = GridData.FILL; + composite.setLayoutData(data); + + return composite; + } + + private void addSecondSection(Composite parent) + { + Composite composite = createDefaultComposite(parent); + + // Label for machine + Label ownerLabel = new Label(composite, SWT.NONE); + ownerLabel.setText("Machine definition"); + + // Machine choice + machineSelect = MachineContextSwtTools.createMachineSelector(composite, SWT.NONE); + machineSelect.addListener(md -> setPageComplete(isValid())); + GridData gd = new GridData(); +// machineSelect.setLayoutData(gd); + } + + public boolean isValid() + { + return machineSelect.isValidSelection(); + } + + @Override + public void setVisible(boolean visible) + { + super.setVisible(visible); + if (visible) + { +// machineSelect.getCombo().getCCombo().setFocus(); + } + } + + public final MograsimProjectConfig getMograsimProjectConfig() + { + return new MograsimProjectConfig(machineSelect.getSelection().getId()); + } + + public static final class MograsimProjectConfig + { + final String machineId; + + public MograsimProjectConfig(String machineId) + { + this.machineId = machineId; + } + + public final String getMachineId() + { + return machineId; + } + } +}