Project

General

Profile

« Previous | Next » 

Revision f919df55

Added by Andreas Kohlbecker almost 4 years ago

ref #7189 Connect dialog resizable and allowing for automatic size calculation

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
147 147
    private StyledText styledTxtMessage;
148 148

  
149 149

  
150
    private final int MIN_WIDTH = 530;
151
    private final int MIN_HEIGHT = 220;
152
    private final int MIN_EXP_HEIGHT = 380;
150
//    private final int MIN_WIDTH = 530;
151
//    private final int MIN_HEIGHT = 220;
152
//    private final int MIN_EXP_HEIGHT = 380;
153 153
    private final int MESSAGE_HEIGHT = 50;
154 154
    private Label lblEditorVersion;
155 155
    private Text txtEditorVersion;
......
205 205
        populateCdmServerCombo();
206 206
        shlConnect.open();
207 207
        shlConnect.layout();
208
        Point newSize = shlConnect.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
209
        shlConnect.setSize(newSize);
208 210

  
209 211
        xpndblcmpstAdvanced.setExpanded(false);
210 212

  
......
225 227
     * Create contents of the dialog.
226 228
     */
227 229
    private void createContents() {
228
        shlConnect = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
229
        shlConnect.setMinimumSize(new Point(MIN_WIDTH, MIN_HEIGHT));
230
        shlConnect.setSize(MIN_WIDTH, MIN_HEIGHT);
230
        shlConnect = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
231
        //shlConnect.setMinimumSize(new Point(MIN_WIDTH, MIN_HEIGHT));
232
        // shlConnect.setSize(MIN_WIDTH, MIN_HEIGHT);
231 233
        shlConnect.setText(Messages.RemotingLoginDialog_LABEL_CONNECT);
232 234
        shlConnect.setLayout(new FillLayout(SWT.HORIZONTAL));
233 235

  
......
236 238

  
237 239
        Composite cdmServerComposite = new Composite(remotingComposite, SWT.NONE);
238 240
        GridData gd_cdmServerComposite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
239
        gd_cdmServerComposite.heightHint = 68;
241
        // gd_cdmServerComposite.heightHint = 68;
240 242
        cdmServerComposite.setLayoutData(gd_cdmServerComposite);
241 243
        cdmServerComposite.setLayout(new GridLayout(4, false));
242 244

  
......
254 256
            }
255 257
        });
256 258
        GridData gd_comboCdmServer = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
257
        gd_comboCdmServer.widthHint = 150;
259
        //gd_comboCdmServer.widthHint = 150;
258 260
        comboCdmServer.setLayoutData(gd_comboCdmServer);
259 261
        comboCdmServer.select(0);
260 262

  
......
262 264
        txtCdmServerStatus.setBackground(SWTResourceManager.getColor(SWT.COLOR_INFO_BACKGROUND));
263 265
        txtCdmServerStatus.setEditable(false);
264 266
        GridData gd_txtCdmServerStatus = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
265
        gd_txtCdmServerStatus.widthHint = 100;
267
        //gd_txtCdmServerStatus.widthHint = 100;
266 268

  
267 269
        txtCdmServerStatus.setLayoutData(gd_txtCdmServerStatus);
268 270

  
......
278 280

  
279 281
        Label lblCdmInstance = new Label(cdmServerComposite, SWT.NONE);
280 282
        GridData gd_lblCdmInstance = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
281
        gd_lblCdmInstance.heightHint = 30;
283
        //gd_lblCdmInstance.heightHint = 30;
282 284
        lblCdmInstance.setLayoutData(gd_lblCdmInstance);
283 285
        lblCdmInstance.setText(Messages.RemotingLoginDialog_LABEL_CDM_INSTANCE);
284 286
        lblCdmInstance.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
......
291 293
            }
292 294
        });
293 295
        GridData gd_comboCdmInstance = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
294
        gd_comboCdmInstance.widthHint = 150;
296
        //gd_comboCdmInstance.widthHint = 150;
295 297
        comboCdmInstance.setLayoutData(gd_comboCdmInstance);
296 298
        comboCdmInstance.select(0);
297 299

  
......
299 301
        txtCdmInstanceStatus.setBackground(SWTResourceManager.getColor(SWT.COLOR_INFO_BACKGROUND));
300 302
        txtCdmInstanceStatus.setEditable(false);
301 303
        GridData gd_txtCdmInstanceStatus = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
302
        gd_txtCdmInstanceStatus.widthHint = 100;
304
        //gd_txtCdmInstanceStatus.widthHint = 100;
303 305
        txtCdmInstanceStatus.setLayoutData(gd_txtCdmInstanceStatus);
304 306

  
305 307
        btnCdmInstanceRefresh = new Button(cdmServerComposite, SWT.FLAT);
......
310 312
            }
311 313
        });
312 314
        GridData gd_btnCdmInstanceRefresh = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
313
        gd_btnCdmInstanceRefresh.widthHint = 110;
314
        gd_btnCdmInstanceRefresh.heightHint = 30;
315
//        gd_btnCdmInstanceRefresh.widthHint = 110;
316
//        gd_btnCdmInstanceRefresh.heightHint = 30;
315 317
        btnCdmInstanceRefresh.setLayoutData(gd_btnCdmInstanceRefresh);
316 318
        btnCdmInstanceRefresh.setText(Messages.RemotingLoginDialog_LABEL_REFRESH);
317 319

  
318 320
        loginComposite = new Composite(remotingComposite, SWT.NONE);
319 321
        GridData gd_loginComposite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
320
        gd_loginComposite.widthHint = 487;
321
        gd_loginComposite.heightHint = 70;
322
//        gd_loginComposite.widthHint = 487;
323
//        gd_loginComposite.heightHint = 70;
322 324
        loginComposite.setLayoutData(gd_loginComposite);
323 325
        GridLayout gl_loginComposite = new GridLayout(6, false);
324 326
        gl_loginComposite.marginTop = 5;
......
326 328

  
327 329
        lblLogin = new Label(loginComposite, SWT.CENTER);
328 330
        GridData gd_lblLogin = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
329
        gd_lblLogin.widthHint = 50;
331
//        gd_lblLogin.widthHint = 50;
330 332
        lblLogin.setLayoutData(gd_lblLogin);
331 333
        lblLogin.setText(Messages.RemotingLoginDialog_LABEL_LOGIN_COLON);
332 334
        lblLogin.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
......
334 336
        txtLogin = new Text(loginComposite, SWT.BORDER);
335 337
        GridData gd_txtLogin = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
336 338
        gd_txtLogin.minimumWidth = 80;
337
        gd_txtLogin.widthHint = 80;
338
        gd_txtLogin.heightHint = 15;
339
//        gd_txtLogin.widthHint = 80;
340
//        gd_txtLogin.heightHint = 15;
339 341
        txtLogin.setLayoutData(gd_txtLogin);
340 342

  
341 343
        lblPassword = new Label(loginComposite, SWT.CENTER);
......
346 348
        txtPassword = new Text(loginComposite, SWT.BORDER | SWT.PASSWORD);
347 349
        GridData gd_txtPassword = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
348 350
        gd_txtPassword.minimumWidth = 80;
349
        gd_txtPassword.widthHint = 80;
350
        gd_txtPassword.heightHint = 15;
351
//        gd_txtPassword.widthHint = 80;
352
//        gd_txtPassword.heightHint = 15;
351 353
        txtPassword.setLayoutData(gd_txtPassword);
352 354
        new Label(loginComposite, SWT.NONE);
353 355
        txtPassword.addKeyListener(new KeyAdapter() {
......
392 394
        GridData gd_styledTxtMessage = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
393 395
        gd_styledTxtMessage.exclude = true;
394 396
        gd_styledTxtMessage.minimumHeight = MESSAGE_HEIGHT;
395
        gd_styledTxtMessage.heightHint = MESSAGE_HEIGHT;
396
        gd_styledTxtMessage.widthHint = MIN_WIDTH - 5;
397
        // gd_styledTxtMessage.heightHint = MESSAGE_HEIGHT;
398
        //gd_styledTxtMessage.widthHint = MIN_WIDTH - 5;
397 399

  
398 400
        styledTxtMessage.setLayoutData(gd_styledTxtMessage);
399 401

  
400 402
        xpndblcmpstAdvanced = new ExpandableComposite(remotingComposite, SWT.NONE, ExpandableComposite.TWISTIE);
401 403
        GridData gd_xpndblcmpstAdvanced = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1);
402
        gd_xpndblcmpstAdvanced.heightHint = 19;
403
        gd_xpndblcmpstAdvanced.widthHint = MIN_WIDTH - 10;
404
        // gd_xpndblcmpstAdvanced.heightHint = 19;
405
        // gd_xpndblcmpstAdvanced.widthHint = MIN_WIDTH - 10;
404 406
        xpndblcmpstAdvanced.setLayoutData(gd_xpndblcmpstAdvanced);
405 407
        xpndblcmpstAdvanced.addExpansionListener(new IExpansionListener() {
406 408
            @Override
407 409
            public void expansionStateChanged(ExpansionEvent e) {
408 410
                if(e.getState()) {
409
                    shlConnect.setSize(MIN_WIDTH, MIN_EXP_HEIGHT);
411
                    Point newSize = shlConnect.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
412
                    shlConnect.setSize(newSize);
410 413
                } else {
411
                    shlConnect.setSize(MIN_WIDTH, MIN_HEIGHT);
414
                    Point newSize = shlConnect.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
415
                    shlConnect.setSize(newSize);
412 416
                }
413 417

  
414 418
            }
......
425 429

  
426 430
        lblPort = new Label(compAdvanced, SWT.CENTER);
427 431
        lblPort.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
428
        lblPort.setSize(0, 0);
432
        //lblPort.setSize(0, 0);
429 433
        lblPort.setText(Messages.RemotingLoginDialog_LABEL_PORT);
430 434
        lblPort.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
431 435

  
432 436
        txtPort = new Text(compAdvanced, SWT.BORDER);
433 437
        GridData gd_txtPort = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
434 438
        gd_txtPort.minimumWidth = 50;
435
        gd_txtPort.widthHint = 50;
439
        // gd_txtPort.widthHint = 50;
436 440
        txtPort.setLayoutData(gd_txtPort);
437 441

  
438 442
        lblServerVersion = new Label(compAdvanced, SWT.CENTER);
......
484 488
        txtEditorCDMVersion.setEditable(false);
485 489
        txtEditorCDMVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
486 490

  
491

  
487 492
    }
488 493

  
489 494
	private void connectButtonPressed() {
......
1098 1103
            styledTxtMessage.setText(message);
1099 1104
            styledTxtMessage.setVisible(true);
1100 1105
            ((GridData)styledTxtMessage.getLayoutData()).exclude = false;
1101
            shlConnect.setSize(MIN_WIDTH, getHeightWithoutMessage() + MESSAGE_HEIGHT);
1102
            shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage() + MESSAGE_HEIGHT);
1106
//            shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage() + MESSAGE_HEIGHT);
1107
            Point newSize = shlConnect.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
1108
            shlConnect.setSize(newSize);
1103 1109
        } else {
1104 1110
            if (!styledTxtMessage.isDisposed()){
1105 1111
                styledTxtMessage.setText(""); //$NON-NLS-1$
......
1107 1113
                ((GridData)styledTxtMessage.getLayoutData()).exclude = true;
1108 1114
            }
1109 1115
            if(!shlConnect.isDisposed()){
1110
                shlConnect.setSize(MIN_WIDTH, getHeightWithoutMessage());
1111
                shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage());
1116
//                shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage());
1117
                Point newSize = shlConnect.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
1118
                shlConnect.setSize(newSize);
1112 1119
            }
1113 1120
        }
1114 1121
        if (!remotingComposite.isDisposed()){
......
1116 1123
        }
1117 1124
    }
1118 1125

  
1119
    private int getHeightWithoutMessage() {
1120
        if(xpndblcmpstAdvanced.isExpanded()) {
1121
            return MIN_EXP_HEIGHT;
1122
        } else {
1123
            return MIN_HEIGHT;
1124
        }
1125
    }
1126
//    private int getHeightWithoutMessage() {
1127
//        if(xpndblcmpstAdvanced.isExpanded()) {
1128
//            return MIN_EXP_HEIGHT;
1129
//        } else {
1130
//            return MIN_HEIGHT;
1131
//        }
1132
//    }
1126 1133

  
1127 1134

  
1128 1135
    public void hide(boolean isHidden) {

Also available in: Unified diff