summaryrefslogtreecommitdiff
path: root/propertysheet/src/org/eclipse/wb/internal/core/model/property/editor/LocalePropertyEditor.java
blob: 9a6563d2c2224a3ce95610f569491c53713eee49 (plain)
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
/*******************************************************************************
 * Copyright (c) 2011 Google, Inc.
 * 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:
 *    Google, Inc. - initial API and implementation
 *******************************************************************************/
package org.eclipse.wb.internal.core.model.property.editor;

import org.eclipse.wb.internal.core.model.property.Property;

import java.util.Locale;

/**
 * {@link PropertyEditor} for {@link Locale}.
 *
 * @author sablin_aa
 * @coverage core.model.property.editor
 */
public final class LocalePropertyEditor extends TextDialogPropertyEditor {
  ////////////////////////////////////////////////////////////////////////////
  //
  // Instance
  //
  ////////////////////////////////////////////////////////////////////////////
  public static final PropertyEditor INSTANCE = new LocalePropertyEditor();

  private LocalePropertyEditor() {
  }

  ////////////////////////////////////////////////////////////////////////////
  //
  // Presentation
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  protected String getText(Property property) throws Exception {
    Object value = property.getValue();
    if (value instanceof Locale) {
      return ((Locale) value).getDisplayName();
    }
    // unknown value
    return null;
  }

  ////////////////////////////////////////////////////////////////////////////
  //
  // Editing
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  protected void openDialog(Property property) throws Exception {
    Object value = property.getValue();
//    ChooseLocaleDialog localeDialog;
//    if (value instanceof Locale) {
//      localeDialog = new ChooseLocaleDialog(DesignerPlugin.getShell(), (Locale) value);
//    } else {
//      localeDialog = new ChooseLocaleDialog(DesignerPlugin.getShell(), null);
//    }
//    // open dialog
//    if (localeDialog.open() == Window.OK) {
//      property.setValue(localeDialog.getSelectedLocale().getLocale());
//    }
    System.out.println("TODO: Custom locale chooser here");
  }
}