Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7e39d867dd5eac324390b02ded773c38a072f67e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*******************************************************************************
 * Copyright (c) 2001, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.wst.wsdl.ui.internal.actions;


import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.wst.wsdl.Definition;
import org.eclipse.wst.wsdl.WSDLElement;
import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin;
import org.eclipse.wst.wsdl.ui.internal.commands.AddMessageCommand;
import org.eclipse.wst.wsdl.ui.internal.util.NameUtil;
import org.eclipse.wst.wsdl.ui.internal.widgets.NewComponentDialog;
import org.eclipse.wst.wsdl.util.WSDLConstants;



public final class AddMessageUIAction extends WSDLElementUIAction
{
  private Definition definition;
  private String name;
  
  public AddMessageUIAction
  	(Definition definition, 
     String name, 
     boolean createPart)
  {
    super
    	(new AddMessageCommand(definition,name,createPart), 
    	 WSDLEditorPlugin.getWSDLString("_UI_ACTION_ADD"), 
    	 WSDLConstants.MESSAGE_ELEMENT_TAG, 
    	 WSDLEditorPlugin.getImageDescriptor("icons/message_obj.gif"));
    
    this.definition = definition;
    this.name = name;
  }
 
  protected boolean showDialog()
  {
	  name = NameUtil.buildUniqueMessageName(definition, name);
	  name = showDialogHelper(WSDLEditorPlugin.getWSDLString("_UI_ACTION_NEW_MESSAGE"), name);
	  return name != null;
  }
  
  protected String showDialogHelper(String title, String defaultName)
  {   
    String result = defaultName;                                                                                             
    NewComponentDialog dialog = new NewComponentDialog(WSDLEditorPlugin.getShell(), title, defaultName);
    int rc = dialog.createAndOpen();
    if (rc == IDialogConstants.OK_ID)
    {
      result = dialog.getName();  
    }
    else
    {
      result = null;
    }               
    return result;
  } 
  
  protected void preRun()
  {
    ((AddMessageCommand)super.modelAction).setLocalName(name);
  }

  protected WSDLElement getOwner()
  {
    return definition;
  }

}

Back to the top