You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by rg...@apache.org on 2005/08/05 18:07:01 UTC
svn commit: r230486 - in
/forrest/trunk/tools/eclipse/plugins/org.apache.forrest: ./
src/org/apache/forrest/eclipse/popup/actions/
src/org/apache/forrest/eclipse/wizards/
Author: rgardler
Date: Fri Aug 5 09:06:39 2005
New Revision: 230486
URL: http://svn.apache.org/viewcvs?rev=230486&view=rev
Log:
add actions to edit skinconf and selectd properties (thanks to Anil Ramnanan, FOR-596
Added:
forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/ModifyConfigs.java (with props)
forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/ModifyPlugins.java (with props)
forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/ModifyPluginsWizard.java (with props)
forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/ModifyProjectWizard.java (with props)
Modified:
forrest/trunk/tools/eclipse/plugins/org.apache.forrest/plugin.xml
Modified: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/plugin.xml
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/plugin.xml?rev=230486&r1=230485&r2=230486&view=diff
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/plugin.xml (original)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/plugin.xml Fri Aug 5 09:06:39 2005
@@ -87,6 +87,22 @@
class="org.apache.forrest.eclipse.popup.actions.BuildWARSite"
menubarPath="org.apache.forrest.eclipse.siteMenu/Static"
id="org.apache.forrest.eclipse.BuildWARServer"/>
+ <action
+ class="org.apache.forrest.eclipse.popup.actions.modifyConfigs"
+ enablesFor="1"
+ id="org.apache.forrest.eclipse.ModifyConfigs"
+ label="Modify Configurations"
+ menubarPath="org.apache.forrest.eclipse.configMenu"/>
+ <action
+ class="org.apache.forrest.eclipse.popup.actions.modifyPlugins"
+ enablesFor="1"
+ id="org.apache.forrest.eclipse.ModifyPlugins"
+ label="Modify Plugin Selection"
+ menubarPath="org.apache.forrest.eclipse.configMenu"/>
+ <menu
+ id="org.apache.forrest.eclipse.configMenu"
+ label="Modify Project Configurations"
+ path="projStart"/>
</objectContribution>
</extension>
Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/ModifyConfigs.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/ModifyConfigs.java?rev=230486&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/ModifyConfigs.java (added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/ModifyConfigs.java Fri Aug 5 09:06:39 2005
@@ -0,0 +1,87 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.eclipse.popup.actions;
+
+import org.apache.forrest.eclipse.wizards.ModifyProjectWizard;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+
+public class ModifyConfigs implements IObjectActionDelegate,
+ IJavaLaunchConfigurationConstants {
+
+ private IProject activeProject;
+
+ private Shell parent;
+
+ protected String projectName;
+
+ protected String xDocPath;
+
+ /**
+ * Constructor for Action1.
+ */
+ public ModifyConfigs() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ parent = targetPart.getSite().getShell();
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+
+ ModifyProjectWizard elementCreation_ = new ModifyProjectWizard(xDocPath);
+ elementCreation_.init(PlatformUI.getWorkbench(), null); // initializes
+ // the
+ // wizard
+ WizardDialog dialog = new WizardDialog(parent, elementCreation_);
+ dialog.open();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ // REFACTOR: see http://issues.apache.org/jira/browse/FOR-599
+ Object first = ((IStructuredSelection) selection).getFirstElement();
+ IResource resource = (IResource) first;
+ if (resource != null) {
+ IProject newActiveProject = resource.getProject();
+ if (newActiveProject != activeProject) {
+ // TODO: only attempt to load config file if this is a Forrest
+ // project
+ activeProject = newActiveProject;
+ projectName = activeProject.getProject().getName();
+ xDocPath = (activeProject.getProject().getLocation().toString() + java.io.File.separator);
+ }
+ }
+ }
+
+}
Propchange: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/ModifyConfigs.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/ModifyPlugins.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/ModifyPlugins.java?rev=230486&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/ModifyPlugins.java (added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/ModifyPlugins.java Fri Aug 5 09:06:39 2005
@@ -0,0 +1,86 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.eclipse.popup.actions;
+
+import org.apache.forrest.eclipse.wizards.ModifyPluginsWizard;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+
+public class ModifyPlugins implements IObjectActionDelegate,
+ IJavaLaunchConfigurationConstants {
+
+ private IProject activeProject;
+
+ private Shell parent;
+
+ protected String projectName;
+
+ protected String xDocPath;
+
+ /**
+ * Constructor for Action1.
+ */
+ public ModifyPlugins() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ parent = targetPart.getSite().getShell();
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ ModifyPluginsWizard elementCreation_ = new ModifyPluginsWizard(xDocPath);
+ elementCreation_.init(PlatformUI.getWorkbench(), null); // initializes
+ // the
+ // wizard
+ WizardDialog dialog = new WizardDialog(parent, elementCreation_);
+ dialog.open();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ // REFACTOR: see http://issues.apache.org/jira/browse/FOR-599
+ Object first = ((IStructuredSelection) selection).getFirstElement();
+ IResource resource = (IResource) first;
+ if (resource != null) {
+ IProject newActiveProject = resource.getProject();
+ if (newActiveProject != activeProject) {
+ // TODO: only attempt to load config file if this is a Forrest
+ // project
+ activeProject = newActiveProject;
+ projectName = activeProject.getProject().getName();
+ xDocPath = (activeProject.getProject().getLocation().toString() + java.io.File.separator);
+ }
+ }
+ }
+
+}
Propchange: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/ModifyPlugins.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/ModifyPluginsWizard.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/ModifyPluginsWizard.java?rev=230486&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/ModifyPluginsWizard.java (added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/ModifyPluginsWizard.java Fri Aug 5 09:06:39 2005
@@ -0,0 +1,104 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.eclipse.wizards;
+
+import org.apache.forrest.eclipse.actions.Utilities;
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+
+/**
+ * Create a new Content Package project.
+ */
+
+public class ModifyPluginsWizard extends Wizard implements INewWizard {
+ /**
+ * Logger for this class
+ */
+ private static final Logger logger = Logger
+ .getLogger(ModifyPluginsWizard.class);
+
+ private ActivatePluginsPage pluginPage;
+
+ private SiteOptionsPage siteOptionsPage;
+
+ private String path;
+
+ /**
+ * Constructor for ModifyProjectWizard.
+ *
+ * @param activeProject
+ */
+ public ModifyPluginsWizard(String newPath) {
+ super();
+ setWindowTitle("Modify Plugin Selection");
+ path = newPath;
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * Adding the page to the wizard.
+ */
+
+ public void addPages() {
+
+ pluginPage = new ActivatePluginsPage();
+ pluginPage.setTitle("Modify Plugin Selection");
+ pluginPage.setDescription("Modify Plugin Selectiion");
+ addPage(pluginPage);
+
+ }
+
+ /**
+ * This method is called when 'Finish' button is pressed in the wizard. We
+ * will create an operation and run it using wizard as execution context.
+ */
+ public boolean performFinish() {
+ if (pluginPage.getActivateViewValue()) {
+ Utilities.activateForrestProperty(path + "forrest.properties",
+ "project.skin=leather-dev");
+ Utilities
+ .addForrestPluginProperty(
+ path + "\\forrest.properties",
+ "org.apache.forrest.plugin.output.viewHelper.xhtml,org.apache.forrest.plugin.internal.view");
+ }
+ if (pluginPage.getSelectedPlugins() != null) {
+ Utilities.addForrestPluginProperty(path + "forrest.properties",
+ pluginPage.getSelectedPlugins());
+ }
+
+ return true;
+ }
+
+ /**
+ * This updated a configuration file based on the settings in siteconfig.xml
+ *
+ */
+
+ /**
+ * We will accept the selection in the workbench to see if we can initialize
+ * from it.
+ *
+ * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ }
+
+}
\ No newline at end of file
Propchange: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/ModifyPluginsWizard.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/ModifyProjectWizard.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/ModifyProjectWizard.java?rev=230486&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/ModifyProjectWizard.java (added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/ModifyProjectWizard.java Fri Aug 5 09:06:39 2005
@@ -0,0 +1,126 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.eclipse.wizards;
+
+import org.apache.forrest.eclipse.views.DOMUtilities;
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * Create a new Content Package project.
+ */
+
+public class ModifyProjectWizard extends Wizard implements INewWizard {
+ /**
+ * Logger for this class
+ */
+ private static final Logger logger = Logger
+ .getLogger(ModifyProjectWizard.class);
+
+ private WizardNewProjectCreationPage page;
+
+ private ActivatePluginsPage pluginPage;
+
+ private SiteOptionsPage siteOptionsPage;
+
+ private String path;
+
+ /**
+ * Constructor for ModifyProjectWizard.
+ *
+ * @param activeProject
+ */
+ public ModifyProjectWizard(String newPath) {
+ super();
+ setWindowTitle("Modify Forrest Project");
+ path = newPath;
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * Adding the page to the wizard.
+ */
+
+ public void addPages() {
+
+ siteOptionsPage = new SiteOptionsPage();
+ siteOptionsPage.setTitle("Modify Site Options");
+ siteOptionsPage.setDescription("Modify Site Options ");
+ addPage(siteOptionsPage);
+
+ }
+
+ /**
+ * This method is called when 'Finish' button is pressed in the wizard. We
+ * will create an operation and run it using wizard as execution context.
+ */
+ public boolean performFinish() {
+ updateConfig(path);
+
+ return true;
+ }
+
+ public void updateConfig(String path) {
+ Document document = siteOptionsPage.getOptionsValue();
+ NodeList configList = document.getElementsByTagName("configFile");
+ for (int y = 0; y < configList.getLength(); y++) {
+ Element config = (Element) configList.item(y);
+ Document configDoc = DOMUtilities.loadDOM(path
+ + config.getAttribute("location"));
+ NodeList itemList = document.getElementsByTagName("field");
+ for (int x = 0; x < itemList.getLength(); x++) {
+ Element oneItem = (Element) itemList.item(x);
+ String argument1 = oneItem.getAttribute("tag");
+ NodeList configNodes = configDoc
+ .getElementsByTagName(argument1);
+ for (int i = 0; i < configNodes.getLength(); i++) {
+ Element configItem = (Element) configNodes.item(i);
+ String argument2 = configItem.getNodeName();
+ if (argument1.equals(argument2)) {
+ Text value = (Text) configItem.getFirstChild();
+ value.setData(oneItem.getAttribute("default"));
+ }
+ }
+
+ }
+
+ DOMUtilities.SaveDOM(configDoc, path
+ + config.getAttribute("location"));
+ // TODO: change to the perspective specified in the plugin.xml
+ }
+
+ }
+
+ /**
+ * We will accept the selection in the workbench to see if we can initialize
+ * from it.
+ *
+ * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ }
+
+}
\ No newline at end of file
Propchange: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/ModifyProjectWizard.java
------------------------------------------------------------------------------
svn:eol-style = native