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;
18 private Label machineDescription;
20 public MograsimSettingsPage(IStructuredSelection selection)
25 public MograsimSettingsPage()
27 super("Mograsim Project Settings");
28 setPageComplete(false);
32 public void createControl(Composite parent)
34 Composite composite = new Composite(parent, SWT.NULL);
35 initializeDialogUnits(parent);
37 composite.setLayout(new GridLayout());
38 composite.setLayoutData(new GridData(GridData.FILL_BOTH));
40 addFirstSection(composite);
41 addSeparator(composite);
42 addSecondSection(composite);
44 // Show description on opening
45 setErrorMessage(null);
47 setControl(composite);
48 Dialog.applyDialogFont(composite);
51 private void addFirstSection(Composite parent)
53 Composite composite = createDefaultComposite(parent, false);
55 // Label for path field
56 Label pathLabel = new Label(composite, SWT.NONE);
57 pathLabel.setText("Please configure the machine that Mograsim should use:");
60 private void addSeparator(Composite parent)
62 Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
63 GridData gridData = new GridData();
64 gridData.horizontalAlignment = GridData.FILL;
65 gridData.grabExcessHorizontalSpace = true;
66 separator.setLayoutData(gridData);
69 private Composite createDefaultComposite(Composite parent, boolean grabExcessVerticalSpace)
71 Composite composite = new Composite(parent, SWT.NULL);
72 GridLayout layout = new GridLayout();
73 layout.numColumns = 2;
74 composite.setLayout(layout);
76 GridData data = new GridData();
77 data.verticalAlignment = GridData.FILL;
78 data.horizontalAlignment = GridData.FILL;
79 data.grabExcessHorizontalSpace = true;
80 data.grabExcessVerticalSpace = grabExcessVerticalSpace;
81 composite.setLayoutData(data);
86 private void addSecondSection(Composite parent)
88 Composite composite = createDefaultComposite(parent, true);
91 Label ownerLabel = new Label(composite, SWT.NONE);
92 ownerLabel.setText("Machine definition");
95 machineSelect = MachineContextSwtTools.createMachineSelector(composite, SWT.NONE);
96 machineSelect.addListener(md -> setPageComplete(isValid()));
98 machineDescription = new Label(composite, SWT.NONE);
99 machineSelect.addListener(md -> machineDescription.setText(md.getDescription()));
100 machineDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
103 public boolean isValid()
105 return machineSelect.isValidSelection();
109 public void setVisible(boolean visible)
111 super.setVisible(visible);
114 // machineSelect.getCombo().getCCombo().setFocus();
118 public final MograsimProjectConfig getMograsimProjectConfig()
120 return new MograsimProjectConfig(machineSelect.getSelection().getId());
123 public static final class MograsimProjectConfig
125 final String machineId;
127 public MograsimProjectConfig(String machineId)
129 this.machineId = machineId;
132 public final String getMachineId()