use of java.util.Formatter in project neo4j-mobile-android by neo4j-contrib.
the class MainActivity method confirmOpenOfNeo4jDatabase.
private void confirmOpenOfNeo4jDatabase(final String databaseName) {
AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.setTitle(R.string.main_open_database_title);
Formatter formatter = new Formatter();
formatter.format(getResources().getString(R.string.main_open_database_question), databaseName);
dialog.setMessage(formatter.toString());
dialog.setButton(getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (dbManager.isCurrentNeo4jDatabaseOpen()) {
shutdownNeo4jDatabase(dbManager.getCurrentNeo4jDatabaseName());
}
openOrCreateNeo4jDatabase(databaseName);
}
});
dialog.setButton2(getResources().getString(android.R.string.no), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
dialog.show();
formatter.close();
}
use of java.util.Formatter in project neo4j-mobile-android by neo4j-contrib.
the class RelationshipActivity method askCreateRelationship.
private void askCreateRelationship() {
List<Long> nodeIds;
try {
nodeIds = getAllNodeIds();
} catch (Exception e) {
Ln.e(e, "database exception");
showErrorDialog();
return;
}
View relationshipCreateView = inflater.inflate(R.layout.relationship_create, null);
final TextView relationshipCreateStartNodeIdText = (TextView) relationshipCreateView.findViewById(R.id.relationshipCreateStartNodeIdText);
Formatter formatter = new Formatter();
formatter.format(getResources().getString(R.string.relationship_create_startnode), centerNodeId);
relationshipCreateStartNodeIdText.setText(formatter.toString());
formatter.close();
final EditText relationshipCreateNameText = (EditText) relationshipCreateView.findViewById(R.id.relationshipCreateNameText);
final Spinner relationshipCreateEndnodeIdSpinner = (Spinner) relationshipCreateView.findViewById(R.id.relationshipCreateEndnodeIdSpinner);
ArrayAdapter<Long> spinnerAdapter = new ArrayAdapter<Long>(context, android.R.layout.simple_spinner_item, nodeIds);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
relationshipCreateEndnodeIdSpinner.setAdapter(spinnerAdapter);
AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.setTitle(R.string.relationship_create_title);
dialog.setView(relationshipCreateView);
dialog.setButton(getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String name = relationshipCreateNameText.getText().toString();
long endNodeId = (Long) relationshipCreateEndnodeIdSpinner.getSelectedItem();
try {
createRelationship(name, endNodeId);
} catch (Exception e) {
Ln.e(e, "could not create relationship");
showErrorDialog();
}
updateRelationshipsList();
}
});
dialog.setButton2(getResources().getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
dialog.show();
}
use of java.util.Formatter in project neo4j-mobile-android by neo4j-contrib.
the class RelationshipPropertiesActivity method confirmDeletionOfProperty.
private void confirmDeletionOfProperty(final String key, final Object value) {
AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.setTitle(R.string.property_delete_title);
Formatter formatter = new Formatter();
formatter.format(getResources().getString(R.string.property_delete_from_relationship_question), key, value, relationshipId);
dialog.setMessage(formatter.toString());
dialog.setButton(getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
GraphDatabase database = dbManager.getCurrentNeo4jDatabase();
database.beginTx();
try {
ParcelableRelationship relationship = database.getRelationshipById(relationshipId);
relationship.removeProperty(key);
database.updateRelationship(relationship);
database.txSuccess();
} finally {
database.txFinish();
}
} catch (Exception e) {
Ln.e(e, "failed to delete property with key '" + key + "' and value '" + value + "' from relationship with id '" + relationshipId + "'.");
showErrorDialog();
}
}
});
dialog.setButton2(getResources().getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
dialog.show();
formatter.close();
}
use of java.util.Formatter in project neo4j-mobile-android by neo4j-contrib.
the class RelationshipPropertiesActivity method confirmDeletionOfRelationship.
private void confirmDeletionOfRelationship() {
AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.setTitle(R.string.relationship_delete_title);
Formatter formatter = new Formatter();
formatter.format(getResources().getString(R.string.relationship_delete_question), relationshipId);
dialog.setMessage(formatter.toString());
dialog.setButton(getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
GraphDatabase database = dbManager.getCurrentNeo4jDatabase();
database.beginTx();
try {
ParcelableRelationship relationship = database.getRelationshipById(relationshipId);
database.deleteRelationship(relationship.getId());
database.txSuccess();
} finally {
database.txFinish();
}
Intent data = new Intent();
data.putExtra(DBInspectorConstants.INTENTEXTRA_RELATIONSHIP_DELETED, true);
setResult(RESULT_OK, data);
finish();
} catch (Exception e) {
Ln.e(e, "failed to delete relationship with id '" + relationshipId + "'.");
showErrorDialog();
}
}
});
dialog.setButton2(getResources().getString(android.R.string.no), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
dialog.show();
formatter.close();
}
use of java.util.Formatter in project neo4j-mobile-android by neo4j-contrib.
the class RelationshipPropertiesActivity method showPropertyKeyValueEmptyError.
private void showPropertyKeyValueEmptyError(String key, String value) {
AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.setTitle(R.string.error_title);
Formatter formatter = new Formatter();
formatter.format(getResources().getString(R.string.property_key_or_value_empty_error), key, value);
dialog.setMessage(formatter.toString());
dialog.setButton(getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
dialog.show();
formatter.close();
}
Aggregations