Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) 2014 Leibniz Institute of Plant Genetics and Crop Plant Research (IPK), Gatersleben, Germany.
   * All rights reserved. This program and the accompanying materials
   * are made available under the terms of the Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0)
   * which accompanies this distribution, and is available at http://creativecommons.org/licenses/by-nd/4.0/
   *
   * Contributors:
   *      Leibniz Institute of Plant Genetics and Crop Plant Research (IPK), Gatersleben, Germany - RMI Client, FileChooser and WebDAV
   */
 package de.ipk_gatersleben.bit.bi.edal.rmi.client.gui.editor;
 
 import java.util.List;
 
 
PermissionNewuserDialog provides a mechanism for the user to add new users and manage there permissions of EDAL File System.

The following code pops up a PermissionNewuserDialog for the user's directory

 PermissionNewuserDialog permission = new PermissionNewuserDialog(directory,
   client);
 permission.showOpenDialog();
 

Author(s):
Jinbo Chen
Version:
1.0
 
 public class PermissionNewuserDialog extends JDialog {
 	private static final long serialVersionUID = 1L;

Return value if cancel is chosen.
 
 	public static final int CANCEL_OPTION = 1;
Return value if approve (yes, ok) is chosen.
 
 	public static final int APPROVE_OPTION = 0;
 
 	private JButton savebtn;
 	private JButton cancelbtn;
 
 	public int returnvalue;
 
 	private ClientPrimaryDataEntity dataentry = null;
 	private List<Stringprincipals = new ArrayList<String>();
 	private List<Class<? extends Principal>> supportedprincipals;
 	private JTextField usertext = new JTextField();
 	private Principal principal;

Constructs a PermissionNewuserDialog that is initialized with dataentry as the EDAL dataentry, and client as the rmi client datamanager. If any of the parameters are null this method will not initialize.

Parameters:
dataentry the EDAL dataentry
client the rmi client datamanager
 
 			ClientDataManager client) {
		this. = dataentry;
		this. = client;
		setTitle("Add NewUser");
		JPanel contents = (JPanelgetContentPane();
		contents.setLayout(new BorderLayout());
		JPanel userselectpanel = new JPanel();
		userselectpanel.setLayout(new FlowLayout(.,10,15)); 
		JLabel principallabel = new JLabel("UserName:".);
		userselectpanel.add(principallabel);
		userselectpanel.add();
		for (Class<? extends Principalobj : ) {
		}
		userselectpanel.add();
		JPanel editPane = new JPanel();
		editPane.setLayout(new BorderLayout());
		editPane.add(userselectpanel.);
		contents.add(editPane.);
		this.setSize(new Dimension(600, 120));
		this.setResizable(false);
	}
	private class ItemChangeListener implements ItemListener{
	    @Override
	    public void itemStateChanged(ItemEvent event) {
	       if (event.getStateChange() == .) {
	          Object item = event.getItem();
	         if("ALLPrincipal".equals(item.toString()))
	         {
	        	 .setText("ALL");
	        	 .setEditable(false);
	         }
	         else
	         {
	        	 .setText("");
	        	 .setEditable(true);
	         }
	       }
	    }       
	}

pop up a PermissionNewuserDialog Dialog
	public int showOpenDialog() {
		setModal(true);
		return ;
	}
	public Principal getPrincipal() {
		return ;
	}
	private void loadconstants() {
		try {
			if ( != null) {
				for (GrantableMethods.Methods m : commonskeysets) {
				}
					for (GrantableMethods.Methods m : keysets) {
					}
else {
					for (GrantableMethods.Methods m : keysets) {
					}
				}
			}
catch (RemoteException e) {
			ErrorDialog.showError(e);
catch (EdalException e) {
			ErrorDialog.showError(e);
		}
	}
		JPanel buttonPane = new JPanel(new FlowLayout(., 5, 5));
		buttonPane.add();
		buttonPane.add();
		return buttonPane;
	}
	private void assignpermission() {
		// get principal
		String currentuser = .getText().trim();
		if (currentuser.length() == 0) {
			JOptionPane.showMessageDialog(null"Please Input UserName!",
					"EdalFileChooser".);
			return;
		}
		String currentprincipalname = .get(
		 = PrincipalUtil.getInstance(currentprincipalnamecurrentuser);
		JOptionPane.showMessageDialog(null"we created a new user:"+currentuser+"!","EdalFileChooser".);
	}
	private Action okAction = new AbstractAction("Ok") {
		private static final long serialVersionUID = 1L;
		public void actionPerformed(ActionEvent e) {
		}
	};
	private Action cancelAction = new AbstractAction("Cancel") {
		private static final long serialVersionUID = 1L;
		public void actionPerformed(ActionEvent e) {
		}
	};
New to GrepCode? Check out our FAQ X