Author: scabanovich
Date: 2007-10-24 06:38:16 -0400 (Wed, 24 Oct 2007)
New Revision: 4452
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/messages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
Log:
JBIDE-982
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 2007-10-24
10:09:20 UTC (rev 4451)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2007-10-24
10:38:16 UTC (rev 4452)
@@ -383,6 +383,12 @@
public static String SEAM_TARGET_SERVER;
+ public static String RUNTIME_DELETE_CONFIRM_TITLE;
+
+ public static String RUNTIME_DELETE_NOT_USED_CONFIRM;
+
+ public static String RUNTIME_DELETE_USED_CONFIRM;
+
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, SeamUIMessages.class);
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 2007-10-24
10:09:20 UTC (rev 4451)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2007-10-24
10:38:16 UTC (rev 4452)
@@ -187,4 +187,7 @@
SEAM_RUNTIME_LIST_FIELD_EDITOR_THE_SELECTED_SEAM_APPEARS_TO_BE_OF_INCOMATIBLE_VERSION=The
selected seam appears to be of an incompatible version '
SEAM_GENERATE_ENTITIES_WIZARD_THIS_METHOD_IS_NOT_RELEVANT_IN_GENERATING_SEAM_ENTITIES=This
method is not relevant in generating seam entities.
SEAM_FORM_WIZARD_PAGE1_JAVA_INTERFACE_SLSB_AND_KEY_SEAMEJB3_ANNOTATIONS_WILL_BE_CREATED=Java
Interface, SLSB and key Seam/EJB3 annotations will be created.
-SEAM_TARGET_SERVER=Target Server
\ No newline at end of file
+SEAM_TARGET_SERVER=Target Server
+RUNTIME_DELETE_CONFIRM_TITLE=Confirm Runtime Delete
+RUNTIME_DELETE_NOT_USED_CONFIRM=Are you sure you want to delete runtime {0}?
+RUNTIME_DELETE_USED_CONFIRM=Runtime {0} is used by seam projects. Are you sure you want
to delete it?
\ No newline at end of file
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 2007-10-24
10:09:20 UTC (rev 4451)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2007-10-24
10:38:16 UTC (rev 4452)
@@ -25,7 +25,10 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
@@ -42,6 +45,7 @@
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -54,6 +58,7 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
+import org.jboss.tools.seam.core.ISeamProject;
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;
@@ -531,14 +536,34 @@
while(i.hasNext()) {
Object o = i.next();
if(o instanceof SeamRuntime) {
- removed.add((SeamRuntime)o);
- if(added.contains(o)) {
- added.remove(o);
- }
- ((List)getValue()).remove(o);
+ removeRuntime((SeamRuntime)o);
}
}
tableView.refresh();
}
}
+
+ private void removeRuntime(SeamRuntime r) {
+ boolean used = isRuntimeUsed(r.getName());
+ String title = SeamUIMessages.RUNTIME_DELETE_CONFIRM_TITLE;
+ String message = (used)
+ ? NLS.bind(SeamUIMessages.RUNTIME_DELETE_USED_CONFIRM, r.getName())
+ : NLS.bind(SeamUIMessages.RUNTIME_DELETE_NOT_USED_CONFIRM, r.getName());
+ boolean b = MessageDialog.openConfirm(removeBtn.getShell(), title, message);
+ if(!b) return;
+ removed.add(r);
+ if(added.contains(r)) {
+ added.remove(r);
+ }
+ ((List)getValue()).remove(r);
+ }
+
+ private boolean isRuntimeUsed(String runtimeName) {
+ IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (int i = 0; i < ps.length; i++) {
+ ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
+ if(sp != null && runtimeName.equals(sp.getRuntimeName())) return true;
+ }
+ return false;
+ }
}
Show replies by date