Example usage for java.lang Throwable getLocalizedMessage

List of usage examples for java.lang Throwable getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang Throwable getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.eclipse.jubula.client.ui.rcp.Plugin.java

/**
 * {@inheritDoc}//from   w  ww. j  a v a2s .c om
 */
public Object handleError(final Throwable e) {
    Plugin.getDisplay().asyncExec(new Runnable() {
        @SuppressWarnings("synthetic-access")
        public void run() {
            if (e instanceof RuntimeException
                    && OperationCanceledUtil.isOperationCanceled((RuntimeException) e)) {
                // root cause of exception is the cancelation of an
                // operation, so it can be safely ignored
                return;
            }
            log.error(Messages.UnhandledThrowable + StringConstants.SPACE + StringConstants.COLON
                    + StringConstants.SPACE, e);
            if (e instanceof JBRuntimeException) {
                JBRuntimeException gdEx = (JBRuntimeException) e;
                ErrorHandlingUtil.createMessageDialog(gdEx);
            } else if (e instanceof JBException) {
                JBException gdEx = (JBException) e;
                ErrorHandlingUtil.createMessageDialog(gdEx, null, null);
            } else if (isRCPException(e)) {
                // there are a few bugs in RCP which will trigger
                // an exception, notably the 
                // org.eclipse.ui.views.markers.internal.MarkerAdapter.buildAllMarkers()
                // well known racing condition. Since the error is not
                // critical, is is ignored.
                log.error(Messages.InternalRcpError, e);

            } else if (isGEFException(e)) {
                // there are a few bugs in GEF which will trigger
                // an exception, notably the 
                // org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.addSourceCommands
                // well known racing condition. Since the error is not
                // critical, is is ignored.
                log.error(Messages.InternalGefError, e);

            } else if (e instanceof PersistenceException) {
                ErrorHandlingUtil.createMessageDialog(MessageIDs.E_DATABASE_GENERAL, null,
                        new String[] { e.getLocalizedMessage() });
            } else {
                ErrorHandlingUtil
                        .createMessageDialog(new JBFatalException(e, MessageIDs.E_UNEXPECTED_EXCEPTION));
            }
        }

    });
    return null;
}

From source file:org.opencms.importexport.CmsImportVersion10.java

/**
 * Creates a new additional information entry for the current user.<p>
 *
 * @param infoName the name of the additional information entry
 * @param infoType the type of the additional information entry
 * @param infoValue the value of the additional information entry
 *///from w  w  w.  j a va2s .c o m
public void importUserInfo(String infoName, String infoType, String infoValue) {

    if (m_userInfos == null) {
        m_userInfos = new HashMap<String, Object>();
    }
    try {
        m_userInfos.put(infoName, CmsDataTypeUtil.dataImport(infoValue, infoType));
    } catch (Throwable e) {
        if (LOG.isErrorEnabled()) {
            LOG.error(e.getLocalizedMessage(), e);
        }
    }
}

From source file:org.rhq.core.pc.inventory.InventoryManager.java

/**
 * This will send a resource error to the server (if applicable) to indicate that the given resource could not be
 * connected to due to an invalid plugin configuration.
 *
 * @param resource the resource that could not be connected to
 * @param t        the exception that indicates the problem with the plugin configuration
 * @return         true if the error was sent successfully, or false otherwise
 *//*from w  w  w.  jav  a  2  s . c o  m*/
public boolean handleInvalidPluginConfigurationResourceError(Resource resource, Throwable t) {
    resource.setConnected(false); // invalid plugin configuration infers the resource component is disconnected
    // Give the server-side an error message describing the connection failure that can be
    // displayed on the resource's Inventory page.
    ResourceError resourceError = new ResourceError(resource, ResourceErrorType.INVALID_PLUGIN_CONFIGURATION,
            t.getLocalizedMessage(), ThrowableUtil.getStackAsString(t), System.currentTimeMillis());
    return sendResourceErrorToServer(resourceError);
}

From source file:org.opencms.importexport.CmsImportVersion7.java

/**
 * Sets the membership information that could not been set immediately,
 * because of import order issues.<p> 
 *//*from  ww w  . j av a  2  s .  co m*/
public void setMembership() {

    if ((m_orgUnit == null) || (m_membership == null)) {
        return;
    }

    // get the membership data to set
    Map membership = (Map) m_membership.get(m_orgUnit.getName());
    if (membership == null) {
        return;
    }

    // set group membership
    Map groups = (Map) membership.get(I_CmsPrincipal.PRINCIPAL_GROUP);
    if (groups != null) {
        Iterator it = groups.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            String userName = (String) entry.getKey();
            String groupName = (String) entry.getValue();

            // set the users group
            try {
                getCms().addUserToGroup(userName, groupName);
            } catch (Throwable e) {
                getReport().println(Messages.get().container(Messages.RPT_USER_COULDNT_BE_ADDED_TO_GROUP_2,
                        userName, groupName), I_CmsReport.FORMAT_WARNING);
                if (LOG.isDebugEnabled()) {
                    LOG.debug(e.getLocalizedMessage(), e);
                }
            }
        }
    }

    // set role membership
    Map roles = (Map) membership.get(I_CmsPrincipal.PRINCIPAL_USER);
    if (roles != null) {
        Iterator it = roles.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            String userName = (String) entry.getKey();
            String roleName = (String) entry.getValue();

            // set the users roles
            CmsRole role = CmsRole.valueOfRoleName(roleName);
            try {
                // set the user role
                OpenCms.getRoleManager().addUserToRole(getCms(), role, userName);
                return;
            } catch (Throwable e) {
                getReport().println(Messages.get().container(Messages.RPT_USER_COULDNT_BE_ADDED_TO_ROLE_2,
                        userName, roleName), I_CmsReport.FORMAT_WARNING);
                if (LOG.isDebugEnabled()) {
                    LOG.debug(e.getLocalizedMessage(), e);
                }
            }
        }
    }
}

From source file:cl.gisred.android.OtRouteActivity.java

private void cerrarDialogCrear(boolean bSave, @Nullable View viewDialog) {
    final AtomicReference<String> resp = new AtomicReference<>("");

    if (bSave) {/*from   w w w.  ja va 2s .  c  o  m*/
        if (!validarVista(viewDialog)) {
            DialogoConfirmacion oDialog = new DialogoConfirmacion();
            oDialog.show(getFragmentManager(), "tagAlert");
            return;
        } else {
            switch (idResLayoutSelect) {
            case R.layout.dialog_poste:
                oLyAddGraphs = LyAddPoste;
                break;
            case R.layout.dialog_direccion:
                oLyAddGraphs = LyAddDireccion;
                break;
            case R.layout.dialog_cliente:
                oLyAddGraphs = LyAddCliente;
                break;
            case R.layout.dialog_cliente_cnr:
                oLyAddGraphs = LyAddClienteCnr;
                break;
            }

            if (oLyAddGraphs != null) {
                View oView = getLayoutValidate(viewDialog);
                Util oUtil = new Util(oUbicacion);

                ArrayList<Map<String, Object>> oAttrToSave = oUtil.getAttrAddByView(oView, idResLayoutSelect,
                        empresa);

                Map<String, Object> attributes = oAttrToSave.get(0);
                Graphic newFeatureGraphic = new Graphic(oUbicacion, null, attributes);
                Graphic[] adds = { newFeatureGraphic };

                if (idResLayoutSelect == R.layout.dialog_cliente_cnr
                        || idResLayoutSelect == R.layout.dialog_cliente) {
                    addsUnion = Util.addAttrUnionPoint(oAttrToSave, oUbicacion);
                }

                oLyAddGraphs.applyEdits(adds, null, null, new CallbackListener<FeatureEditResult[][]>() {

                    @Override
                    public void onCallback(FeatureEditResult[][] featureEditResults) {
                        if (featureEditResults[0] != null) {
                            if (featureEditResults[0][0] != null && featureEditResults[0][0].isSuccess()) {

                                resp.set(
                                        "Guardado Correctamente Id: " + featureEditResults[0][0].getObjectId());

                                if (idResLayoutSelect == R.layout.dialog_cliente_cnr
                                        || idResLayoutSelect == R.layout.dialog_cliente)
                                    LyAddUnion.applyEdits(addsUnion, null, null, callBackUnion());

                                runOnUiThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        Util.showConfirmation(OtRouteActivity.this, resp.get());
                                    }
                                });
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable throwable) {
                        resp.set("Error al grabar: " + throwable.getLocalizedMessage());
                        Log.w("onError", resp.get());

                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                Toast.makeText(OtRouteActivity.this, resp.get(), Toast.LENGTH_SHORT).show();
                            }
                        });
                    }

                });
            }
        }
    } else {
        resp.set("Cancelado");
        Toast.makeText(OtRouteActivity.this, resp.get(), Toast.LENGTH_LONG).show();
    }

    bMapTap = false;

    if (mBusquedaLayer != null && myMapView.getLayerByID(mBusquedaLayer.getID()) != null)
        myMapView.removeLayer(mBusquedaLayer);

    if (mUbicacionLayer != null && myMapView.getLayerByID(mUbicacionLayer.getID()) != null)
        myMapView.removeLayer(mUbicacionLayer);

    if (mSeleccionLayer != null && myMapView.getLayerByID(mSeleccionLayer.getID()) != null)
        myMapView.removeLayer(mSeleccionLayer);

    oUbicacion = null;
    if (bVerCapas)
        toogleCapas(fabVerCapas);
    //setLayerAddToggle(false);
    if (bIngCliente)
        menuMultipleActions.setVisibility(View.VISIBLE);
    fabShowDialog.setVisibility(View.GONE);
    dialogCrear.dismiss();
    if (oLyAddGraphs != null)
        oLyAddGraphs.setVisible(true);
}

From source file:com.google.enterprise.connector.otex.LivelinkConnectorType.java

/**
 * {@inheritDoc}//  w w  w .j  av a2s .c  om
 * <p>
 * This method will use the provided configuration
 * information to attempt to instantiate a LivelinkConnector
 * and call its <code>login</code> method. This allows this
 * method to determine whether the configuration information
 * provided is sufficient to connect to Livelink for
 * traversal. It does not attempt to validate the separate
 * authentication configuration, if any, since no separate
 * user information can be provided, and it's possible that
 * the traversal username isn't one that can be authenticated
 * using the authentication properties. For example,
 * traversal might be done as a Livelink admin user using the
 * Livelink server port, while authentication is done using a
 * web server. The Livelink admin user may not be a defined
 * user in the web server's authentication scheme.
 */
/*
 * TODO: Add init method and parameter validation to
 * LivelinkConnector.
 */
@Override
public ConfigureResponse validateConfig(Map<String, String> configData, Locale locale,
        ConnectorFactory connectorFactory) {
    if (LOGGER.isLoggable(Level.CONFIG)) {
        LOGGER.config("validateConfig data: " + getMaskedMap(configData));
        LOGGER.config("validateConfig locale: " + locale);
    }

    try {
        ResourceBundle bundle = getResources(locale);
        FormContext formContext = new FormContext(configData);

        // We want to change the passed in properties, but avoid
        // changing the original configData parameter.
        HashMap<String, String> config = new HashMap<String, String>(configData);
        config.put(VERSION_PROPERTY, VERSION_NUMBER);

        // If the user supplied a URL as the server, pull out the host name.
        smartConfig(config);

        // Update the properties to copy the enabler properties to
        // the uses.
        Boolean changeHttp = changeFormDisplay(config, "useHttpTunneling", "enableHttpTunneling");
        Boolean changeAuth = changeFormDisplay(config, "useSeparateAuthentication",
                "enableSeparateAuthentication");

        // Skip validation if one of the groups has been enabled.
        // The configuration is probably incomplete in this case,
        // and at least one more call to validateConfig will be
        // made, so we will eventually validate any of the other
        // changes that have been made this time.
        if (changeHttp == Boolean.TRUE || changeAuth == Boolean.TRUE) {
            if (LOGGER.isLoggable(Level.FINEST)) {
                LOGGER.finest(
                        "SKIPPING VALIDATION: changeHttp = " + changeHttp + "; changeAuth = " + changeAuth);
            }
            return getResponse(null, bundle, config, formContext);
        }

        // Instantiate a LivelinkConnector to check connectivity.
        LivelinkConnector conn = null;
        try {
            conn = (LivelinkConnector) connectorFactory.makeConnector(config);
        } catch (Throwable t) {
            LOGGER.log(Level.WARNING, "Failed to create connector", t);
            t = t.getCause();
            while (t != null) {
                if (t instanceof PropertyBatchUpdateException) {
                    PropertyAccessException[] pae = ((PropertyBatchUpdateException) t)
                            .getPropertyAccessExceptions();
                    for (int i = 0; i < pae.length; i++)
                        LOGGER.warning(pae[i].getMessage());
                } else
                    LOGGER.warning(t.toString());
                t = t.getCause();
            }
            return getResponse(failedInstantiation(bundle), bundle, config, formContext);
        }

        if (!ignoreDisplayUrlErrors(config)) {
            try {
                String url = config.get("displayUrl");
                LOGGER.finer("Validating display URL " + url);
                validateUrl(url, bundle);
                url = conn.getPublicContentDisplayUrl();
                LOGGER.finer("Validating public content display URL " + url);
                validateUrl(url, bundle);
            } catch (UrlConfigurationException e) {
                LOGGER.log(Level.WARNING, "Error in configuration", e);
                formContext.setHideIgnoreDisplayUrlErrors(false);
                return getResponse(errorInConfiguration(bundle, e.getLocalizedMessage()), bundle, config,
                        formContext);
            }
        }

        try {
            conn.login();
        } catch (LivelinkException e) {
            // XXX: Should this be an errorInConfiguration error?
            return getResponse(e.getLocalizedMessage(bundle), bundle, config, formContext);
        } catch (ConfigurationException c) {
            LOGGER.log(Level.WARNING, "Error in configuration", c);
            return getResponse(errorInConfiguration(bundle, c.getLocalizedMessage(bundle)), bundle, config,
                    formContext);
        } catch (Throwable t) {
            LOGGER.log(Level.WARNING, "Error in configuration", t);
            return getResponse(errorInConfiguration(bundle, t.getLocalizedMessage()), bundle, config,
                    formContext);
        }

        // Return the OK configuration.
        return getResponse(null, null, config, null);
    } catch (Throwable t) {
        // One last catch to be sure we return a message.
        LOGGER.log(Level.SEVERE, "Failed to create config form", t);
        return getErrorResponse(getExceptionMessages(null, t));
    }
}

From source file:cl.gisred.android.MedidorActivity.java

private void cerrarFormCrear(boolean bSave, View v) {
    if (bSave) {//from   w  w  w.  j a  v a  2  s .co m

        final AtomicReference<String> resp = new AtomicReference<>("");

        if (!validarForm(v)) {
            DialogoConfirmacion oDialog = new DialogoConfirmacion();
            oDialog.show(getFragmentManager(), "tagAlert");
            return;
        } else {
            View vAction = getLayoutValidate(v);
            Map<String, Object> objectMap = new HashMap<>();
            for (View view : vAction.getTouchables()) {

                if (view.getClass().getGenericSuperclass().equals(EditText.class)) {
                    EditText oText = (EditText) view;

                    if (oText.getId() == R.id.txtNroMedidor) {
                        String oVal = (oText.getText().toString().isEmpty()) ? "0" : oText.getText().toString();
                        objectMap.put("nro_medidor", oVal);
                    }
                    if (oText.getId() == R.id.txtLectura) {
                        String oVal = (oText.getText().toString().isEmpty()) ? "0" : oText.getText().toString();
                        objectMap.put("lectura_actual", oVal);
                    }
                    if (oText.getId() == R.id.txtPoste)
                        objectMap.put("poste", oText.getText().toString());
                    if (oText.getId() == R.id.txtDireccion)
                        objectMap.put("direccion", oText.getText().toString());

                } else if (view.getClass().getGenericSuperclass().equals(Spinner.class)) {
                    Spinner oSpinner = (Spinner) view;
                    String sValue = oSpinner.getSelectedItem().toString();

                    if (oSpinner.getId() == R.id.spinnerEstado)
                        objectMap.put("estado", sValue);
                    else if (oSpinner.getId() == R.id.spinnerTipoEdific)
                        objectMap.put("tipo_edificacion", sValue);
                    else if (oSpinner.getId() == R.id.spinnerUser)
                        objectMap.put("lector", sValue);
                }
            }

            Graphic newFeatureGraphic = new Graphic(oUbicacion, null, objectMap);
            Graphic[] adds = { newFeatureGraphic };
            LyAddMedidores.applyEdits(adds, null, null, new CallbackListener<FeatureEditResult[][]>() {
                @Override
                public void onCallback(FeatureEditResult[][] featureEditResults) {
                    if (featureEditResults[0] != null) {
                        if (featureEditResults[0][0] != null && featureEditResults[0][0].isSuccess()) {

                            resp.set("Guardado Correctamente Id: " + featureEditResults[0][0].getObjectId());

                            runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    Util.showConfirmation(MedidorActivity.this, resp.get());
                                }
                            });
                        }
                    }
                }

                @Override
                public void onError(Throwable throwable) {
                    resp.set("Error al ingresar: " + throwable.getLocalizedMessage());
                    Log.w("onError", resp.get());

                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            Toast.makeText(MedidorActivity.this, resp.get(), Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            });
        }
    }

    bMapTap = false;
    oUbicacion = null;

    if (mBusquedaLayer != null && myMapView.getLayerByID(mBusquedaLayer.getID()) != null)
        myMapView.removeLayer(mBusquedaLayer);

    if (mUbicacionLayer != null && myMapView.getLayerByID(mUbicacionLayer.getID()) != null)
        myMapView.removeLayer(mUbicacionLayer);

    if (mSeleccionLayer != null && myMapView.getLayerByID(mSeleccionLayer.getID()) != null)
        myMapView.removeLayer(mSeleccionLayer);

    if (bVerCapas)
        toogleCapas(fabVerCapas);

    if (bIngCliente)
        menuMultipleActions.setVisibility(View.VISIBLE);
    menuMedidorActions.setVisibility(View.VISIBLE);
    fabShowForm.setVisibility(View.GONE);
    formCrear.dismiss();

    if (LyAddMedidores != null)
        LyAddMedidores.setVisible(true);
}

From source file:cl.gisred.android.MedidorActivity.java

private void cerrarDialogCrear(boolean bSave, @Nullable View viewDialog) {
    final AtomicReference<String> resp = new AtomicReference<>("");

    if (bSave) {/*from   ww  w.  ja v  a2  s  . c o m*/
        if (!validarVista(viewDialog)) {
            DialogoConfirmacion oDialog = new DialogoConfirmacion();
            oDialog.show(getFragmentManager(), "tagAlert");
            return;
        } else {
            switch (idResLayoutSelect) {
            case R.layout.dialog_poste:
                oLyAddGraphs = LyAddPoste;
                break;
            case R.layout.dialog_direccion:
                oLyAddGraphs = LyAddDireccion;
                break;
            case R.layout.dialog_cliente:
                oLyAddGraphs = LyAddCliente;
                break;
            case R.layout.dialog_cliente_cnr:
                oLyAddGraphs = LyAddClienteCnr;
                break;
            }

            if (oLyAddGraphs != null) {
                View oView = getLayoutValidate(viewDialog);
                Util oUtil = new Util(oUbicacion);

                ArrayList<Map<String, Object>> oAttrToSave = oUtil.getAttrAddByView(oView, idResLayoutSelect,
                        empresa);

                Map<String, Object> attributes = oAttrToSave.get(0);
                Graphic newFeatureGraphic = new Graphic(oUbicacion, null, attributes);
                Graphic[] adds = { newFeatureGraphic };

                if (idResLayoutSelect == R.layout.dialog_cliente_cnr
                        || idResLayoutSelect == R.layout.dialog_cliente) {
                    addsUnion = Util.addAttrUnionPoint(oAttrToSave, oUbicacion);
                }

                oLyAddGraphs.applyEdits(adds, null, null, new CallbackListener<FeatureEditResult[][]>() {

                    @Override
                    public void onCallback(FeatureEditResult[][] featureEditResults) {
                        if (featureEditResults[0] != null) {
                            if (featureEditResults[0][0] != null && featureEditResults[0][0].isSuccess()) {

                                resp.set(
                                        "Guardado Correctamente Id: " + featureEditResults[0][0].getObjectId());

                                if (idResLayoutSelect == R.layout.dialog_cliente_cnr
                                        || idResLayoutSelect == R.layout.dialog_cliente)
                                    LyAddUnion.applyEdits(addsUnion, null, null, callBackUnion());

                                runOnUiThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        Util.showConfirmation(MedidorActivity.this, resp.get());
                                    }
                                });
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable throwable) {
                        resp.set("Error al grabar: " + throwable.getLocalizedMessage());
                        Log.w("onError", resp.get());

                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                Toast.makeText(MedidorActivity.this, resp.get(), Toast.LENGTH_SHORT).show();
                            }
                        });
                    }

                });
            }
        }
    } else {
        resp.set("Cancelado");
        Toast.makeText(MedidorActivity.this, resp.get(), Toast.LENGTH_LONG).show();
    }

    bMapTap = false;

    if (mBusquedaLayer != null && myMapView.getLayerByID(mBusquedaLayer.getID()) != null)
        myMapView.removeLayer(mBusquedaLayer);

    if (mUbicacionLayer != null && myMapView.getLayerByID(mUbicacionLayer.getID()) != null)
        myMapView.removeLayer(mUbicacionLayer);

    if (mSeleccionLayer != null && myMapView.getLayerByID(mSeleccionLayer.getID()) != null)
        myMapView.removeLayer(mSeleccionLayer);

    oUbicacion = null;
    if (bVerCapas)
        toogleCapas(fabVerCapas);
    //setLayerAddToggle(false);
    if (bIngCliente)
        menuMultipleActions.setVisibility(View.VISIBLE);
    menuMedidorActions.setVisibility(View.VISIBLE);
    fabShowDialog.setVisibility(View.GONE);
    dialogCrear.dismiss();
    if (oLyAddGraphs != null)
        oLyAddGraphs.setVisible(true);
}

From source file:cl.gisred.android.LectorActivity.java

private void cerrarFormCrear(boolean bSave, View v) {
    if (bSave) {/*from  w w  w. j  a  va  2 s  . c  o m*/

        final AtomicReference<String> resp = new AtomicReference<>("");

        if (!validarForm(v)) {
            DialogoConfirmacion oDialog = new DialogoConfirmacion();
            oDialog.show(getFragmentManager(), "tagAlert");
            return;
        } else {
            View vAction = getLayoutValidate(v);
            Map<String, Object> objectMap = new HashMap<>();
            for (View view : vAction.getTouchables()) {

                if (view.getClass().getGenericSuperclass().equals(EditText.class)) {
                    EditText oText = (EditText) view;

                    if (oText.getId() == R.id.txtNroMedidor) {
                        String oVal = (oText.getText().toString().isEmpty()) ? "0" : oText.getText().toString();
                        objectMap.put("nro_medidor", oVal);
                    }
                    if (oText.getId() == R.id.txtLectura) {
                        String oVal = (oText.getText().toString().isEmpty()) ? "0" : oText.getText().toString();
                        objectMap.put("lectura_actual", oVal);
                    }
                    if (oText.getId() == R.id.txtPoste)
                        objectMap.put("poste", oText.getText().toString());
                    if (oText.getId() == R.id.txtDireccion)
                        objectMap.put("direccion", oText.getText().toString());

                } else if (view.getClass().getGenericSuperclass().equals(Spinner.class)) {
                    Spinner oSpinner = (Spinner) view;
                    String sValue = oSpinner.getSelectedItem().toString();

                    if (oSpinner.getId() == R.id.spinnerEstado)
                        objectMap.put("estado", sValue);
                    else if (oSpinner.getId() == R.id.spinnerTipoEdific)
                        objectMap.put("tipo_edificacion", sValue);
                    else if (oSpinner.getId() == R.id.spinnerUser)
                        objectMap.put("lector", sValue);
                }
            }

            Graphic newFeatureGraphic = new Graphic(oUbicacion, null, objectMap);
            Graphic[] adds = { newFeatureGraphic };
            LyAddLectores.applyEdits(adds, null, null, new CallbackListener<FeatureEditResult[][]>() {
                @Override
                public void onCallback(FeatureEditResult[][] featureEditResults) {
                    if (featureEditResults[0] != null) {
                        if (featureEditResults[0][0] != null && featureEditResults[0][0].isSuccess()) {

                            resp.set("Guardado Correctamente Id: " + featureEditResults[0][0].getObjectId());

                            runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    Util.showConfirmation(LectorActivity.this, resp.get());
                                }
                            });
                        }
                    }
                }

                @Override
                public void onError(Throwable throwable) {
                    resp.set("Error al ingresar: " + throwable.getLocalizedMessage());
                    Log.w("onError", resp.get());

                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            Toast.makeText(LectorActivity.this, resp.get(), Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            });
        }
    }

    bMapTap = false;
    oUbicacion = null;

    if (mBusquedaLayer != null && myMapView.getLayerByID(mBusquedaLayer.getID()) != null)
        myMapView.removeLayer(mBusquedaLayer);

    if (mUbicacionLayer != null && myMapView.getLayerByID(mUbicacionLayer.getID()) != null)
        myMapView.removeLayer(mUbicacionLayer);

    if (mSeleccionLayer != null && myMapView.getLayerByID(mSeleccionLayer.getID()) != null)
        myMapView.removeLayer(mSeleccionLayer);

    if (bVerCapas)
        toogleCapas(fabVerCapas);

    if (bIngCliente)
        menuMultipleActions.setVisibility(View.VISIBLE);
    menuLectorActions.setVisibility(View.VISIBLE);
    fabShowForm.setVisibility(View.GONE);
    formCrear.dismiss();

    if (LyAddLectores != null)
        LyAddLectores.setVisible(true);
}

From source file:cl.gisred.android.LectorActivity.java

private void cerrarDialogCrear(boolean bSave, @Nullable View viewDialog) {
    final AtomicReference<String> resp = new AtomicReference<>("");

    if (bSave) {//from   w  w  w .j  a  v  a 2s . c om
        if (!validarVista(viewDialog)) {
            DialogoConfirmacion oDialog = new DialogoConfirmacion();
            oDialog.show(getFragmentManager(), "tagAlert");
            return;
        } else {
            switch (idResLayoutSelect) {
            case R.layout.dialog_poste:
                oLyAddGraphs = LyAddPoste;
                break;
            case R.layout.dialog_direccion:
                oLyAddGraphs = LyAddDireccion;
                break;
            case R.layout.dialog_cliente:
                oLyAddGraphs = LyAddCliente;
                break;
            case R.layout.dialog_cliente_cnr:
                oLyAddGraphs = LyAddClienteCnr;
                break;
            }

            if (oLyAddGraphs != null) {
                View oView = getLayoutValidate(viewDialog);
                Util oUtil = new Util(oUbicacion);

                ArrayList<Map<String, Object>> oAttrToSave = oUtil.getAttrAddByView(oView, idResLayoutSelect,
                        empresa);

                Map<String, Object> attributes = oAttrToSave.get(0);
                Graphic newFeatureGraphic = new Graphic(oUbicacion, null, attributes);
                Graphic[] adds = { newFeatureGraphic };

                if (idResLayoutSelect == R.layout.dialog_cliente_cnr
                        || idResLayoutSelect == R.layout.dialog_cliente) {
                    addsUnion = Util.addAttrUnionPoint(oAttrToSave, oUbicacion);
                }

                oLyAddGraphs.applyEdits(adds, null, null, new CallbackListener<FeatureEditResult[][]>() {

                    @Override
                    public void onCallback(FeatureEditResult[][] featureEditResults) {
                        if (featureEditResults[0] != null) {
                            if (featureEditResults[0][0] != null && featureEditResults[0][0].isSuccess()) {

                                resp.set(
                                        "Guardado Correctamente Id: " + featureEditResults[0][0].getObjectId());

                                if (idResLayoutSelect == R.layout.dialog_cliente_cnr
                                        || idResLayoutSelect == R.layout.dialog_cliente)
                                    LyAddUnion.applyEdits(addsUnion, null, null, callBackUnion());

                                runOnUiThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        Util.showConfirmation(LectorActivity.this, resp.get());
                                    }
                                });
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable throwable) {
                        resp.set("Error al grabar: " + throwable.getLocalizedMessage());
                        Log.w("onError", resp.get());

                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                Toast.makeText(LectorActivity.this, resp.get(), Toast.LENGTH_SHORT).show();
                            }
                        });
                    }

                });
            }
        }
    } else {
        resp.set("Cancelado");
        Toast.makeText(LectorActivity.this, resp.get(), Toast.LENGTH_LONG).show();
    }

    bMapTap = false;

    if (mBusquedaLayer != null && myMapView.getLayerByID(mBusquedaLayer.getID()) != null)
        myMapView.removeLayer(mBusquedaLayer);

    if (mUbicacionLayer != null && myMapView.getLayerByID(mUbicacionLayer.getID()) != null)
        myMapView.removeLayer(mUbicacionLayer);

    if (mSeleccionLayer != null && myMapView.getLayerByID(mSeleccionLayer.getID()) != null)
        myMapView.removeLayer(mSeleccionLayer);

    oUbicacion = null;
    if (bVerCapas)
        toogleCapas(fabVerCapas);
    //setLayerAddToggle(false);
    if (bIngCliente)
        menuMultipleActions.setVisibility(View.VISIBLE);
    menuLectorActions.setVisibility(View.VISIBLE);
    fabShowDialog.setVisibility(View.GONE);
    dialogCrear.dismiss();
    if (oLyAddGraphs != null)
        oLyAddGraphs.setVisible(true);
}