Skip to main content
summaryrefslogtreecommitdiffstats
blob: 0ceebf1ea88f907a3fb713f09b8a10d3678245ac (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*******************************************************************************
 * Copyright (c) 2004, 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 * yyyymmdd bug      Email and other contact information
 * -------- -------- -----------------------------------------------------------
 * 20080430   214624 makandre@ca.ibm.com - Andrew Mak, Remove favourite UDDI registries from Web Service Publish page
 *******************************************************************************/
package org.eclipse.jst.ws.internal.consumption.ui.widgets;

import java.util.Vector;

import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
import org.eclipse.jst.ws.internal.consumption.ui.wizard.PrivateUDDIRegistryTypeRegistry;
import org.eclipse.jst.ws.internal.ui.uddi.PrivateUDDIRegistryType;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
import org.eclipse.wst.ws.internal.explorer.LaunchOption;
import org.eclipse.wst.ws.internal.explorer.LaunchOptions;


public class PublishWSWidget extends SimpleWidgetDataContributor
{
  /* CONTEXT_ID PWPB0001 for the UDDI Publish Page */
  private String INFOPOP_PWPB_PAGE = WebServiceConsumptionUIPlugin.ID + ".PWPB0001";
  /* CONTEXT_ID PWPB0002 for the UDDI Launch check box of the UDDI Publish Page */
  private String INFOPOP_PWPB_CHECKBOX_WS_LAUNCH = WebServiceConsumptionUIPlugin.ID + ".PWPB0002";
  private Button launchUDDICheckbox_;
  private Button launchPrivateUDDICheckbox_;
  private Listener statusListener;
  private Boolean publish;

  public PublishWSWidget(boolean publish)
  {
	  this.publish = new Boolean(publish);
  }

  public WidgetDataEvents addControls(Composite parent, Listener statusListener)
  {
    this.statusListener = statusListener;
    Listener selListener = new Listener()
    {
      public void handleEvent(Event event)
      {
        handleSelectionEvent(event);
      }
    };
    parent.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWPB_PAGE);
    IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
    helpSystem.setHelp(parent, INFOPOP_PWPB_PAGE);
    launchPrivateUDDICheckbox_ = new Button(parent, SWT.CHECK);
    if (publish.booleanValue())
      launchPrivateUDDICheckbox_.setText(ConsumptionUIMessages.BUTTON_WS_PUBLISH_PRIVATE_UDDI);
    else
      launchPrivateUDDICheckbox_.setText(ConsumptionUIMessages.BUTTON_WS_FIND_PRIVATE_UDDI);
    launchPrivateUDDICheckbox_.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWPB_CHECKBOX_WS_LAUNCH);
    launchPrivateUDDICheckbox_.addListener(SWT.Selection, selListener);
    helpSystem.setHelp(launchPrivateUDDICheckbox_, INFOPOP_PWPB_CHECKBOX_WS_LAUNCH);
    launchUDDICheckbox_ = new Button(parent, SWT.CHECK);
    if (publish.booleanValue())
      launchUDDICheckbox_.setText(ConsumptionUIMessages.BUTTON_WS_PUBLISH);
    else
      launchUDDICheckbox_.setText(ConsumptionUIMessages.BUTTON_WS_FIND);
    launchUDDICheckbox_.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWPB_CHECKBOX_WS_LAUNCH);
    launchUDDICheckbox_.addListener(SWT.Selection, selListener);
    helpSystem.setHelp(launchUDDICheckbox_, INFOPOP_PWPB_CHECKBOX_WS_LAUNCH);
    initPrivateUDDI();
    return this;
  }

  private void initPrivateUDDI()
  {
    if (!publish.booleanValue() && !PrivateUDDIRegistryTypeRegistry.getInstance().getPrivateUDDIRegistryType().isPrivateUDDIRegistryInstalled())
      launchPrivateUDDICheckbox_.setEnabled(false);
  }

  private void handleSelectionEvent(Event event)
  {
    statusListener.handleEvent(event);
  }

  public void setPublishToPublicUDDI(boolean publish)
  {
    launchUDDICheckbox_.setSelection(publish);
  }

  public void setPublishToPublicUDDI(Boolean publish)
  {
    setPublishToPublicUDDI(publish.booleanValue());
  }

  public void setPublishToPrivateUDDI(boolean publish)
  {
    launchPrivateUDDICheckbox_.setSelection(publish);
  }

  public void setPublishToPrivateUDDI(Boolean publish)
  {
    setPublishToPrivateUDDI(publish.booleanValue());
  }

  public boolean getPublishToPublicUDDI()
  {
    return launchUDDICheckbox_.getSelection();
  }

  public boolean getPublishToPrivateUDDI()
  {
    return launchPrivateUDDICheckbox_.getSelection();
  }

  public boolean getForceLaunchOutsideIDE()
  {
    return false;
  }

  public LaunchOption[] getLaunchOptions()
  {
    Vector launchOptionVector = new Vector();
    if (launchUDDICheckbox_.getSelection())
    {
      launchOptionVector.add(new LaunchOption(LaunchOptions.INQUIRY_URL, ""));
      launchOptionVector.add(new LaunchOption(LaunchOptions.PUBLISH_URL, ""));
    }
    if (launchPrivateUDDICheckbox_.getSelection())
    {
      PrivateUDDIRegistryTypeRegistry privateReg = PrivateUDDIRegistryTypeRegistry.getInstance();
      PrivateUDDIRegistryType privateType = privateReg.getPrivateUDDIRegistryType();
      String[] privateInquiryURL = privateType.getPrivateUDDIRegistryInquiryAPI();
      String[] privatePublishURL = privateType.getPrivateUDDIRegistryPublishAPI();
      for (int i = 0; i < privateInquiryURL.length; i++)
      {
        launchOptionVector.add(new LaunchOption(LaunchOptions.INQUIRY_URL, privateInquiryURL[i]));
        launchOptionVector.add(new LaunchOption(LaunchOptions.PUBLISH_URL, privatePublishURL[i]));
      }
    }
    return (LaunchOption[]) launchOptionVector.toArray(new LaunchOption[0]);
  }
}

Back to the top