Mercurial > hg > thermostat-tools-eclipse
changeset 3:91e5ed8dbda1
Data in Commands tab is automaticaly updated
author | Andriy Petrus <apetrus@redhat.com> |
---|---|
date | Tue, 26 Nov 2013 16:41:13 -0500 |
parents | 12f694a80bd4 |
children | 10fbd1b9e25d |
files | bin/com/redhat/thermostat/plugin/eclipse/Activator.class bin/com/redhat/thermostat/plugin/eclipse/actions/ThermostatAction.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizard.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPage$1.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPage$2.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPage$3.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPage$4.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPage$5.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPage.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPageTwo$1.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPageTwo.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatWizard$1.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatWizard$2.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatWizard.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatWizardPage$1.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatWizardPage$2.class bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatWizardPage.class bin/thermostatplugin/editors/MultiPageEditor$1.class bin/thermostatplugin/editors/MultiPageEditor$2.class bin/thermostatplugin/editors/MultiPageEditor.class bin/thermostatplugin/editors/MultiPageEditorContributor$1.class bin/thermostatplugin/editors/MultiPageEditorContributor.class plugin.xml src/thermostatplugin/editors/MultiPageEditor.java |
diffstat | 24 files changed, 84 insertions(+), 86 deletions(-) [+] |
line wrap: on
line diff
Binary file bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizard.class has changed
Binary file bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPage$1.class has changed
Binary file bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPage$2.class has changed
Binary file bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPage$3.class has changed
Binary file bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPage$4.class has changed
Binary file bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPage$5.class has changed
Binary file bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPage.class has changed
Binary file bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPageTwo$1.class has changed
Binary file bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatProjectCreationWizardPageTwo.class has changed
Binary file bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatWizardPage$1.class has changed
Binary file bin/com/redhat/thermostat/plugin/eclipse/wizards/ThermostatWizardPage$2.class has changed
--- a/plugin.xml Mon Nov 25 13:00:23 2013 -0500 +++ b/plugin.xml Tue Nov 26 16:41:13 2013 -0500 @@ -5,14 +5,6 @@ <extension point="org.eclipse.ui.editors"> <editor - name="Sample XML Editor" - extensions="xml" - icon="icons/sample.gif" - contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor" - class="com.redhat.thermostat.plugin.eclipse.editors.XMLEditor" - id="thermostatplugin.editors.XMLEditor"> - </editor> - <editor class="thermostatplugin.editors.MultiPageEditor" contributorClass="thermostatplugin.editors.MultiPageEditorContributor" extensions="xml" @@ -61,36 +53,5 @@ id="thermostatplugin.wizards.CreateNewThermostatPluginWizard"> </wizard> </extension> - - <extension - point="org.eclipse.ui.editors"> - <editor - name="Thermostat Plugin" - default="true" - icon="icons/thermostat.gif" - class="com.redhat.thermostat.plugin.eclipse.form.editors.ThermostatFormEditor" - id="org.eclipse.ui.forms.article.base-editor"> - </editor> - </extension> - <extension - point="org.eclipse.ui.actionSets"> - <actionSet - label="Thermostat Action Set" - id="org.eclipse.ui.forms.article.actionSet"> - <menu - label="Thermostat Form Editor" - id="org.eclipse.ui.forms.article.menu"> - <groupMarker - name="group"> - </groupMarker> - </menu> - <action - label="Thermostat Plugin Editor" - class="com.redhat.thermostat.plugin.eclipse.form.editors.OpenThermostatPluginEditor" - menubarPath="org.eclipse.ui.forms.article.menu/group" - id="org.eclipse.ui.forms.article.simple"> - </action> - </actionSet> - </extension> </plugin>
--- a/src/thermostatplugin/editors/MultiPageEditor.java Mon Nov 25 13:00:23 2013 -0500 +++ b/src/thermostatplugin/editors/MultiPageEditor.java Tue Nov 26 16:41:13 2013 -0500 @@ -12,7 +12,6 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; @@ -26,6 +25,8 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.dialogs.IPageChangedListener; +import org.eclipse.jface.dialogs.PageChangedEvent; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.SelectionAdapter; @@ -77,8 +78,11 @@ /** The text widget used in page 2. */ private StyledText text; - private String extensionName; - private String extensionDescription; + private String commandName; + Text commandNameText; + + private String commandDescription; + Text commandEnvironmentText; /** * Creates a multi-page editor example. @@ -86,13 +90,25 @@ public MultiPageEditor() { super(); ResourcesPlugin.getWorkspace().addResourceChangeListener(this); - extensionName = new String(""); + commandName = null; + commandNameText = null; + commandEnvironmentText = null; } - + + /** + * Creates the pages of the multi-page editor. + */ + protected void createPages() { + createOverviewPage(); + createSourcePage(); + createCommandPage(); + createTempPage(); + } + /** * Creates page 0 of the multi-page editor, which contains a text editor. */ - void createPage0() { + void createSourcePage() { try { editor = new TextEditor(); int index = addPage(editor, getEditorInput()); @@ -103,10 +119,7 @@ } } - /** - * Creates page 2 of the multi-page editor, which shows the sorted text. - */ - void createPage1() { + void createTempPage() { Composite composite = new Composite(getContainer(), SWT.NONE); FillLayout layout = new FillLayout(); composite.setLayout(layout); @@ -117,40 +130,39 @@ setPageText(index, "Preview"); } - /** - * Creates the pages of the multi-page editor. - */ - protected void createPages() { - createPage0(); - createExtensionsPage(); - createPage1(); + private void createOverviewPage() { + getEditorInput(); + Composite composite = new Composite(getContainer(), SWT.NONE); + GridLayout layout = new GridLayout(); + composite.setLayout(layout); + + int index = addPage(composite); + setPageText(index, "Overview"); } - private void createExtensionsPage() { + private void createCommandPage() { getEditorInput(); Composite composite = new Composite(getContainer(), SWT.NONE); GridLayout layout = new GridLayout(); composite.setLayout(layout); layout.numColumns = 2; - final Label extensionNameLabel = new Label(composite, SWT.NONE); - extensionNameLabel.setText("Initial Extension Name: "); - extensionNameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, + final Label commandNameLabel = new Label(composite, SWT.NONE); + commandNameLabel.setText("Command Name: "); + commandNameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - getAttributes(); - final Text extensionNameText = new Text(composite, SWT.BORDER); - extensionNameText.setText(extensionName); - extensionNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, + commandNameText = new Text(composite, SWT.BORDER); + commandNameText.setText(""); + commandNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); - Label extensionDescriptionLabel = new Label(composite, SWT.NONE); - extensionDescriptionLabel.setText("Extension Description: "); - extensionDescriptionLabel.setLayoutData(new GridData(SWT.RIGHT, + Label commandDescriptionLabel = new Label(composite, SWT.NONE); + commandDescriptionLabel.setText("Command Description: "); + commandDescriptionLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - - final Text extensionEnvironmentText = new Text(composite, SWT.BORDER); - extensionEnvironmentText.setText(extensionDescription); - extensionEnvironmentText.setLayoutData(new GridData(SWT.FILL, + commandEnvironmentText = new Text(composite, SWT.BORDER); + commandEnvironmentText.setText(""); + commandEnvironmentText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); Button fontButton = new Button(composite, SWT.NONE); GridData gd = new GridData(GridData.BEGINNING); @@ -158,19 +170,33 @@ fontButton.setLayoutData(gd); fontButton.setText("Save..."); + getAttributes(); + setCommandPageFields(); + fontButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - // setFont(); - // extensionNameText.setText("Saved..."); - extensionName = new String(extensionNameText.getText()); - // extensionEnvironmentText.setText(extensionNameText.getText()); + commandName = new String(commandNameText.getText()); updateElementValues(); } }); + addPageChangedListener(new IPageChangedListener() { + @Override + public void pageChanged(PageChangedEvent event) { + if (!isDirty()) { + getAttributes(); + setCommandPageFields(); + } + } + }); int index = addPage(composite); - setPageText(index, "Extensions"); + setPageText(index, "Commands"); + + } + private void setCommandPageFields() { + commandNameText.setText(commandName); + commandEnvironmentText.setText(commandDescription); } /** @@ -200,6 +226,7 @@ editor.doSaveAs(); setPageText(0, editor.getTitle()); setInput(editor.getEditorInput()); + setCommandPageFields(); } /* @@ -236,6 +263,7 @@ super.pageChange(newPageIndex); if (newPageIndex == 2) { sortWords(); + // setExtensionPageFields(); } } @@ -278,8 +306,8 @@ NodeList nList = doc.getElementsByTagName("command"); for (int i = 0; i < nList.getLength(); i++) { Element element = (Element) nList.item(i); - extensionName = getValueFromElement(element, "name"); - extensionDescription = getValueFromElement(element, + commandName = getAttributeValueFromElement(element, "name"); + commandDescription = getAttributeValueFromElement(element, "description"); } } catch (SAXException e) { @@ -294,8 +322,7 @@ } } - public static String getValueFromElement(Element element, - String attribute) { + public static String getAttributeValueFromElement(Element element, String attribute) { NodeList name = element.getElementsByTagName(attribute); Element line = (Element) name.item(0); @@ -326,7 +353,7 @@ element = (Element) nList.item(i); Node name = element.getElementsByTagName("name").item(0) .getFirstChild(); - name.setNodeValue(extensionName); + name.setNodeValue(commandName); } TransformerFactory transformerFactory = TransformerFactory .newInstance(); @@ -339,13 +366,23 @@ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); String path = new String(root.getLocation().toOSString()); - // String projectPath = root.getProject().getName(); TODO find a way to correctly find project/container name + // String projectPath = root.getProject().getName(); TODO find a way + // to correctly find project/container name String fileName = editor.getEditorInput().getName(); - String filePath = new String(path + "/test/" + fileName); //TODO replace /test/ with an actual container name and system path separators - - System.out.println(filePath); //TEST OUTPUT, TODO remove this. - StreamResult result = new StreamResult(new File(filePath)); + String filePath = new String(path + "/test/" + fileName); // TODO + // replace + // /test/ + // with an + // actual + // container + // name + // and + // system + // path + // separators + + StreamResult result = new StreamResult(new File(filePath)); transformer.transform(source, result); } catch (SAXException e) {