Changeset 736

Show
Ignore:
Timestamp:
06/22/07 11:17:14 (2 years ago)
Author:
nozawa
Message:

use org.jalcedo.client.login plugin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.jalcedo.client.examples/trunk/org.jalcedo.client.examples.loginsample/META-INF/MANIFEST.MF

    r714 r736  
    77Require-Bundle: org.eclipse.ui, 
    88 org.eclipse.core.runtime, 
    9  org.eclipse.jface 
     9 org.eclipse.jface, 
     10 org.jalcedo.client.login 
    1011Eclipse-LazyStart: true 
    1112Bundle-ClassPath: . 
  • org.jalcedo.client.examples/trunk/org.jalcedo.client.examples.loginsample/plugin.xml

    r714 r736  
    2828      </view> 
    2929   </extension> 
    30    <extension 
    31          point="org.eclipse.ui.preferencePages"> 
    32       <page 
    33             class="org.jalcedo.client.examples.login.logins.GeneralPreferencePage" 
    34             id="org.jalcedo.client.examples.login.general" 
    35             name="General"> 
    36       </page> 
    37    </extension> 
    3830</plugin> 
  • org.jalcedo.client.examples/trunk/org.jalcedo.client.examples.loginsample/src/org/jalcedo/client/examples/login/Application.java

    r714 r736  
    11package org.jalcedo.client.examples.login; 
    22 
    3  
    4 import java.lang.reflect.InvocationTargetException; 
    5  
    6 import org.eclipse.core.runtime.IProgressMonitor; 
    73import org.eclipse.core.runtime.Platform; 
    8 import org.eclipse.core.runtime.Preferences; 
    9 import org.eclipse.core.runtime.preferences.IPreferencesService; 
    104import org.eclipse.equinox.app.IApplication; 
    115import org.eclipse.equinox.app.IApplicationContext; 
    12 import org.eclipse.jface.dialogs.ProgressMonitorDialog; 
    13 import org.eclipse.jface.operation.IRunnableWithProgress; 
    14 import org.eclipse.jface.window.Window; 
    156import org.eclipse.swt.widgets.Display; 
    167import org.eclipse.ui.IWorkbench; 
    178import org.eclipse.ui.PlatformUI; 
    18 import org.jalcedo.client.examples.login.logins.BasicLoginDialog; 
    19 import org.jalcedo.client.examples.login.logins.ConnectionDetails; 
    20 import org.jalcedo.client.examples.login.logins.GeneralPreferencePage; 
    21 import org.jalcedo.client.examples.login.models.Session; 
    22  
    23  
     9import org.jalcedo.client.examples.login.models.ItemSession; 
     10import org.jalcedo.client.login.LoginManager; 
    2411 
    2512/** 
     
    2714 */ 
    2815public class Application implements IApplication { 
    29     public static final String PLUGIN_ID ="org.jalcedo.client.examples.login"; 
     16    public static final String PLUGIN_ID = "org.jalcedo.client.examples.login"; 
     17 
    3018    /* 
    3119     * (non-Javadoc) 
     
    3725        try { 
    3826            Platform.endSplash(); 
    39             if(!login()){ 
     27            ItemSession itemSession = ItemSession.getInstance(); 
     28            LoginManager loginManager = new LoginManager(); 
     29            if (!loginManager.login(itemSession)) { 
    4030                return IApplication.EXIT_OK; 
    4131            } 
    42                int returnCode = PlatformUI.createAndRunWorkbench(display, 
    43                        new ApplicationWorkbenchAdvisor()); 
    44                if (returnCode == PlatformUI.RETURN_RESTART) { 
    45                    return IApplication.EXIT_RESTART; 
    46                
    47                return IApplication.EXIT_OK; 
     32            int returnCode = PlatformUI.createAndRunWorkbench(display, 
     33                    new ApplicationWorkbenchAdvisor()); 
     34            if (returnCode == PlatformUI.RETURN_RESTART) { 
     35                return IApplication.EXIT_RESTART; 
     36           
     37            return IApplication.EXIT_OK; 
    4838        } finally { 
    4939            display.dispose(); 
     
    5141    } 
    5242 
    53     private boolean login(){ 
    54         final Session session = Session.getInstance(); 
    55         boolean firstTry = true; 
    56         BasicLoginDialog loginDialog = new BasicLoginDialog(null); 
    57         while (session.getConnection() == null || !session.getConnection().isAuthenticated()) { 
    58             IPreferencesService service = Platform.getPreferencesService(); 
    59             boolean auto_login = service.getBoolean(Application.PLUGIN_ID, 
    60                     GeneralPreferencePage.AUTO_LOGIN, true, null); 
    61             ConnectionDetails details = loginDialog.getConnectionDetails(); 
    62             if (!auto_login || details == null || !firstTry) { 
    63                 if (loginDialog.open() != Window.OK) { 
    64                     return false; 
    65                 } 
    66                 details = loginDialog.getConnectionDetails(); 
    67             } 
    68             firstTry = false; 
    69      
    70             session.setConnectionDetails(loginDialog.getConnectionDetails()); 
    71             connectWithProgress(session); 
    72              
    73         } 
    74          
    75         return true; 
    76     } 
    77     private void connectWithProgress(final Session session) { 
    78         ProgressMonitorDialog progress = new ProgressMonitorDialog(null); 
    79         progress.setCancelable(true); 
    80  
    81         try { 
    82             progress.run(true, true, new IRunnableWithProgress() { 
    83  
    84                 public void run(IProgressMonitor monitor) 
    85                         throws InvocationTargetException, InterruptedException { 
    86                     try{ 
    87                         session.connectAndLogin(monitor); 
    88                     }catch (Exception e){ 
    89                         throw new InvocationTargetException(e); 
    90                     } 
    91                 } 
    92  
    93             }); 
    94         } catch (InvocationTargetException e) { 
    95             // TODO Auto-generated catch block 
    96             e.printStackTrace(); 
    97         } catch (InterruptedException e) { 
    98             // TODO Auto-generated catch block 
    99             e.printStackTrace(); 
    100         } 
    101     } 
    10243    /* 
    10344     * (non-Javadoc) 
  • org.jalcedo.client.examples/trunk/org.jalcedo.client.examples.loginsample/src/org/jalcedo/client/examples/login/views/ItemView.java

    r715 r736  
    1414import org.jalcedo.client.examples.login.models.ItemGroup; 
    1515import org.jalcedo.client.examples.login.models.ItemsListener; 
    16 import org.jalcedo.client.examples.login.models.Session; 
     16import org.jalcedo.client.examples.login.models.ItemSession; 
    1717 
    1818public class ItemView extends ViewPart { 
    1919    public static final String ID = "org.jalcedo.client.examples.login.views.ItemView"; 
    2020    private TreeViewer treeViewer; 
    21     private Session session; 
     21    private ItemSession itemSession; 
    2222    private IAdapterFactory adapterFactory = new ItemAdapterFactory(); 
    2323 
     
    3232        treeViewer.setLabelProvider(new WorkbenchLabelProvider()); 
    3333        treeViewer.setContentProvider(new BaseWorkbenchContentProvider()); 
    34         treeViewer.setInput(session.getRoot()); 
    35         session.getRoot().addItemsListener(new ItemsListener(){ 
     34        treeViewer.setInput(itemSession.getRoot()); 
     35        itemSession.getRoot().addItemsListener(new ItemsListener(){ 
    3636 
    3737            public void itemChanged(ItemGroup datasource, ItemEntry item) { 
     
    4444 
    4545    private void initializeSession() { 
    46         session = Session.getInstance(); 
    47         ItemGroup root = session.getRoot(); 
     46        itemSession = ItemSession.getInstance(); 
     47        ItemGroup root = itemSession.getRoot(); 
    4848        ItemGroup testGroup = new ItemGroup(root, "Test"); 
    4949        root.addItem(testGroup);