Java Code Examples for org.eclipse.jface.dialogs.InputDialog#getReturnCode()

The following examples show how to use org.eclipse.jface.dialogs.InputDialog#getReturnCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void renamePressed(){
	if (getSelected() == null) return;
	
	String result = this.getSelected();
	
	IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
	
	// gets current number of configurations
	int config_count = 0;
	int oldNameCount = 0;
	try {
		config_count = settings.getInt(Messages.getString("SootConfigManagerDialog.config_count")); //$NON-NLS-1$
	}
	catch (NumberFormatException e) {	
	}

	ArrayList currentNames = new ArrayList();
	for (int i = 1; i <= config_count; i++) {
		currentNames.add(settings.get(Messages.getString("SootConfigManagerDialog.soot_run_config")+i)); //$NON-NLS-1$
		if (((String)currentNames.get(i-1)).equals(result)){
			oldNameCount = i;
		}
	}

	
	// sets validator to know about already used names 
	SootConfigNameInputValidator validator = new SootConfigNameInputValidator();
	validator.setAlreadyUsed(currentNames);
	
	InputDialog nameDialog = new InputDialog(this.getShell(), Messages.getString("SootConfigManagerDialog.Rename_Saved_Configuration"), Messages.getString("SootConfigManagerDialog.Enter_new_name"), "", validator);  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	nameDialog.open();
	if (nameDialog.getReturnCode() == Dialog.OK){
		settings.put(Messages.getString("SootConfigManagerDialog.soot_run_config")+oldNameCount, nameDialog.getValue()); //$NON-NLS-1$
		settings.put(nameDialog.getValue(), settings.getArray(result));
		getTreeRoot().renameChild(result, nameDialog.getValue());
		saveMainClass(nameDialog.getValue(), settings.get(result+"_mainClass"));
	}
	refreshTree();
}
 
Example 2
private void clonePressed(){
	if (getSelected() == null) return;
	
	String result = this.getSelected();
	
	IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
	
	// gets current number of configurations
	int config_count = 0;
	try {
		config_count = settings.getInt(Messages.getString("SootConfigManagerDialog.config_count")); //$NON-NLS-1$
	}
	catch (NumberFormatException e) {	
	}
	ArrayList currentNames = new ArrayList();
	for (int i = 1; i <= config_count; i++) {
		currentNames.add(settings.get(Messages.getString("SootConfigManagerDialog.soot_run_config")+i)); //$NON-NLS-1$
		
	}

	
	// sets validator to know about already used names 
	SootConfigNameInputValidator validator = new SootConfigNameInputValidator();
	validator.setAlreadyUsed(currentNames);
	
	InputDialog nameDialog = new InputDialog(this.getShell(), Messages.getString("SootConfigManagerDialog.Clone_Saved_Configuration"), Messages.getString("SootConfigManagerDialog.Enter_new_name"), result, validator);  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	nameDialog.open();
	if (nameDialog.getReturnCode() == Dialog.OK){
		config_count++;
		settings.put(Messages.getString("SootConfigManagerDialog.soot_run_config")+config_count, nameDialog.getValue()); //$NON-NLS-1$
		settings.put(nameDialog.getValue(), settings.getArray(result));
		settings.put(Messages.getString("SootConfigManagerDialog.config_count"), config_count); //$NON-NLS-1$
		getTreeRoot().addChild(new SootConfiguration(nameDialog.getValue()));
		saveMainClass(nameDialog.getValue(), settings.get(result+"_mainClass"));
	}
	refreshTree();
}
 
Example 3
private void newPressed() {
	IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
	
	// gets current number of configurations before adding any
	int config_count = 0;
	try {
		config_count = settings.getInt(Messages.getString("SootConfigManagerDialog.config_count")); //$NON-NLS-1$
	}
	catch (NumberFormatException e) {	
	}
	
	ArrayList currentNames = new ArrayList();
	for (int i = 1; i <= config_count; i++) {
		currentNames.add(settings.get(Messages.getString("SootConfigManagerDialog.soot_run_config")+i)); //$NON-NLS-1$
	}
	
	// sets validator to know about already used names - but it doesn't use
	// them because then editing a file cannot use same file name
	SootConfigNameInputValidator validator = new SootConfigNameInputValidator();
	validator.setAlreadyUsed(currentNames);
	

	// create dialog to get name
	InputDialog nameDialog = new InputDialog(this.getShell(), Messages.getString("SootConfigManagerDialog.Saving_Configuration_Name"), Messages.getString("SootConfigManagerDialog.Enter_name_to_save_configuration_with"), "", validator);  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	nameDialog.open();
	
	if (nameDialog.getReturnCode() == Dialog.OK) {
		setEditDefs(null);
		int returnCode = displayOptions(nameDialog.getValue(), "soot.Main");
		//handle selection of main class here
		
		if (returnCode != Dialog.CANCEL) {
			getTreeRoot().addChild(new SootConfiguration(nameDialog.getValue()));
			refreshTree();
			
		}
	
	}
	else {
		// cancel and do nothing
	}
}