1 19 20 package org.netbeans.api.options; 21 22 import java.util.Arrays ; 23 import java.util.logging.Logger ; 24 import org.netbeans.modules.options.CategoryModel; 25 import org.netbeans.modules.options.OptionsDisplayerImpl; 26 import org.openide.util.Mutex; 27 32 public final class OptionsDisplayer { 33 private static final OptionsDisplayer INSTANCE = new OptionsDisplayer(); 34 private final OptionsDisplayerImpl impl = new OptionsDisplayerImpl(false); 35 private static Logger log = Logger.getLogger(OptionsDisplayer.class.getName()); 36 37 private OptionsDisplayer() {} 38 42 public static OptionsDisplayer getDefault() { 43 return INSTANCE; 44 } 45 46 52 public boolean open() { 53 return open(CategoryModel.getInstance().getCurrentCategoryID()); 54 } 55 56 74 public boolean open(final String categoryId) { 75 log.fine("Open Options Dialog: " + categoryId); return openImpl(categoryId); 77 } 78 79 private boolean openImpl(final String categoryId) { 80 Boolean retval = Mutex.EVENT.readAccess(new Mutex.Action<Boolean > () { 81 public Boolean run() { 82 Boolean r = impl.isOpen(); 83 boolean retvalForRun = !r; 84 if (retvalForRun) { 85 retvalForRun = Arrays.asList(CategoryModel.getInstance().getCategoryIDs()).contains(categoryId); 86 if (!retvalForRun) { 87 log.warning("Unknown categoryId: " + categoryId); } 89 } else { 90 log.warning("Options Dialog is opened"); } 92 if (retvalForRun) { 93 impl.showOptionsDialog(categoryId); 94 } 95 return Boolean.valueOf(retvalForRun); 96 } 97 }); 98 return retval; 99 } 100 } | Popular Tags |