Skip to main content
summaryrefslogtreecommitdiffstats
blob: ef14da7a822679a712cf7d0e01cf63ea401a812b (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/*******************************************************************************
 * Copyright (c) 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.jst.ws.internal.consumption.ui.widgets.binding;

import org.eclipse.jst.ws.internal.consumption.ui.command.GenerateHandlerSkeletonCommand;
import org.eclipse.jst.ws.internal.consumption.ui.widgets.ClientHandlersWidgetDefaultingCommand;
import org.eclipse.jst.ws.internal.consumption.ui.widgets.ClientHandlersWidgetOutputCommand;
import org.eclipse.jst.ws.internal.consumption.ui.widgets.ConfigClientHandlersTableWidget;
import org.eclipse.jst.ws.internal.consumption.ui.widgets.ConfigServiceHandlersTableWidget;
import org.eclipse.jst.ws.internal.consumption.ui.widgets.HandlersDefaultingCommand;
import org.eclipse.jst.ws.internal.consumption.ui.widgets.ServiceHandlersWidgetDefaultingCommand;
import org.eclipse.jst.ws.internal.consumption.ui.widgets.ServiceHandlersWidgetOutputCommand;
import org.eclipse.wst.command.internal.env.core.fragment.BooleanFragment;
import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
import org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactory;
import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
import org.eclipse.wst.command.internal.env.ui.widgets.CanFinishRegistry;
import org.eclipse.wst.command.internal.env.ui.widgets.CommandWidgetBinding;
import org.eclipse.wst.command.internal.env.ui.widgets.SelectionCommand;
import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributor;
import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributorFactory;
import org.eclipse.wst.command.internal.env.ui.widgets.WidgetRegistry;
import org.eclipse.wst.command.internal.provisional.env.core.common.Condition;
import org.eclipse.wst.command.internal.provisional.env.core.common.MessageUtils;
import org.eclipse.wst.command.internal.provisional.env.core.data.DataMappingRegistry;


public class ConfigureHandlersWidgetBinding implements CommandWidgetBinding {


  public ConfigureHandlersWidgetBinding() {

  }

  /*
   * (non-Javadoc)
   * 
   * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#create()
   */
  public CommandFragmentFactory create() {
    return new CommandFragmentFactory() {

      public CommandFragment create() {
        return new HandlersCommandFragment();
      }
    };
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerCanFinish(org.eclipse.wst.command.env.ui.widgets.CanFinishRegistry)
   */
  public void registerCanFinish(CanFinishRegistry canFinishRegistry) {
  }

  /*
   * (non-Javadoc),
   * 
   * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerDataMappings(org.eclipse.wst.command.internal.provisional.env.core.data.DataMappingRegistry)
   */
  public void registerDataMappings(DataMappingRegistry dataRegistry) {

    // Map client-side widgets to commands
    dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class, "Handlers", ConfigClientHandlersTableWidget.class, "WsRefsToHandlers", null);

    dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class, "GenSkeletonEnabled", ConfigClientHandlersTableWidget.class);
    dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class, "SourceOutputLocation", ConfigClientHandlersTableWidget.class);
    dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class, "ServiceRefName", ConfigClientHandlersTableWidget.class);
    dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class, "RefNameToServiceRef", ConfigClientHandlersTableWidget.class);

    dataRegistry.addMapping(ConfigClientHandlersTableWidget.class, "WsRefsToHandlers", ClientHandlersWidgetOutputCommand.class, "HandlersTable", null);

    dataRegistry.addMapping(ConfigClientHandlersTableWidget.class, "SourceOutputLocation", GenerateHandlerSkeletonCommand.class, "OutputLocation", null);
    dataRegistry.addMapping(ConfigClientHandlersTableWidget.class, "HandlerClassNames", GenerateHandlerSkeletonCommand.class, "HandlerNames", null);
    dataRegistry.addMapping(ConfigClientHandlersTableWidget.class, "GenSkeletonEnabled", GenerateHandlerSkeletonCommand.class);

    // Map service-side widgets to commands
    dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "WsRefsToHandlers", ConfigServiceHandlersTableWidget.class);
    dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "GenSkeletonEnabled", ConfigServiceHandlersTableWidget.class);
    dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "SourceOutputLocation", ConfigServiceHandlersTableWidget.class);
    dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "ServiceDescNameToDescObj", ConfigServiceHandlersTableWidget.class);

    dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "DescriptionName", ConfigServiceHandlersTableWidget.class);

    dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class, "HandlersList", ServiceHandlersWidgetOutputCommand.class);
    dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class, "WsDescToHandlers", ServiceHandlersWidgetOutputCommand.class);
    dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "ServiceDescNameToDescObj", ServiceHandlersWidgetOutputCommand.class);

    dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class, "SourceOutputLocation", GenerateHandlerSkeletonCommand.class, "OutputLocation", null);
    dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class, "HandlerClassNames", GenerateHandlerSkeletonCommand.class, "HandlerNames", null);
    dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class, "GenSkeletonEnabled", GenerateHandlerSkeletonCommand.class);

  }

  /*
   * (non-Javadoc)
   * 
   * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerWidgetMappings(org.eclipse.wst.command.env.ui.widgets.WidgetRegistry)
   */
  public void registerWidgetMappings(WidgetRegistry widgetRegistry) {
    String pluginId_ = "org.eclipse.jst.ws.consumption.ui";
    MessageUtils msgUtils = new MessageUtils(pluginId_ + ".plugin", this);

    widgetRegistry.add("ConfigServiceHandlersTableWidget", msgUtils.getMessage("PAGE_TITLE_SERVICE_HDLR_CONFIG"), msgUtils
        .getMessage("PAGE_DESC_SERVICE_HDLR_CONFIG"), new WidgetContributorFactory() {

      public WidgetContributor create() {
        return new ConfigServiceHandlersTableWidget();
      }
    });

    widgetRegistry.add("ConfigClientHandlersTableWidget", msgUtils.getMessage("PAGE_TITLE_CLIENT_HDLR_CONFIG"), msgUtils
        .getMessage("PAGE_DESC_CLIENT_HDLR_CONFIG"), new WidgetContributorFactory() {

      public WidgetContributor create() {
        return new ConfigClientHandlersTableWidget();
      }
    });

  }

  private class HandlersCommandFragment extends SequenceFragment {

    public HandlersCommandFragment() {

      add(new SimpleFragment(new HandlersDefaultingCommand(), ""));

      add(new ServiceHandlersFragment());
      add(new ClientHandlersFragment());
    }

    public void registerDataMappings(DataMappingRegistry dataRegistry) {

      dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", HandlersDefaultingCommand.class);

      dataRegistry.addMapping(HandlersDefaultingCommand.class, "IsClientHandler", ClientHandlersFragment.class, "ClientHandlersEnabled", null);
      dataRegistry.addMapping(HandlersDefaultingCommand.class, "IsServiceHandler", ServiceHandlersFragment.class, "ServiceHandlersEnabled", null);

      dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"WsClientResource", ClientHandlersWidgetOutputCommand.class);
      dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"WsServiceRefs", ClientHandlersWidgetOutputCommand.class);      
      dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"ClientProject", ClientHandlersWidgetOutputCommand.class);
     
      dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "WsddResource", ServiceHandlersWidgetOutputCommand.class);

    }

    public void registerCanFinish(CanFinishRegistry canFinishRegistry) {
    }
  }

  private class ClientHandlersFragment extends BooleanFragment {

    boolean isClient_ = false;

    public ClientHandlersFragment() {
      setCondition(new Condition() {

        public boolean evaluate() {
          return isClient_;
        }
      });

      SequenceFragment clientHandlersRootFragment = new SequenceFragment();

      clientHandlersRootFragment.add(new SimpleFragment(new ClientHandlersWidgetDefaultingCommand(), ""));

      clientHandlersRootFragment.add(new SimpleFragment("ConfigClientHandlersTableWidget"));
      clientHandlersRootFragment.add(new SimpleFragment(new ClientHandlersWidgetOutputCommand(), ""));
      clientHandlersRootFragment.add(new SimpleFragment(new GenerateHandlerSkeletonCommand(), ""));

      setTrueFragment(clientHandlersRootFragment);
    }

    public void setClientHandlersEnabled(boolean isClient) {
      isClient_ = isClient;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragment#registerDataMappings(org.eclipse.wst.command.internal.provisional.env.core.data.DataMappingRegistry)
     */
    public void registerDataMappings(DataMappingRegistry dataRegistry) {
      dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ClientHandlersWidgetDefaultingCommand.class);

      dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class, "WsClientResource", ClientHandlersWidgetOutputCommand.class);
      dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class, "ClientProject", ClientHandlersWidgetOutputCommand.class);

    }

  }

  private class ServiceHandlersFragment extends BooleanFragment {

    boolean isService_ = false;

    public ServiceHandlersFragment() {
      setCondition(new Condition() {

        public boolean evaluate() {
          return isService_;
        }
      });

      SequenceFragment serviceHandlersRootFragment = new SequenceFragment();
      serviceHandlersRootFragment.add(new SimpleFragment(new ServiceHandlersWidgetDefaultingCommand(), ""));

      SequenceFragment serviceHandlersFragment = new SequenceFragment();
      serviceHandlersFragment.add(new SimpleFragment("ConfigServiceHandlersTableWidget"));
      serviceHandlersFragment.add(new SimpleFragment(new ServiceHandlersWidgetOutputCommand(), ""));
      serviceHandlersFragment.add(new SimpleFragment(new GenerateHandlerSkeletonCommand(), ""));

      serviceHandlersRootFragment.add(serviceHandlersFragment);

      setTrueFragment(serviceHandlersRootFragment);
    }

    public void setServiceHandlersEnabled(boolean isService) {
      isService_ = isService;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragment#registerDataMappings(org.eclipse.wst.command.internal.provisional.env.core.data.DataMappingRegistry)
     */
    public void registerDataMappings(DataMappingRegistry dataRegistry) {
      dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ServiceHandlersWidgetDefaultingCommand.class);

      dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "WsddResource", ServiceHandlersWidgetOutputCommand.class);

    }

  }
}

Back to the top