Author: dazarov
Date: 2010-11-03 10:14:14 -0400 (Wed, 03 Nov 2010)
New Revision: 26226
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddNewSeamRuntimeMarkerResolution.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/MarkerResolutionGenerator.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
Log:
https://jira.jboss.org/browse/JBIDE-5134
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2010-11-03
14:10:08 UTC (rev 26225)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2010-11-03
14:14:14 UTC (rev 26226)
@@ -387,8 +387,11 @@
public static String ADD_ANNOTATED_DESTROY_METHOD_MARKER_RESOLUTION_TITLE;
public static String CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE;
+
public static String ADD_SETTER_MARKER_RESOLUTION_TITLE;
+ public static String ADD_NEW_SEAM_RUNTIME_MARKER_RESOLUTION_TITLE;
+
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, SeamUIMessages.class);
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddNewSeamRuntimeMarkerResolution.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddNewSeamRuntimeMarkerResolution.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddNewSeamRuntimeMarkerResolution.java 2010-11-03
14:14:14 UTC (rev 26226)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.marker;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
+import org.jboss.tools.seam.core.project.facet.SeamVersion;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.SeamGuiPlugin;
+import org.jboss.tools.seam.ui.SeamUIMessages;
+import org.jboss.tools.seam.ui.preferences.SeamPreferencesMessages;
+import org.jboss.tools.seam.ui.widget.editor.SeamRuntimeListFieldEditor;
+
+
+/**
+ * @author Daniel Azarov
+ */
+public class AddNewSeamRuntimeMarkerResolution implements IMarkerResolution2{
+ private IProject project;
+ private String runtimeName;
+ private String label;
+
+ private SeamRuntimeListFieldEditor seamRuntimes;
+
+ public AddNewSeamRuntimeMarkerResolution(IMarker marker){
+ project = (IProject)marker.getResource();
+
+ IEclipsePreferences preferences = SeamCorePlugin.getSeamPreferences(project);
+
+ runtimeName =
preferences.get(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,"");
+ this.label =
MessageFormat.format(SeamUIMessages.ADD_NEW_SEAM_RUNTIME_MARKER_RESOLUTION_TITLE, new
Object[]{runtimeName});
+ seamRuntimes = new SeamRuntimeListFieldEditor(
+ "rtlist", SeamPreferencesMessages.SEAM_PREFERENCE_PAGE_SEAM_RUNTIMES, new
ArrayList<SeamRuntime>(Arrays.asList(SeamRuntimeManager.getInstance().getRuntimes())));
//$NON-NLS-1$
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ Composite root = new Composite(shell, SWT.NONE);
+ root.setVisible(false);
+ seamRuntimes.getEditorControls(root);
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void run(IMarker marker) {
+ if(marker.getResource() instanceof IProject){
+ String runtimeVersion = "";
+
+ try{
+ IProjectFacet facet =
ProjectFacetsManager.getProjectFacet(ISeamFacetDataModelProperties.SEAM_FACET_ID);
+
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project);
+ if(facetedProject!=null) {
+ IProjectFacetVersion facetVersion = facetedProject.getInstalledVersion(facet);
+ if(facetVersion!=null){
+ runtimeVersion =
SeamVersion.parseFromString(facetVersion.getVersionString()).toString();
+ }
+ }
+ }catch(CoreException ex){
+ SeamGuiPlugin.getPluginLog().logError(ex);
+ }
+
+ seamRuntimes.getAddAction().run(runtimeName, runtimeVersion);
+
+ for (SeamRuntime rt : seamRuntimes.getAddedSeamRuntimes()) {
+ SeamRuntimeManager.getInstance().addRuntime(rt);
+ }
+ SeamRuntimeManager.getInstance().save();
+ }
+ }
+
+ public String getDescription() {
+ return null;
+ }
+
+ public Image getImage() {
+ return null;
+ }
+
+}
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddNewSeamRuntimeMarkerResolution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/MarkerResolutionGenerator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/MarkerResolutionGenerator.java 2010-11-03
14:10:08 UTC (rev 26225)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/MarkerResolutionGenerator.java 2010-11-03
14:14:14 UTC (rev 26226)
@@ -45,7 +45,7 @@
public IMarkerResolution[] getResolutions(IMarker marker) {
if(findResolutions(marker))
- return new IMarkerResolution[] { new SeamRuntimeMarkerResolution() };
+ return new IMarkerResolution[] { new SeamRuntimeMarkerResolution(), new
AddNewSeamRuntimeMarkerResolution(marker) };
else
return new IMarkerResolution[]{};
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2010-11-03
14:10:08 UTC (rev 26225)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2010-11-03
14:14:14 UTC (rev 26226)
@@ -203,3 +203,4 @@
ADD_ANNOTATED_DESTROY_METHOD_MARKER_RESOLUTION_TITLE=Add @Destroy annotated method
CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE=Change scope to ''{0}''
ADD_SETTER_MARKER_RESOLUTION_TITLE=Add setter for ''{0}'' property in
''{1}'' class
+ADD_NEW_SEAM_RUNTIME_MARKER_RESOLUTION_TITLE=Add ''{0}'' Seam Runtime
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2010-11-03
14:10:08 UTC (rev 26225)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2010-11-03
14:14:14 UTC (rev 26226)
@@ -108,6 +108,8 @@
private List<SeamRuntime> added = new ArrayList<SeamRuntime>();
private List<SeamRuntime> removed = new ArrayList<SeamRuntime>();
+
+ private AddAction addAction;
// ------------------------------------------------------------------------
// Constructors
@@ -127,6 +129,12 @@
Object defaultValue) {
super(name, label, defaultValue);
}
+
+ public AddAction getAddAction(){
+ if(addAction == null)
+ addAction = new AddAction();
+ return addAction;
+ }
/**
* TBD
@@ -334,7 +342,7 @@
protected void createActionBar() {
actionPanel = new ActionPanel(root, new BaseAction[] {
- new AddAction(), new EditAction(), new RemoveAction()});
+ getAddAction(), new EditAction(), new RemoveAction()});
tableView.addSelectionChangedListener(actionPanel);
}
@@ -1024,6 +1032,21 @@
tableView.refresh();
setDefaultRuntimes();
}
+
+ public void run(String name, String version) {
+ SeamRuntimeNewWizard wiz = new SeamRuntimeNewWizard(
+ (List<SeamRuntime>) getValue(), added);
+
+ wiz.page1.name.setValue(name);
+
+ wiz.page1.version.setValue(version);
+
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
+ setDefaultRuntimes();
+ }
}
/**