use of com.att.aro.core.configuration.pojo.Profile in project VideoOptimzer by attdevsupport.
the class ConfigurationFrame method getApplyAction.
/**
* Initializes and returns the Apply menu item under the file menu.
*/
private JMenuItem getApplyAction() {
if (applyAction == null) {
applyAction = new JMenuItem(DEFAULTBUNDLE.getString("configuration.menu.file.apply"));
applyAction.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
try {
// Make sure current editor is closed
TableCellEditor networkAttrEditor = networkAttributesTable.getCellEditor();
TableCellEditor deviceAttrEditor = deviceAttributesTable.getCellEditor();
if (networkAttrEditor != null) {
networkAttrEditor.stopCellEditing();
}
if (deviceAttrEditor != null) {
deviceAttrEditor.stopCellEditing();
}
Profile profile = tableModel.getProfile();
aroMain.updateProfile(profile);
// todo: udpate user preferences
} catch (ProfileException e) {
handleProfileException(e);
}
}
});
}
return applyAction;
}
use of com.att.aro.core.configuration.pojo.Profile in project VideoOptimzer by attdevsupport.
the class ProfileManager method getPredefinedProfilesList.
/**
* Returns the list of predefined profiles that are displayed on the Select
* Profile dialog.
*
* @return The collection of predefined device profiles.
* @throws IOException
* @throws ProfileException
*/
public Collection<Profile> getPredefinedProfilesList() throws IOException, ProfileException {
Collection<Profile> predefinedProfies = new ArrayList<Profile>();
Set<String> profileNames = ProfileManager.getInstance().getPredefinedProfileNames();
for (String profileName : profileNames) {
Profile profile = ProfileManager.getInstance().getPredefinedProfile(profileName);
if (profile != null) {
predefinedProfies.add(profile);
}
}
return predefinedProfies;
}
use of com.att.aro.core.configuration.pojo.Profile in project VideoOptimzer by attdevsupport.
the class ProfileManager method getPredefinedProfile.
/**
* Loads the pre-defined profile with the specified name.
*
* @param name
* The name of a pre-defined profile returned by the
* getPredefinedProfileNames() method.
*
* @return The pre-defined profile, or null, if the profile is not found.
*
* @throws java.io.IOException
* - An unexpected exception that, occurs when there is an error
* reading the profile.
*
* @throws ProfileException
*/
public Profile getPredefinedProfile(String name) throws IOException, ProfileException {
String filename = predefinedProfiles.get(name);
if (filename != null) {
InputStream input = ProfileManager.class.getClassLoader().getResourceAsStream(filename);
if (input != null) {
try {
Properties prop = new Properties();
prop.load(input);
ProfileType type = ProfileType.T3G;
if (name.indexOf("3G") > 0) {
type = ProfileType.T3G;
} else if (name.indexOf("LTE") > 0) {
type = ProfileType.LTE;
} else if (name.indexOf("WiFi") > 0) {
type = ProfileType.WIFI;
} else {
return null;
}
if (profileFactory == null) {
profileFactory = ContextAware.getAROConfigContext().getBean(IProfileFactory.class);
}
Profile profile = profileFactory.create(type, prop);
profile.setName(name);
return profile;
} finally {
input.close();
}
}
}
// Return null when not successful
return null;
}
use of com.att.aro.core.configuration.pojo.Profile in project VideoOptimzer by attdevsupport.
the class ProfileManager method getLastUserProfile.
/**
* Gets the last profile used for the analysis.
*
* @return A Profile object that is the last profile used.
* @throws ProfileException
* - If data in the profile is corrupt.
*
* @throws java.io.IOException
* - If the application is unable to load the profile.
*/
public Profile getLastUserProfile(ProfileType profileType) throws ProfileException, IOException {
String profile = UserPreferencesFactory.getInstance().create().getLastProfile(profileType);
Profile result = null;
if (profile != null) {
File file = new File(profile);
if (file.isAbsolute()) {
try {
result = getProfile(file);
} catch (IOException e) {
LOGGER.warn("Unable to load previous profile file: " + file.getAbsolutePath());
throw new IOException(e);
}
}
if (result == null) {
// Not in file, try pre-defined
try {
String name = profileType == ProfileType.LTE ? DEFAULT_PROFILE_LTE : DEFAULT_PROFILE;
result = getPredefinedProfile(name);
} catch (IOException e) {
LOGGER.warn("Unable to load previous pre-defined profile: " + profile);
}
}
}
return result == null ? getDefaultProfile(profileType) : result;
}
use of com.att.aro.core.configuration.pojo.Profile in project VideoOptimzer by attdevsupport.
the class ConfigurationTableModel method getProfile.
/**
* Returns the profile represented by this table model.
*
* @return The profile for the Configuration table.
*
* @throws ProfileException
*/
public Profile getProfile() throws ProfileException {
Properties props = new Properties();
props = setProperties(props, getNetworkAttributesTableModel().getData());
props = setProperties(props, getDeviceAttributesTableModel().getData());
IProfileFactory profileFactory = ContextAware.getAROConfigContext().getBean(IProfileFactory.class);
Profile profile = profileFactory.create(profileType, props);
profile.setName(profileName);
return profile;
}
Aggregations