1 20 21 package org.apache.directory.ldapstudio.view; 22 23 24 import java.net.MalformedURLException ; 25 import java.net.URL ; 26 27 import org.apache.directory.ldapstudio.Messages; 28 import org.eclipse.jface.dialogs.MessageDialog; 29 import org.eclipse.swt.SWT; 30 import org.eclipse.swt.events.SelectionAdapter; 31 import org.eclipse.swt.events.SelectionEvent; 32 import org.eclipse.swt.graphics.Font; 33 import org.eclipse.swt.graphics.Image; 34 import org.eclipse.swt.layout.GridData; 35 import org.eclipse.swt.layout.GridLayout; 36 import org.eclipse.swt.widgets.Button; 37 import org.eclipse.swt.widgets.Composite; 38 import org.eclipse.swt.widgets.Label; 39 import org.eclipse.ui.PartInitException; 40 import org.eclipse.ui.PlatformUI; 41 import org.eclipse.ui.part.ViewPart; 42 43 44 50 public class WelcomeView extends ViewPart 51 { 52 public static final String ID = "org.apache.directory.ldapstudio.view.WelcomeView"; 54 57 public void createPartControl( Composite parent ) 58 { 59 Composite container = new Composite( parent, SWT.NULL ); 60 GridLayout layout = new GridLayout( 2, true ); 61 container.setLayout( layout ); 62 63 Label welcomeLabel = new Label( container, SWT.CENTER ); 65 welcomeLabel.setFont( new Font( null, "Georgia", 13, SWT.BOLD ) ); welcomeLabel.setText( Messages.getString( "WelcomeView.Welcome_message" ) ); welcomeLabel.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true, 2, 1 ) ); 68 69 Image ldapBrowserImage = new Image( PlatformUI.getWorkbench().getDisplay(), getClass().getResourceAsStream( 71 "ldapstudio_ldap-browser-plugin.png" ) ); Button ldapBrowserButton = new Button( container, SWT.FLAT ); 73 ldapBrowserButton.setImage( ldapBrowserImage ); 74 ldapBrowserButton.setLayoutData( new GridData( SWT.CENTER, SWT.NONE, false, false ) ); 75 ldapBrowserButton.addSelectionListener( new SelectionAdapter() 76 { 77 public void widgetSelected( SelectionEvent e ) 78 { 79 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setPerspective( 80 PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId( 81 "org.apache.directory.ldapstudio.browser.ui.perspective.BrowserPerspective" ) ); } 83 } ); 84 85 Image schemasEditorImage = new Image( PlatformUI.getWorkbench().getDisplay(), getClass().getResourceAsStream( 87 "ldapstudio_schemas-editor-plugin.png" ) ); Button schemasEditorButton = new Button( container, SWT.FLAT ); 89 schemasEditorButton.setImage( schemasEditorImage ); 90 schemasEditorButton.setLayoutData( new GridData( SWT.CENTER, SWT.NONE, false, false ) ); 91 schemasEditorButton.addSelectionListener( new SelectionAdapter() 92 { 93 public void widgetSelected( SelectionEvent e ) 94 { 95 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setPerspective( 96 PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId( 97 "org.apache.directory.ldapstudio.schemas.perspective" ) ); } 99 } ); 100 101 Label ldapBrowserLabel = new Label( container, SWT.NONE ); 103 ldapBrowserLabel.setFont( new Font( null, "Georgia", 13, SWT.BOLD ) ); ldapBrowserLabel.setText( Messages.getString("WelcomeView.LDAP_Browser_Plugin") ); ldapBrowserLabel.setLayoutData( new GridData( SWT.CENTER, SWT.NONE, true, true ) ); 106 107 Label schemasEditorLabel = new Label( container, SWT.NONE ); 109 schemasEditorLabel.setFont( new Font( null, "Georgia", 13, SWT.BOLD ) ); schemasEditorLabel.setText( Messages.getString("WelcomeView.Schemas_Editor_Plugin") ); schemasEditorLabel.setLayoutData( new GridData( SWT.CENTER, SWT.NONE, true, true ) ); 112 113 Image asfLogoImange = new Image( PlatformUI.getWorkbench().getDisplay(), getClass().getResourceAsStream( 115 "asf-logo.gif" ) ); Button asfLogoButton = new Button( container, SWT.FLAT ); 117 asfLogoButton.setImage( asfLogoImange ); 118 asfLogoButton.setLayoutData( new GridData( SWT.CENTER, SWT.NONE, false, false, 2, 1 ) ); 119 asfLogoButton.addSelectionListener( new SelectionAdapter() 120 { 121 public void widgetSelected( SelectionEvent e ) 122 { 123 try 124 { 125 PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL( 126 new URL ( Messages.getString("WelcomeView.Apache.org_url") ) ); } 128 catch ( PartInitException e1 ) 129 { 130 MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 132 Messages.getString("WelcomeView.Error"), Messages.getString("WelcomeView.LDAP_Studio_was_unable_to_open_www.apache.org") ); } 134 catch ( MalformedURLException e1 ) 135 { 136 } 138 } 139 } ); 140 141 Label copyrightLabel = new Label( container, SWT.NONE ); 143 copyrightLabel.setText( Messages.getString("WelcomeView.Copyright") ); copyrightLabel.setLayoutData( new GridData( SWT.CENTER, SWT.NONE, false, false, 2, 1 ) ); 145 } 146 147 148 151 public void setFocus() 152 { 153 } 155 } | Popular Tags |