use of com.ramussoft.net.common.User in project ramus by Vitaliy-Yakovchuk.
the class Client method run.
public void run(final String[] args) {
final SplashScreen screen = new SplashScreen() {
/**
*/
private static final long serialVersionUID = -4641958771849938048L;
@Override
protected String getImageName() {
for (String s : args) if (s.equals("-season"))
return "/com/ramussoft/season/about.png";
return "/com/ramussoft/gui/about.png";
}
};
if (Metadata.CLIENT) {
Metadata.REGISTERED_FOR = ClientConnection.getName();
Metadata.DEMO_REGISTERED = ClientConnection.getName() != null;
}
screen.setLocationRelativeTo(null);
boolean hide = false;
for (String s : args) if ("--hide-splash".equals(s))
hide = true;
if (!hide)
screen.setVisible(true);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
List<PluginProvider> suits = new ArrayList<PluginProvider>();
suits.add(new SimpleAttributePluginSuit());
initAdditionalPluginSuits(suits);
PluginFactory factory = createPluginFactory(suits);
PersistentFactory persistentFactory = new PersistentFactory(null, factory.getAttributePlugins(), null);
persistentFactory.reinit();
Engine engine = getEngine(factory, persistentFactory);
AccessRules rules = getAccessRules();
e = engine;
e.setPluginProperty("Core", "PluginList", factory.getPlugins());
e.setPluginProperty("Core", "PluginFactory", factory);
LightClient.staticEngine = e;
LightClient.staticAccessRules = rules;
List<GUIPlugin> list = new ArrayList<GUIPlugin>();
QualifierPluginSuit.addPlugins(list, e, rules);
initAdditionalGuiPlugins(list);
User me = getMe();
List<Group> groups = me.getGroups();
String[] grps = new String[groups.size()];
for (int i = 0; i < grps.length; i++) grps[i] = groups.get(i).getName();
AbstractGUIPluginFactory factory1;
String ws = Options.getString("WindowsControl", "simple");
if (ws.equals("simple"))
factory1 = new SimleGUIPluginFactory(list, e, rules, getType(), grps, loadPlugins);
else
factory1 = new GUIPluginFactory(list, e, rules, getType(), grps, loadPlugins);
framework = factory1.getFramework();
framework.addCloseMainFrameListener(new CloseMainFrameAdapter() {
@Override
public void afterClosed() {
Client.this.close();
}
});
final JFrame frame = factory1.getMainFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String title = getTitle();
frame.setTitle(title);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
frame.setVisible(true);
screen.setVisible(false);
}
});
}
});
t.start();
Thread thread = new Thread("Icons-buffer-cleaner") {
@Override
public void run() {
while (true) {
try {
Thread.sleep(20000);
IconFactory.clearIconsBuffer(LightClient.staticEngine);
IconFactory.clearQualifierIconsBuffer(LightClient.staticEngine);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
thread.setDaemon(true);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
use of com.ramussoft.net.common.User in project ramus by Vitaliy-Yakovchuk.
the class UserProviderImpl method changePassword.
@Override
public void changePassword(String newPassword) {
User me = me();
me.setPassword(newPassword);
factory.updateUser(me);
}
use of com.ramussoft.net.common.User in project ramus by Vitaliy-Yakovchuk.
the class ClientPlugin method getActionDescriptors.
@Override
public ActionDescriptor[] getActionDescriptors() {
ActionDescriptor changePassword = new ActionDescriptor();
changePassword.setAction(new AbstractAction() {
/**
*/
private static final long serialVersionUID = 1388478861191637977L;
{
putValue(ACTION_COMMAND_KEY, "Action.ChangePassword");
}
public void actionPerformed(ActionEvent e) {
final JPasswordField oldPassword = new JPasswordField();
final JPasswordField newPassword = new JPasswordField();
final JPasswordField conformNewPassword = new JPasswordField();
double[][] size = { { 5, TableLayout.FILL, 5 }, { 5, TableLayout.FILL, 5, TableLayout.FILL, 5, TableLayout.FILL, 5, TableLayout.FILL, 5, TableLayout.FILL, 5, TableLayout.FILL, 5 } };
final JPanel panel = new JPanel(new TableLayout(size));
panel.add(new JLabel(getString("Message.OldPassword")), "1,1");
panel.add(oldPassword, "1,3");
panel.add(new JLabel(getString("Message.NewPassword")), "1,5");
panel.add(newPassword, "1,7");
panel.add(new JLabel(getString("Message.ConformNewPassword")), "1,9");
panel.add(conformNewPassword, "1,11");
BaseDialog dialog = new BaseDialog(framework.getMainFrame(), true) {
{
setTitle(getString("ChangePasswordDialog.Title"));
setMainPane(panel);
}
/**
*/
private static final long serialVersionUID = 1L;
@Override
protected void onOk() {
if (!Arrays.equals(newPassword.getPassword(), conformNewPassword.getPassword())) {
JOptionPane.showMessageDialog(framework.getMainFrame(), getString("Message.ConforPasswordsFailded"));
return;
}
User user = provider.me();
if (Arrays.equals(user.getPassword().toCharArray(), oldPassword.getPassword())) {
provider.changePassword(new String(newPassword.getPassword()));
super.onOk();
} else {
JOptionPane.showMessageDialog(framework.getMainFrame(), getString("Message.OldPasswordWrong"));
}
}
};
dialog.pack();
dialog.setResizable(false);
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
}
});
changePassword.setMenu("Net");
ActionDescriptor refresh = new ActionDescriptor();
refreshAction.putValue(Action.ACTION_COMMAND_KEY, "Refresh");
refreshAction.putValue(Action.SMALL_ICON, getIcon("/com/ramussoft/gui/refresh.png"));
// refreshAction.putValue(Action.LARGE_ICON_KEY,
// getIcon("/com/ramussoft/gui/22x22/refresh.png"));
refresh.setAction(refreshAction);
refresh.setMenu("Edit");
refresh.setToolBar("Edit");
if (refreshSupport)
return new ActionDescriptor[] { changePassword, refresh };
else
return new ActionDescriptor[] { changePassword };
}
use of com.ramussoft.net.common.User in project ramus by Vitaliy-Yakovchuk.
the class EditUsersDialog method createModels.
private void createModels() {
userModel = new AbstractTableModel() {
/**
*/
private static final long serialVersionUID = -5788741544620802246L;
private String[] columnNames = new String[] { plugin.getString("Column.User.Login"), plugin.getString("Column.User.Name") };
public int getColumnCount() {
return 2;
}
public int getRowCount() {
return users.size();
}
public Object getValueAt(int rowIndex, int columnIndex) {
User user = users.get(rowIndex);
return (columnIndex == 0) ? user.getLogin() : user.getName();
}
public String getColumnName(int column) {
return columnNames[column];
}
};
groupModel = new AbstractTableModel() {
/**
*/
private static final long serialVersionUID = 2848439255843446217L;
private String[] columnNames = new String[] { plugin.getString("Column.Selected"), plugin.getString("Column.Group.Name") };
public int getColumnCount() {
return 2;
}
public int getRowCount() {
return groups.size();
}
public Object getValueAt(int rowIndex, int columnIndex) {
if (columnIndex == 0) {
if (getActiveUser() != null) {
return getActiveUser().getGroups().indexOf(groups.get(rowIndex)) >= 0;
} else
return false;
}
return groups.get(rowIndex).getName();
}
public Class<?> getColumnClass(int columnIndex) {
if (columnIndex == 0)
return Boolean.class;
return super.getColumnClass(columnIndex);
}
public String getColumnName(int column) {
return columnNames[column];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return (columnIndex == 0) && (getActiveUser() != null);
}
public void setValueAt(Object value, int rowIndex, int columnIndex) {
User user = getActiveUser();
if (user != null) {
updateUser(user);
Group group = groups.get(rowIndex);
if ((Boolean) value)
user.getGroups().add(group);
else
user.getGroups().remove(group);
}
}
};
qualifierModel = new AbstractTableModel() {
/**
*/
private static final long serialVersionUID = -8072350565904373494L;
private String[] columnNames = new String[] { plugin.getString("Column.Selected"), plugin.getString("Column.Qualifier.Name") };
public int getColumnCount() {
return 2;
}
public int getRowCount() {
return qualifiers.size();
}
public Object getValueAt(int rowIndex, int columnIndex) {
if (columnIndex == 0) {
if (getActiveGroup() != null) {
return getActiveGroup().getQualifierIds().indexOf(qualifiers.get(rowIndex).getId()) >= 0;
} else
return Boolean.FALSE;
}
return qualifiers.get(rowIndex).getName();
}
public Class<?> getColumnClass(int columnIndex) {
if (columnIndex == 0)
return Boolean.class;
return super.getColumnClass(columnIndex);
}
public String getColumnName(int column) {
return columnNames[column];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return (columnIndex == 0) && (getActiveGroup() != null);
}
public void setValueAt(Object value, int rowIndex, int columnIndex) {
Group group = getActiveGroup();
if (group != null) {
updateGroup(group);
long qualifierId = qualifiers.get(rowIndex).getId();
if ((Boolean) value)
group.getQualifierIds().add(qualifierId);
else
group.getQualifierIds().remove(qualifierId);
}
}
};
}
use of com.ramussoft.net.common.User in project ramus by Vitaliy-Yakovchuk.
the class EditUsersDialog method updateUser.
private void updateUser(User user) {
User u = findUser(user.getLogin(), usersToUpdate);
if (u != null)
usersToUpdate.remove(u);
usersToUpdate.add(user);
}
Aggregations