1 package net.mograsim.plugin.wizards.newWizards;
3 import org.eclipse.jface.dialogs.Dialog;
4 import org.eclipse.jface.viewers.IStructuredSelection;
5 import org.eclipse.jface.wizard.WizardPage;
6 import org.eclipse.swt.SWT;
7 import org.eclipse.swt.layout.GridData;
8 import org.eclipse.swt.layout.GridLayout;
9 import org.eclipse.swt.widgets.Composite;
10 import org.eclipse.swt.widgets.Label;
12 import net.mograsim.plugin.nature.MachineContextSwtTools;
13 import net.mograsim.plugin.nature.MachineContextSwtTools.MachineCombo;
15 public class MograsimSettingsPage extends WizardPage
17 private MachineCombo machineSelect;
19 public MograsimSettingsPage(IStructuredSelection selection)
24 public MograsimSettingsPage()
26 super("Mograsim Project Settings");
27 setPageComplete(false);
31 public void createControl(Composite parent)
33 Composite composite = new Composite(parent, SWT.NULL);
34 initializeDialogUnits(parent);
36 composite.setLayout(new GridLayout());
37 composite.setLayoutData(new GridData(GridData.FILL_BOTH));
39 addFirstSection(composite);
40 addSeparator(composite);
41 addSecondSection(composite);
43 // Show description on opening
44 setErrorMessage(null);
46 setControl(composite);
47 Dialog.applyDialogFont(composite);
50 private void addFirstSection(Composite parent)
52 Composite composite = createDefaultComposite(parent);
54 // Label for path field
55 Label pathLabel = new Label(composite, SWT.NONE);
56 pathLabel.setText("Please configure the machine that Mograsim should use:");
59 private void addSeparator(Composite parent)
61 Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
62 GridData gridData = new GridData();
63 gridData.horizontalAlignment = GridData.FILL;
64 gridData.grabExcessHorizontalSpace = true;
65 separator.setLayoutData(gridData);
68 private Composite createDefaultComposite(Composite parent)
70 Composite composite = new Composite(parent, SWT.NULL);
71 GridLayout layout = new GridLayout();
72 layout.numColumns = 2;
73 composite.setLayout(layout);
75 GridData data = new GridData();
76 data.verticalAlignment = GridData.FILL;
77 data.horizontalAlignment = GridData.FILL;
78 composite.setLayoutData(data);
83 private void addSecondSection(Composite parent)
85 Composite composite = createDefaultComposite(parent);
88 Label ownerLabel = new Label(composite, SWT.NONE);
89 ownerLabel.setText("Machine definition");
92 machineSelect = MachineContextSwtTools.createMachineSelector(composite, SWT.NONE);
93 machineSelect.addListener(md -> setPageComplete(isValid()));
94 GridData gd = new GridData();
95 // machineSelect.setLayoutData(gd);
98 public boolean isValid()
100 return machineSelect.isValidSelection();
104 public void setVisible(boolean visible)
106 super.setVisible(visible);
109 // machineSelect.getCombo().getCCombo().setFocus();
113 public final MograsimProjectConfig getMograsimProjectConfig()
115 return new MograsimProjectConfig(machineSelect.getSelection().getId());
118 public static final class MograsimProjectConfig
120 final String machineId;
122 public MograsimProjectConfig(String machineId)
124 this.machineId = machineId;
127 public final String getMachineId()