Package com.dci.intellij.dbn.common.locale.options

Examples of com.dci.intellij.dbn.common.locale.options.RegionalSettings


    public JPanel getComponent() {
        return mainPanel;
    }

    public void applyChanges() throws ConfigurationException {
        RegionalSettings regionalSettings = getConfiguration();

        Locale locale = getSelectedLocale();
        regionalSettings.setLocale(locale);

        DBDateFormat dateFormat = getSelectedDateFormat();
        regionalSettings.setDateFormatOption(dateFormat);

        DBNumberFormat numberFormat = getSelectedNumberFormat();
        regionalSettings.setNumberFormatOption(numberFormat);
       
        regionalSettings.getUseCustomFormats().applyChanges(customPatternsRadioButton);
        regionalSettings.getCustomDateFormat().applyChanges(customDateFormatTextField);
        regionalSettings.getCustomTimeFormat().applyChanges(customTimeFormatTextField);
        regionalSettings.getCustomNumberFormat().applyChanges(customNumberFormatTextField);
    }
View Full Code Here


        regionalSettings.getCustomTimeFormat().applyChanges(customTimeFormatTextField);
        regionalSettings.getCustomNumberFormat().applyChanges(customNumberFormatTextField);
    }

    public void resetChanges() {
        RegionalSettings regionalSettings = getConfiguration();
        setSelectedLocale(regionalSettings.getLocale());

        Boolean useCustomFormats = regionalSettings.getUseCustomFormats().value();
        customPatternsRadioButton.setSelected(useCustomFormats);
        presetPatternsRadioButton.setSelected(!useCustomFormats);
        if (customPatternsRadioButton.isSelected()) {
            regionalSettings.getCustomDateFormat().resetChanges(customDateFormatTextField);
            regionalSettings.getCustomTimeFormat().resetChanges(customTimeFormatTextField);
            regionalSettings.getCustomNumberFormat().resetChanges(customNumberFormatTextField);
        }

        DBDateFormat dateFormat = regionalSettings.getDateFormatOption();
        if (dateFormat == DBDateFormat.SHORT) shortRadioButton.setSelected(true); else
        if (dateFormat == DBDateFormat.MEDIUM) mediumRadioButton.setSelected(true); else
        if (dateFormat == DBDateFormat.LONG) longRadioButton.setSelected(true);

        DBNumberFormat numberFormat = regionalSettings.getNumberFormatOption();
        if (numberFormat == DBNumberFormat.GROUPED) groupedRadioButton.setSelected(true); else
        if (numberFormat == DBNumberFormat.UNGROUPED) ungroupedRadioButton.setSelected(true);
       
       
    }
View Full Code Here

    }

    @Override
    public String getFormattedUserValue() {
        if (formattedUserValue == null && userValue != null) {
            RegionalSettings regionalSettings = RegionalSettings.getInstance(getProject());
            Formatter formatter = regionalSettings.getFormatter();
            formattedUserValue = formatter.formatObject(userValue);
        }
        return formattedUserValue;
    }
View Full Code Here

    public void performExport(DataExportModel model, DataExportInstructions instructions, ConnectionHandler connectionHandler) throws DataExportException {
        StringBuilder buffer = new StringBuilder();
        buffer.append("<table name=\"");
        buffer.append(model.getTableName());
        buffer.append("\">\n");
        RegionalSettings regionalSettings = RegionalSettings.getInstance(connectionHandler.getProject());

        for (int rowIndex=0; rowIndex < model.getRowCount(); rowIndex++) {
            buffer.append("    <row index=\"");
            buffer.append(rowIndex);
            buffer.append("\">\n");
            for (int columnIndex=0; columnIndex < model.getColumnCount(); columnIndex++){
                String columnName = model.getColumnName(columnIndex);
                GenericDataType genericDataType = model.getGenericDataType(columnIndex);
                String value = null;
                if (genericDataType == GenericDataType.LITERAL ||
                        genericDataType == GenericDataType.NUMERIC ||
                        genericDataType == GenericDataType.DATE_TIME) {

                    Object object = model.getValue(rowIndex, columnIndex);

                    if (object != null) {
                        Formatter formatter = regionalSettings.getFormatter();
                        if (object instanceof Number) {
                            Number number = (Number) object;
                            value = formatter.formatNumber(number);
                        } else if (object instanceof Date) {
                            Date date = (Date) object;
View Full Code Here

            }
        }

        buffer.append("            </tr>\n");

        RegionalSettings regionalSettings = RegionalSettings.getInstance(connectionHandler.getProject());

        for (int rowIndex=0; rowIndex < model.getRowCount(); rowIndex++) {
            buffer.append("            <tr>\n");

            for (int columnIndex=0; columnIndex < model.getColumnCount(); columnIndex++){
                GenericDataType genericDataType = model.getGenericDataType(columnIndex);
                String value = null;
                if (genericDataType == GenericDataType.LITERAL ||
                        genericDataType == GenericDataType.NUMERIC ||
                        genericDataType == GenericDataType.DATE_TIME) {

                    Object object = model.getValue(rowIndex, columnIndex);

                    if (object != null) {
                        Formatter formatter = regionalSettings.getFormatter();
                        if (object instanceof Number) {
                            Number number = (Number) object;
                            value = formatter.formatNumber(number);
                        } else if (object instanceof Date) {
                            Date date = (Date) object;
View Full Code Here

        }
        else if (StringUtil.isNotEmptyOrSpaces(value)) {
            DBDataType dataType = column == null ? null : column.getDataType();
            if (dataType != null && dataType.isNative()) {
                ConnectionHandler connectionHandler = dataset.getConnectionHandler();
                RegionalSettings regionalSettings = RegionalSettings.getInstance(connectionHandler.getProject());
                GenericDataType genericDataType = dataType.getNativeDataType().getBasicDataType();
                if (genericDataType == GenericDataType.LITERAL) {
                    value = com.intellij.openapi.util.text.StringUtil.replace(value, "'", "''");
                    value = "'" + value + "'";
                } else if (genericDataType == GenericDataType.DATE_TIME) {
                    DatabaseMetadataInterface metadataInterface = connectionHandler.getInterfaceProvider().getMetadataInterface();
                    try {
                        Date date = regionalSettings.getFormatter().parseDateTime(value);
                        value = metadataInterface.createDateString(date);
                    } catch (ParseException e) {
                        try {
                            Date date = regionalSettings.getFormatter().parseDate(value);
                            value = metadataInterface.createDateString(date);
                        } catch (ParseException e1) {
                            // value can be something like "sysdate" => not parseable
                            //e1.printStackTrace();
                        }
View Full Code Here

        for (StatementExecutionVariable variable : variables) {
            String value = temporary ? variable.getTemporaryValueProvider().getValue() : variable.getValue();
            GenericDataType genericDataType = temporary ? variable.getTemporaryValueProvider().getDataType() : variable.getDataType();

            if (!StringUtil.isEmpty(value)) {
                RegionalSettings regionalSettings = RegionalSettings.getInstance(connectionHandler.getProject());

                if (genericDataType == GenericDataType.LITERAL) {
                    value = StringUtil.replace(value, "'", "''");
                    value = "'" + value + "'" ;
                } else if (genericDataType == GenericDataType.DATE_TIME){
                    DatabaseMetadataInterface metadataInterface = connectionHandler.getInterfaceProvider().getMetadataInterface();
                    try {
                        Date date = regionalSettings.getFormatter().parseDateTime(value);
                        value = metadataInterface.createDateString(date);
                    } catch (ParseException e) {
                        try {
                            Date date = regionalSettings.getFormatter().parseDate(value);
                            value = metadataInterface.createDateString(date);
                        } catch (ParseException e1) {
                            addError(variable, "Invalid date");
                        }
                    }
                } else if (genericDataType == GenericDataType.NUMERIC){
                    try {
                        regionalSettings.getFormatter().parseNumber(value);
                    } catch (ParseException e) {
                        addError(variable, "Invalid number");
                    }

                } else {
View Full Code Here

    private RegionalSettings regionalSettings;
    private EnvironmentSettings environmentSettings;

    public GeneralProjectSettings(Project project) {
        super(project);
        regionalSettings = new RegionalSettings();
        environmentSettings = new EnvironmentSettings(project);
    }
View Full Code Here

TOP

Related Classes of com.dci.intellij.dbn.common.locale.options.RegionalSettings

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.