Example usage for java.util Locale getDisplayLanguage

List of usage examples for java.util Locale getDisplayLanguage

Introduction

In this page you can find the example usage for java.util Locale getDisplayLanguage.

Prototype

public String getDisplayLanguage(Locale inLocale) 

Source Link

Document

Returns a name for the locale's language that is appropriate for display to the user.

Usage

From source file:org.itracker.core.resources.ITrackerResources.java

public static String getLocaleFullDN(Locale locale, Locale displayLocale) {

    if (null == locale) {
        locale = new Locale("");
    }/*from w w w .j a  va  2s .  c  o  m*/
    String fullName = StringUtils.trimToNull(getLocaleNativeName(locale));
    if (null == displayLocale || locale.getLanguage().equals(displayLocale.getLanguage())) {
        return fullName;
    }
    if (StringUtils.equals(fullName, String.valueOf(locale))) {
        fullName = getLocaleDN(locale, displayLocale);
        return fullName;
    } else {
        String localizedName = StringUtils.trimToNull(getLocaleDN(locale, displayLocale));
        if (null != fullName && !StringUtils.equals(fullName, localizedName)) {
            return fullName.trim() + " (" + localizedName.trim() + ")";
        } else if (null != localizedName) {
            return localizedName.trim();
        } else if (null != fullName) {
            return fullName.trim();
        }
    }

    return locale.getDisplayName()
            + (!locale.equals(displayLocale) ? " (" + locale.getDisplayLanguage(locale) + ")" : "");

}

From source file:org.obiba.onyx.quartz.editor.questionnaire.QuestionnairePanel.java

public QuestionnairePanel(String id, final IModel<Questionnaire> model, boolean newQuestionnaire) {
    super(id, model);
    final Questionnaire questionnaire = model.getObject();

    add(CSSPackageResource.getHeaderContribution(QuestionnairePanel.class, "QuestionnairePanel.css"));

    feedbackPanel = new FeedbackPanel("content");
    feedbackWindow = new FeedbackWindow("feedback");
    feedbackWindow.setOutputMarkupId(true);
    add(feedbackWindow);/*from w w  w .  j  ava 2s.  c o m*/

    Form<Questionnaire> form = new Form<Questionnaire>("form", model);
    add(form);

    TextField<String> name = new TextField<String>("name", new PropertyModel<String>(form.getModel(), "name"));
    name.setLabel(new ResourceModel("Name"));
    name.setEnabled(newQuestionnaire);
    name.add(new RequiredFormFieldBehavior());
    name.add(new PatternValidator(QuartzEditorPanel.ELEMENT_NAME_PATTERN));
    name.add(new AbstractValidator<String>() {
        @Override
        protected void onValidate(final IValidatable<String> validatable) {
            boolean isNewName = Iterables.all(questionnaireBundleManager.bundles(),
                    new Predicate<QuestionnaireBundle>() {
                        @Override
                        public boolean apply(QuestionnaireBundle input) {
                            return !input.getName().equals(validatable.getValue());
                        }
                    });
            if (!isNewName && !validatable.getValue().equals(questionnaire.getName())) {
                error(validatable, "NameAlreadyExist");
            }
        }
    });
    form.add(name).add(new SimpleFormComponentLabel("nameLabel", name))
            .add(new HelpTooltipPanel("nameHelp", new ResourceModel("Name.Tooltip")));

    TextField<String> version = new TextField<String>("version",
            new PropertyModel<String>(form.getModel(), "version"));
    version.setLabel(new ResourceModel("Version"));
    version.add(new RequiredFormFieldBehavior());
    form.add(version).add(new SimpleFormComponentLabel("versionLabel", version));

    CheckBox commentable = new CheckBox("commentable",
            new PropertyModel<Boolean>(questionnaire, "commentable"));
    commentable.setLabel(new ResourceModel("Commentable"));
    form.add(commentable);
    form.add(new SimpleFormComponentLabel("commentableLabel", commentable));
    form.add(new HelpTooltipPanel("commentableHelp", new ResourceModel("Commentable.Tooltip")));

    QuestionnaireFinder.getInstance(questionnaire).buildQuestionnaireCache();
    guessUIType(questionnaire);

    RadioGroup<String> uiType = new RadioGroup<String>("uiType",
            new PropertyModel<String>(form.getModel(), "uiType"));
    uiType.setLabel(new ResourceModel("UIType"));
    uiType.setRequired(true);
    form.add(uiType);

    Radio<String> standardUiType = new Radio<String>("standard", new Model<String>(Questionnaire.STANDARD_UI));
    standardUiType.setLabel(new ResourceModel("UIType.standard"));
    uiType.add(standardUiType).add(new SimpleFormComponentLabel("standardLabel", standardUiType));

    Radio<String> simplifiedUiType = new Radio<String>("simplified",
            new Model<String>(Questionnaire.SIMPLIFIED_UI));
    simplifiedUiType.setLabel(new ResourceModel("UIType.simplified"));
    uiType.add(simplifiedUiType).add(new SimpleFormComponentLabel("simplifiedLabel", simplifiedUiType));
    form.add(new HelpTooltipPanel("uiHelp", new ResourceModel("UIType.Tooltip")));

    form.add(new HelpTooltipPanel("labelsHelp", new ResourceModel("LanguagesProperties.Tooltip")));

    Map<String, IModel<String>> labelsTooltips = new HashMap<String, IModel<String>>();
    labelsTooltips.put("label", new ResourceModel("Questionnaire.Tooltip.label"));
    labelsTooltips.put("description", new ResourceModel("Questionnaire.Tooltip.description"));
    labelsTooltips.put("labelNext", new ResourceModel("Questionnaire.Tooltip.otherNavigation"));
    labelsTooltips.put("labelPrevious", new ResourceModel("Questionnaire.Tooltip.otherNavigation"));
    labelsTooltips.put("labelStart", new ResourceModel("Questionnaire.Tooltip.otherNavigation"));
    labelsTooltips.put("labelFinish", new ResourceModel("Questionnaire.Tooltip.otherNavigation"));
    labelsTooltips.put("labelInterrupt", new ResourceModel("Questionnaire.Tooltip.otherNavigation"));
    labelsTooltips.put("labelResume", new ResourceModel("Questionnaire.Tooltip.otherNavigation"));
    labelsTooltips.put("labelCancel", new ResourceModel("Questionnaire.Tooltip.otherNavigation"));

    localePropertiesModel = new Model<LocaleProperties>(
            newQuestionnaire ? LocaleProperties.createForNewQuestionnaire(questionnaire)
                    : localePropertiesUtils.load(questionnaire, questionnaire));
    final LabelsPanel labelsPanel = new LabelsPanel("labels", localePropertiesModel, model, feedbackPanel,
            feedbackWindow, labelsTooltips, null);
    form.add(labelsPanel);

    final Locale userLocale = Session.get().getLocale();
    IChoiceRenderer<Locale> renderer = new IChoiceRenderer<Locale>() {
        @Override
        public String getIdValue(Locale locale, int index) {
            return locale.toString();
        }

        @Override
        public Object getDisplayValue(Locale locale) {
            return locale.getDisplayLanguage(userLocale);
        }
    };

    IModel<List<Locale>> localeChoices = new LoadableDetachableModel<List<Locale>>() {
        @Override
        protected List<Locale> load() {
            List<Locale> locales = new ArrayList<Locale>();
            for (String language : Locale.getISOLanguages()) {
                locales.add(new Locale(language));
            }
            Collections.sort(locales, new Comparator<Locale>() {
                @Override
                public int compare(Locale locale1, Locale locale2) {
                    return locale1.getDisplayLanguage(userLocale)
                            .compareTo(locale2.getDisplayLanguage(userLocale));
                }
            });
            return locales;
        }
    };

    Palette<Locale> localesPalette = new Palette<Locale>("languages",
            new PropertyModel<List<Locale>>(model.getObject(), "locales"), localeChoices, renderer, 5, false) {

        @Override
        protected Recorder<Locale> newRecorderComponent() {
            Recorder<Locale> recorder = super.newRecorderComponent();
            recorder.setLabel(new ResourceModel("Languages"));
            recorder.add(new AjaxFormComponentUpdatingBehavior("onchange") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    LocaleProperties localeProperties = localePropertiesModel.getObject();
                    Collection<Locale> selectedLocales = getModelCollection();
                    @SuppressWarnings("unchecked")
                    Collection<Locale> removedLocales = CollectionUtils.subtract(localeProperties.getLocales(),
                            selectedLocales);
                    for (Locale locale : removedLocales) {
                        localeProperties.removeLocale(questionnaire, locale);
                    }
                    for (Locale locale : selectedLocales) {
                        if (!localeProperties.getLocales().contains(locale)) {
                            localeProperties.addLocale(questionnaire, locale);
                        }
                    }
                    labelsPanel.onModelChange(target);
                }
            });
            return recorder;
        }
    };

    form.add(localesPalette);

    form.add(new SaveCancelPanel("saveCancel", form) {
        @Override
        protected void onSave(AjaxRequestTarget target, Form<?> form1) {
            try {
                if (questionnaire.getLocales().isEmpty()) {
                    error(new StringResourceModel("LanguagesRequired", QuestionnairePanel.this, null)
                            .getString());
                    feedbackWindow.setContent(feedbackPanel);
                    feedbackWindow.show(target);
                    return;
                }
                prepareSave(target, questionnaire);
                questionnairePersistenceUtils.persist(questionnaire, localePropertiesModel.getObject());
                QuestionnairePanel.this.onSave(target, questionnaire);
            } catch (Exception e) {
                log.error("Cannot persist questionnaire", e);
                error("Cannot persist questionnaire: " + e.getMessage());
                feedbackWindow.setContent(feedbackPanel);
                feedbackWindow.show(target);
            }
        }

        @Override
        protected void onCancel(AjaxRequestTarget target, @SuppressWarnings("hiding") Form<?> form) {
            QuestionnairePanel.this.onCancel(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, @SuppressWarnings("hiding") Form<?> form) {
            feedbackWindow.setContent(feedbackPanel);
            feedbackWindow.show(target);
        }
    });

}

From source file:de.mirkosertic.desktopsearch.LuceneIndexHandler.java

public QueryResult performQuery(String aQueryString, String aBacklink, String aBasePath,
        Configuration aConfiguration, Map<String, String> aDrilldownFields) throws IOException {

    searcherManager.maybeRefreshBlocking();
    IndexSearcher theSearcher = searcherManager.acquire();
    SortedSetDocValuesReaderState theSortedSetState = new DefaultSortedSetDocValuesReaderState(
            theSearcher.getIndexReader());

    List<QueryResultDocument> theResultDocuments = new ArrayList<>();

    long theStartTime = System.currentTimeMillis();

    LOGGER.info("Querying for " + aQueryString);

    DateFormat theDateFormat = new SimpleDateFormat("dd.MMMM.yyyy", Locale.ENGLISH);

    try {/*w w w  .ja v  a  2 s .co m*/

        List<FacetDimension> theDimensions = new ArrayList<>();

        // Search only if a search query is given
        if (!StringUtils.isEmpty(aQueryString)) {

            Query theQuery = computeBooleanQueryFor(aQueryString);

            LOGGER.info(" query is " + theQuery);

            theQuery = theQuery.rewrite(theSearcher.getIndexReader());

            LOGGER.info(" rewritten query is " + theQuery);

            DrillDownQuery theDrilldownQuery = new DrillDownQuery(facetsConfig, theQuery);
            aDrilldownFields.entrySet().stream().forEach(aEntry -> {
                LOGGER.info(" with Drilldown " + aEntry.getKey() + " for " + aEntry.getValue());
                theDrilldownQuery.add(aEntry.getKey(), aEntry.getValue());
            });

            FacetsCollector theFacetCollector = new FacetsCollector();

            TopDocs theDocs = FacetsCollector.search(theSearcher, theDrilldownQuery, null,
                    aConfiguration.getNumberOfSearchResults(), theFacetCollector);
            SortedSetDocValuesFacetCounts theFacetCounts = new SortedSetDocValuesFacetCounts(theSortedSetState,
                    theFacetCollector);

            List<Facet> theAuthorFacets = new ArrayList<>();
            List<Facet> theFileTypesFacets = new ArrayList<>();
            List<Facet> theLastModifiedYearFacet = new ArrayList<>();
            List<Facet> theLanguageFacet = new ArrayList<>();

            LOGGER.info("Found " + theDocs.scoreDocs.length + " documents");

            // We need this cache to detect duplicate documents while searching for similarities
            Set<Integer> theUniqueDocumentsFound = new HashSet<>();

            Map<String, QueryResultDocument> theDocumentsByHash = new HashMap<>();

            for (int i = 0; i < theDocs.scoreDocs.length; i++) {
                int theDocumentID = theDocs.scoreDocs[i].doc;
                theUniqueDocumentsFound.add(theDocumentID);
                Document theDocument = theSearcher.doc(theDocumentID);

                String theUniqueID = theDocument.getField(IndexFields.UNIQUEID).stringValue();
                String theFoundFileName = theDocument.getField(IndexFields.FILENAME).stringValue();
                String theHash = theDocument.getField(IndexFields.CONTENTMD5).stringValue();
                QueryResultDocument theExistingDocument = theDocumentsByHash.get(theHash);
                if (theExistingDocument != null) {
                    theExistingDocument.addFileName(theFoundFileName);
                } else {
                    Date theLastModified = new Date(
                            theDocument.getField(IndexFields.LASTMODIFIED).numericValue().longValue());
                    SupportedLanguage theLanguage = SupportedLanguage
                            .valueOf(theDocument.getField(IndexFields.LANGUAGESTORED).stringValue());
                    String theFieldName;
                    if (analyzerCache.supportsLanguage(theLanguage)) {
                        theFieldName = analyzerCache.getFieldNameFor(theLanguage);
                    } else {
                        theFieldName = IndexFields.CONTENT;
                    }

                    String theOriginalContent = theDocument.getField(theFieldName).stringValue();

                    final Query theFinalQuery = theQuery;

                    ForkJoinTask<String> theHighligherResult = executorPool.submit(() -> {
                        StringBuilder theResult = new StringBuilder(theDateFormat.format(theLastModified));
                        theResult.append("&nbsp;-&nbsp;");
                        Highlighter theHighlighter = new Highlighter(new SimpleHTMLFormatter(),
                                new QueryScorer(theFinalQuery));
                        for (String theFragment : theHighlighter.getBestFragments(analyzer, theFieldName,
                                theOriginalContent, NUMBER_OF_FRAGMENTS)) {
                            if (theResult.length() > 0) {
                                theResult = theResult.append("...");
                            }
                            theResult = theResult.append(theFragment);
                        }
                        return theResult.toString();
                    });

                    int theNormalizedScore = (int) (theDocs.scoreDocs[i].score / theDocs.getMaxScore() * 5);

                    File theFileOnDisk = new File(theFoundFileName);
                    if (theFileOnDisk.exists()) {

                        boolean thePreviewAvailable = previewProcessor.previewAvailableFor(theFileOnDisk);

                        theExistingDocument = new QueryResultDocument(theDocumentID, theFoundFileName,
                                theHighligherResult,
                                Long.parseLong(theDocument.getField(IndexFields.LASTMODIFIED).stringValue()),
                                theNormalizedScore, theUniqueID, thePreviewAvailable);
                        theDocumentsByHash.put(theHash, theExistingDocument);
                        theResultDocuments.add(theExistingDocument);
                    }
                }
            }

            if (aConfiguration.isShowSimilarDocuments()) {

                MoreLikeThis theMoreLikeThis = new MoreLikeThis(theSearcher.getIndexReader());
                theMoreLikeThis.setAnalyzer(analyzer);
                theMoreLikeThis.setMinTermFreq(1);
                theMoreLikeThis.setMinDocFreq(1);
                theMoreLikeThis.setFieldNames(analyzerCache.getAllFieldNames());

                for (QueryResultDocument theDocument : theResultDocuments) {
                    Query theMoreLikeThisQuery = theMoreLikeThis.like(theDocument.getDocumentID());
                    TopDocs theMoreLikeThisTopDocs = theSearcher.search(theMoreLikeThisQuery, 5);
                    for (ScoreDoc theMoreLikeThisScoreDoc : theMoreLikeThisTopDocs.scoreDocs) {
                        int theSimilarDocument = theMoreLikeThisScoreDoc.doc;
                        if (theUniqueDocumentsFound.add(theSimilarDocument)) {
                            Document theMoreLikeThisDocument = theSearcher.doc(theSimilarDocument);
                            String theFilename = theMoreLikeThisDocument.getField(IndexFields.FILENAME)
                                    .stringValue();
                            theDocument.addSimilarFile(theFilename);
                        }
                    }
                }
            }

            LOGGER.info("Got Dimensions");
            for (FacetResult theResult : theFacetCounts.getAllDims(20000)) {
                String theDimension = theResult.dim;
                if ("author".equals(theDimension)) {
                    for (LabelAndValue theLabelAndValue : theResult.labelValues) {
                        if (!StringUtils.isEmpty(theLabelAndValue.label)) {
                            theAuthorFacets.add(new Facet(theLabelAndValue.label,
                                    theLabelAndValue.value.intValue(), aBasePath + "/" + encode(
                                            FacetSearchUtils.encode(theDimension, theLabelAndValue.label))));
                        }
                    }
                }
                if ("extension".equals(theDimension)) {
                    for (LabelAndValue theLabelAndValue : theResult.labelValues) {
                        if (!StringUtils.isEmpty(theLabelAndValue.label)) {
                            theFileTypesFacets.add(new Facet(theLabelAndValue.label,
                                    theLabelAndValue.value.intValue(), aBasePath + "/" + encode(
                                            FacetSearchUtils.encode(theDimension, theLabelAndValue.label))));
                        }
                    }
                }
                if ("last-modified-year".equals(theDimension)) {
                    for (LabelAndValue theLabelAndValue : theResult.labelValues) {
                        if (!StringUtils.isEmpty(theLabelAndValue.label)) {
                            theLastModifiedYearFacet.add(new Facet(theLabelAndValue.label,
                                    theLabelAndValue.value.intValue(), aBasePath + "/" + encode(
                                            FacetSearchUtils.encode(theDimension, theLabelAndValue.label))));
                        }
                    }
                }
                if (IndexFields.LANGUAGEFACET.equals(theDimension)) {
                    for (LabelAndValue theLabelAndValue : theResult.labelValues) {
                        if (!StringUtils.isEmpty(theLabelAndValue.label)) {
                            Locale theLocale = new Locale(theLabelAndValue.label);
                            theLanguageFacet.add(new Facet(theLocale.getDisplayLanguage(Locale.ENGLISH),
                                    theLabelAndValue.value.intValue(), aBasePath + "/" + encode(
                                            FacetSearchUtils.encode(theDimension, theLabelAndValue.label))));
                        }
                    }
                }

                LOGGER.info(" " + theDimension);
            }

            if (!theAuthorFacets.isEmpty()) {
                theDimensions.add(new FacetDimension("Author", theAuthorFacets));
            }
            if (!theLastModifiedYearFacet.isEmpty()) {
                theDimensions.add(new FacetDimension("Last modified", theLastModifiedYearFacet));
            }
            if (!theFileTypesFacets.isEmpty()) {
                theDimensions.add(new FacetDimension("File types", theFileTypesFacets));
            }
            if (!theLanguageFacet.isEmpty()) {
                theDimensions.add(new FacetDimension("Language", theLanguageFacet));
            }

            // Wait for all Tasks to complete for the search result highlighter
            ForkJoinTask.helpQuiesce();
        }

        long theDuration = System.currentTimeMillis() - theStartTime;

        LOGGER.info("Total amount of time : " + theDuration + "ms");

        return new QueryResult(System.currentTimeMillis() - theStartTime, theResultDocuments, theDimensions,
                theSearcher.getIndexReader().numDocs(), aBacklink);
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        searcherManager.release(theSearcher);
    }
}

From source file:org.sakaiproject.util.ResourceLoader.java

/**
** Return a locale's display Name/*from w  w  w  . jav  a 2  s .  c  om*/
**
** @return String used to display Locale
**
** @author Jean-Francois Leveque (Universite Pierre et Marie Curie - Paris 6)
**/
public String getLocaleDisplayName(Locale loc) {
    Locale preferedLoc = getLocale();

    StringBuilder displayName = new StringBuilder(loc.getDisplayLanguage(loc));

    if (StringUtils.isNotBlank(loc.getDisplayCountry(loc))) {
        displayName.append(" - ").append(loc.getDisplayCountry(loc));
    }

    if (StringUtils.isNotBlank(loc.getVariant())) {
        displayName.append(" (").append(loc.getDisplayVariant(loc)).append(")");
    }

    displayName.append(" [").append(loc.toString()).append("] ");
    displayName.append(loc.getDisplayLanguage(preferedLoc));

    if (StringUtils.isNotBlank(loc.getDisplayCountry(preferedLoc))) {
        displayName.append(" - ").append(loc.getDisplayCountry(preferedLoc));
    }

    return displayName.toString();
}

From source file:com.globalsight.everest.projecthandler.MachineTranslateAdapter.java

private String getLanguagePairNameForProMt(Locale p_sourceLocale, Locale p_targetLocale) {
    if (p_sourceLocale == null || p_targetLocale == null) {
        return null;
    }//www  . jav  a  2s.c  o  m

    String srcLang = p_sourceLocale.getDisplayLanguage(Locale.ENGLISH);
    String srcCountry = p_sourceLocale.getDisplayCountry(Locale.ENGLISH);
    if ("Chinese".equals(srcLang) && "China".equals(srcCountry)) {
        srcLang = "Chinese (Simplified)";
    }

    String trgLang = p_targetLocale.getDisplayLanguage(Locale.ENGLISH);
    String trgCountry = p_targetLocale.getDisplayCountry(Locale.ENGLISH);
    if ("Chinese".equals(trgLang) && "China".equals(trgCountry)) {
        trgLang = "Chinese (Simplified)";
    }

    return (srcLang + "-" + trgLang);
}

From source file:com.globalsight.connector.blaise.BlaiseCreateJobHandler.java

private void setEntryInfo(HttpServletRequest request)
        throws LocaleManagerException, RemoteException, GeneralException {
    HttpSession session = request.getSession(false);
    Locale uiLocale = (Locale) session.getAttribute(UILOCALE);

    HashMap<Long, String> id2FileNameMap = new HashMap<Long, String>();
    HashMap<Long, String> id2LocaleMap = new HashMap<Long, String>();
    for (TranslationInboxEntryVo entry : currPageEntries) {
        id2FileNameMap.put(entry.getId(), BlaiseHelper.getEntryFileName(entry));

        Locale javaLocale = entry.getTargetLocale();
        String localeCode = BlaiseHelper.fixLocale(javaLocale.getLanguage() + "_" + javaLocale.getCountry());
        StringBuilder sb = new StringBuilder(localeCode).append(" (")
                .append(javaLocale.getDisplayLanguage(uiLocale)).append("_")
                .append(javaLocale.getDisplayCountry(uiLocale)).append(")");
        id2LocaleMap.put(entry.getId(), sb.toString());
    }/*  ww w  .  ja v a 2s.c  om*/

    getSessionManager(request).setAttribute("id2FileNameMap", id2FileNameMap);
    getSessionManager(request).setAttribute("id2LocaleMap", id2LocaleMap);
}

From source file:org.obiba.onyx.quartz.editor.locale.LabelsPanel.java

public void onModelChange(AjaxRequestTarget target) {
    LocaleProperties localeProperties = (LocaleProperties) getDefaultModelObject();
    final ListMultimap<Locale, KeyValue> elementLabels = localeProperties
            .getElementLabels(elementModel.getObject());
    Locale userLocale = Session.get().getLocale();

    @SuppressWarnings("unchecked")
    Collection<Locale> removedLocales = CollectionUtils.subtract(tabByLocale.keySet(),
            localeProperties.getLocales());
    List<ITab> tabs = tabbedPanel.getTabs();
    for (Locale locale : removedLocales) {
        ITab tabToRemove = tabByLocale.get(locale);
        int selectedTabIndex = tabbedPanel.getSelectedTab();
        ITab selectedTab = tabs.get(selectedTabIndex);
        tabs.remove(tabToRemove);/*from w w  w .  java  2s  .c  o  m*/
        tabByLocale.remove(locale);

        if (tabToRemove != selectedTab) {
            for (int i = 0; i < tabs.size(); i++) {
                ITab tab = tabs.get(i);
                if (selectedTab == tab) {
                    tabbedPanel.setSelectedTab(i);
                    break;
                }
            }
        } else {
            tabbedPanel.setSelectedTab(0);
        }
    }

    for (final Locale locale : localeProperties.getLocales()) {
        if (!tabByLocale.containsKey(locale)) {
            AbstractTab tab = new AbstractTab(new Model<String>(locale.getDisplayLanguage(userLocale))) {
                @Override
                public Panel getPanel(String panelId) {
                    return new InputPanel(panelId, new ListModel<KeyValue>(elementLabels.get(locale)), null);
                }
            };
            ITab panelCachingTab = new PanelCachingTab(tab);
            tabByLocale.put(locale, panelCachingTab);
            tabs.add(panelCachingTab);
            if (tabs.size() == 1)
                tabbedPanel.setSelectedTab(0);
        }
    }
    tabbedPanel.setVisible(tabs.size() > 0);
    target.addComponent(tabsContainer);
}

From source file:com.doculibre.constellio.services.IndexFieldServicesImpl.java

@Override
public Map<String, String> getDefaultLabelledValues(IndexField indexField, Locale locale) {
    Map<String, String> labels = new HashMap<String, String>();
    String indexFieldName = indexField.getName();
    if (IndexField.COLLECTION_ID_FIELD.equals(indexFieldName)) {
        RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
        for (RecordCollection collection : collectionServices.list()) {
            Locale displayLocale = collection.getDisplayLocale(locale);
            labels.put("" + collection.getId(), collection.getTitle(displayLocale));
        }/*  w  w  w . ja va 2s. c o  m*/
    } else if (IndexField.CONNECTOR_INSTANCE_ID_FIELD.equals(indexFieldName)) {
        ConnectorInstanceServices connectorInstanceServices = ConstellioSpringUtils
                .getConnectorInstanceServices();
        for (ConnectorInstance connectorInstance : connectorInstanceServices.list()) {
            labels.put("" + connectorInstance.getId(), connectorInstance.getDisplayName());
        }
    } else if (IndexField.CONNECTOR_TYPE_ID_FIELD.equals(indexFieldName)) {
        ConnectorTypeServices connectorTypeServices = ConstellioSpringUtils.getConnectorTypeServices();
        for (ConnectorType connectorType : connectorTypeServices.list()) {
            labels.put("" + connectorType.getId(), connectorType.getName());
        }
    } else if (IndexField.LANGUAGE_FIELD.equals(indexFieldName)) {
        for (Locale availableLocale : Locale.getAvailableLocales()) {
            labels.put(availableLocale.getLanguage(),
                    StringUtils.capitalize(availableLocale.getDisplayLanguage(locale)));
        }
    } else if (IndexField.MIME_TYPE_FIELD.equals(indexFieldName)) {
        // Source : http://www.w3schools.com/media/media_mimeref.asp
        String prefix = "mimeType.";
        Set<String> mimeTypeResourceKeys = ResourceBundleUtils.getKeys(prefix, ApplicationResources.class);
        for (String mimeTypeResourceKey : mimeTypeResourceKeys) {
            String mimeType = mimeTypeResourceKey.substring(prefix.length());
            String mimeTypeLabel = ResourceBundleUtils.getString(mimeTypeResourceKey, locale,
                    ApplicationResources.class);
            labels.put(mimeType, mimeTypeLabel);
        }
    }
    return labels;
}

From source file:com.freedomotic.jfrontend.MainWindow.java

/**
 * //from  w ww .  java  2s  . c  om
 * @param evt 
 */
private void mnuLanguageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuLanguageActionPerformed
    //JDK 1,7 version: JComboBox<i18n.ComboLanguage> combo = new JComboBox<i18n.ComboLanguage>(I18n.getAvailableLocales());
    //JDK 1.6 version: next line
    Vector<ComboLanguage> languages = new Vector<ComboLanguage>();
    for (Locale loc : i18n.getAvailableLocales()) {
        languages.add(new ComboLanguage(
                loc.getDisplayCountry(i18n.getDefaultLocale()) + " - " + loc.getDisplayLanguage(loc),
                loc.toString(), loc));
    }
    Collections.sort(languages);
    languages.add(new ComboLanguage("Automatic", "auto", Locale.ENGLISH));

    JComboBox combo = new JComboBox(languages);

    for (ComboLanguage cmb : languages) {
        if (cmb.getValue().equals(i18n.getDefaultLocale())) {
            combo.setSelectedItem(cmb);
            break;
        }
    }
    JLabel lbl = new JLabel(i18n.msg("language"));
    int result = JOptionPane.showConfirmDialog(this, new Object[] { lbl, combo }, i18n.msg("language"),
            JOptionPane.OK_CANCEL_OPTION);
    if (result == JOptionPane.OK_OPTION) {
        ComboLanguage selected = (ComboLanguage) combo.getSelectedItem();
        i18n.setDefaultLocale(selected.getValue());
        updateStrings();
    }
}

From source file:org.dbgl.gui.SettingsDialog.java

protected void createContents() {
    shell = new Shell(getParent(), SWT.TITLE | SWT.CLOSE | SWT.BORDER | SWT.RESIZE | SWT.APPLICATION_MODAL);
    shell.setLayout(new BorderLayout(0, 0));
    shell.addControlListener(new SizeControlAdapter(shell, "settingsdialog"));
    shell.setText(settings.msg("dialog.settings.title"));

    final TabFolder tabFolder = new TabFolder(shell, SWT.NONE);

    final TabItem generalTabItem = new TabItem(tabFolder, SWT.NONE);
    generalTabItem.setText(settings.msg("dialog.settings.tab.general"));

    final Composite composite = new Composite(tabFolder, SWT.NONE);
    composite.setLayout(new GridLayout());
    generalTabItem.setControl(composite);

    final Group dosboxGroup = new Group(composite, SWT.NONE);
    dosboxGroup.setText(settings.msg("dialog.settings.dosbox"));
    dosboxGroup.setLayout(new GridLayout(2, false));

    final Label showConsoleLabel = new Label(dosboxGroup, SWT.NONE);
    showConsoleLabel.setText(settings.msg("dialog.settings.hidestatuswindow"));

    final Button console = new Button(dosboxGroup, SWT.CHECK);
    console.setSelection(conf.getBooleanValue("dosbox", "hideconsole"));

    final Group sendToGroup = new Group(composite, SWT.NONE);
    sendToGroup.setText(settings.msg("dialog.settings.sendto"));
    sendToGroup.setLayout(new GridLayout(2, false));

    final Label enableCommLabel = new Label(sendToGroup, SWT.NONE);
    enableCommLabel.setText(settings.msg("dialog.settings.enableport"));

    final Button portEnabled = new Button(sendToGroup, SWT.CHECK);
    portEnabled.setSelection(conf.getBooleanValue("communication", "port_enabled"));
    portEnabled.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent event) {
            port.setEnabled(portEnabled.getSelection());
        }//from  w  ww.j  av a2 s  .  c om
    });

    final Label portnumberLabel = new Label(sendToGroup, SWT.NONE);
    portnumberLabel.setText(settings.msg("dialog.settings.port"));

    port = new Text(sendToGroup, SWT.BORDER);
    port.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    port.setText(conf.getValue("communication", "port"));
    port.setEnabled(portEnabled.getSelection());

    final Group profileDefGroup = new Group(composite, SWT.NONE);
    profileDefGroup.setText(settings.msg("dialog.settings.profiledefaults"));
    profileDefGroup.setLayout(new GridLayout(3, false));

    final Label configFileLabel = new Label(profileDefGroup, SWT.NONE);
    configFileLabel.setText(settings.msg("dialog.settings.configfile"));

    confLocation = new Combo(profileDefGroup, SWT.READ_ONLY);
    confLocation.setItems(confLocations);
    confLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    confLocation.select(conf.getIntValue("profiledefaults", "confpath"));

    confFilename = new Combo(profileDefGroup, SWT.READ_ONLY);
    confFilename.setItems(confFilenames);
    confFilename.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    confFilename.select(conf.getIntValue("profiledefaults", "conffile"));

    final Group i18nGroup = new Group(composite, SWT.NONE);
    i18nGroup.setText(settings.msg("dialog.settings.i18n"));
    i18nGroup.setLayout(new GridLayout(2, false));

    final Label languageLabel = new Label(i18nGroup, SWT.NONE);
    languageLabel.setText(settings.msg("dialog.settings.languagecountry"));

    localeCombo = new Combo(i18nGroup, SWT.READ_ONLY);
    Locale locale = new Locale(conf.getValue("locale", "language"), conf.getValue("locale", "country"),
            conf.getValue("locale", "variant"));

    final SortedMap<String, Locale> locales = new TreeMap<String, Locale>();
    String locString = "";

    java.util.List<String> supportedLanguages = new ArrayList<String>(SUPPORTED_LANGUAGES);
    File[] files = new File("./plugins/i18n").listFiles();
    if (files != null) {
        for (File file : files) {
            String name = file.getName();
            if (name.startsWith("MessagesBundle_") && name.endsWith(".properties")) {
                String code = name.substring("MessagesBundle_".length(), name.indexOf(".properties"));
                if (code.length() > 0) {
                    supportedLanguages.add(code);
                }
            }
        }
    }

    for (String lang : supportedLanguages) {
        Locale loc = allLocales.get(lang);
        String variant = null;
        if (loc == null && StringUtils.countMatches(lang, "_") == 2) {
            String langWithoutVariant = StringUtils.removeEnd(StringUtils.substringBeforeLast(lang, "_"), "_");
            variant = StringUtils.substringAfterLast(lang, "_");
            loc = allLocales.get(langWithoutVariant);
        }
        if (loc != null) {
            StringBuffer s = new StringBuffer(loc.getDisplayLanguage(Locale.getDefault()));
            if (loc.getCountry().length() > 0)
                s.append(" - ").append(loc.getDisplayCountry(Locale.getDefault()));
            if (variant != null) {
                s.append(" (").append(variant).append(')');
                loc = new Locale(loc.getLanguage(), loc.getCountry(), variant);
            }
            locales.put(s.toString(), loc);
            if (loc.equals(locale)) {
                locString = s.toString();
            }
        }
    }

    for (String sloc : locales.keySet()) {
        localeCombo.add(sloc);
    }
    localeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    localeCombo.setText(locString);
    localeCombo.setVisibleItemCount(20);

    columnsTabItem = new TabItem(tabFolder, SWT.NONE);
    columnsTabItem.setText(settings.msg("dialog.settings.tab.profiletable"));

    final Composite composite2 = new Composite(tabFolder, SWT.NONE);
    composite2.setLayout(new BorderLayout(0, 0));
    columnsTabItem.setControl(composite2);

    final Group visColumnsGroup = new Group(composite2, SWT.NONE);
    visColumnsGroup.setLayout(new FillLayout());
    visColumnsGroup.setText(settings.msg("dialog.settings.visiblecolunms"));

    visible_columns = new Table(visColumnsGroup, SWT.FULL_SELECTION | SWT.BORDER | SWT.CHECK);
    visible_columns.setLinesVisible(true);

    TableColumn column1 = new TableColumn(visible_columns, SWT.NONE);
    column1.setWidth(350);

    java.util.List<Integer> visibleColumnIDs = new ArrayList<Integer>();
    for (int i = 0; i < MainWindow.columnNames.length; i++)
        if (conf.getBooleanValue("gui", "column" + (i + 1) + "visible"))
            visibleColumnIDs.add(i);
    java.util.List<Integer> orderedVisibleColumnIDs = new ArrayList<Integer>();
    int[] columnOrder = conf.getIntValues("gui", "columnorder");
    for (int i = 0; i < columnOrder.length; i++)
        orderedVisibleColumnIDs.add(visibleColumnIDs.get(columnOrder[i]));
    java.util.List<Integer> remainingColumnIDs = new ArrayList<Integer>();
    for (int i = 0; i < MainWindow.columnNames.length; i++)
        if (!orderedVisibleColumnIDs.contains(i))
            remainingColumnIDs.add(i);
    allColumnIDs = new ArrayList<Integer>(orderedVisibleColumnIDs);
    allColumnIDs.addAll(remainingColumnIDs);

    visibleColumns = new TableItem[MainWindow.columnNames.length];

    for (int i = 0; i < MainWindow.columnNames.length; i++) {
        visibleColumns[i] = new TableItem(visible_columns, SWT.BORDER);
        visibleColumns[i].setText(MainWindow.columnNames[allColumnIDs.get(i)]);
        visibleColumns[i]
                .setChecked(conf.getBooleanValue("gui", "column" + (allColumnIDs.get(i) + 1) + "visible"));
    }

    final TableEditor editor = new TableEditor(visible_columns);
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    editor.minimumWidth = 50;

    visible_columns.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent event) {
            // Clean up any previous editor control
            Control oldEditor = editor.getEditor();
            if (oldEditor != null) {
                oldEditor.dispose();
            }

            // Identify the selected row
            TableItem item = (TableItem) event.item;
            if (item == null) {
                return;
            }
            int selIdx = item.getParent().getSelectionIndex();
            if (selIdx == -1)
                return;
            int idx = allColumnIDs.get(selIdx);
            if (idx < Constants.RO_COLUMN_NAMES
                    || idx >= (Constants.RO_COLUMN_NAMES + Constants.EDIT_COLUMN_NAMES))
                return;

            // The control that will be the editor must be a child of the table
            Text newEditor = new Text(visible_columns, SWT.NONE);
            newEditor.setText(item.getText(EDITABLE_COLUMN));
            newEditor.addModifyListener(new ModifyListener() {
                public void modifyText(final ModifyEvent mEvent) {
                    Text text = (Text) editor.getEditor();
                    editor.getItem().setText(EDITABLE_COLUMN, text.getText());
                }
            });
            newEditor.selectAll();
            newEditor.setFocus();
            editor.setEditor(newEditor, item, EDITABLE_COLUMN);
        }
    });

    final Group addProfGroup = new Group(composite2, SWT.NONE);
    addProfGroup.setLayout(new GridLayout(2, false));
    addProfGroup.setText(settings.msg("dialog.settings.addeditduplicateprofile"));
    addProfGroup.setLayoutData(BorderLayout.SOUTH);

    final Label autoSortLabel = new Label(addProfGroup, SWT.NONE);
    autoSortLabel.setText(settings.msg("dialog.settings.autosort"));

    final Button autosort = new Button(addProfGroup, SWT.CHECK);
    autosort.setSelection(conf.getBooleanValue("gui", "autosortonupdate"));

    final TabItem dynTabItem = new TabItem(tabFolder, SWT.NONE);
    dynTabItem.setText(settings.msg("dialog.settings.tab.dynamicoptions"));

    final Composite composite_1 = new Composite(tabFolder, SWT.NONE);
    composite_1.setLayout(new FillLayout());
    dynTabItem.setControl(composite_1);

    final Group dynOptionsGroup = new Group(composite_1, SWT.NONE);
    dynOptionsGroup.setLayout(new GridLayout(2, false));
    dynOptionsGroup.setText(settings.msg("dialog.settings.dynamicoptions"));

    final Label optionsLabel = new Label(dynOptionsGroup, SWT.NONE);
    optionsLabel.setText(settings.msg("dialog.settings.options"));

    final Label valuesLabel = new Label(dynOptionsGroup, SWT.NONE);
    valuesLabel.setText(settings.msg("dialog.settings.values"));

    options = new List(dynOptionsGroup, SWT.V_SCROLL | SWT.BORDER);
    options.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent event) {
            storeValues();
            previousSelection = options.getSelectionIndex();
            if (previousSelection != -1) {
                values.setText(conf.getMultilineValues("profile", options.getItem(previousSelection),
                        values.getLineDelimiter()));
            }
        }
    });
    options.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    for (String s : conf.getAllItemNames("profile")) {
        options.add(s);
    }

    values = new Text(dynOptionsGroup, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
    values.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    final TabItem guiTabItem = new TabItem(tabFolder, SWT.NONE);
    guiTabItem.setText(settings.msg("dialog.settings.tab.gui"));
    final Composite composite1 = new Composite(tabFolder, SWT.NONE);
    composite1.setLayout(new GridLayout(2, false));
    guiTabItem.setControl(composite1);
    Group screenshots = new Group(composite1, SWT.NONE);
    screenshots.setLayout(new GridLayout(3, false));
    GridData screenshotsLData = new GridData();
    screenshotsLData.grabExcessHorizontalSpace = true;
    screenshotsLData.horizontalAlignment = GridData.FILL;
    screenshotsLData.horizontalSpan = 2;
    screenshots.setLayoutData(screenshotsLData);
    screenshots.setText(settings.msg("dialog.settings.screenshots"));
    Label heightLabel = new Label(screenshots, SWT.NONE);
    heightLabel.setText(settings.msg("dialog.settings.height"));
    GridData sshotsHeightData = new GridData();
    sshotsHeightData.grabExcessHorizontalSpace = true;
    sshotsHeightData.horizontalAlignment = GridData.FILL;
    screenshotsHeight = new Scale(screenshots, SWT.NONE);
    screenshotsHeight.setMaximum(750);
    screenshotsHeight.setMinimum(50);
    screenshotsHeight.setLayoutData(sshotsHeightData);
    screenshotsHeight.setIncrement(25);
    screenshotsHeight.setPageIncrement(100);
    screenshotsHeight.setSelection(conf.getIntValue("gui", "screenshotsheight"));
    screenshotsHeight.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent evt) {
            heightValue.setText(screenshotsHeight.getSelection() + settings.msg("dialog.settings.px"));
            heightValue.pack();
        }
    });
    heightValue = new Label(screenshots, SWT.NONE);
    heightValue.setText(screenshotsHeight.getSelection() + settings.msg("dialog.settings.px"));

    final Label displayFilenameLabel = new Label(screenshots, SWT.NONE);
    displayFilenameLabel.setText(settings.msg("dialog.settings.screenshotsfilename"));
    final Button displayFilename = new Button(screenshots, SWT.CHECK);
    displayFilename.setSelection(conf.getBooleanValue("gui", "screenshotsfilename"));

    Group screenshotsColumn = new Group(composite1, SWT.NONE);
    screenshotsColumn.setLayout(new GridLayout(3, false));
    GridData screenshotsCData = new GridData();
    screenshotsCData.grabExcessHorizontalSpace = true;
    screenshotsCData.horizontalAlignment = GridData.FILL;
    screenshotsCData.horizontalSpan = 2;
    screenshotsColumn.setLayoutData(screenshotsCData);
    screenshotsColumn.setText(settings.msg("dialog.settings.screenshotscolumn"));
    Label columnHeightLabel = new Label(screenshotsColumn, SWT.NONE);
    columnHeightLabel.setText(settings.msg("dialog.settings.height"));
    screenshotsColumnHeight = new Scale(screenshotsColumn, SWT.NONE);
    screenshotsColumnHeight.setMaximum(200);
    screenshotsColumnHeight.setMinimum(16);
    GridData sshotsColumnHeightData = new GridData();
    sshotsColumnHeightData.grabExcessHorizontalSpace = true;
    sshotsColumnHeightData.horizontalAlignment = GridData.FILL;
    screenshotsColumnHeight.setLayoutData(sshotsColumnHeightData);
    screenshotsColumnHeight.setIncrement(4);
    screenshotsColumnHeight.setPageIncrement(16);
    screenshotsColumnHeight.setSelection(conf.getIntValue("gui", "screenshotscolumnheight"));
    screenshotsColumnHeight.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent evt) {
            columnHeightValue
                    .setText(screenshotsColumnHeight.getSelection() + settings.msg("dialog.settings.px"));
            columnHeightValue.pack();
        }
    });
    columnHeightValue = new Label(screenshotsColumn, SWT.NONE);
    columnHeightValue.setText(screenshotsColumnHeight.getSelection() + settings.msg("dialog.settings.px"));

    final Label stretchLabel = new Label(screenshotsColumn, SWT.NONE);
    stretchLabel.setText(settings.msg("dialog.settings.screenshotscolumnstretch"));
    final Button stretch = new Button(screenshotsColumn, SWT.CHECK);
    stretch.setSelection(conf.getBooleanValue("gui", "screenshotscolumnstretch"));
    new Label(screenshotsColumn, SWT.NONE);
    final Label keepAspectRatioLabel = new Label(screenshotsColumn, SWT.NONE);
    keepAspectRatioLabel.setText(settings.msg("dialog.settings.screenshotscolumnkeepaspectratio"));
    final Button keepAspectRatio = new Button(screenshotsColumn, SWT.CHECK);
    keepAspectRatio.setSelection(conf.getBooleanValue("gui", "screenshotscolumnkeepaspectratio"));
    new Label(screenshotsColumn, SWT.NONE);
    keepAspectRatio.setEnabled(stretch.getSelection());
    stretch.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent event) {
            keepAspectRatio.setEnabled(stretch.getSelection());
        }
    });

    Group buttonsGroup = new Group(composite1, SWT.NONE);
    buttonsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
    buttonsGroup.setLayout(new GridLayout(2, false));
    buttonsGroup.setText(settings.msg("dialog.settings.buttons"));

    final Label buttonLabel = new Label(buttonsGroup, SWT.NONE);
    buttonLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    buttonLabel.setText(settings.msg("dialog.settings.display"));

    buttonDisplay = new Combo(buttonsGroup, SWT.READ_ONLY);
    buttonDisplay.setItems(buttonDisplayOptions);
    buttonDisplay.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    buttonDisplay.select(conf.getIntValue("gui", "buttondisplay"));

    final Group notesGroup = new Group(composite1, SWT.NONE);
    notesGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    notesGroup.setLayout(new GridLayout(2, false));
    notesGroup.setText(settings.msg("dialog.profile.notes"));

    final Label fontLabel = new Label(notesGroup, SWT.NONE);
    fontLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    fontLabel.setText(settings.msg("dialog.settings.font"));

    final Button fontButton = new Button(notesGroup, SWT.PUSH);
    fontButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Font f = GeneralPurposeGUI.stringToFont(shell.getDisplay(), port.getFont(),
            conf.getValues("gui", "notesfont"));
    fontButton.setText(f.getFontData()[0].getName());
    fontButton.setFont(f);
    fontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            FontDialog fd = new FontDialog(shell, SWT.NONE);
            fd.setFontList(fontButton.getFont().getFontData());
            FontData newFont = fd.open();
            if (newFont != null) {
                fontButton.setText(newFont.getName());
                fontButton.setFont(new Font(shell.getDisplay(), newFont));
                notesGroup.setSize(notesGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));
                composite1.layout();
            }
        }
    });

    final TabItem enginesTabItem = new TabItem(tabFolder, SWT.NONE);
    enginesTabItem.setText(settings.msg("dialog.settings.tab.engines"));
    Composite compositeHoldingSubTabs = new Composite(tabFolder, SWT.NONE);
    compositeHoldingSubTabs.setLayout(new FillLayout());
    enginesTabItem.setControl(compositeHoldingSubTabs);
    final TabFolder enginesTabFolder = new TabFolder(compositeHoldingSubTabs, SWT.NONE);

    setTitle = new Button[NR_OF_ENGINES];
    setDev = new Button[NR_OF_ENGINES];
    setPub = new Button[NR_OF_ENGINES];
    setYear = new Button[NR_OF_ENGINES];
    setGenre = new Button[NR_OF_ENGINES];
    setLink = new Button[NR_OF_ENGINES];
    setRank = new Button[NR_OF_ENGINES];
    setDescr = new Button[NR_OF_ENGINES];
    allRegionsCoverArt = new Button[NR_OF_ENGINES];
    chooseCoverArt = new Button[NR_OF_ENGINES];
    chooseScreenshot = new Button[NR_OF_ENGINES];
    maxCoverArt = new Spinner[NR_OF_ENGINES];
    maxScreenshots = new Spinner[NR_OF_ENGINES];
    platformFilterValues = new Text[NR_OF_ENGINES];

    for (int i = 0; i < NR_OF_ENGINES; i++) {
        WebSearchEngine engine = EditProfileDialog.webSearchEngines.get(i);
        final TabItem engineTabItem = new TabItem(enginesTabFolder, SWT.NONE);
        engineTabItem.setText(settings.msg("dialog.settings.tab." + engine.getSimpleName()));
        Composite composite3 = new Composite(enginesTabFolder, SWT.NONE);
        composite3.setLayout(new GridLayout(1, true));
        engineTabItem.setControl(composite3);
        Group consult = new Group(composite3, SWT.NONE);
        consult.setLayout(new GridLayout(2, false));
        GridData consultLData = new GridData();
        consultLData.grabExcessHorizontalSpace = true;
        consultLData.horizontalAlignment = GridData.FILL;
        consultLData.grabExcessVerticalSpace = true;
        consultLData.verticalAlignment = GridData.FILL;
        consult.setLayoutData(consultLData);
        consult.setText(settings.msg("dialog.settings.consult", new String[] { engine.getName() }));
        Label titleLabel = new Label(consult, SWT.NONE);
        titleLabel.setText(settings.msg("dialog.settings.settitle"));
        setTitle[i] = new Button(consult, SWT.CHECK);
        setTitle[i].setSelection(conf.getBooleanValue(engine.getSimpleName(), "set_title"));
        Label devLabel = new Label(consult, SWT.NONE);
        devLabel.setText(settings.msg("dialog.settings.setdeveloper"));
        setDev[i] = new Button(consult, SWT.CHECK);
        setDev[i].setSelection(conf.getBooleanValue(engine.getSimpleName(), "set_developer"));
        if (engine.getSimpleName().equals("mobygames") || engine.getSimpleName().equals("hotud")
                || engine.getSimpleName().equals("thegamesdb")) {
            Label pubLabel = new Label(consult, SWT.NONE);
            pubLabel.setText(settings.msg("dialog.settings.setpublisher"));
            setPub[i] = new Button(consult, SWT.CHECK);
            setPub[i].setSelection(conf.getBooleanValue(engine.getSimpleName(), "set_publisher"));
        }
        Label yearLabel = new Label(consult, SWT.NONE);
        yearLabel.setText(settings.msg("dialog.settings.setyear"));
        setYear[i] = new Button(consult, SWT.CHECK);
        setYear[i].setSelection(conf.getBooleanValue(engine.getSimpleName(), "set_year"));
        Label genreLabel = new Label(consult, SWT.NONE);
        genreLabel.setText(settings.msg("dialog.settings.setgenre"));
        setGenre[i] = new Button(consult, SWT.CHECK);
        setGenre[i].setSelection(conf.getBooleanValue(engine.getSimpleName(), "set_genre"));
        Label linkLabel = new Label(consult, SWT.NONE);
        linkLabel.setText(settings.msg("dialog.settings.setlink", new String[] { engine.getName() }));
        setLink[i] = new Button(consult, SWT.CHECK);
        setLink[i].setSelection(conf.getBooleanValue(engine.getSimpleName(), "set_link"));
        Label rankLabel = new Label(consult, SWT.NONE);
        rankLabel.setText(settings.msg("dialog.settings.setrank",
                new Object[] { MainWindow.columnNames[Constants.RO_COLUMN_NAMES + 8] }));
        setRank[i] = new Button(consult, SWT.CHECK);
        setRank[i].setSelection(conf.getBooleanValue(engine.getSimpleName(), "set_rank"));
        if (engine.getSimpleName().equals("mobygames") || engine.getSimpleName().equals("hotud")
                || engine.getSimpleName().equals("thegamesdb")) {
            Label descrLabel = new Label(consult, SWT.NONE);
            descrLabel.setText(settings.msg("dialog.settings.setdescription"));
            setDescr[i] = new Button(consult, SWT.CHECK);
            setDescr[i].setSelection(conf.getBooleanValue(engine.getSimpleName(), "set_description"));
        }
        if (engine.getSimpleName().equals("mobygames") || engine.getSimpleName().equals("thegamesdb")) {
            Label chooseCoverArtLabel = new Label(consult, SWT.NONE);
            chooseCoverArtLabel.setText(settings.msg("dialog.settings.choosecoverart"));
            Composite comp = new Composite(consult, SWT.NONE);
            GridLayout layout = new GridLayout(3, false);
            layout.marginWidth = 0;
            comp.setLayout(layout);
            chooseCoverArt[i] = new Button(comp, SWT.CHECK);
            chooseCoverArt[i].setSelection(conf.getBooleanValue(engine.getSimpleName(), "choose_coverart"));

            if (engine.getSimpleName().equals("mobygames")) {
                Label allRegionsCoverArtLabel = new Label(comp, SWT.NONE);
                allRegionsCoverArtLabel.setText(settings.msg("dialog.settings.allregionscoverart"));
                GridData gd = new GridData();
                gd.horizontalIndent = 40;
                allRegionsCoverArtLabel.setLayoutData(gd);

                allRegionsCoverArt[i] = new Button(comp, SWT.CHECK);
                allRegionsCoverArt[i].setSelection(
                        conf.getBooleanValue(engine.getSimpleName(), "force_all_regions_coverart"));
            }
        }
        if (engine.getSimpleName().equals("mobygames") || engine.getSimpleName().equals("pouet")
                || engine.getSimpleName().equals("thegamesdb")) {
            Label chooseScreenshotLabel = new Label(consult, SWT.NONE);
            chooseScreenshotLabel.setText(settings.msg("dialog.settings.choosescreenshot"));
            chooseScreenshot[i] = new Button(consult, SWT.CHECK);
            chooseScreenshot[i].setSelection(conf.getBooleanValue(engine.getSimpleName(), "choose_screenshot"));
        }
        if (engine.getSimpleName().equals("mobygames") || engine.getSimpleName().equals("thegamesdb")) {
            final Label maxCoverArtLabel = new Label(consult, SWT.NONE);
            maxCoverArtLabel.setText(settings.msg("dialog.settings.multieditmaxcoverart"));
            maxCoverArt[i] = new Spinner(consult, SWT.BORDER);
            maxCoverArt[i].setLayoutData(new GridData(100, SWT.DEFAULT));
            maxCoverArt[i].setMinimum(0);
            maxCoverArt[i].setMaximum(Integer.MAX_VALUE);
            maxCoverArt[i].setSelection(conf.getIntValue(engine.getSimpleName(), "multi_max_coverart"));
        }
        if (engine.getSimpleName().equals("mobygames") || engine.getSimpleName().equals("pouet")
                || engine.getSimpleName().equals("thegamesdb")) {
            final Label maxScreenshotsLabel = new Label(consult, SWT.NONE);
            maxScreenshotsLabel.setText(settings.msg("dialog.settings.multieditmaxscreenshot"));
            maxScreenshots[i] = new Spinner(consult, SWT.BORDER);
            maxScreenshots[i].setLayoutData(new GridData(100, SWT.DEFAULT));
            maxScreenshots[i].setMinimum(0);
            maxScreenshots[i].setMaximum(Integer.MAX_VALUE);
            maxScreenshots[i].setSelection(conf.getIntValue(engine.getSimpleName(), "multi_max_screenshot"));
        }
        Label filterLabel = new Label(consult, SWT.NONE);
        filterLabel.setText(settings.msg("dialog.settings.platformfilter"));
        if (engine.getSimpleName().equals("mobygames") || engine.getSimpleName().equals("pouet")) {
            platformFilterValues[i] = new Text(consult, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
            platformFilterValues[i].setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            platformFilterValues[i].setText(conf.getMultilineValues(engine.getSimpleName(), "platform_filter",
                    platformFilterValues[i].getLineDelimiter()));
        } else {
            platformFilterValues[i] = new Text(consult, SWT.BORDER);
            platformFilterValues[i].setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
            platformFilterValues[i].setText(conf.getValue(engine.getSimpleName(), "platform_filter"));
        }
    }

    final TabItem envTabItem = new TabItem(tabFolder, SWT.NONE);
    envTabItem.setText(settings.msg("dialog.settings.tab.environment"));
    Composite composite4 = new Composite(tabFolder, SWT.NONE);
    composite4.setLayout(new GridLayout(1, true));
    envTabItem.setControl(composite4);
    Group envGroup = new Group(composite4, SWT.NONE);
    envGroup.setLayout(new GridLayout(2, false));
    GridData envLData = new GridData();
    envLData.grabExcessHorizontalSpace = true;
    envLData.horizontalAlignment = GridData.FILL;
    envLData.grabExcessVerticalSpace = true;
    envLData.verticalAlignment = GridData.FILL;
    envGroup.setLayoutData(envLData);
    envGroup.setText(settings.msg("dialog.settings.environment"));
    Label enableEnvLabel = new Label(envGroup, SWT.NONE);
    enableEnvLabel.setText(settings.msg("dialog.settings.enableenvironment"));
    final Button enableEnv = new Button(envGroup, SWT.CHECK);
    enableEnv.setSelection(conf.getBooleanValue("environment", "use"));
    enableEnv.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent event) {
            envValues.setEnabled(enableEnv.getSelection());
        }
    });
    Label envLabel = new Label(envGroup, SWT.NONE);
    envLabel.setText(settings.msg("dialog.settings.environmentvariables"));
    envValues = new Text(envGroup, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
    envValues.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    envValues.setText(conf.getMultilineValues("environment", "value", envValues.getLineDelimiter()));
    envValues.setEnabled(enableEnv.getSelection());

    final Composite composite_7 = new Composite(shell, SWT.NONE);
    composite_7.setLayout(new GridLayout(2, true));
    composite_7.setLayoutData(BorderLayout.SOUTH);

    final Button okButton = new Button(composite_7, SWT.NONE);
    okButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent event) {
            if (!isValid()) {
                return;
            }

            changedVisColumns = haveColumnsBeenChanged();
            if (changedVisColumns)
                updateColumnSettings();

            conf.setBooleanValue("dosbox", "hideconsole", console.getSelection());
            conf.setBooleanValue("communication", "port_enabled", portEnabled.getSelection());
            conf.setValue("communication", "port", port.getText());
            conf.setIntValue("profiledefaults", "confpath", confLocation.getSelectionIndex());
            conf.setIntValue("profiledefaults", "conffile", confFilename.getSelectionIndex());
            conf.setValue("locale", "language", locales.get(localeCombo.getText()).getLanguage());
            conf.setValue("locale", "country", locales.get(localeCombo.getText()).getCountry());
            conf.setValue("locale", "variant", locales.get(localeCombo.getText()).getVariant());
            for (int i = 0; i < MainWindow.columnNames.length; i++) {
                conf.setBooleanValue("gui", "column" + (i + 1) + "visible",
                        visibleColumns[allColumnIDs.indexOf(i)].getChecked());
            }
            conf.setBooleanValue("gui", "autosortonupdate", autosort.getSelection());
            for (int i = 0; i < Constants.EDIT_COLUMN_NAMES; i++) {
                conf.setValue("gui", "custom" + (i + 1),
                        visibleColumns[allColumnIDs.indexOf(i + Constants.RO_COLUMN_NAMES)].getText());
            }
            conf.setIntValue("gui", "screenshotsheight", screenshotsHeight.getSelection());
            conf.setBooleanValue("gui", "screenshotsfilename", displayFilename.getSelection());
            conf.setIntValue("gui", "screenshotscolumnheight", screenshotsColumnHeight.getSelection());
            conf.setBooleanValue("gui", "screenshotscolumnstretch", stretch.getSelection());
            conf.setBooleanValue("gui", "screenshotscolumnkeepaspectratio", keepAspectRatio.getSelection());

            Rectangle rec = shell.getBounds();
            conf.setIntValue("gui", "settingsdialog_width", rec.width);
            conf.setIntValue("gui", "settingsdialog_height", rec.height);
            conf.setIntValue("gui", "buttondisplay", buttonDisplay.getSelectionIndex());
            conf.setMultilineValues("gui", "notesfont",
                    GeneralPurposeGUI.fontToString(shell.getDisplay(), fontButton.getFont()), "|");

            for (int i = 0; i < NR_OF_ENGINES; i++) {
                WebSearchEngine engine = EditProfileDialog.webSearchEngines.get(i);
                conf.setBooleanValue(engine.getSimpleName(), "set_title", setTitle[i].getSelection());
                conf.setBooleanValue(engine.getSimpleName(), "set_developer", setDev[i].getSelection());
                if (engine.getSimpleName().equals("mobygames") || engine.getSimpleName().equals("hotud")
                        || engine.getSimpleName().equals("thegamesdb")) {
                    conf.setBooleanValue(engine.getSimpleName(), "set_publisher", setPub[i].getSelection());
                    conf.setBooleanValue(engine.getSimpleName(), "set_description", setDescr[i].getSelection());
                }
                conf.setBooleanValue(engine.getSimpleName(), "set_year", setYear[i].getSelection());
                conf.setBooleanValue(engine.getSimpleName(), "set_genre", setGenre[i].getSelection());
                conf.setBooleanValue(engine.getSimpleName(), "set_link", setLink[i].getSelection());
                conf.setBooleanValue(engine.getSimpleName(), "set_rank", setRank[i].getSelection());
                if (engine.getSimpleName().equals("mobygames")) {
                    conf.setBooleanValue(engine.getSimpleName(), "force_all_regions_coverart",
                            allRegionsCoverArt[i].getSelection());
                }
                if (engine.getSimpleName().equals("mobygames") || engine.getSimpleName().equals("thegamesdb")) {
                    conf.setBooleanValue(engine.getSimpleName(), "choose_coverart",
                            chooseCoverArt[i].getSelection());
                    conf.setIntValue(engine.getSimpleName(), "multi_max_coverart",
                            maxCoverArt[i].getSelection());
                }
                if (engine.getSimpleName().equals("mobygames") || engine.getSimpleName().equals("pouet")
                        || engine.getSimpleName().equals("thegamesdb")) {
                    conf.setBooleanValue(engine.getSimpleName(), "choose_screenshot",
                            chooseScreenshot[i].getSelection());
                    conf.setIntValue(engine.getSimpleName(), "multi_max_screenshot",
                            maxScreenshots[i].getSelection());
                }
                if (engine.getSimpleName().equals("mobygames") || engine.getSimpleName().equals("pouet")) {
                    conf.setMultilineValues(engine.getSimpleName(), "platform_filter",
                            platformFilterValues[i].getText(), platformFilterValues[i].getLineDelimiter());
                } else {
                    conf.setValue(engine.getSimpleName(), "platform_filter", platformFilterValues[i].getText());
                }
            }

            conf.setBooleanValue("environment", "use", enableEnv.getSelection());
            conf.setMultilineValues("environment", "value", envValues.getText(), envValues.getLineDelimiter());

            storeValues();
            settings.getSettings().injectValuesFrom(conf);
            shell.close();
        }

        private boolean haveColumnsBeenChanged() {
            for (int i = 0; i < MainWindow.columnNames.length; i++)
                if ((conf.getBooleanValue("gui",
                        "column" + (allColumnIDs.get(i) + 1) + "visible") != visibleColumns[i].getChecked())
                        || !MainWindow.columnNames[allColumnIDs.get(i)].equals(visibleColumns[i].getText()))
                    return true;
            return false;
        }
    });
    shell.setDefaultButton(okButton);
    okButton.setText(settings.msg("button.ok"));

    final Button cancelButton = new Button(composite_7, SWT.NONE);
    cancelButton.setText(settings.msg("button.cancel"));
    cancelButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent event) {
            shell.close();
        }
    });

    final GridData gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.widthHint = GeneralPurposeGUI.getWidth(okButton, cancelButton);
    okButton.setLayoutData(gridData);
    cancelButton.setLayoutData(gridData);
}