Author: oberhack Date: Tue Aug 31 21:01:03 2004 New Revision: 37297 Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/MetroStudioUI.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/MetroStudioUIResources.properties avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/CommonDialogs.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/IModelObject.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/IUIStoreConstants.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/IViewPresentationService.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/ModelObject.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/constants/ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/constants/IUIStoreConstants.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/controller/ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/controller/CreateBlockProjectOperation.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/controller/NewMetroProjectWizardController.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/controller/PreferencesController.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/panels/ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/panels/RepositorySettingsPanel.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/panels/ServerSettingsPanel.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/preferences/ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/preferences/MainPreferencePage.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/preferences/RepositoryPreferencePage.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/preferences/ServerPreferencePage.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/properties/ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/properties/SamplePropertyPage.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/ - copied from rev 22169, avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/avalon/ide/eclipse/merlin/ui/tools/ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/wizards/ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/wizards/NewMetroProjectSelectionPage.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/wizards/NewMetroProjectWizard.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/wizards/WizardUtil.java Modified: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/AvalonProposals.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/ExampleBuilder.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/ImageViewerEditor.java avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/JavadocProcessor.java Log:
Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/MetroStudioUI.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/MetroStudioUI.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,151 @@ +/* + + Copyright 2004. The Apache Software Foundation. + + 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.metro.studio.eclipse.ui; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + * The main plugin class to be used in the desktop. + */ +public class MetroStudioUI extends AbstractUIPlugin +{ + //The shared instance. + private static MetroStudioUI plugin; + //Resource bundle. + private ResourceBundle resourceBundle; + public static final String PLUGIN_ID = "org.apache.metro.MetroStudioUI"; + /** + * The constructor. + */ + public MetroStudioUI() + { + super(); + plugin = this; + try + { + resourceBundle = + ResourceBundle.getBundle( + "org.apache.metro.studio.eclipse.ui.MetroStudioUIResources"); + } catch (MissingResourceException x) + { + resourceBundle = null; + } + } + + /** + * Returns the shared instance. + */ + public static MetroStudioUI getDefault() + { + return plugin; + } + + /** + * Returns the workspace instance. + */ + public static IWorkspace getWorkspace() + { + return ResourcesPlugin.getWorkspace(); + } + + /** + * Returns the string from the plugin's resource bundle, or 'key' if not + * found. + */ + public static String getResourceString(String key) + { + ResourceBundle bundle = MetroStudioUI.getDefault().getResourceBundle(); + try + { + return (bundle != null ? bundle.getString(key) : key); + } catch (MissingResourceException e) + { + return key; + } + } + + /** + * Returns the plugin's resource bundle, + */ + public ResourceBundle getResourceBundle() + { + return resourceBundle; + } + + public static void log(IStatus status) + { + getDefault().getLog().log(status); + } + + public static void log(Throwable e, String message) + { + boolean isDebugging = true; // change to false for production + IStatus status = + new Status( + IStatus.ERROR, + ResourcesPlugin.getPlugin().getBundle().getSymbolicName(), + IStatus.ERROR, + message, + e); + + log(status); + if (isDebugging) + { + System.out.println(message + ": " + e.getMessage()); //$NON-NLS-1$ + } + } + + public static ImageDescriptor getImageDescriptor(String path) + { + try + { + URL prefix = MetroStudioUI.getDefault().getBundle().getEntry("/"); + return ImageDescriptor.createFromURL(new URL(prefix, path)); + } catch (MalformedURLException e) + { + log(e, "getResourceBundle() handling MalformedURLException"); //$NON-NLS-1$ + return null; + } + } + + /** + * This method is called upon plug-in activation + */ + public void start(BundleContext context) throws Exception { + super.start(context); + } + + /** + * This method is called when the plug-in is stopped + */ + public void stop(BundleContext context) throws Exception { + super.stop(context); + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/MetroStudioUIResources.properties ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/MetroStudioUIResources.properties Tue Aug 31 21:01:03 2004 @@ -0,0 +1,45 @@ +######################################### +# +# +# +# Copyright 2004. The Apache Software Foundation. +# +# 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. +# +# +# +######################################### + +new.MerlinDevelopment.window.title=New Merlin Project +new.MerlinDevelopment.errorDialog.title=Error +new.MerlinDevelopment.mainPage.title=Merlin Block Development +new.MerlinDevelopment.mainPage.description=Create a project to develop blocks for the Merlin container +new.MerlinDevelopment.selectionPage.title=Project Selection Page +new.MerlinDevelopment.selectionPage.description=Select a type of project you want to create. +new.MerlinDevelopment.containerPage.title=Project Details +new.MerlinDevelopment.containerPage.description=Enter required data to create your Merlin project +javadoc.avalon.component=mark a class as merlin component +javadoc.avalon.component.tag=avalon.component name="xx" version="1.0.0" livestyle="singleton" +javadoc.avalon.dependency=defines a dependency +javadoc.avalon.dependency.tag=avalon.dependency type="xx" key="yy" +javadoc.avalon.service.tag=avalon.service type="xx" version="1.0.0" +javadoc.avalon.service=defines the service interface +javadoc.avalon.entry.tag=avalon.entry entry="urn:avalon:xx" +javadoc.avalon.entry=defines an entry for special context values +javadoc.avalon.stage=define lifecycle extensions +javadoc.avalon.stage.tag=avalon.stage id="urn:name:type" +javadoc.avalon.extension=definition of an extension +javadoc.avalon.extension.tag=avalon.extension id="urn:name:type" +javadoc.avalon.logger.tag=avalon.logger name="xx.yy" +javadoc.avalon.logger=defines a logger + Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/CommonDialogs.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/CommonDialogs.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,54 @@ +/* + * Created on 20.08.2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +package org.apache.metro.studio.eclipse.ui.common; + +import java.io.File; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; + +/** + * @author EH2OBCK + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class CommonDialogs { + + public static String getPath(Shell shell) + { + File directory = null; + DirectoryDialog fileDialog = new DirectoryDialog(shell, SWT.OPEN); + //if (startingDirectory != null) + //fileDialog.setFilterPath(startingDirectory.getPath()); + String dir = fileDialog.open(); + if (dir != null) { + dir = dir.trim(); + if (dir.length() > 0) + directory = new File(dir); + } + if(dir == null) return null; + return directory.getAbsolutePath(); + } + public static String getFilePath(Shell shell) + { + File directory = null; + FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); + //if (startingDirectory != null) + //fileDialog.setFilterPath(startingDirectory.getPath()); + String dir = fileDialog.open(); + if (dir != null) { + dir = dir.trim(); + if (dir.length() > 0) + directory = new File(dir); + } + if(dir == null) return null; + return directory.getAbsolutePath(); + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/IModelObject.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/IModelObject.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,16 @@ +/* + * Created on 20.08.2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +package org.apache.metro.studio.eclipse.ui.common; + +/** + * @author EH2OBCK + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public interface IModelObject { +} Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/IUIStoreConstants.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/IUIStoreConstants.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,21 @@ +/* + * Created on 19.08.2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +package org.apache.metro.studio.eclipse.ui.common; + +/** + * @author EH2OBCK + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public interface IUIStoreConstants { + + public static final String METRO_LIB = "lib"; + public static final String METRO_LIB_DEFAULT = "merlin-cli-1.3.0.jar"; + public static final String METRO_LANG = "lang"; + public static final String METRO_LANG_DEFAULT = "en"; +} Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/IViewPresentationService.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/IViewPresentationService.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,16 @@ +/* + * Created on 20.08.2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +package org.apache.metro.studio.eclipse.ui.common; + +/** + * @author EH2OBCK + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public interface IViewPresentationService { +} Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/ModelObject.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/common/ModelObject.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,115 @@ +/* + * Created on 20.08.2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +package org.apache.metro.studio.eclipse.ui.common; + +import java.util.Hashtable; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.dialogs.DialogPage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.ui.dialogs.PropertyPage; + +/** + * @author EH2OBCK + * + * This ModelObject implements the Presentation IModelObject + * without using the event handling + * It only shield the differences between the stores used by PreferencePages + * or PropertyPages so that this Panel can be reused in either situation. + */ +public class ModelObject implements IModelObject { + private transient Hashtable defaults = new Hashtable(); + + private IResource element; + private IViewPresentationService service; + private IPreferenceStore store; + /** + * + */ + public ModelObject(DialogPage page) { + super(); + if(page instanceof PropertyPage) + { + element = (IResource)((PropertyPage)page).getElement(); + } else + { + store = ((PreferencePage)page).getPreferenceStore(); + } + } + public String getDefaultString(String name) + { + if(element != null) + {return (String)defaults.get(name); + } + if(store != null) + { + return store.getDefaultString(name); + } + return null; + } + public String getString(String name) + { + try { + if(element != null) + {return (String)element.getPersistentProperty(new QualifiedName("", name)); + } + if(store != null) + { + return store.getString(name); + } + } catch (CoreException e) { + e.printStackTrace(); + } + return null; + } + /** + * @param repository_panel + */ + public ModelObject controlClicked(String controlName) { + + // local = service.clicked(controlName, this); + return this; + } + public void setDefaultString(String name, String defaultValue) + { + if(element != null) + {defaults.put(name, defaultValue); + } + if(store != null) + { + store.setDefault(name, defaultValue); + } + } + + public void setString(String name, String value) + { + try { + if(element != null) + {element.setPersistentProperty(new QualifiedName("", name), + value); + } + if(store != null) + { + store.setValue(name, value); + } + } catch (CoreException e) { + e.printStackTrace(); + } + } + /** + * @param repository_panel + * @return + */ + public ModelObject windowCreated(String repository_panel) { + + return this; + } + +} Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/constants/IUIStoreConstants.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/constants/IUIStoreConstants.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,23 @@ +/* + * Created on 19.08.2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +package org.apache.metro.studio.eclipse.ui.constants; + +/** + * @author EH2OBCK + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public interface IUIStoreConstants { + + public static final String METRO_LIB = "lib"; + public static final String METRO_LIB_DEFAULT = "merlin-cli-1.3.0.jar"; + public static final String METRO_LANG = "lang"; + public static final String METRO_LANG_DEFAULT = "en"; + + public static final String METRO_HOME = "metro.home"; +} Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/controller/CreateBlockProjectOperation.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/controller/CreateBlockProjectOperation.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,76 @@ +/* + + Copyright 2004. The Apache Software Foundation. + + 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.metro.studio.eclipse.ui.controller; + +import java.lang.reflect.InvocationTargetException; + +import org.apache.metro.facility.presentationservice.api.IModelChannel; +import org.apache.metro.facility.presentationservice.impl.ChannelException; +import org.apache.metro.studio.eclipse.ui.wizards.NewMetroProjectWizard; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.operation.IRunnableWithProgress; + +/** + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + * + */ +public class CreateBlockProjectOperation implements IRunnableWithProgress +{ + + private IModelChannel channel; + + public CreateBlockProjectOperation() + {} + + /** + * @param pParam + * @param pModel + */ + public CreateBlockProjectOperation(IModelChannel channel) + { + this.channel = channel; + } + + public void run(IProgressMonitor monitor) + throws InvocationTargetException, InterruptedException + { + if (monitor == null) + { + monitor = new NullProgressMonitor(); + } + try + { + try + { + // monitor.beginTask(MerlinDeveloperUI.getResourceString("NewWebAppProjectOperation.createWebAppTask.description"), 1); //$NON-NLS-1$ + + channel.controlClicked(NewMetroProjectWizard.NEW_PROJECT_FINISH); + + } finally + { + monitor.done(); + } + } catch (ChannelException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} \ No newline at end of file Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/controller/NewMetroProjectWizardController.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/controller/NewMetroProjectWizardController.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,128 @@ +/* + + Copyright 2004. The Apache Software Foundation. + +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.metro.studio.eclipse.ui.controller; + +import org.apache.metro.facility.presentationservice.api.ChannelListener; +import org.apache.metro.facility.presentationservice.impl.ChannelEvent; +import org.apache.metro.facility.presentationservice.impl.ChannelException; +import org.apache.metro.facility.presentationservice.impl.ViewChannel; +import org.apache.metro.studio.eclipse.core.templateengine.BlockProjectManager; +import org.apache.metro.studio.eclipse.core.templateengine.ResourceTemplateManager; +import org.apache.metro.studio.eclipse.ui.wizards.NewMetroProjectSelectionPage; +import org.apache.metro.studio.eclipse.ui.wizards.NewMetroProjectWizard; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; + +/** + * @author <a href="mailto:dev@avalon.apache.org">Metro Development Team</a> + * 22.08.2004 + * last change: + * + */ +public class NewMetroProjectWizardController +{ + ResourceTemplateManager rm; + /** + * + */ + public NewMetroProjectWizardController() + { + super(); + } + + private ChannelEvent selectionListClicked(ChannelEvent event) + { + + String help = BlockProjectManager.getResourceHelp(event.getValue(NewMetroProjectSelectionPage.SELECTION_CONTROL_SELECTED)); + event.putValue("resource.help", help); + return event; + } + + private ChannelEvent selectionApplyClicked(ChannelEvent event) + { + try + { + String projectName = event.getValue(NewMetroProjectWizard.NEW_PROJECT_NAME); + String templateName = event.getValue(NewMetroProjectSelectionPage.SELECTION_CONTROL_SELECTED); + + IProject project = BlockProjectManager.create(projectName, templateName); + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) + { + + e.printStackTrace(); + } + + + return event; + } + + private ChannelEvent selectionWindowCreated(ChannelEvent event) + { + rm = ResourceTemplateManager.load(ResourceTemplateManager.DEFAULT_CONFIG_PATH); + event.putValueArray(NewMetroProjectSelectionPage.SELECTION_CONTROL_LIST, BlockProjectManager.listTemplateNames()); + return event; + } + + /** + * register all event listeners + * + */ + public void initialize() + { + + try + { + ViewChannel channel = new ViewChannel("newBlockWizard"); + + channel.addControlClickedListener(NewMetroProjectSelectionPage.SELECTION_CONTROL, new ChannelListener (){ + public ChannelEvent notify(ChannelEvent event) throws ChannelException + { + selectionListClicked(event); + return event; + + } + }); + + channel.addControlClickedListener(NewMetroProjectWizard.NEW_PROJECT_FINISH, new ChannelListener (){ + public ChannelEvent notify(ChannelEvent event) throws ChannelException + { + selectionApplyClicked(event); + return event; + + } + }); + + channel.addWindowCreatedListener(NewMetroProjectSelectionPage.SELECTION_PANEL, new ChannelListener (){ + public ChannelEvent notify(ChannelEvent event) throws ChannelException + { + event = selectionWindowCreated(event); + return event; + + } + }); + + } catch (ChannelException e) + { + e.printStackTrace(); + } + + } + +} Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/controller/PreferencesController.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/controller/PreferencesController.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,103 @@ +/* + + Copyright 2004. The Apache Software Foundation. + +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.metro.studio.eclipse.ui.controller; + +import org.apache.metro.facility.presentationservice.api.ChannelListener; +import org.apache.metro.facility.presentationservice.impl.ChannelEvent; +import org.apache.metro.facility.presentationservice.impl.ChannelException; +import org.apache.metro.facility.presentationservice.impl.ViewChannel; +import org.apache.metro.studio.eclipse.core.environment.MetroEnvironment; +import org.apache.metro.studio.eclipse.core.environment.ServerEnvironment; +import org.apache.metro.studio.eclipse.ui.panels.ServerSettingsPanel; + +/** + * @author <a href="mailto:dev@avalon.apache.org">Metro Development Team</a> + * 22.08.2004 + * last change: + * + */ +public class PreferencesController +{ + + /** + * + */ + public PreferencesController() + { + super(); + } + + private void serverApplyClicked(ChannelEvent event) + { + event.getValue(ServerSettingsPanel.SERVER_DEPLOY); + event.getValue(ServerSettingsPanel.SERVER_LANG); + event.getValue(ServerSettingsPanel.SERVER_ROOT_BLOCK); + event.getValue(ServerSettingsPanel.SERVER_ROOT_FACILITY); + event.getValue(ServerSettingsPanel.SERVER_STARTUP_JAR); + + } + + private void serverWindowCreated(ChannelEvent event) + { + MetroEnvironment env = new MetroEnvironment(); + + event.putValue(ServerSettingsPanel.SERVER_DEPLOY, ""); + event.putValue(ServerSettingsPanel.SERVER_LANG, ServerEnvironment.DEFAULT_LANG); + event.putValue(ServerSettingsPanel.SERVER_ROOT_BLOCK, env.getMerlinHome()); + event.putValue(ServerSettingsPanel.SERVER_ROOT_FACILITY, ""); + event.putValue(ServerSettingsPanel.SERVER_STARTUP_JAR, ""); + + } + + /** + * register all event listeners + * + */ + public void initialize() + { + + try + { + ViewChannel channel = new ViewChannel("server"); + + channel.addControlClickedListener(ServerSettingsPanel.SERVER_APPLY, new ChannelListener (){ + public ChannelEvent notify(ChannelEvent event) throws ChannelException + { + serverApplyClicked(event); + return event; + + } + }); + + channel.addWindowCreatedListener(ServerSettingsPanel.SERVER_PANEL, new ChannelListener (){ + public ChannelEvent notify(ChannelEvent event) throws ChannelException + { + serverWindowCreated(event); + return event; + + } + }); + + } catch (ChannelException e) + { + e.printStackTrace(); + } + + } + +} Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/panels/RepositorySettingsPanel.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/panels/RepositorySettingsPanel.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,238 @@ +/* + * Created on 17.08.2004 + * + * TODO To change the template for this generated file go to Window - + * Preferences - Java - Code Generation - Code and Comments + */ +package org.apache.metro.studio.eclipse.ui.panels; +import org.apache.metro.studio.eclipse.ui.common.CommonDialogs; +import org.apache.metro.studio.eclipse.ui.common.ModelObject; +import org.eclipse.swt.SWT; +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.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +/** + * @author EH2OBCK + * + * TODO To change the template for this generated type comment go to Window - + * Preferences - Java - Code Generation - Code and Comments + */ +public class RepositorySettingsPanel { + + public static final String REPOSITORY_PANEL = "repository.panel"; + public static final String REPOSITORY_APPLY = "repository.apply"; + public static final String REPOSITORY_DEFAULT = "repository.default"; + + public static final String REPOSITORY_USER = "repository.user"; + public static final String REPOSITORY_SYSTEM = "repository.system"; + public static final String REPOSITORY_REMOTE = "repository.remote"; + public static final String REPOSITORY_PROXY_HOST = "repository.proxyhost"; + public static final String REPOSITORY_PROXY_PORT = "repository.proxyport"; + public static final String REPOSITORY_PROXY_USER = "repository.proxyuser"; + public static final String REPOSITORY_PROXY_PWD = "repository.proxypwd"; + + private Text password; + private Text userName; + private Text proxyPort; + private Text proxyHome; + private List remoteHosts; + private Text userRepository; + private Text systemRepository; + private Text metroHome; + private Shell shell; + + private ModelObject model; + + /** + * + */ + public RepositorySettingsPanel() { + super(); + } + + public void initializeControls(ModelObject cModel) + { + this.model = cModel.windowCreated(REPOSITORY_PANEL); + showControls(); + + } + + public void performApply() + { + storeControls(); + model.controlClicked(REPOSITORY_APPLY); + } + + public void performDefaults() + { + model = model.controlClicked(REPOSITORY_DEFAULT); + showControls(); + } + + private void storeControls() + { + model.setString(REPOSITORY_PROXY_PWD, password.getText()); + model.setString(REPOSITORY_PROXY_USER, userName.getText()); + model.setString(REPOSITORY_PROXY_PORT, proxyPort.getText()); + model.setString(REPOSITORY_PROXY_HOST, proxyHome.getText()); + model.setString(REPOSITORY_USER, userRepository.getText()); + model.setString(REPOSITORY_SYSTEM, systemRepository.getText()); + } + private void showControls() + { + password.setText(model.getString(REPOSITORY_PROXY_PWD)); + userName.setText(model.getString(REPOSITORY_PROXY_USER)); + proxyPort.setText(model.getString(REPOSITORY_PROXY_PORT)); + proxyHome.setText(model.getString(REPOSITORY_PROXY_HOST)); + //remoteHosts.setText(model.getString(REPOSITORY_PROXY_PWD)); + userRepository.setText(model.getString(REPOSITORY_USER)); + systemRepository.setText(model.getString(REPOSITORY_SYSTEM)); + + } + /** + * Create all controls + * @param parent + * @return + */ + public Control createControls(Composite parent) { + shell = parent.getShell(); + Composite contents = new Composite(parent, SWT.NONE); + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 3; + contents.setLayout(gridLayout); + contents.setLayoutData(new GridData(GridData.FILL_BOTH)); + { + final Label label = new Label(contents, SWT.NONE); + label.setText("Metro Home:"); + } + { + metroHome = new Text(contents, SWT.BORDER); + metroHome.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + } + { + final Button button = new Button(contents, SWT.NONE); + button.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + metroHome.setText(CommonDialogs.getPath(shell)); } + }); + button.setText("..."); + } + { + final Label label = new Label(contents, SWT.NONE); + label.setText("System Repository:"); + } + { + systemRepository = new Text(contents, SWT.BORDER); + systemRepository.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); + } + { + final Button button = new Button(contents, SWT.NONE); + button.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + systemRepository.setText(CommonDialogs.getPath(shell)); } + }); + button.setText("..."); + } + { + final Label label = new Label(contents, SWT.NONE); + label.setText("User Repository:"); + } + { + userRepository = new Text(contents, SWT.BORDER); + userRepository.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); + } + { + final Button button = new Button(contents, SWT.NONE); + button.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + userRepository.setText(CommonDialogs.getPath(shell)); } + }); + button.setText("..."); + } + { + final Label label = new Label(contents, SWT.NONE); + final GridData gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); + gridData.verticalSpan = 2; + label.setLayoutData(gridData); + label.setText("Remote Repositories:"); + } + { + remoteHosts = new List(contents, SWT.BORDER); + final GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + gridData.heightHint = 80; + gridData.verticalSpan = 2; + remoteHosts.setLayoutData(gridData); + } + { + final Button button = new Button(contents, SWT.NONE); + final GridData gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); + gridData.verticalSpan = 2; + button.setLayoutData(gridData); + button.setText("..."); + } + { + final Label label = new Label(contents, SWT.NONE); + label.setText("Proxy Host:"); + } + { + proxyHome = new Text(contents, SWT.BORDER); + final GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + proxyHome.setLayoutData(gridData); + } + { + final Label label = new Label(contents, SWT.NONE); + } + { + final Label label = new Label(contents, SWT.NONE); + label.setText("Proxy Port:"); + } + { + proxyPort = new Text(contents, SWT.BORDER); + final GridData gridData = new GridData(); + gridData.widthHint = 150; + gridData.horizontalSpan = 2; + proxyPort.setLayoutData(gridData); + } + { + final Label label = new Label(contents, SWT.NONE); + label.setText("Username:"); + } + { + userName = new Text(contents, SWT.BORDER); + final GridData gridData = new GridData(); + gridData.widthHint = 150; + gridData.horizontalSpan = 2; + userName.setLayoutData(gridData); + } + { + final Label label = new Label(contents, SWT.NONE); + label.setText("Password:"); + } + { + password = new Text(contents, SWT.BORDER); + final GridData gridData = new GridData(); + gridData.widthHint = 150; + gridData.horizontalSpan = 2; + password.setLayoutData(gridData); + } + { + final Label label = new Label(contents, SWT.NONE); + } + { + final Button button = new Button(contents, SWT.CHECK); + button.setText("Test Remote Repository"); + } + + + return contents; + } + +} \ No newline at end of file Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/panels/ServerSettingsPanel.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/panels/ServerSettingsPanel.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,257 @@ +/* + * Created on 17.08.2004 + * + * TODO To change the template for this generated file go to Window - + * Preferences - Java - Code Generation - Code and Comments + */ +package org.apache.metro.studio.eclipse.ui.panels; +import org.apache.metro.facility.presentationservice.api.IModelChannel; +import org.apache.metro.facility.presentationservice.impl.ChannelException; +import org.apache.metro.facility.presentationservice.impl.ModelChannel; +import org.apache.metro.studio.eclipse.ui.common.CommonDialogs; +import org.apache.metro.studio.eclipse.ui.common.ModelObject; +import org.apache.metro.studio.eclipse.ui.controller.PreferencesController; +import org.eclipse.swt.SWT; +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.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +/** + * @author EH2OBCK + * + * TODO To change the template for this generated type comment go to Window - + * Preferences - Java - Code Generation - Code and Comments + */ +public class ServerSettingsPanel { + + public static final String SERVER_PANEL = "server.panel"; + public static final String SERVER_APPLY = "server.apply"; + public static final String SERVER_DEFAULT = "server.default"; + + public static final String SERVER_STARTUP_JAR = "server.startup.jar"; + public static final String SERVER_ROOT_FACILITY = "server.facility"; + public static final String SERVER_ROOT_BLOCK = "server.block"; + public static final String SERVER_LANG = "server.lang"; + public static final String SERVER_TIMEOUT = "server.timeout"; + public static final String SERVER_DEBUG = "server.debug"; + public static final String SERVER_DEPLOY = "server.deploy"; + public static final String SERVER_EXECUTE = "server.execute"; + public static final String SERVER_ASSAMBLY = "server.assambly"; + public static final String SERVER_SECURITY = "server.security"; + + private Text deploymentTimeout; + private Text language; + private Text rootBlock; + private Text rootFacility; + private Text serverLib; + + private Shell shell; + private IModelChannel model; + + /** + * + */ + public ServerSettingsPanel() { + super(); + } + + public void initializeControls(ModelObject cModel) + { + try + { + // initialize the controller + new PreferencesController().initialize(); + model = new ModelChannel("server"); + model.windowCreated(SERVER_PANEL); + showControls(); + } catch (ChannelException e) + { + e.printStackTrace(); + } + } + + public void performDefaults() + { + try + { + model.controlClicked(SERVER_DEFAULT); + showControls(); + } catch (ChannelException e) + { + e.printStackTrace(); + } + } + + public void performApply() + { + try + { + storeControls(); + model.controlClicked(SERVER_APPLY); + } catch (ChannelException e) + { + e.printStackTrace(); + } + } + + private void showControls() + { + deploymentTimeout.setText(model.getValue(SERVER_DEPLOY)); + language.setText(model.getValue(SERVER_LANG)); + rootBlock.setText(model.getValue(SERVER_ROOT_BLOCK)); + rootFacility.setText(model.getValue(SERVER_ROOT_FACILITY)); + serverLib.setText(model.getValue(SERVER_STARTUP_JAR)); + } + + private void storeControls() + { + model.putValue(SERVER_DEPLOY, deploymentTimeout.getText()); + model.putValue(SERVER_LANG, language.getText()); + model.putValue(SERVER_ROOT_BLOCK, rootBlock.getText()); + model.putValue(SERVER_ROOT_FACILITY, rootFacility.getText()); + model.putValue(SERVER_STARTUP_JAR, serverLib.getText()); + } + + public Control createControls(Composite parent) { + shell = parent.getShell(); + + Composite contents = new Composite(parent, SWT.NONE); + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 3; + contents.setLayout(gridLayout); + contents.setLayoutData(new GridData(GridData.FILL_BOTH)); + { + final Label label = new Label(contents, SWT.NONE); + label.setText("Server &Lib (*.jar):"); + } + { + serverLib = new Text(contents, SWT.BORDER); + serverLib.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + } + { + final Button button = new Button(contents, SWT.NONE); + button.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + serverLib.setText(CommonDialogs.getFilePath(shell)); + } + }); + button.setText("..."); + } + { + final Label label = new Label(contents, SWT.NONE); + label.setText("Root &Facility:"); + } + { + rootFacility = new Text(contents, SWT.BORDER); + rootFacility.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); + } + { + final Button button = new Button(contents, SWT.NONE); + button.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + rootFacility.setText(CommonDialogs.getFilePath(shell)); + } + }); + button.setText("..."); + } + { + final Label label = new Label(contents, SWT.NONE); + label.setText("Root &Block:"); + } + { + rootBlock = new Text(contents, SWT.BORDER); + rootBlock.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); + } + { + final Button button = new Button(contents, SWT.NONE); + button.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) + { + rootBlock.setText(CommonDialogs.getFilePath(shell)); + } + }); + button.setText("..."); + } + { + final Label label = new Label(contents, SWT.NONE); + label.setText("Language:"); + } + { + language = new Text(contents, SWT.BORDER); + final GridData gridData = new GridData(); + gridData.horizontalSpan = 2; + gridData.widthHint = 150; + language.setLayoutData(gridData); + } + { + final Label label = new Label(contents, SWT.NONE); + label.setText("Deployment Timeout:"); + } + { + deploymentTimeout = new Text(contents, SWT.BORDER); + final GridData gridData = new GridData(); + gridData.horizontalSpan = 2; + gridData.widthHint = 150; + deploymentTimeout.setLayoutData(gridData); + } + { + final Label label = new Label(contents, SWT.NONE); + } + { + final Button button = new Button(contents, SWT.CHECK); + final GridData gridData = new GridData(); + gridData.horizontalSpan = 2; + button.setLayoutData(gridData); + button.setText("Show debug messages"); + } + { + final Label label = new Label(contents, SWT.NONE); + } + { + final Button button = new Button(contents, SWT.CHECK); + final GridData gridData = new GridData(); + gridData.horizontalSpan = 2; + button.setLayoutData(gridData); + button.setText("Show deployment parameters"); + } + { + final Label label = new Label(contents, SWT.NONE); + } + { + final Button button = new Button(contents, SWT.CHECK); + final GridData gridData = new GridData(); + gridData.horizontalSpan = 2; + button.setLayoutData(gridData); + button.setText("Start in server mode"); + } + { + final Label label = new Label(contents, SWT.NONE); + } + { + final Button button = new Button(contents, SWT.CHECK); + final GridData gridData = new GridData(); + gridData.horizontalSpan = 2; + button.setLayoutData(gridData); + button.setText("Show assambly model"); + } + { + final Label label = new Label(contents, SWT.NONE); + } + { + final Button button = new Button(contents, SWT.CHECK); + final GridData gridData = new GridData(); + gridData.horizontalSpan = 2; + button.setLayoutData(gridData); + button.setText("Enable code security:"); + } + + return contents; + } + +} \ No newline at end of file Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/preferences/MainPreferencePage.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/preferences/MainPreferencePage.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,59 @@ +package org.apache.metro.studio.eclipse.ui.preferences; + +import org.apache.metro.studio.eclipse.ui.MetroStudioUI; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing <samp>FieldEditorPreferencePage</samp>, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + * <p> + * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + + +public class MainPreferencePage + extends PreferencePage + implements IWorkbenchPreferencePage { + + public MainPreferencePage() { + super(); + setPreferenceStore(MetroStudioUI.getDefault().getPreferenceStore()); + setDescription("A demonstration of a preference page implementation"); + initializeDefaults(); + } +/** + * Sets the default values of the preferences. + */ + private void initializeDefaults() { + IPreferenceStore store = getPreferenceStore(); + // store.setDefault(ILaunchConfigConstants.MERLIN_DIR, "test"); + } + + protected Control createContents(Composite parent) + { + Composite composite = new Composite(parent, SWT.NONE); + FillLayout layout = new FillLayout(); + layout.marginHeight = 20; + composite.setLayout(layout); + + // new DirectorySettingsPanel().createControls(composite); + return composite; + } + + public void init(IWorkbench workbench) { + } +} \ No newline at end of file Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/preferences/RepositoryPreferencePage.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/preferences/RepositoryPreferencePage.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,71 @@ +package org.apache.metro.studio.eclipse.ui.preferences; + +import org.apache.metro.studio.eclipse.ui.MetroStudioUI; +import org.apache.metro.studio.eclipse.ui.common.ModelObject; +import org.apache.metro.studio.eclipse.ui.panels.RepositorySettingsPanel; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +/** + * This class represents a preference page that is contributed to the + * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage </samp>, + * we can use the field support built into JFace that allows us to create a page + * that is small and knows how to save, restore and apply itself. + * <p> + * This page is used to modify preferences only. They are stored in the + * preference store that belongs to the main plug-in class. That way, + * preferences can be accessed directly via the preference store. + */ +public class RepositoryPreferencePage extends PreferencePage + implements + IWorkbenchPreferencePage { + + RepositorySettingsPanel panel; + + public RepositoryPreferencePage() { + super(); + setPreferenceStore(MetroStudioUI.getDefault().getPreferenceStore()); + setDescription("A demonstration of a preference page implementation"); + } + + + protected Control createContents(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + FillLayout layout = new FillLayout(); + composite.setLayout(layout); + + panel = new RepositorySettingsPanel(); + + panel.createControls(composite); + panel.initializeControls(new ModelObject(this)); + return composite; + } + + public void init(IWorkbench workbench) { + } + /** + * @see org.eclipse.jface.preference.PreferencePage#performApply() + */ + protected void performApply() { + panel.performApply(); + super.performApply(); + } + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#performDefaults() + */ + protected void performDefaults() { + panel.performDefaults(); + super.performDefaults(); + } + /* (non-Javadoc) + * @see org.eclipse.jface.preference.IPreferencePage#performOk() + */ + public boolean performOk() { + panel.performApply(); + return super.performOk(); + } +} \ No newline at end of file Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/preferences/ServerPreferencePage.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/preferences/ServerPreferencePage.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,72 @@ +package org.apache.metro.studio.eclipse.ui.preferences; + +import org.apache.metro.studio.eclipse.ui.MetroStudioUI; +import org.apache.metro.studio.eclipse.ui.common.ModelObject; +import org.apache.metro.studio.eclipse.ui.panels.ServerSettingsPanel; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +/** + * This class represents a preference page that is contributed to the + * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage </samp>, + * we can use the field support built into JFace that allows us to create a page + * that is small and knows how to save, restore and apply itself. + * <p> + * This page is used to modify preferences only. They are stored in the + * preference store that belongs to the main plug-in class. That way, + * preferences can be accessed directly via the preference store. + */ +public class ServerPreferencePage extends PreferencePage + implements + IWorkbenchPreferencePage { + + ServerSettingsPanel panel; + + public ServerPreferencePage() { + super(); + setPreferenceStore(MetroStudioUI.getDefault().getPreferenceStore()); + setDescription("A demonstration of a preference page implementation"); + } + + /** + * Create all controls. + * This is extracted to a Panel class so that the layout can be + * reused in Property- or Wizard- classes + */ + protected Control createContents(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + FillLayout layout = new FillLayout(); + composite.setLayout(layout); + + panel = new ServerSettingsPanel(); + panel.createControls(composite); + panel.initializeControls(new ModelObject(this)); + return composite; + } + /** + * Apply button pressed + */ + protected void performApply() { + panel.performApply(); + } + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#performDefaults() + */ + protected void performDefaults() { + panel.performDefaults(); + + } + /* (non-Javadoc) + * @see org.eclipse.jface.preference.IPreferencePage#performOk() + */ + public boolean performOk() { + panel.performApply(); + return super.performOk(); + } + public void init(IWorkbench workbench) { + } +} \ No newline at end of file Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/properties/SamplePropertyPage.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/properties/SamplePropertyPage.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,127 @@ +package org.apache.metro.studio.eclipse.ui.properties; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.PropertyPage; + +public class SamplePropertyPage extends PropertyPage { + + private static final String PATH_TITLE = "Path:"; + private static final String OWNER_TITLE = "&Owner:"; + private static final String OWNER_PROPERTY = "OWNER"; + private static final String DEFAULT_OWNER = "John Doe"; + + private static final int TEXT_FIELD_WIDTH = 50; + + private Text ownerText; + + /** + * Constructor for SamplePropertyPage. + */ + public SamplePropertyPage() { + super(); + } + + private void addFirstSection(Composite parent) { + Composite composite = createDefaultComposite(parent); + + //Label for path field + Label pathLabel = new Label(composite, SWT.NONE); + pathLabel.setText(PATH_TITLE); + + // Path text field + Text pathValueText = new Text(composite, SWT.WRAP | SWT.READ_ONLY); + pathValueText.setText(((IResource) getElement()).getFullPath().toString()); + } + + private void addSeparator(Composite parent) { + Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); + GridData gridData = new GridData(); + gridData.horizontalAlignment = GridData.FILL; + gridData.grabExcessHorizontalSpace = true; + separator.setLayoutData(gridData); + } + + private void addSecondSection(Composite parent) { + Composite composite = createDefaultComposite(parent); + + // Label for owner field + Label ownerLabel = new Label(composite, SWT.NONE); + ownerLabel.setText(OWNER_TITLE); + + // Owner text field + ownerText = new Text(composite, SWT.SINGLE | SWT.BORDER); + GridData gd = new GridData(); + gd.widthHint = convertWidthInCharsToPixels(TEXT_FIELD_WIDTH); + ownerText.setLayoutData(gd); + + // Populate owner text field + try { + String owner = + ((IResource) getElement()).getPersistentProperty( + new QualifiedName("", OWNER_PROPERTY)); + ownerText.setText((owner != null) ? owner : DEFAULT_OWNER); + } catch (CoreException e) { + ownerText.setText(DEFAULT_OWNER); + } + } + + /** + * @see PreferencePage#createContents(Composite) + */ + protected Control createContents(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + FillLayout layout = new FillLayout(); + layout.marginHeight = 20; + composite.setLayout(layout); + /* + addFirstSection(composite); + addSeparator(composite); + addSecondSection(composite); + */ + // new DirectorySettingsPanel().createControls(composite); + return composite; + } + + private Composite createDefaultComposite(Composite parent) { + Composite composite = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + composite.setLayout(layout); + + GridData data = new GridData(); + data.verticalAlignment = GridData.FILL; + data.horizontalAlignment = GridData.FILL; + composite.setLayoutData(data); + + return composite; + } + + protected void performDefaults() { + // Populate the owner text field with the default value + ownerText.setText(DEFAULT_OWNER); + } + + public boolean performOk() { + // store the value in the owner text field + try { + ((IResource) getElement()).setPersistentProperty( + new QualifiedName("", OWNER_PROPERTY), + ownerText.getText()); + } catch (CoreException e) { + return false; + } + return true; + } + +} \ No newline at end of file Modified: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/AvalonProposals.java ============================================================================== --- avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/avalon/ide/eclipse/merlin/ui/tools/AvalonProposals.java (original) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/AvalonProposals.java Tue Aug 31 21:01:03 2004 @@ -15,7 +15,7 @@ limitations under the License. */ -package org.apache.avalon.ide.eclipse.merlin.ui.tools; +package org.apache.metro.studio.eclipse.ui.tools; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; import org.eclipse.jface.text.BadLocationException; Modified: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/ExampleBuilder.java ============================================================================== --- avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/avalon/ide/eclipse/merlin/ui/tools/ExampleBuilder.java (original) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/ExampleBuilder.java Tue Aug 31 21:01:03 2004 @@ -26,7 +26,7 @@ */ -package org.apache.avalon.ide.eclipse.merlin.ui.tools; +package org.apache.metro.studio.eclipse.ui.tools; import java.util.Map; Modified: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/ImageViewerEditor.java ============================================================================== --- avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/avalon/ide/eclipse/merlin/ui/tools/ImageViewerEditor.java (original) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/ImageViewerEditor.java Tue Aug 31 21:01:03 2004 @@ -16,7 +16,7 @@ */ -package org.apache.avalon.ide.eclipse.merlin.ui.tools; +package org.apache.metro.studio.eclipse.ui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.swt.SWT; @@ -38,6 +38,7 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.EditorPart; import org.eclipse.ui.part.FileEditorInput; + public class ImageViewerEditor extends EditorPart { Modified: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/JavadocProcessor.java ============================================================================== --- avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/avalon/ide/eclipse/merlin/ui/tools/JavadocProcessor.java (original) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/tools/JavadocProcessor.java Tue Aug 31 21:01:03 2004 @@ -15,14 +15,14 @@ limitations under the License. */ -package org.apache.avalon.ide.eclipse.merlin.ui.tools; +package org.apache.metro.studio.eclipse.ui.tools; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.ResourceBundle; -import org.apache.avalon.ide.eclipse.merlin.ui.MerlinDeveloperUI; +import org.apache.metro.studio.eclipse.ui.MetroStudioUI; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; import org.eclipse.jdt.ui.text.java.IJavadocCompletionProcessor; @@ -56,7 +56,7 @@ // TODO Auto-generated method stub List props = new ArrayList(); - ResourceBundle bundle = MerlinDeveloperUI.getDefault().getResourceBundle(); + ResourceBundle bundle = MetroStudioUI.getDefault().getResourceBundle(); Enumeration enum = bundle.getKeys(); while (enum.hasMoreElements()) { @@ -65,8 +65,8 @@ { AvalonProposals prop = new AvalonProposals(offset, length); prop.setKey("@" + key.substring(8,key.length())); - prop.setDescription(MerlinDeveloperUI.getResourceString(key)); - prop.setTag(MerlinDeveloperUI.getResourceString(key + ".tag")); + prop.setDescription(MetroStudioUI.getResourceString(key)); + prop.setTag(MetroStudioUI.getResourceString(key + ".tag")); props.add(prop); } } Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/wizards/NewMetroProjectSelectionPage.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/wizards/NewMetroProjectSelectionPage.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,275 @@ +/* + + Copyright 2004. The Apache Software Foundation. + + 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.metro.studio.eclipse.ui.wizards; + +import java.util.Iterator; +import java.util.List; + +import org.apache.metro.facility.presentationservice.api.IModelChannel; +import org.apache.metro.facility.presentationservice.impl.ChannelException; +import org.apache.metro.studio.eclipse.ui.wizards.WizardUtil.SelectionPageCellModifier; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.CheckboxCellEditor; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TableLayout; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.pde.internal.ui.elements.ListContentProvider; +import org.eclipse.pde.internal.ui.parts.FormBrowser; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; + + +/** + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public class NewMetroProjectSelectionPage extends WizardPage implements ISelectionChangedListener +{ + public static final String SELECTION_PANEL = "new.selection.panel"; + public static final String SELECTION_FINISH = "new.selection.finish"; + public static final String SELECTION_CONTROL = "new.selection.control"; + public static final String SELECTION_CONTROL_SELECTED = "new.selection.control.selected"; + public static final String SELECTION_CONTROL_LIST = "new.selection.control.list"; + + private WizardSelectedAction doubleClickAction = new WizardSelectedAction(); + private FormBrowser text; + private TableViewer projectTabel; + private List projectModels; + private String currentSelectedWizard = null; + private IModelChannel channel; + + private class WizardSelectedAction extends Action + { + public WizardSelectedAction() + { + super("wizardSelection"); + } + } + + public NewMetroProjectSelectionPage(String pageName, IModelChannel channel) + { + super(pageName); + this.channel = channel; + } + + /** + * Main method to create all controls of this page. This method is called + * by the wizard framework. + * + */ + public void createControl(Composite parent) + { + Composite composite = new Composite(parent, SWT.NULL); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + createContainerGroup(composite); + setControl(composite); + + + } + + /** + * create all controls. + * + */ + protected void createContainerGroup(Composite parent) + { + Composite area = new Composite(parent, SWT.NULL); + final GridLayout gridLayout = new GridLayout(); + gridLayout.makeColumnsEqualWidth = true; + gridLayout.numColumns = 2; + area.setLayout(gridLayout); + area.setLayoutData(new GridData(GridData.FILL_BOTH)); + + { + /** + * Titel for all controls + */ + final Label label = new Label(area, SWT.NONE); + final GridData gridData = new GridData(); + gridData.horizontalSpan = 2; + label.setLayoutData(gridData); + label.setText("sample blocks"); + } + { + /** + * Tabel for Project Types + */ + Table table = createTable(area); + createTableView(table); + + try + { + channel.windowCreated(SELECTION_PANEL); + String[] value = channel.getValueArray(SELECTION_CONTROL_LIST); + projectTabel.add(value); + super.setPageComplete(true); + + } catch (ChannelException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + { + /** + * HTML Text Editor foe showing the project description + */ + text = new FormBrowser(SWT.BORDER | SWT.V_SCROLL); + text.createControl(area); + final GridData gridData = new GridData(GridData.FILL_BOTH); + Control c = text.getControl(); + c.setLayoutData(gridData); + } + + } + + /** + * @param table + */ + private void createTableView(Table table) + { + projectTabel = new TableViewer(table); + projectTabel.setColumnProperties(new String []{"", "", ""}); + projectTabel.setContentProvider(new ListContentProvider()); + projectTabel.setLabelProvider(WizardUtil.TABLE_LABEL_PROVIDER); + + // Set the cell modifier for the viewer + projectTabel.setCellModifier(new SelectionPageCellModifier(this)); + // Create the cell editors + CellEditor[] editors = new CellEditor[3]; + // Column 1 : Completed (Checkbox) + editors[0] = new CheckboxCellEditor(table); + // Assign the cell editors to the viewer + projectTabel.setCellEditors(editors); + projectTabel.addDoubleClickListener(new IDoubleClickListener() + { + public void doubleClick(DoubleClickEvent event) + { + doubleClickAction.run(); + } + }); + projectTabel.addSelectionChangedListener(this); + + // list view pane. Add a border to the pane. + projectTabel.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); + } + + public TableViewer getProjectTable(){ + return projectTabel; + } + /** + * Create the Table Control, which is part of the TableViewer + * @param pParent + * @param pStyle + * @return + */ + private Table createTable(Composite parent) + { + int style = SWT.SINGLE | SWT.BORDER | + SWT.FULL_SELECTION | SWT.HIDE_SELECTION; + + Table table = new Table(parent, style); + table.setLayoutData(new GridData(GridData.FILL_VERTICAL)); + + TableColumn column = new TableColumn(table, SWT.NONE, 0); + column.setWidth(22); + column = new TableColumn(table, SWT.NONE, 1); + column.setWidth(20); + column = new TableColumn(table, SWT.NONE, 2); + column.setWidth(150); + TableLayout layout = new TableLayout(); + //layout.addColumnData(new ColumnWeightData(100)); + table.setLayout(layout); + return table; + } + + public void selectionChanged(SelectionChangedEvent event) + { + + setErrorMessage(null); + IStructuredSelection selection = (IStructuredSelection) event.getSelection(); + Iterator iter = selection.iterator(); + + if (iter.hasNext()) + currentSelectedWizard = (String) iter.next(); + + BusyIndicator.showWhile(projectTabel.getControl().getDisplay(), new Runnable() + { + public void run() + { + try + { + channel.putValue(SELECTION_CONTROL_SELECTED, currentSelectedWizard); + channel.controlClicked(SELECTION_CONTROL); + // get the text and display it + text.setText(channel.getValue("resource.help")); + + } catch (ChannelException e) + { + e.printStackTrace(); + } + } + }); + + + } + + /** + * @return + */ + public String getSelectedProjectTemplate() + { + // TODO Auto-generated method stub + return null; + } + + /** + * @param pTask + */ + /* + public void updateTable(ProjectModel pTask) + { + Iterator it = projectModels.iterator(); + while(it.hasNext()){ + ProjectModel model = (ProjectModel)it.next(); + if(model.isSelected() && !(model.equals(pTask))){ + model.setSelected(false); + projectTabel.update(model, new String[]{"",""}); + } + } + + projectTabel.update(pTask, new String[]{"",""}); + } + */ +} \ No newline at end of file Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/wizards/NewMetroProjectWizard.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/wizards/NewMetroProjectWizard.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,121 @@ +/* + + Copyright 2004. The Apache Software Foundation. + + 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.metro.studio.eclipse.ui.wizards; + +import java.lang.reflect.InvocationTargetException; + +import org.apache.metro.facility.presentationservice.api.IModelChannel; +import org.apache.metro.facility.presentationservice.impl.ModelChannel; +import org.apache.metro.studio.eclipse.ui.MetroStudioUI; +import org.apache.metro.studio.eclipse.ui.controller.CreateBlockProjectOperation; +import org.apache.metro.studio.eclipse.ui.controller.NewMetroProjectWizardController; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation; +import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; + +/** + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>* + */ +public class NewMetroProjectWizard extends Wizard implements INewWizard +{ + + private WizardNewProjectCreationPage projectPage; + private NewMetroProjectSelectionPage selectionPage; + + public static final String NEW_PROJECT_NAME = "new.project.name"; + public static final String NEW_PROJECT_FINISH = "new.project.finish"; + + private IModelChannel channel; + + public boolean canFinish() + { + IWizardPage page = getContainer().getCurrentPage(); + if (page == getProjectPage()) + return false; + if (page == getSelectionPage()) + return true; + return false; + } + + public boolean performFinish() + { + try + { + channel.putValue(NEW_PROJECT_NAME, getProjectPage().getProjectName()); + // run project creation in background + CreateBlockProjectOperation operation = + new CreateBlockProjectOperation(channel); + IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(operation); + getContainer().run(false, true, op); + } catch (InvocationTargetException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InterruptedException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return true; + } + + public void init(IWorkbench workbench, IStructuredSelection selection) + { + setWindowTitle(MetroStudioUI.getResourceString("new.blockDevelopment.window.title")); //$NON-NLS-1$ + setDefaultPageImageDescriptor(MetroStudioUI.getImageDescriptor("icons/full/wizban/newjprj_wiz.gif")); //$NON-NLS-1$ + + } + + public void addPages() + { + channel = new ModelChannel("newBlockWizard"); + new NewMetroProjectWizardController().initialize(); + + projectPage = new WizardNewProjectCreationPage("mainPage"); //$NON-NLS-1$ + projectPage.setTitle(MetroStudioUI.getResourceString("new.MerlinDevelopment.mainPage.title")); //$NON-NLS-1$ + projectPage.setDescription(MetroStudioUI.getResourceString("new.MerlinDevelopment.mainPage.description")); //$NON-NLS-1$ + addPage(projectPage); + + selectionPage = new NewMetroProjectSelectionPage("selectionPage", channel); + selectionPage.setTitle(MetroStudioUI.getResourceString("new.MerlinDevelopment.selectionPage.title")); //$NON-NLS-1$ + selectionPage.setDescription(MetroStudioUI.getResourceString("new.MerlinDevelopment.mainPage.description")); //$NON-NLS-1$ + addPage(selectionPage); + } + + /** + * @return + */ + public WizardNewProjectCreationPage getProjectPage() + { + return projectPage; + } + + /** + * @return + */ + public NewMetroProjectSelectionPage getSelectionPage() + { + return selectionPage; + } + +} \ No newline at end of file Added: avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/wizards/WizardUtil.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/ui/src/org/apache/metro/studio/eclipse/ui/wizards/WizardUtil.java Tue Aug 31 21:01:03 2004 @@ -0,0 +1,208 @@ +/* + + Copyright 2004. The Apache Software Foundation. + + 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.metro.studio.eclipse.ui.wizards; + +import org.apache.metro.studio.eclipse.ui.MetroStudioUI; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.jface.viewers.ICellModifier; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.pde.internal.ui.elements.ElementLabelProvider; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.TableItem; + +/** + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>* + */ +public class WizardUtil +{ + + /** + * This class is used as Labelprovider in SelectionPage + * + */ + static class TableLabelProvider extends ElementLabelProvider implements ITableLabelProvider + { + + // Names of images used to represent checkboxes + public static final String CHECKED_IMAGE = "checked"; + public static final String UNCHECKED_IMAGE = "unchecked"; + public static final String MERLIN_IMAGE = "merlin"; + + // For the checkbox images + private static ImageRegistry imageRegistry = new ImageRegistry(); + + /** + * Note: An image registry owns all of the image objects registered + * with it, and automatically disposes of them the SWT Display is + * disposed. + */ + static { + imageRegistry.put( + CHECKED_IMAGE, + MetroStudioUI.getImageDescriptor("icons/" + CHECKED_IMAGE + ".gif")); + imageRegistry.put( + UNCHECKED_IMAGE, + MetroStudioUI.getImageDescriptor("icons/" + UNCHECKED_IMAGE + ".gif")); + imageRegistry.put( + MERLIN_IMAGE, + MetroStudioUI.getImageDescriptor("icons/" + MERLIN_IMAGE + ".gif")); + + } + + /** + * Returns the image with the given key, or <code>null</code> if not + * found. + */ + private Image getImage(boolean isSelected) + { + String key = isSelected ? CHECKED_IMAGE : UNCHECKED_IMAGE; + return imageRegistry.get(key); + } + + /** + * show the text label + * + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, + * int) + */ + public String getColumnText(Object o, int index) + { + String result = ""; + switch (index) + { + case 0 : // COMPLETED_COLUMN + result = ""; + break; + case 1 : // merlin icon + result = ""; + break; + case 2 : // merlin icon + result = (String)o; + break; + default : + } + return result; + } + /** + * show the icon + * + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, + * int) + */ + public Image getColumnImage(Object element, int columnIndex) + { + Image result = null; + switch (columnIndex) + { + case 0 : // COMPLETED_COLUMN + result = getImage(false); + break; + case 1 : // merlin icon + result = imageRegistry.get(MERLIN_IMAGE); + break; + case 2: + result = null; + break; + default : + } + return result; + } + + } + public static class SelectionPageCellModifier implements ICellModifier + { + private NewMetroProjectSelectionPage selectionPage; + private String[] columnNames; + + /** + * Constructor + * + * @param selectionPage + * an instance of a selectionPage + */ + public SelectionPageCellModifier(NewMetroProjectSelectionPage tableViewer) + { + super(); + this.selectionPage = tableViewer; + } + + /** + * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, + * java.lang.String) + */ + public boolean canModify(Object element, String property) + { + return true; + } + + /** + * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, + * java.lang.String) + */ + public Object getValue(Object element, String property) + { + + // Find the index of the column + int columnIndex = 0; + + Object result = null; + //&& ProjectModel task = (ProjectModel) element; + + switch (columnIndex) + { + case 0 : // COMPLETED_COLUMN + //&& result = new Boolean(task.isSelected()); + result = new Boolean(true); + break; + default : + result = ""; + } + return result; + } + + /** + * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, + * java.lang.String, java.lang.Object) + */ + public void modify(Object element, String property, Object value) + { + + // Find the index of the column + int columnIndex = 0; + + TableItem item = (TableItem) element; + // ProjectModel task = (ProjectModel) item.getData(); + + switch (columnIndex) + { + case 0 : // COMPLETED_COLUMN + // task.setSelected(((Boolean) value).booleanValue()); + break; + default : + } + //selectionPage.updateTable(task); + } + } + public static final ILabelProvider TABLE_LABEL_PROVIDER = new TableLabelProvider(); + + public WizardUtil() + { + super(); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]