krysalis-version/src/java/org/krysalis/version/eclipse/plugin/actions PopupMenuActionDelegate.java,NONE,1.1 ViewActionDelegate.java,NONE,1.1 EditorActionDelegate.java,NONE,1.1 ConstraintEditorActionBarContributor.java,NONE,1.1 AddConstraintMarkerAction.java,NONE,1.1 ConstraintDropActionDelegate.java,NONE,1.1 WindowActionDelegate.java,NONE,1.1
[email protected] Fri, 21 Mar 2003 15:33:01 -0800
| Newsgroups | gmane.comp.krysalis.sandbox |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/eclipse/plugin/actions
In directory sc8-pr-cvs1:/tmp/cvs-serv22996/src/java/org/krysalis/version/eclipse/plugin/actions
Added Files:
PopupMenuActionDelegate.java ViewActionDelegate.java
EditorActionDelegate.java
ConstraintEditorActionBarContributor.java
AddConstraintMarkerAction.java
ConstraintDropActionDelegate.java WindowActionDelegate.java
Log Message:
Constraint changes
--- NEW FILE: PopupMenuActionDelegate.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.actions;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.krysalis.version.eclipse.plugin.util.MessageUtil;
/**
* Action delegate for handling popup menu actions on a constraint file.
*/
public class PopupMenuActionDelegate implements IObjectActionDelegate
{
private IWorkbenchPart part;
/** (non-Javadoc)
* Method declared on IDropActionDelegate
*/
public void run(IAction action)
{
MessageDialog.openInformation(this.part.getSite().getShell(), MessageUtil.getString("Constraint_Example"), //$NON-NLS-1$
MessageUtil.getString("Popup_Menu_Action_executed")); //$NON-NLS-1$
}
/** (non-Javadoc)
* Method declared on IActionDelegate
*/
public void selectionChanged(IAction action, ISelection selection)
{
//Ignored for this example
}
/** (non-Javadoc)
* Method declared on IObjectActionDelegate
*/
public void setActivePart(IAction action, IWorkbenchPart targetPart)
{
this.part = targetPart;
}
}
/*
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: ViewActionDelegate.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.actions;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.krysalis.version.eclipse.plugin.util.MessageUtil;
/**
* This class is used to demonstrate view action extensions.
* An extension should be defined in the constraint plugin.xml.
*/
public class ViewActionDelegate implements IViewActionDelegate
{
public IViewPart view;
/**
* Creates a new ViewActionDelegate.
*/
public ViewActionDelegate()
{
super();
}
/* (non-Javadoc)
* Method declared on IViewActionDelegate
*/
public void init(IViewPart view)
{
this.view = view;
}
/* (non-Javadoc)
* Method declared on IActionDelegate
*/
public void run(org.eclipse.jface.action.IAction action)
{
MessageDialog.openInformation(view.getSite().getShell(), MessageUtil.getString("Constraint_Editor"), //$NON-NLS-1$
MessageUtil.getString("View_Action_executed")); //$NON-NLS-1$
}
/* (non-Javadoc)
* Method declared on IActionDelegate
*/
public void selectionChanged(
org.eclipse.jface.action.IAction action,
org.eclipse.jface.viewers.ISelection selection)
{
}
}
/*
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: EditorActionDelegate.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.actions;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorActionDelegate;
import org.eclipse.ui.IEditorPart;
import org.krysalis.version.eclipse.plugin.util.MessageUtil;
/**
* This class is used to demonstrate editor action extensions.
* An extension should be defined in the constraint plugin.xml.
*/
public class EditorActionDelegate implements IEditorActionDelegate
{
private IEditorPart editor;
/**
* Creates a new EditorActionDelegate.
*/
public EditorActionDelegate()
{
}
/* (non-Javadoc)
* Method declared on IActionDelegate
*/
public void run(IAction action)
{
MessageDialog.openInformation(editor.getSite().getShell(), MessageUtil.getString("Constraint_Editor"), //$NON-NLS-1$
MessageUtil.getString("Editor_Action_executed")); //$NON-NLS-1$
}
/**
* The <code>EditorActionDelegate</code> implementation of this
* <code>IActionDelegate</code> method
*
* Selection in the desktop has changed. Plugin provider
* can use it to change the availability of the action
* or to modify other presentation properties.
*
* <p>Action delegate cannot be notified about
* selection changes before it is loaded. For that reason,
* control of action's enable state should also be performed
* through simple XML rules defined for the extension
* point. These rules allow enable state control before
* the delegate has been loaded.</p>
*/
public void selectionChanged(IAction action, ISelection selection)
{
}
/**
* The <code>EditorActionDelegate</code> implementation of this
* <code>IEditorActionDelegate</code> method
*
* The matching editor has been activated. Notification
* guarantees that only editors that match the type for which
* this action has been registered will be tracked.
*
* @param action action proxy that represents this delegate in the desktop
* @param editor the matching editor that has been activated
*/
public void setActiveEditor(IAction action, IEditorPart editor)
{
this.editor = editor;
}
}
/*
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: ConstraintEditorActionBarContributor.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.actions;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.actions.LabelRetargetAction;
import org.eclipse.ui.actions.RetargetAction;
import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
import org.krysalis.version.eclipse.plugin.property.DirtyStateContribution;
import org.krysalis.version.eclipse.plugin.util.MessageUtil;
/**
* This class demonstrates action contribution for the constraint editor.
* A number of menu, toolbar, and status line contributions are defined
* in the workbench window. These actions are shared among all
* constraint editors, and are only visible when a constraint editor is
* active. Otherwise, they are invisible.
*/
public class ConstraintEditorActionBarContributor extends BasicTextEditorActionContributor
{
private EditorAction action1;
private RetargetAction action2;
private LabelRetargetAction action3;
private EditorAction handler2;
private EditorAction handler3;
private EditorAction handler4;
private EditorAction handler5;
private DirtyStateContribution dirtyStateContribution;
class EditorAction extends Action
{
private Shell shell;
private IEditorPart activeEditor;
public EditorAction(String label)
{
super(label);
}
public void setShell(Shell shell)
{
this.shell = shell;
}
public void run()
{
String editorName = MessageUtil.getString("Empty_Editor_Name"); //$NON-NLS-1$
if (activeEditor != null)
editorName = activeEditor.getTitle();
MessageDialog.openInformation(shell, MessageUtil.getString("Constraint_Editor"), //$NON-NLS-1$
MessageUtil.format("ConstraintEditorActionExecuted", new Object[] { getText(), editorName })); //$NON-NLS-1$
}
public void setActiveEditor(IEditorPart part)
{
activeEditor = part;
}
}
/**
* Creates a new ConstraintEditorActionBarContributor.
*/
public ConstraintEditorActionBarContributor()
{
/*ImageRegistry registry = VersionPlugin.getDefault().getImageRegistry();
action1 = new EditorAction(MessageUtil.getString("Editor_Action1")); //$NON-NLS-1$
action1.setToolTipText(MessageUtil.getString("Constraint_Editor_Action1")); //$NON-NLS-1$
action1.setDisabledImageDescriptor(ConstraintImages.EDITOR_ACTION1_IMAGE_DISABLE);
action1.setImageDescriptor(ConstraintImages.EDITOR_ACTION1_IMAGE_ENABLE);
action1.setHoverImageDescriptor(ConstraintImages.EDITOR_ACTION1_IMAGE);
WorkbenchHelp.setHelp(action1, IConstraintConstants.EDITOR_ACTION1_CONTEXT);
action2 = new RetargetAction(IConstraintConstants.RETARGET2, MessageUtil.getString("Editor_Action2")); //$NON-NLS-1$
action2.setToolTipText(MessageUtil.getString("Constraint_Editor_Action2")); //$NON-NLS-1$
action2.setDisabledImageDescriptor(ConstraintImages.EDITOR_ACTION2_IMAGE_DISABLE);
action2.setImageDescriptor(ConstraintImages.EDITOR_ACTION2_IMAGE_ENABLE);
action2.setHoverImageDescriptor(ConstraintImages.EDITOR_ACTION2_IMAGE);
action3 = new LabelRetargetAction(IConstraintConstants.LABELRETARGET3, MessageUtil.getString("Editor_Action3")); //$NON-NLS-1$
action3.setDisabledImageDescriptor(ConstraintImages.EDITOR_ACTION3_IMAGE_DISABLE);
action3.setImageDescriptor(ConstraintImages.EDITOR_ACTION3_IMAGE_ENABLE);
action3.setHoverImageDescriptor(ConstraintImages.EDITOR_ACTION3_IMAGE);
handler2 = new EditorAction(MessageUtil.getString("Editor_Action2")); //$NON-NLS-1$
WorkbenchHelp.setHelp(action2, IConstraintConstants.EDITOR_ACTION2_CONTEXT);
handler3 = new EditorAction(MessageUtil.getString("Editor_Action3")); //$NON-NLS-1$
handler3.setToolTipText(MessageUtil.getString("Constraint_Editor_Action3")); //$NON-NLS-1$
WorkbenchHelp.setHelp(action3, IConstraintConstants.EDITOR_ACTION3_CONTEXT);
handler4 = new EditorAction(MessageUtil.getString("Editor_Action4")); //$NON-NLS-1$
handler5 = new EditorAction(MessageUtil.getString("Editor_Action5")); //$NON-NLS-1$
handler5.setToolTipText(MessageUtil.getString("Constraint_Editor_Action5")); //$NON-NLS-1$
*/
dirtyStateContribution = new DirtyStateContribution();
}
/** (non-Javadoc)
* Method declared on EditorActionBarContributor
*/
public void contributeToMenu(IMenuManager menuManager)
{
// Run super.
super.contributeToMenu(menuManager);
// Editor-specitic menu
MenuManager constraintMenu = new MenuManager(MessageUtil.getString("Constraint_Menu")); //$NON-NLS-1$
// It is important to append the menu to the
// group "additions". This group is created
// between "Project" and "Tools" menus
// for this purpose.
/*menuManager.insertAfter("additions", constraintMenu); //$NON-NLS-1$
constraintMenu.add(action1);
constraintMenu.add(action2);
constraintMenu.add(action3);*/
}
/** (non-Javadoc)
* Method declared on EditorActionBarContributor
*/
public void contributeToStatusLine(IStatusLineManager statusLineManager)
{
// Run super.
super.contributeToStatusLine(statusLineManager);
// Test status line.
statusLineManager.setMessage(MessageUtil.getString("Editor_is_active")); //$NON-NLS-1$
statusLineManager.add(dirtyStateContribution);
}
/** (non-Javadoc)
* Method declared on EditorActionBarContributor
*/
public void contributeToToolBar(IToolBarManager toolBarManager)
{
// Run super.
super.contributeToToolBar(toolBarManager);
// Add toolbar stuff.
/*toolBarManager.add(new Separator("ConstraintEditor")); //$NON-NLS-1$
toolBarManager.add(action1);
toolBarManager.add(action2);
toolBarManager.add(action3);*/
}
/** (non-Javadoc)
* Method declared on IEditorActionBarContributor
*/
public void dispose()
{
// Remove retarget actions as page listeners
//getPage().removePartListener(action2);
//getPage().removePartListener(action3);
}
/** (non-Javadoc)
* Method declared on IEditorActionBarContributor
*/
public void init(IActionBars bars, IWorkbenchPage page)
{
super.init(bars, page);
/*bars.setGlobalActionHandler(IConstraintConstants.RETARGET2, handler2);
bars.setGlobalActionHandler(IConstraintConstants.LABELRETARGET3, handler3);
bars.setGlobalActionHandler(IConstraintConstants.ACTION_SET_RETARGET4, handler4);
bars.setGlobalActionHandler(IConstraintConstants.ACTION_SET_LABELRETARGET5, handler5);
// Hook retarget actions as page listeners
page.addPartListener(action2);
page.addPartListener(action3);
IWorkbenchPart activePart = page.getActivePart();
if (activePart != null)
{
action2.partActivated(activePart);
action3.partActivated(activePart);
}*/
}
/** (non-Javadoc)
* Method declared on IEditorActionBarContributor
*/
public void setActiveEditor(IEditorPart editor)
{
// Run super.
super.setActiveEditor(editor);
// Target shared actions to new editor
/*action1.setActiveEditor(editor);
handler2.setActiveEditor(editor);
handler3.setActiveEditor(editor);
handler4.setActiveEditor(editor);
handler5.setActiveEditor(editor);*/
dirtyStateContribution.editorChanged(editor);
}
}
/*
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: AddConstraintMarkerAction.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.actions;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.MarkerUtilities;
import org.krysalis.version.eclipse.plugin.util.MessageUtil;
/**
* Action for creating a Constraint marker with a specfic id
* attribute value.
*/
public class AddConstraintMarkerAction extends Action {
private ITextEditor textEditor;
private Object[][] customAttributes;
private String message;
private final static String MARKER_TYPE = "org.krysalis.version.eclipse.plugin.constraintmarker"; //$NON-NLS-1$
/**
* Creates a new action for the given text editor.
*
* @param editor the text editor
* @param label the label for the action
* @param attributes the custom attributes for this marker
* @param message the message for the marker
*/
public AddConstraintMarkerAction(ITextEditor editor, String label, Object[][] attributes, String message) {
textEditor = editor;
setText(label);
this.customAttributes = attributes;
this.message = message;
}
/*
* @see IAction#run()
*/
public void run() {
Map attributes= new HashMap(11);
ITextSelection selection= (ITextSelection) textEditor.getSelectionProvider().getSelection();
if (!selection.isEmpty()) {
int start= selection.getOffset();
int length= selection.getLength();
if (length < 0) {
length= -length;
start -= length;
}
MarkerUtilities.setCharStart(attributes, start);
MarkerUtilities.setCharEnd(attributes, start + length);
// marker line numbers are 1-based
int line= selection.getStartLine();
MarkerUtilities.setLineNumber(attributes, line == -1 ? -1 : line + 1);
// set custom attribute values
for (int i = 0; i < customAttributes.length; i++) {
attributes.put(customAttributes[i][0], customAttributes[i][1]);
}
MarkerUtilities.setMessage(attributes, message);
}
try {
MarkerUtilities.createMarker(getResource(), attributes, MARKER_TYPE);
} catch (CoreException x) {
Platform.getPlugin(PlatformUI.PLUGIN_ID).getLog().log(x.getStatus());
Shell shell= textEditor.getSite().getShell();
String title= MessageUtil.getString("Add_constraint_marker_error_title"); //$NON-NLS-1$
String msg= MessageUtil.getString("Add_constraint_marker_error_message"); //$NON-NLS-1$
ErrorDialog.openError(shell, title, msg, x.getStatus());
}
}
/**
* Returns the resource on which to create the marker,
* or <code>null</code> if there is no applicable resource. This
* queries the editor's input using <code>getAdapter(IResource.class)</code>.
*
* @return the resource to which to attach the newly created marker
*/
protected IResource getResource() {
IEditorInput input= textEditor.getEditorInput();
return (IResource) ((IAdaptable) input).getAdapter(IResource.class);
}
}
/*
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: ConstraintDropActionDelegate.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.actions;
import java.io.ByteArrayInputStream;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.part.IDropActionDelegate;
import org.krysalis.version.eclipse.plugin.util.MessageUtil;
/**
* Adapter for handling the dropping of constraint segments into
* another plugin. In this case, we expect the segments
* to be dropped onto <code>IFile</code> object, or an adapter
* that supports <code>IFile</code>.
*/
public class ConstraintDropActionDelegate implements IDropActionDelegate
{
public static final String ID = "org_krysalis_version_eclipse_plugin_constraint_drop_actions"; //$NON-NLS-1$
/** (non-Javadoc)
* Method declared on IDropActionDelegate
*/
public boolean run(Object source, Object target)
{
if (source instanceof byte[] && target instanceof IFile)
{
IFile file = (IFile) target;
try
{
file.appendContents(new ByteArrayInputStream((byte[]) source), false, true, null);
}
catch (CoreException e)
{
System.out.println(MessageUtil.getString("Exception_in_constraint_drop_adapter") + e.getStatus().getMessage()); //$NON-NLS-1$
return false;
}
return true;
}
return false;
}
}
/*
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: WindowActionDelegate.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.actions;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.krysalis.version.eclipse.plugin.model.ConstraintModelFactory;
import org.krysalis.version.eclipse.plugin.wizard.SectionsDialog;
/**
* This class shows how <code>IActionDelegate</code> implementations
* should be used for global action registration for menu
* and tool bars. Action proxy object is created in the
* desktop based on presentation information in the plugin.xml
* file. Delegate is not loaded until the first time the user
* presses the button or selects the menu. Based on the action
* availability, it is possible that the button will disable
* instead of executing.
*/
public class WindowActionDelegate implements IWorkbenchWindowActionDelegate
{
private IWorkbenchWindow window;
private ISelection selection;
/* (non-Javadoc)
* Method declared on IWorkbenchActionDelegate
*/
public void dispose()
{
}
/* (non-Javadoc)
* Method declared on IWorkbenchActionDelegate
*/
public void init(IWorkbenchWindow window)
{
this.window = window;
}
/**
* The <code>WindowActionDelegate</code> implementation of this
* <code>IActionDelegate</code> method
* launches a stand-alone dialog that contains a list of sections for
* the selected Constraint file in the navigator.
*/
public void run(IAction action)
{
SectionsDialog dialog =
new SectionsDialog(window.getShell(), ConstraintModelFactory.getInstance().getSections(selection));
dialog.open();
}
/**
* The <code>WindowActionDelegate</code> implementation of this
* <code>IActionDelegate</code> method
* does nothing - we will let simple rules in the XML
* config file react to selections.
*/
public void selectionChanged(IAction action, ISelection selection)
{
this.selection = selection;
}
}
/*
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