Home | History | Annotate | Download | only in editor
      1 /*******************************************************************************
      2  * Copyright (c) 2011 Google, Inc.
      3  * All rights reserved. This program and the accompanying materials
      4  * are made available under the terms of the Eclipse Public License v1.0
      5  * which accompanies this distribution, and is available at
      6  * http://www.eclipse.org/legal/epl-v10.html
      7  *
      8  * Contributors:
      9  *    Google, Inc. - initial API and implementation
     10  *******************************************************************************/
     11 package org.eclipse.wb.internal.core.model.property.editor;
     12 
     13 import org.eclipse.wb.internal.core.model.property.Property;
     14 
     15 import java.util.Locale;
     16 
     17 /**
     18  * {@link PropertyEditor} for {@link Locale}.
     19  *
     20  * @author sablin_aa
     21  * @coverage core.model.property.editor
     22  */
     23 public final class LocalePropertyEditor extends TextDialogPropertyEditor {
     24   ////////////////////////////////////////////////////////////////////////////
     25   //
     26   // Instance
     27   //
     28   ////////////////////////////////////////////////////////////////////////////
     29   public static final PropertyEditor INSTANCE = new LocalePropertyEditor();
     30 
     31   private LocalePropertyEditor() {
     32   }
     33 
     34   ////////////////////////////////////////////////////////////////////////////
     35   //
     36   // Presentation
     37   //
     38   ////////////////////////////////////////////////////////////////////////////
     39   @Override
     40   protected String getText(Property property) throws Exception {
     41     Object value = property.getValue();
     42     if (value instanceof Locale) {
     43       return ((Locale) value).getDisplayName();
     44     }
     45     // unknown value
     46     return null;
     47   }
     48 
     49   ////////////////////////////////////////////////////////////////////////////
     50   //
     51   // Editing
     52   //
     53   ////////////////////////////////////////////////////////////////////////////
     54   @Override
     55   protected void openDialog(Property property) throws Exception {
     56     Object value = property.getValue();
     57 //    ChooseLocaleDialog localeDialog;
     58 //    if (value instanceof Locale) {
     59 //      localeDialog = new ChooseLocaleDialog(DesignerPlugin.getShell(), (Locale) value);
     60 //    } else {
     61 //      localeDialog = new ChooseLocaleDialog(DesignerPlugin.getShell(), null);
     62 //    }
     63 //    // open dialog
     64 //    if (localeDialog.open() == Window.OK) {
     65 //      property.setValue(localeDialog.getSelectedLocale().getLocale());
     66 //    }
     67     System.out.println("TODO: Custom locale chooser here");
     68   }
     69 }