krysalis-version/src/java/org/krysalis/version/eclipse/plugin/wizard ConstraintCreationPage.java,NONE,1.1 ConstraintFilePropertyPage2.java,NONE,1.1 ConstraintFilePropertyPage.java,NONE,1.1 ConstraintCreationWizard.java,NONE,1.1 SectionsDialog.java,NONE,1.1
[email protected] Fri, 21 Mar 2003 15:33:00 -0800
| Newsgroups | gmane.comp.krysalis.sandbox |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/eclipse/plugin/wizard
In directory sc8-pr-cvs1:/tmp/cvs-serv22996/src/java/org/krysalis/version/eclipse/plugin/wizard
Added Files:
ConstraintCreationPage.java ConstraintFilePropertyPage2.java
ConstraintFilePropertyPage.java ConstraintCreationWizard.java
SectionsDialog.java
Log Message:
Constraint changes
--- NEW FILE: ConstraintCreationPage.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Patchy *
* Software License version 1.1_01, a copy of which has been included *
* at the bottom of this file. *
*****************************************************************************/
package org.krysalis.version.eclipse.plugin.wizard;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.eclipse.ui.help.WorkbenchHelp;
import org.krysalis.version.eclipse.plugin.util.IConstraintConstants;
import org.krysalis.version.eclipse.plugin.util.MessageUtil;
/**
* This class is the only page of the Constraint file resource creation wizard.
* It subclasses the standard file resource creation page class,
* and consequently inherits the file resource creation functionality.
*
* This page provides users with the choice of creating sample headings for
* sections and subsections. Additionally, the option is presented to open
* the file immediately for editing after creation.
*/
public class ConstraintCreationPage extends WizardNewFileCreationPage
{
private IWorkbench workbench;
// widgets
private Button constraintCheckbox;
private Button openFileCheckbox;
// constants
private static int nameCounter = 1;
/**
* Creates the page for the Constraint creation wizard.
*
* @param workbench the workbench on which the page should be created
* @param selection the current selection
*/
public ConstraintCreationPage(IWorkbench workbench, IStructuredSelection selection)
{
super("sampleCreateConstraintPage1", selection); //$NON-NLS-1$
this.setTitle(MessageUtil.getString("Create_Constraint_File")); //$NON-NLS-1$
this.setDescription(MessageUtil.getString("Create_a_new_Constraint_file_resource")); //$NON-NLS-1$
this.workbench = workbench;
}
/** (non-Javadoc)
* Method declared on IDialogPage.
*/
public void createControl(Composite parent)
{
// inherit default container and name specification widgets
super.createControl(parent);
Composite composite = (Composite) getControl();
WorkbenchHelp.setHelp(composite, IConstraintConstants.CREATION_WIZARD_PAGE_CONTEXT);
GridData data = (GridData) composite.getLayoutData();
this.setFileName("sample" + nameCounter + ".vcnt"); //$NON-NLS-1$ //$NON-NLS-2$
new Label(composite, SWT.NONE); // vertical spacer
// sample section generation group
Group group = new Group(composite, SWT.NONE);
group.setLayout(new GridLayout());
group.setText(MessageUtil.getString("Automatic_sample_constraint_generation")); //$NON-NLS-1$
group.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
// sample section generation checkboxes
constraintCheckbox = new Button(group, SWT.CHECK);
constraintCheckbox.setText(MessageUtil.getString("Generate_sample_constraint")); //$NON-NLS-1$
constraintCheckbox.setSelection(true);
constraintCheckbox.addListener(SWT.Selection, this);
/*subsectionCheckbox = new Button(group, SWT.CHECK);
subsectionCheckbox.setText(MessageUtil.getString("Generate_sample_subsection_titles")); //$NON-NLS-1$
subsectionCheckbox.setSelection(true);
subsectionCheckbox.addListener(SWT.Selection, this);
*/
new Label(composite, SWT.NONE); // vertical spacer
// open file for editing checkbox
openFileCheckbox = new Button(composite, SWT.CHECK);
openFileCheckbox.setText(MessageUtil.getString("Open_file_for_editing_when_done")); //$NON-NLS-1$
openFileCheckbox.setSelection(true);
setPageComplete(validatePage());
}
/**
* Creates a new file resource as requested by the user. If everything
* is OK then answer true. If not, false will cause the dialog
* to stay open.
*
* @return whether creation was successful
* @see ConstraintCreationWizard#performFinish()
*/
public boolean finish()
{
// create the new file resource
IFile newFile = createNewFile();
if (newFile == null)
return false; // ie.- creation was unsuccessful
// Since the file resource was created fine, open it for editing
// if requested by the user
try
{
if (openFileCheckbox.getSelection())
{
IWorkbenchWindow dwindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = dwindow.getActivePage();
if (page != null)
page.openEditor(newFile);
}
}
catch (PartInitException e)
{
e.printStackTrace();
return false;
}
nameCounter++;
return true;
}
/**
* The <code>ConstraintCreationPage</code> implementation of this
* <code>WizardNewFileCreationPage</code> method
* generates sample headings for sections and subsections in the
* newly-created Constraint file according to the selections of self's
* checkbox widgets
*/
protected InputStream getInitialContents()
{
if (!constraintCheckbox.getSelection())
return null;
StringBuffer sb = new StringBuffer();
sb.append(MessageUtil.getString("SAMPLE_CONSTRAINT1")); //$NON-NLS-1$
sb.append(MessageUtil.getString("SAMPLE_CONSTRAINT2")); //$NON-NLS-1$
return new ByteArrayInputStream(sb.toString().getBytes());
}
/** (non-Javadoc)
* Method declared on WizardNewFileCreationPage.
*/
protected String getNewFileLabel()
{
return MessageUtil.getString("Constraint_file_name"); //$NON-NLS-1$
}
/** (non-Javadoc)
* Method declared on WizardNewFileCreationPage.
*/
public void handleEvent(Event e)
{
Widget source = e.widget;
/*if (source == constraintCheckbox)
{
if (!constraintCheckbox.getSelection())
subsectionCheckbox.setSelection(false);
subsectionCheckbox.setEnabled(constraintCheckbox.getSelection());
}*/
super.handleEvent(e);
}
}
/*
The Krysalis Patchy Software License, Version 1.1_01
Copyright (c) 2002-2003 Nicola Ken Barozzi. All rights reserved.
This Licence is compatible with the BSD licence as described and
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The end-user documentation included with the redistribution,
if any, must include the following acknowledgment:
"This product includes software developed for project
Krysalis (http://www.krysalis.org/)."
Alternately, this acknowledgment may appear in the software itself,
if and wherever such third-party acknowledgments normally appear.
4. The names "Krysalis" and "Nicola Ken Barozzi" and
"Krysalis Centipede" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact [email protected].
5. Products derived from this software may not be called "Krysalis",
"Krysalis Centipede", nor may "Krysalis" appear in their name,
without prior written permission of Nicola Ken Barozzi.
6. This software may contain voluntary contributions made by many
individuals, who decided to donate the code to this project in
respect of this licence.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE KRYSALIS PROJECT OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================*/
--- NEW FILE: ConstraintFilePropertyPage2.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Patchy *
* Software License version 1.1_01, a copy of which has been included *
* at the bottom of this file. *
*****************************************************************************/
package org.krysalis.version.eclipse.plugin.wizard;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.dialogs.PropertyPage;
import org.eclipse.ui.help.WorkbenchHelp;
import org.krysalis.version.eclipse.plugin.util.IConstraintConstants;
import org.krysalis.version.eclipse.plugin.util.MessageUtil;
/**
* This page will be added to the property page dialog
* when "Properties..." popup menu item is selected
* for constraint files.
*
* This page demonstrates conditional property pages which look
* different depending on the state of the element. In this example,
* the arbitrary condition chosen is whether the constraint file is
* greater than 256 bytes in length. If it is smaller than 256 bytes
* in length, this will be a placeholder page containing
* a simple message. If it is 256 bytes or larger, additional
* information will be provided. This information is determined at
* runtime.
*
* This class may be reused to implement a conditional property page.
* The getPageIndex() method tests the condition and returns the
* index of the page to create. The createPage*() methods are called
* upon to create the actual pages.
*/
public class ConstraintFilePropertyPage2 extends PropertyPage
{
/**
* Utility method that creates a new composite and
* sets up its layout data.
*
* @param parent the parent of the composite
* @param numColumns the number of columns in the new composite
* @return the newly-created composite
*/
protected Composite createComposite(Composite parent, int numColumns)
{
Composite composite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = numColumns;
composite.setLayout(layout);
GridData data = new GridData();
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
composite.setLayoutData(data);
return composite;
}
/** (non-Javadoc)
* Method declared on PreferencePage
*/
public Control createContents(Composite parent)
{
// ensure the page has no special buttons
noDefaultAndApplyButton();
Composite panel = createComposite(parent, 2);
WorkbenchHelp.setHelp(panel, IConstraintConstants.PROPERTY_PAGE2_CONTEXT);
// layout the page
int page = getPageIndex();
switch (page)
{
case 1 :
createPageOne(panel);
break;
case 2 :
createPageTwo(panel);
break;
default :
}
return new Canvas(panel, 0);
}
/**
* Utility method that creates a new label and sets up
* its layout data.
*
* @param parent the parent of the label
* @param text the text of the label
* @return the newly-created label
*/
protected Label createLabel(Composite parent, String text)
{
Label label = new Label(parent, SWT.LEFT);
label.setText(text);
GridData data = new GridData();
data.horizontalAlignment = GridData.FILL;
label.setLayoutData(data);
return label;
}
/**
* Creates the first version of the page. This is a placeholder page which
* notified the user that the page is not available.
*
* @param panel the panel in which to create the page
*/
protected void createPageOne(Composite panel)
{
Label l = createLabel(panel, MessageUtil.getString("Additional_Constraint_properties_not_available.")); //$NON-NLS-1$
GridData gd = (GridData) l.getLayoutData();
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
l = createLabel(panel, MessageUtil.getString("This_illustrates_a_property_page_that_is_dynamically_determined")); //$NON-NLS-1$
gd = (GridData) l.getLayoutData();
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
l = createLabel(panel, MessageUtil.getString("not_to_be_available_based_on_the_state_of_the_object.")); //$NON-NLS-1$
gd = (GridData) l.getLayoutData();
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
}
/**
* Creates the second version of the page. This page might contain more information
* about the file or other information.
*
* @param panel the panel in which to create the page
*/
protected void createPageTwo(Composite panel)
{
Label l = createLabel(panel, MessageUtil.getString("The_size_of_the_Constraint_file_is_at_least_256_bytes.")); //$NON-NLS-1$
GridData gd = (GridData) l.getLayoutData();
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
l = createLabel(panel, MessageUtil.getString("Had_it_been_less_than_256_bytes_this_page_would_be_a_placeholder_page.")); //$NON-NLS-1$
gd = (GridData) l.getLayoutData();
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
l = createLabel(panel, MessageUtil.getString("Additional_information")); //$NON-NLS-1$
gd = (GridData) l.getLayoutData();
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
l = createLabel(panel, MessageUtil.getString("This_illustrates_a_property_page_that_is_dynamically_determined")); //$NON-NLS-1$
gd = (GridData) l.getLayoutData();
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
l = createLabel(panel, MessageUtil.getString("to_be_available_based_on_the_state_of_the_object.")); //$NON-NLS-1$
gd = (GridData) l.getLayoutData();
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
}
/**
* Returns which page to display. This implementation
* answers 1 if the size of the Constraint file is less than 256 bytes
* and 2 otherwise.
*
* @return the index of the page to display
*/
protected int getPageIndex()
{
IResource resource = (IResource) getElement();
if (resource.getType() == IResource.FILE)
{
InputStream contentStream = null;
int length = 0;
try
{
IFile file = (IFile) resource;
if (file.isLocal(IResource.DEPTH_ZERO))
{
contentStream = file.getContents();
Reader in = new InputStreamReader(contentStream);
int chunkSize = contentStream.available();
StringBuffer buffer = new StringBuffer(chunkSize);
char[] readBuffer = new char[chunkSize];
int n = in.read(readBuffer);
while (n > 0)
{
buffer.append(readBuffer);
n = in.read(readBuffer);
}
contentStream.close();
length = buffer.length();
}
}
catch (CoreException e)
{
length = 0;
}
catch (IOException e)
{
}
finally
{
if (contentStream != null)
{
try
{
contentStream.close();
}
catch (IOException e)
{
}
}
}
if (length < 256)
return 1;
else
return 2;
}
return 0;
}
/** (non-Javadoc)
* Method declared on PreferencePage
*/
public boolean performOk()
{
// nothing to do - read-only page
return true;
}
}
/*
The Krysalis Patchy Software License, Version 1.1_01
Copyright (c) 2002-2003 Nicola Ken Barozzi. All rights reserved.
This Licence is compatible with the BSD licence as described and
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The end-user documentation included with the redistribution,
if any, must include the following acknowledgment:
"This product includes software developed for project
Krysalis (http://www.krysalis.org/)."
Alternately, this acknowledgment may appear in the software itself,
if and wherever such third-party acknowledgments normally appear.
4. The names "Krysalis" and "Nicola Ken Barozzi" and
"Krysalis Centipede" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact [email protected].
5. Products derived from this software may not be called "Krysalis",
"Krysalis Centipede", nor may "Krysalis" appear in their name,
without prior written permission of Nicola Ken Barozzi.
6. This software may contain voluntary contributions made by many
individuals, who decided to donate the code to this project in
respect of this licence.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE KRYSALIS PROJECT OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================*/
--- NEW FILE: ConstraintFilePropertyPage.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Patchy *
* Software License version 1.1_01, a copy of which has been included *
* at the bottom of this file. *
*****************************************************************************/
package org.krysalis.version.eclipse.plugin.wizard;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.dialogs.PropertyPage;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.internal.model.AdaptableList;
import org.krysalis.version.eclipse.plugin.model.ConstraintModelFactory;
import org.krysalis.version.eclipse.plugin.util.IConstraintConstants;
import org.krysalis.version.eclipse.plugin.util.MessageUtil;
/**
* This page will be added to the property page dialog
* when the "Properties..." popup menu item is selected
* for Constraint files.
*/
public class ConstraintFilePropertyPage extends PropertyPage
{
/**
* Utility method that creates a new composite and
* sets up its layout data.
*
* @param parent the parent of the composite
* @param numColumns the number of columns in the new composite
* @return the newly-created composite
*/
protected Composite createComposite(Composite parent, int numColumns)
{
Composite composite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = numColumns;
composite.setLayout(layout);
GridData data = new GridData();
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
composite.setLayoutData(data);
return composite;
}
/** (non-Javadoc)
* Method declared on PreferencePage
*/
public Control createContents(Composite parent)
{
// ensure the page has no special buttons
noDefaultAndApplyButton();
Composite panel = createComposite(parent, 2);
WorkbenchHelp.setHelp(panel, IConstraintConstants.PROPERTY_PAGE_CONTEXT);
// layout the page
IResource resource = (IResource) getElement();
IStatus result = null;
if (resource.getType() == IResource.FILE)
{
Label l = createLabel(panel, MessageUtil.getString("File_name")); //$NON-NLS-1$
l = createLabel(panel, resource.getName());
grabExcessSpace(l);
//
createLabel(panel, MessageUtil.getString("Path")); //$NON-NLS-1$
l = createLabel(panel, resource.getFullPath().setDevice(null).toString());
grabExcessSpace(l);
//
createLabel(panel, MessageUtil.getString("Size")); //$NON-NLS-1$
InputStream contentStream = null;
try
{
IFile file = (IFile) resource;
if (!file.isLocal(IResource.DEPTH_ZERO))
l = createLabel(panel, MessageUtil.getString("<file_contents_not_local>")); //$NON-NLS-1$
else
{
contentStream = file.getContents();
Reader in = new InputStreamReader(contentStream);
int chunkSize = contentStream.available();
StringBuffer buffer = new StringBuffer(chunkSize);
char[] readBuffer = new char[chunkSize];
int n = in.read(readBuffer);
while (n > 0)
{
buffer.append(readBuffer);
n = in.read(readBuffer);
}
contentStream.close();
l = createLabel(panel, Integer.toString(buffer.length()));
}
}
catch (CoreException e)
{
result = e.getStatus();
String message = result.getMessage();
if (message == null)
l = createLabel(panel, MessageUtil.getString("<Unknown>")); //$NON-NLS-1$
else
l = createLabel(panel, message);
}
catch (IOException e)
{
l = createLabel(panel, MessageUtil.getString("<Unknown>")); //$NON-NLS-1$
}
finally
{
if (contentStream != null)
{
try
{
contentStream.close();
}
catch (IOException e)
{
}
}
}
grabExcessSpace(l);
createLabel(panel, MessageUtil.getString("Number_of_sections")); //$NON-NLS-1$
// We will get the sections property and simply
// report number of elements found.
IAdaptable sections = getSections(resource);
if (sections instanceof AdaptableList)
{
AdaptableList list = (AdaptableList) sections;
l = createLabel(panel, String.valueOf(list.size()));
grabExcessSpace(l);
}
}
//
Label l = createLabel(panel, MessageUtil.getString("Additional_information")); //$NON-NLS-1$
grabExcessSpace(l);
GridData gd = (GridData) l.getLayoutData();
gd.horizontalSpan = 2;
return new Canvas(panel, 0);
}
/**
* Utility method that creates a new label and sets up its layout data.
*
* @param parent the parent of the label
* @param text the text of the label
* @return the newly-created label
*/
protected Label createLabel(Composite parent, String text)
{
Label label = new Label(parent, SWT.LEFT);
label.setText(text);
GridData data = new GridData();
data.horizontalAlignment = GridData.FILL;
label.setLayoutData(data);
return label;
}
/**
* Returns the Constraint sections for this resource, or null
* if not applicable (resource is not a Constraint file).
*/
private AdaptableList getSections(IAdaptable adaptable)
{
if (adaptable instanceof IFile)
return ConstraintModelFactory.getInstance().getSections((IFile) adaptable);
else
return null;
}
/**
* Sets this control to grab any excess horizontal space
* left in the window.
*
* @param control the control for which to grab excess space
*/
private void grabExcessSpace(Control control)
{
GridData gd = (GridData) control.getLayoutData();
if (gd != null)
{
gd.grabExcessHorizontalSpace = true;
}
}
/** (non-Javadoc)
* Method declared on PreferencePage
*/
public boolean performOk()
{
// nothing to do - read-only page
return true;
}
}
--- NEW FILE: ConstraintCreationWizard.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Patchy *
* Software License version 1.1_01, a copy of which has been included *
* at the bottom of this file. *
*****************************************************************************/
package org.krysalis.version.eclipse.plugin.wizard;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.krysalis.version.eclipse.plugin.util.ConstraintImages;
import org.krysalis.version.eclipse.plugin.util.MessageUtil;
/**
* This class implements the interface required by the desktop
* for all 'New' wizards. This wizard creates Constraint files.
*/
public class ConstraintCreationWizard extends Wizard implements INewWizard
{
private IStructuredSelection selection;
private IWorkbench workbench;
private ConstraintCreationPage mainPage;
/** (non-Javadoc)
* Method declared on Wizard.
*/
public void addPages()
{
mainPage = new ConstraintCreationPage(workbench, selection);
addPage(mainPage);
}
/** (non-Javadoc)
* Method declared on INewWizard
*/
public void init(IWorkbench workbench, IStructuredSelection selection)
{
this.workbench = workbench;
this.selection = selection;
setWindowTitle(MessageUtil.getString("New_Constraint_File")); //$NON-NLS-1$
setDefaultPageImageDescriptor(ConstraintImages.CONSTRAINT_WIZARD_BANNER);
}
/** (non-Javadoc)
* Method declared on IWizard
*/
public boolean performFinish()
{
return mainPage.finish();
}
}
/*
The Krysalis Patchy Software License, Version 1.1_01
Copyright (c) 2002-2003 Nicola Ken Barozzi. All rights reserved.
This Licence is compatible with the BSD licence as described and
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The end-user documentation included with the redistribution,
if any, must include the following acknowledgment:
"This product includes software developed for project
Krysalis (http://www.krysalis.org/)."
Alternately, this acknowledgment may appear in the software itself,
if and wherever such third-party acknowledgments normally appear.
4. The names "Krysalis" and "Nicola Ken Barozzi" and
"Krysalis Centipede" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact [email protected].
5. Products derived from this software may not be called "Krysalis",
"Krysalis Centipede", nor may "Krysalis" appear in their name,
without prior written permission of Nicola Ken Barozzi.
6. This software may contain voluntary contributions made by many
individuals, who decided to donate the code to this project in
respect of this licence.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE KRYSALIS PROJECT OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================*/
--- NEW FILE: SectionsDialog.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Patchy *
* Software License version 1.1_01, a copy of which has been included *
* at the bottom of this file. *
*****************************************************************************/
package org.krysalis.version.eclipse.plugin.wizard;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.krysalis.version.eclipse.plugin.util.IConstraintConstants;
import org.krysalis.version.eclipse.plugin.util.MessageUtil;
/**
* This dialog is an example of a detached window launched
* from an action in the desktop.
*/
public class SectionsDialog extends Dialog
{
protected IAdaptable input;
/**
* Creates a new SectionsDialog.
*/
public SectionsDialog(Shell parentShell, IAdaptable input)
{
super(parentShell);
this.input = input;
}
/* (non-Javadoc)
* Method declared on Window.
*/
protected void configureShell(Shell newShell)
{
super.configureShell(newShell);
newShell.setText(MessageUtil.getString("Constraint_Sections")); //$NON-NLS-1$
WorkbenchHelp.setHelp(newShell, IConstraintConstants.SECTIONS_DIALOG_CONTEXT);
}
/* (non-Javadoc)
* Method declared on Dialog
*/
protected Control createDialogArea(Composite parent)
{
Composite composite = (Composite) super.createDialogArea(parent);
List list = new List(composite, SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
list.setLayoutData(data);
ListViewer viewer = new ListViewer(list);
viewer.setContentProvider(new WorkbenchContentProvider());
viewer.setLabelProvider(new WorkbenchLabelProvider());
viewer.setInput(input);
return composite;
}
}
/*
The Krysalis Patchy Software License, Version 1.1_01
Copyright (c) 2002-2003 Nicola Ken Barozzi. All rights reserved.
This Licence is compatible with the BSD licence as described and
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The end-user documentation included with the redistribution,
if any, must include the following acknowledgment:
"This product includes software developed for project
Krysalis (http://www.krysalis.org/)."
Alternately, this acknowledgment may appear in the software itself,
if and wherever such third-party acknowledgments normally appear.
4. The names "Krysalis" and "Nicola Ken Barozzi" and
"Krysalis Centipede" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact [email protected].
5. Products derived from this software may not be called "Krysalis",
"Krysalis Centipede", nor may "Krysalis" appear in their name,
without prior written permission of Nicola Ken Barozzi.
6. This software may contain voluntary contributions made by many
individuals, who decided to donate the code to this project in
respect of this licence.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE KRYSALIS PROJECT OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================*/
-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open!
Get cracking and register here for some mind boggling fun and
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en