KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > launcher > AbstractLauncherTab


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.launcher;
12
13 import org.eclipse.debug.core.*;
14 import org.eclipse.debug.ui.*;
15 import org.eclipse.swt.widgets.*;
16 import org.eclipse.core.runtime.*;
17 import org.eclipse.pde.internal.ui.PDEPlugin;
18 import org.eclipse.swt.layout.GridData;
19 import org.eclipse.swt.SWT;
20
21 /**
22  * @version 1.0
23  * @author
24  */

25 public abstract class AbstractLauncherTab extends AbstractLaunchConfigurationTab {
26
27     protected void createStartingSpace(Composite parent, int span) {
28         Label label = new Label(parent, SWT.NULL);
29         GridData data = new GridData();
30         data.horizontalSpan = span;
31         label.setLayoutData(data);
32     }
33
34     public boolean isValid(ILaunchConfiguration config) {
35         return getErrorMessage() == null;
36     }
37     
38     /* (non-Javadoc)
39      * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
40      */

41     public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
42     }
43     
44     /* (non-Javadoc)
45      * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#deactivated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
46      */

47     public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {
48     }
49
50     /**
51      * Updates the status line and the ok button depending on the status
52      */

53     protected void updateStatus(IStatus status) {
54         applyToStatusLine(this, status);
55     }
56
57     /**
58      * Applies the status to a dialog page
59      */

60     public static void applyToStatusLine(AbstractLauncherTab tab, IStatus status) {
61         String JavaDoc errorMessage= null;
62         String JavaDoc warningMessage= null;
63         String JavaDoc statusMessage= status.getMessage();
64         if (statusMessage.length() > 0) {
65             if (status.matches(IStatus.ERROR)) {
66                 errorMessage= statusMessage;
67             } else if (!status.isOK()) {
68                 warningMessage= statusMessage;
69             }
70         }
71         tab.setErrorMessage(errorMessage);
72         tab.setMessage(warningMessage);
73         tab.updateLaunchConfigurationDialog();
74     }
75     
76     public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
77         return (s1.getSeverity() >= s2.getSeverity()) ? s1 : s2;
78     }
79     
80     public static IStatus createStatus(int severity, String JavaDoc message) {
81         return new Status(severity, PDEPlugin.getPluginId(), severity, message, null);
82     }
83     
84     /**
85      * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog()
86      */

87     protected void updateLaunchConfigurationDialog() {
88         super.updateLaunchConfigurationDialog();
89     }
90         
91 }
92
Popular Tags