diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/PreferencesBasedTeaVMProjectSettings.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/PreferencesBasedTeaVMProjectSettings.java index 585949f8c..ad31ae35a 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/PreferencesBasedTeaVMProjectSettings.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/PreferencesBasedTeaVMProjectSettings.java @@ -26,6 +26,7 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting public static final String SOURCE_MAPS = "sourceMaps"; public static final String DEBUG_INFORMATION = "debugInformation"; public static final String PROPERTIES = "properties"; + public static final String TRANSFORMERS = "transformers"; private static final String NEW_PROFILE_NAME = "New profile"; private List profiles = new ArrayList<>(); @@ -142,6 +143,7 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting private boolean sourceMapsGenerated; private boolean debugInformationGenerated; private Properties properties = new Properties(); + private String[] transformers = new String[0]; @Override public String getName() { @@ -272,6 +274,16 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting this.properties.putAll(properties); } + @Override + public String[] getTransformers() { + return transformers.clone(); + } + + @Override + public void setTransformers(String[] transformers) { + this.transformers = transformers.clone(); + } + public void load() throws BackingStoreException { preferences.sync(); enabled = preferences.getBoolean(ENABLED, true); @@ -290,6 +302,9 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting for (String key : propertiesPrefs.keys()) { properties.setProperty(key, propertiesPrefs.get(key, "")); } + Preferences transformersPrefs = preferences.node(TRANSFORMERS); + transformersPrefs.sync(); + transformers = transformersPrefs.keys(); } public void save() throws BackingStoreException { @@ -310,6 +325,12 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting propertiesPrefs.put((String)key, properties.getProperty((String)key)); } propertiesPrefs.flush(); + Preferences transformersPrefs = preferences.node(TRANSFORMERS); + transformersPrefs.clear(); + for (String transformer : transformers) { + transformersPrefs.put(transformer, ""); + } + transformersPrefs.flush(); preferences.flush(); } } diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMProfile.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMProfile.java index e25141922..14de2461f 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMProfile.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMProfile.java @@ -54,4 +54,8 @@ public interface TeaVMProfile { Properties getProperties(); void setProperties(Properties properties); + + String[] getTransformers(); + + void setTransformers(String[] transformers); } diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/ui/TeaVMProfileDialog.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/ui/TeaVMProfileDialog.java index d8eea2fe3..73d668a9c 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/ui/TeaVMProfileDialog.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/ui/TeaVMProfileDialog.java @@ -24,21 +24,12 @@ import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TableViewerColumn; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.MessageBox; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.*; import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; import org.eclipse.ui.model.WorkbenchContentProvider; import org.eclipse.ui.model.WorkbenchLabelProvider; @@ -73,6 +64,9 @@ public class TeaVMProfileDialog extends Dialog { private Button addPropertyButton; private Button deletePropertyButton; private WritableList propertyList = new WritableList(); + private org.eclipse.swt.widgets.List transormersList; + private Button addTransformerButton; + private Button removeTransformerButton; private IJavaProject javaProject; private TeaVMProjectSettings settings; private TeaVMProfile profile; @@ -99,13 +93,26 @@ public class TeaVMProfileDialog extends Dialog { protected Control createDialogArea(Composite parent) { Composite area = (Composite)super.createDialogArea(parent); area.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - //ScrolledComposite scrollContainer = new ScrolledComposite(area, SWT.V_SCROLL | SWT.H_SCROLL); - //scrollContainer.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true)); - Composite container = new Composite(area, SWT.NONE); - container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - /*scrollContainer.setContent(container); + ScrolledComposite scrollContainer = new ScrolledComposite(area, SWT.V_SCROLL | SWT.H_SCROLL); + scrollContainer.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true)); + TabFolder tabFolder = new TabFolder(scrollContainer, SWT.TOP); + scrollContainer.setContent(tabFolder); scrollContainer.setExpandHorizontal(true); - scrollContainer.setExpandVertical(true);*/ + scrollContainer.setExpandVertical(true); + TabItem generalItem = new TabItem(tabFolder, SWT.NONE); + generalItem.setText("General"); + generalItem.setControl(createGeneralTab(tabFolder)); + TabItem advancedItem = new TabItem(tabFolder, SWT.NONE); + advancedItem.setText("Advanced"); + advancedItem.setControl(createAdvancedTab(tabFolder)); + load(); + tabFolder.setSize(tabFolder.computeSize(SWT.DEFAULT, SWT.DEFAULT)); + scrollContainer.setMinSize(tabFolder.getSize()); + return scrollContainer; + } + + private Composite createGeneralTab(TabFolder folder) { + Composite container = new Composite(folder, SWT.NONE); GridLayout layout = new GridLayout(1, false); layout.marginHeight = 8; layout.verticalSpacing = 10; @@ -115,10 +122,16 @@ public class TeaVMProfileDialog extends Dialog { createIncrementalGroup(container); createDebugGroup(container); createPropertiesGroup(container); - load(); - //container.setSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT)); - //scrollContainer.setMinSize(container.getSize()); - //return scrollContainer; + return container; + } + + private Composite createAdvancedTab(TabFolder folder) { + Composite container = new Composite(folder, SWT.NONE); + GridLayout layout = new GridLayout(1, false); + layout.marginHeight = 8; + layout.verticalSpacing = 10; + container.setLayout(layout); + createTransformersGroup(container); return container; } @@ -263,6 +276,20 @@ public class TeaVMProfileDialog extends Dialog { String value = ""; } + private void createTransformersGroup(Composite parent) { + Group group = createGroup(parent, "TeaVM bytecode transformers", 2, true); + transormersList = new org.eclipse.swt.widgets.List(group, SWT.SINGLE | SWT.BORDER); + transormersList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3)); + + addTransformerButton = new Button(group, SWT.PUSH); + addTransformerButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); + addTransformerButton.setText("Add..."); + + removeTransformerButton = new Button(group, SWT.PUSH); + removeTransformerButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); + removeTransformerButton.setText("Remove"); + } + private Group createGroup(Composite parent, String title, int columns, boolean fillVert) { Group group = new Group(parent, SWT.NONE); group.setLayoutData(new GridData(SWT.FILL, fillVert ? SWT.FILL : SWT.TOP, true, fillVert));