Author: dmaliarevich
Date: 2010-03-03 09:22:11 -0500 (Wed, 03 Mar 2010)
New Revision: 20614
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropCommand.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5874 --- dialog opening logic was corrected.
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropCommand.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropCommand.java 2010-03-03
14:21:54 UTC (rev 20613)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropCommand.java 2010-03-03
14:22:11 UTC (rev 20614)
@@ -15,7 +15,8 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.editors.dnd.composite.TagProposalsComposite;
@@ -80,18 +81,33 @@
* @param data
*/
public void execute(DropData data) {
- getDefaultModel().setDropData(data);
- initialize();
- if(getDefaultModel().isWizardRequired()) {
- WizardDialog dialog = new DropWizardDialog(
- Display.getCurrent().getActiveShell(),
- createDropWizard()
- );
- dialog.open();
- } else {
- execute();
+ /*
+ * Fixes
https://jira.jboss.org/jira/browse/JBIDE-5874
+ * Checks it the Dialog Shell was already opened.
+ * If so do not create one more instance.
+ */
+ Shell[] existedShells = PlatformUI.getWorkbench().getDisplay().getShells();
+ boolean dialogWasAlreadyOpened = false;
+ for (Shell sh : existedShells) {
+ if (DropWizardMessages.Wizard_Window_Title
+ .equalsIgnoreCase(sh.getText())) {
+ dialogWasAlreadyOpened = true;
+ }
}
- getDefaultModel().setDropData(null);
+ if (!dialogWasAlreadyOpened) {
+ getDefaultModel().setDropData(data);
+ initialize();
+ if(getDefaultModel().isWizardRequired()) {
+ WizardDialog dialog = new DropWizardDialog(
+ PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ createDropWizard()
+ );
+ dialog.open();
+ } else {
+ execute();
+ }
+ getDefaultModel().setDropData(null);
+ }
}
protected IDropWizard createDropWizard() {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2010-03-03
14:21:54 UTC (rev 20613)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2010-03-03
14:22:11 UTC (rev 20614)
@@ -66,6 +66,7 @@
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.editors.text.ILocationProvider;
import org.eclipse.ui.texteditor.ITextEditor;
@@ -735,7 +736,13 @@
public void runDropCommand(final String flavor, final String data) {
XModelBuffer b = XModelTransferBuffer.getInstance().getBuffer();
final XModelObject o = b == null ? null : b.source();
- Display.getDefault().asyncExec(new Runnable() {
+ /*
+ * Fixes
https://jira.jboss.org/jira/browse/JBIDE-5874
+ * Display.getDefault() should always be replaced by
+ * PlatformUI.getWorkbench().getDisplay().
+ * syncExec() will reduce the number if simultaneously launched threads.
+ */
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
if (o != null
&& !XModelTransferBuffer.getInstance().isEnabled()) {