@@ -126,8 +126,9 @@ public void actionPerformed(ActionEvent e) {
126126 JPanel pnl = new JPanel (new FlowLayout (FlowLayout .CENTER ));
127127 pnl .add (btnCreateOpenfinWindow );
128128 pnl .add (btnCreateJavaWindow );
129-
130- contentPnl .add (new JLabel ("Undock Openfin windows with global hotkey (CTRL+SHIFT+U or CMD+SHIFT+U)" ), BorderLayout .NORTH );
129+
130+ contentPnl .add (new JLabel ("Undock Openfin windows with global hotkey (CTRL+SHIFT+U or CMD+SHIFT+U)" ),
131+ BorderLayout .NORTH );
131132 contentPnl .add (pnl , BorderLayout .CENTER );
132133
133134 this .mainWindow .getContentPane ().add (contentPnl );
@@ -151,8 +152,6 @@ void createApplication(String name, String uuid, String url, AckListener listene
151152 ApplicationOptions appOpt = new ApplicationOptions (name , uuid , url );
152153 WindowOptions mainWindowOptions = new WindowOptions ();
153154 mainWindowOptions .setAutoShow (false );
154- mainWindowOptions .setDefaultHeight (480 );
155- mainWindowOptions .setDefaultWidth (640 );
156155 appOpt .setMainWindowOptions (mainWindowOptions );
157156
158157 this .application = new Application (appOpt , this .desktopConnection , new AckListener () {
@@ -177,7 +176,7 @@ public void onError(Ack ack) {
177176
178177 void createJavaWindow (String windowName ) throws DesktopException {
179178 final JButton btnUndock = new JButton ("undock" );
180-
179+
181180 JFrame f = new JFrame ();
182181 f .setDefaultCloseOperation (JFrame .DISPOSE_ON_CLOSE );
183182 f .setPreferredSize (new Dimension (640 , 480 ));
@@ -187,24 +186,26 @@ void createJavaWindow(String windowName) throws DesktopException {
187186 f .pack ();
188187 f .setLocationRelativeTo (null );
189188 f .setVisible (true );
190-
189+
191190 new ExternalWindowObserver (this .desktopConnection .getPort (), appUuid , windowName , f , new AckListener () {
192191 @ Override
193192 public void onSuccess (Ack ack ) {
194- System .out .println (windowName + ": java window observered" );
195193 ExternalWindowObserver observer = (ExternalWindowObserver ) ack .getSource ();
196- observer .getDesktopConnection ().getChannel ().connect ("of-layouts-service-v1" , new AsyncCallback <ChannelClient >() {
197- @ Override
198- public void onSuccess (ChannelClient client ) {
199- btnUndock .addActionListener (new ActionListener () {
194+ observer .getDesktopConnection ().getChannel ().connect ("of-layouts-service-v1" ,
195+ new AsyncCallback <ChannelClient >() {
200196 @ Override
201- public void actionPerformed (ActionEvent e ) {
202- JSONObject payload = new JSONObject ();
203- payload .put ("uuid" , appUuid );
204- payload .put ("name" , windowName );
205- client .dispatch ("UNDOCK-WINDOW" , payload , null );
206- }});
207- }});
197+ public void onSuccess (ChannelClient client ) {
198+ btnUndock .addActionListener (new ActionListener () {
199+ @ Override
200+ public void actionPerformed (ActionEvent e ) {
201+ JSONObject payload = new JSONObject ();
202+ payload .put ("uuid" , appUuid );
203+ payload .put ("name" , windowName );
204+ client .dispatch ("UNDOCK-WINDOW" , payload , null );
205+ }
206+ });
207+ }
208+ });
208209 }
209210
210211 @ Override
@@ -223,7 +224,6 @@ void createOpenfinWindow() {
223224 winOpts .setName (UUID .randomUUID ().toString ());
224225 winOpts .setUrl ("https://www.google.com" );
225226 application .createChildWindow (winOpts , new AckListener () {
226-
227227 @ Override
228228 public void onSuccess (Ack ack ) {
229229 }
@@ -248,27 +248,10 @@ public void onSuccess(Ack ack) {
248248
249249 @ Override
250250 public void onError (Ack ack ) {
251+ System .out .println ("error creating applicaton: " + ack .getReason ());
251252 }
252253
253254 });
254-
255- // this.desktopConnection.getChannel().connect("of-layouts-service-v1", new
256- // AsyncCallback<ChannelClient>() {
257- //
258- // @Override
259- // public void onSuccess(ChannelClient client) {
260- // channelClient = client;
261- // System.out.println("channel connected: " + client.getChannelId());
262- //
263- // // try {
264- // // desktopConnection.disconnect();
265- // // }
266- // // catch (DesktopException e) {
267- // // // TODO Auto-generated catch block
268- // // e.printStackTrace();
269- // // }
270- // }
271- // });
272255 }
273256
274257 @ Override
@@ -278,24 +261,17 @@ public void onClose(String error) {
278261
279262 @ Override
280263 public void onError (String reason ) {
281- // TODO Auto-generated method stub
282-
283264 }
284265
285266 @ Override
286267 public void onMessage (String message ) {
287- // TODO Auto-generated method stub
288-
289268 }
290269
291270 @ Override
292271 public void onOutgoingMessage (String message ) {
293- // TODO Auto-generated method stub
294-
295272 }
296273
297274 public static void main (String [] args ) {
298275 new LayoutServiceDemo ();
299276 }
300-
301277}
0 commit comments