Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2007 Alin Dreghiciu.
   *
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at
   *
   *   http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed  under the  License is distributed on an "AS IS" BASIS,
  * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
  * implied.
  *
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.ops4j.pax.cursor.ui;
 
 import java.util.List;
 import  org.eclipse.core.runtime.CoreException;
 import  org.eclipse.debug.core.ILaunchConfiguration;
 import  org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import  org.eclipse.debug.ui.ILaunchConfigurationTab;
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.events.SelectionAdapter;
 import  org.eclipse.swt.events.SelectionEvent;
 import  org.eclipse.swt.events.SelectionListener;
 import  org.eclipse.swt.layout.GridData;
 import  org.eclipse.swt.layout.GridLayout;
 import  org.eclipse.swt.widgets.Button;
 import  org.eclipse.swt.widgets.Combo;
 import  org.eclipse.swt.widgets.Composite;
 import  org.eclipse.swt.widgets.Group;
 import  org.eclipse.swt.widgets.Label;
Options Composite of Pax Cursor (upper group).

Author(s):
Alin Dreghiciu
Since:
0.2.0, December 16, 2007
 
 public class OptionsBlock
     extends CursorTabBlock
 {
 
     private final Combo m_logCombo;
     private final Button m_overwriteSystemButton;
     private final Button m_overwriteUserButton;
     private final Button m_overwriteAllButton;
     private final Button m_configProfileButton;
     private final Button m_logProfileButton;
     private final Button m_obrProfileButton;
     private final Button m_webProfileButton;
     private final Button m_warProfileButton;
     private final Button m_springProfileButton;    
     private final Button m_dsProfileButton;    

    

See also:
Composite.Composite(Composite, int)
 
     public OptionsBlockfinal Composite parentfinal int style )
     {
         superparentstyle );
         final GridLayout blockLayout = new GridLayout();
         blockLayout.numColumns = 2;
         setLayout( blockLayout );
 
         final Group optionsGroup = new Group( this, SWT.NONE );
         optionsGroup.setLayoutData( new GridData( SWT.FILL, SWT.FILL, truefalse ) );
         optionsGroup.setText( "Options:" );
         final GridLayout optionsGroupLayout = new GridLayout();
         optionsGroupLayout.numColumns = 4;
         optionsGroup.setLayout( optionsGroupLayout );
 
         final SelectionListener updateNotifier = new SelectionAdapter()
         {
             public void widgetSelectedfinal SelectionEvent e )
             {
                 notifyUpdate();
             }
         };
 
         final Label overwriteLabel = new Label( optionsGroup, SWT.NONE );
         overwriteLabel.setLayoutData( new GridData( SWT.RIGHT, SWT.CENTER, falsefalse ) );
         overwriteLabel.setText( "Overwrite:" );
 
          = new Button( optionsGroup, SWT.CHECK );
         .addSelectionListener( updateNotifier );
         .setText( "All" );
 
          = new Button( optionsGroup, SWT.CHECK );
         .addSelectionListener( updateNotifier );
         .setText( "User" );
 
          = new Button( optionsGroup, SWT.CHECK );
         .addSelectionListener( updateNotifier );
        .setText( "System" );
        final Label logLabel = new Label( optionsGroup, SWT.NONE );
        logLabel.setLayoutData( new GridData( SWT.RIGHT, SWT.CENTER, falsefalse ) );
        logLabel.setText( "Log:" );
         = new Combo( optionsGroup, SWT.READ_ONLY );
        .addSelectionListener( updateNotifier );
        .setItems( new String[]{ "TRACE""DEBUG""INFO""WARN""ERROR" } );
        final GridData logComboLayout = new GridData( SWT.LEFT, SWT.TOP, falsefalse );
        .setLayoutData( logComboLayout );
        final Group profilesGroup = new Group( this, SWT.NONE );
        profilesGroup.setLayoutData( new GridData( SWT.LEFT, SWT.FILL, falsefalse ) );
        profilesGroup.setText( "Profiles:" );
        final GridLayout profileGroupLayout = new GridLayout();
        profileGroupLayout.numColumns = 4;
        profilesGroup.setLayout( profileGroupLayout );
         = new Button( profilesGroup, SWT.CHECK );
        .addSelectionListener( updateNotifier );
        .setText( "log" );
         = new Button( profilesGroup, SWT.CHECK );
        .addSelectionListener( updateNotifier );
        .setText( "web" );
         = new Button( profilesGroup, SWT.CHECK );
        .addSelectionListener( updateNotifier );
        .setText( "war" );
         = new Button(profilesGroup, SWT.CHECK);
        .addSelectionListener( updateNotifier );
        .setText("spring");
         = new Button( profilesGroup, SWT.CHECK );
        .addSelectionListener( updateNotifier );
        .setText( "config" );
         = new Button( profilesGroup, SWT.CHECK );
        .addSelectionListener( updateNotifier );
        .setText( "obr" );
        
         = new Button( profilesGroup, SWT.CHECK );
        .addSelectionListener( updateNotifier );
        .setText( "ds" );
        
        new Label(profilesGroup, SWT.NONE);
    }

    
Initialize block.

See also:
ILaunchConfigurationTab.initializeFrom(ILaunchConfiguration)
    public void initializeFromfinal ILaunchConfiguration configuration )
    {
        // default values
        .setSelection( false );
        .setSelection( false );
        .setSelection( false );
        .setText( "INFO" );
        try
        {
            // get overwrite options
            .setSelection( configuration.getAttribute( .false ) );
            .setSelection( configuration.getAttribute( .false ) );
            .setSelection( configuration.getAttribute( .false ) );
            // get log option
            .setText( configuration.getAttribute( ."INFO" ) );
            // get profiles option
            final List profiles = configuration.getAttribute( .new ArrayList() );
            ifprofiles != null && profiles.size() > 0 )
            {
                .setSelection( profiles.contains"config" ) );
                .setSelection( profiles.contains"log" ) );
                .setSelection( profiles.contains"obr" ) );
                .setSelection( profiles.contains"web" ) );
                .setSelection( profiles.contains"war" ) );
                .setSelection( profiles.contains"spring-dm" ) );                
                .setSelection( profiles.contains"ds" ) );                
            }
        }
        catch( CoreException ignore )
        {
            // DebugUIPlugin.log(ignore.getStatus());
        }
    }

    
Saves block configurations attributes.

See also:
ILaunchConfigurationTab.performApply(ILaunchConfigurationWorkingCopy)
    public void performApplyfinal ILaunchConfigurationWorkingCopy configuration )
    {
        // save overwrite options
        configuration.setAttribute( ..getSelection() );
        configuration.setAttribute( ..getSelection() );
        configuration.setAttribute( ..getSelection() );
        // save log option
        configuration.setAttribute( ..getText() );
        // save profiles option
        final StringBuffer profilesArg = new StringBuffer"--profiles=" );
        List profiles = new ArrayList();
        if.getSelection() )
        {
            profiles.add"config" );
            profilesArg.append"config," );
        }
        if.getSelection() )
        {
            profiles.add"log" );
            profilesArg.append"log," );
        }
        if.getSelection() )
        {
            profiles.add"obr" );
            profilesArg.append"obr," );
        }
        if.getSelection() )
        {
            profiles.add"web" );
            profilesArg.append"web," );
        }
        if.getSelection() )
        {
            profiles.add"war" );
            profilesArg.append"war," );
        }
        if.getSelection() )
        {
            profiles.add"spring-dm" );
            profilesArg.append"spring-dm," );
        }
        if.getSelection() )
        {
            profiles.add"ds" );
            profilesArg.append"ds," );
        }
        // maybe there is no profile selected so then remove the configuration attribute
        ifprofiles.size() == 0 )
        {
            profiles = null;
        }
        configuration.setAttribute( .profiles );
        // finally, save arguments list
        try
        {
            final List arguments = configuration.getAttribute( .new ArrayList() );
            arguments.add"--overwrite=" + .getSelection() );
            arguments.add"--overwriteUserBundles=" + .getSelection() );
            arguments.add"--overwriteSystemBundles=" + .getSelection() );
            if.getText() != null && .getText().trim().length() > 0 )
            {
                arguments.add"--log=" + .getText() );
            }
            ifprofiles != null )
            {
                arguments.addprofilesArg.substring( 0, profilesArg.length() - 1 ) );
            }
            configuration.setAttribute( .arguments );
        }
        catch( CoreException ignore )
        {
            // DebugUIPlugin.log(ignore.getStatus());;
        }
    }
New to GrepCode? Check out our FAQ X