Search in sources :

Example 16 with Profile

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;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) TableCellEditor(javax.swing.table.TableCellEditor) JMenuItem(javax.swing.JMenuItem) Profile(com.att.aro.core.configuration.pojo.Profile)

Example 17 with Profile

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;
}
Also used : ArrayList(java.util.ArrayList) Profile(com.att.aro.core.configuration.pojo.Profile)

Example 18 with Profile

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;
}
Also used : ProfileType(com.att.aro.core.configuration.pojo.ProfileType) InputStream(java.io.InputStream) Properties(java.util.Properties) IProfileFactory(com.att.aro.core.configuration.IProfileFactory) Profile(com.att.aro.core.configuration.pojo.Profile)

Example 19 with Profile

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;
}
Also used : IOException(java.io.IOException) File(java.io.File) Profile(com.att.aro.core.configuration.pojo.Profile)

Example 20 with Profile

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;
}
Also used : Properties(java.util.Properties) IProfileFactory(com.att.aro.core.configuration.IProfileFactory) Profile(com.att.aro.core.configuration.pojo.Profile)

Aggregations

Profile (com.att.aro.core.configuration.pojo.Profile)21 IOException (java.io.IOException)7 File (java.io.File)4 IProfileFactory (com.att.aro.core.configuration.IProfileFactory)3 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)3 RRCState (com.att.aro.core.packetanalysis.pojo.RRCState)3 RrcStateRange (com.att.aro.core.packetanalysis.pojo.RrcStateRange)3 MessageDialogFactory (com.att.aro.ui.commonui.MessageDialogFactory)3 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 TableCellEditor (javax.swing.table.TableCellEditor)3 ProfileLTE (com.att.aro.core.configuration.pojo.ProfileLTE)2 ProfileType (com.att.aro.core.configuration.pojo.ProfileType)2 EnergyModel (com.att.aro.core.packetanalysis.pojo.EnergyModel)2 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 FileNotFoundException (java.io.FileNotFoundException)2 BaseTest (com.att.aro.core.BaseTest)1 BestPracticeType (com.att.aro.core.bestpractice.pojo.BestPracticeType)1