001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.studio.apacheds.properties;
021
022
023 import org.apache.directory.studio.apacheds.ApacheDsPluginUtils;
024 import org.apache.directory.studio.apacheds.model.Server;
025 import org.eclipse.swt.SWT;
026 import org.eclipse.swt.layout.GridData;
027 import org.eclipse.swt.layout.GridLayout;
028 import org.eclipse.swt.widgets.Composite;
029 import org.eclipse.swt.widgets.Control;
030 import org.eclipse.swt.widgets.Label;
031 import org.eclipse.swt.widgets.Text;
032 import org.eclipse.ui.IWorkbenchPropertyPage;
033 import org.eclipse.ui.dialogs.PropertyPage;
034
035
036 /**
037 * This class implements the Info property page for a server.
038 *
039 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
040 * @version $Rev$, $Date$
041 */
042 public class ServerPropertyPage extends PropertyPage implements IWorkbenchPropertyPage
043 {
044 /**
045 * Creates a new instance of ServerPropertyPage.
046 */
047 public ServerPropertyPage()
048 {
049 super();
050
051 super.noDefaultAndApplyButton();
052 }
053
054
055 /* (non-Javadoc)
056 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
057 */
058 protected Control createContents( Composite parent )
059 {
060 // Composite
061 Composite composite = new Composite( parent, SWT.NONE );
062 composite.setLayout( new GridLayout( 2, false ) );
063 composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
064
065 // Name
066 Label nameLabel = new Label( composite, SWT.NONE );
067 nameLabel.setText( Messages.getString( "ServerPropertyPage.Name" ) ); //$NON-NLS-1$
068 Text nameText = new Text( composite, SWT.NONE );
069 nameText.setEditable( false );
070 nameText.setBackground( parent.getBackground() );
071 nameText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
072
073 // Version
074 Label versionLabel = new Label( composite, SWT.NONE );
075 versionLabel.setText( Messages.getString( "ServerPropertyPage.Version" ) ); //$NON-NLS-1$
076 Text versionText = new Text( composite, SWT.NONE );
077 versionText.setEditable( false );
078 versionText.setBackground( parent.getBackground() );
079 versionText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
080
081 // Location
082 Label locationLabel = new Label( composite, SWT.NONE );
083 locationLabel.setText( Messages.getString( "ServerPropertyPage.Location" ) ); //$NON-NLS-1$
084 Text locationText = new Text( composite, SWT.WRAP );
085 locationText.setEditable( false );
086 locationText.setBackground( parent.getBackground() );
087 GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false );
088 gd.widthHint = 300;
089 locationText.setLayoutData( gd );
090
091 // Getting the server
092 Server server = ( Server ) getElement();
093 if ( server != null )
094 {
095 nameText.setText( server.getName() );
096 versionText.setText( server.getVersion().toString() );
097 locationText.setText( ApacheDsPluginUtils.getApacheDsServersFolder().append( server.getId() ).toOSString() );
098 }
099
100 return parent;
101 }
102 }