1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

[260771] - applying patch for drag and drop for make targets

This commit is contained in:
Alena Laskavaia 2009-01-29 18:46:54 +00:00
parent 1117c603d8
commit 571a64414d
21 changed files with 2784 additions and 21 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>

View file

@ -1,7 +1,81 @@
#Thu Nov 20 12:37:55 CET 2008
#Sat Jan 10 18:14:54 EST 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.source=1.3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
#org.eclipse.jdt.core.compiler.problem.discouragedReference=error
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
org.eclipse.jdt.core.compiler.problem.nullReference=error
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.5

View file

@ -0,0 +1,172 @@
#Thu Jan 08 10:49:09 CET 2009
ANNOTATION_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error
ANNOTATION_ELEMENT_TYPE_ADDED_FIELD=Error
ANNOTATION_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error
ANNOTATION_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error
ANNOTATION_ELEMENT_TYPE_ADDED_METHOD=Error
ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error
ANNOTATION_ELEMENT_TYPE_ADDED_TYPE_MEMBER=Error
ANNOTATION_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
ANNOTATION_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error
ANNOTATION_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
ANNOTATION_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error
ANNOTATION_ELEMENT_TYPE_CHANGED_INTERFACE_BOUNDS=Error
ANNOTATION_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error
ANNOTATION_ELEMENT_TYPE_CHANGED_TO_CLASS=Error
ANNOTATION_ELEMENT_TYPE_CHANGED_TO_ENUM=Error
ANNOTATION_ELEMENT_TYPE_CHANGED_TO_INTERFACE=Error
ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
ANNOTATION_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error
ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error
ANNOTATION_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error
ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error
ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD_WITHOUT_DEFAULT_VALUE=Error
ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD_WITH_DEFAULT_VALUE=Error
ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error
API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error
API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error
CLASS_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error
CLASS_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error
CLASS_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error
CLASS_ELEMENT_TYPE_ADDED_METHOD=Error
CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
CLASS_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error
CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERCLASS_SET=Error
CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
CLASS_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error
CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error
CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
CLASS_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error
CLASS_ELEMENT_TYPE_CHANGED_SUPERCLASS=Error
CLASS_ELEMENT_TYPE_CHANGED_TO_ANNOTATION=Error
CLASS_ELEMENT_TYPE_CHANGED_TO_ENUM=Error
CLASS_ELEMENT_TYPE_CHANGED_TO_INTERFACE=Error
CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
CLASS_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error
CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error
CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error
CLASS_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error
CLASS_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error
CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error
CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error
CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error
CONSTRUCTOR_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error
CONSTRUCTOR_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error
CONSTRUCTOR_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error
CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
CONSTRUCTOR_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error
CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
CONSTRUCTOR_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error
CONSTRUCTOR_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error
CONSTRUCTOR_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
CONSTRUCTOR_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error
CONSTRUCTOR_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error
CONSTRUCTOR_ELEMENT_TYPE_CHANGED_TYPE_PARAMETER=Error
CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error
CONSTRUCTOR_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error
CONSTRUCTOR_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error
CONSTRUCTOR_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error
CONSTRUCTOR_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error
CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error
ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
ENUM_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error
ENUM_ELEMENT_TYPE_CHANGED_TO_ANNOTATION=Error
ENUM_ELEMENT_TYPE_CHANGED_TO_CLASS=Error
ENUM_ELEMENT_TYPE_CHANGED_TO_INTERFACE=Error
ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error
ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error
ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error
ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
FIELD_ELEMENT_TYPE_ADDED_VALUE=Error
FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error
FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error
FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error
FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error
FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error
FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error
FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENTS=Error
FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error
ILLEGAL_EXTEND=Warning
ILLEGAL_IMPLEMENT=Warning
ILLEGAL_INSTANTIATE=Warning
ILLEGAL_OVERRIDE=Warning
ILLEGAL_REFERENCE=Warning
INTERFACE_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error
INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error
INTERFACE_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error
INTERFACE_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error
INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error
INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error
INTERFACE_ELEMENT_TYPE_ADDED_TYPE_MEMBER=Error
INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETERS=Error
INTERFACE_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error
INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
INTERFACE_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error
INTERFACE_ELEMENT_TYPE_CHANGED_INTERFACE_BOUNDS=Error
INTERFACE_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error
INTERFACE_ELEMENT_TYPE_CHANGED_TO_ANNOTATION=Error
INTERFACE_ELEMENT_TYPE_CHANGED_TO_CLASS=Error
INTERFACE_ELEMENT_TYPE_CHANGED_TO_ENUM=Error
INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
INTERFACE_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error
INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error
INTERFACE_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error
INTERFACE_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error
INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error
INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
INVALID_JAVADOC_TAG=Warning
INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Warning
LEAK_EXTEND=Warning
LEAK_FIELD_DECL=Warning
LEAK_IMPLEMENT=Warning
LEAK_METHOD_PARAM=Warning
LEAK_METHOD_RETURN_TYPE=Warning
METHOD_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error
METHOD_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error
METHOD_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error
METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
METHOD_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error
METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
METHOD_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error
METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error
METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error
METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error
METHOD_ELEMENT_TYPE_CHANGED_TYPE_PARAMETER=Error
METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error
METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error
METHOD_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error
METHOD_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error
METHOD_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error
METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error
TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error
TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error
TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error
TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error
TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error
TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error
UNUSED_PROBLEM_FILTERS=Warning
eclipse.preferences.version=1
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
invalid_since_tag_version=Error
malformed_since_tag=Error
missing_since_tag=Error
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning

View file

@ -37,4 +37,4 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.compare;bundle-version="[3.3.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="1.2.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Bundle-RequiredExecutionEnvironment: J2SE-1.5

View file

@ -82,7 +82,7 @@ Includes.tooltip=Includes list
Symbols=Symbols
Symbols.tooltip=Macros list
# menu label
Make.targets.menu=Make targets
Make.targets.menu=Make Targets
# Makefile compare font
makeCompareFontDefinition.label= Makefile compare text font

View file

@ -142,6 +142,22 @@ MakeTargetDialog.button.create=Create
MakeTargetDialog.exception.makeTargetError=Make Target Error
MakeTargetDialog.exception.errorAddingTarget=Error adding target
MakeTargetDnD.moving=Moving make targets to
MakeTargetDnD.moving.one=Moving target
MakeTargetDnD.copying=Copying make targets to
MakeTargetDnD.copying.one=Copying target
MakeTargetDnD.deleting=Deleting make targets
MakeTargetDnD.deleting.one=Deleting target
MakeTargetDnD.title.createInfo=Create Make Target Information
MakeTargetDnD.message.createNonFileTargetAttempt=Attempt to create non-file targets will be ignored. Only file selection is supported by this operation.
MakeTargetDnD.title.createError=Create Make Target Error
MakeTargetDnD.message.createError=There were errors creating make targets in Make Target View. See log for more details.
MakeTargetDnD.title.createFromTextConfirm=Confirm Creating Make Targets
MakeTargetDnD.message.createFromTextConfirm=Do you really want to create multiple make targets ({0}) from the multiline text?\n\n
MakeTargetDnD.title.overwriteTargetConfirm=Confirm Overwriting Make Target
MakeTargetDnD.message.overwriteTargetConfirm=Make Target "{0}" exists in this folder. Do you want to overwrite it?
SettingsBlock.title.selectLocationToBuildFrom=Selection Location to build from.
SettingsBlock.label.missingBuilderInformation=Builder is missing or disabled on project.
SettingsBlock.monitor.applyingSettings=Applying Settings...
@ -169,6 +185,14 @@ AddTargetAction.tooltip=Add Make Target
AddTargetAction.exception.internalError=Internal Error
AddTargetAction.=Internal Error
CopyTargetAction.label=&Copy Target
CopyTargetAction.tooltip=Copy Make Target
CopyTargetAction.title.clipboardProblem=Problem Copying to Clipboard
CopyTargetAction.message.clipboardProblem=There was a problem when accessing the system clipboard.
PasteTargetAction.label=&Paste Target
PasteTargetAction.tooltip=Paste Make Target
FilterEmptyFolderAction.label=Hide Empty Folders
FilterEmptyFolderAction.tooltip=Hide Empty Folders

View file

@ -0,0 +1,262 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.dnd;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.core.resources.IContainer;
import org.eclipse.jface.util.TransferDropTargetListener;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.DropTargetListener;
import org.eclipse.swt.dnd.TransferData;
/**
* This abstract class provides a frame for {@link DropTargetListener} able to accept a
* drop into a container area. A container area includes the container itself and
* the items directly belonging to the container. A drop into the container area is
* treated as a drop on the container itself. Also, some flexibility for adjusting
* drop operation is provided.
*
* @see org.eclipse.swt.dnd.DropTargetListener
*
*/
public abstract class AbstractContainerAreaDropAdapter implements TransferDropTargetListener {
private int originallyRequestedOperation = DND.DROP_NONE;
private IContainer lastDragOverContainer = null;
private int lastDragOverOperation = DND.DROP_NONE;
/**
* This method lets changing initial drag operation. The operation will be
* indicated by mouse cursor. This operation is passed in {@code event.detail}
* to {@code dragEnter} method.
*
* @param operation - incoming operation.
* @return changed operation. The return must be one of
* {@link org.eclipse.swt.dnd.DND} operations.
*
* @see DropTargetListener#dragEnter(DropTargetEvent)
* @see DND#DROP_NONE
* @see DND#DROP_COPY
* @see DND#DROP_MOVE
* @see DND#DROP_LINK
* @see DND#DROP_DEFAULT
*/
protected abstract int dragEnterOperation(int operation);
/**
* This method lets adjust drag operation over container area. The operation
* will be indicated by mouse cursor. This operation is passed in {@code
* event.detail} to {@code dragOver} method.
*
* @param operation - incoming operation.
* @param dropContainer - container where drop is going to be.
* @return changed operation. The return must be one of
* {@link org.eclipse.swt.dnd.DND} operations.
*
*
* @see DropTargetListener#dragOver(DropTargetEvent)
* @see DND#DROP_NONE
* @see DND#DROP_COPY
* @see DND#DROP_MOVE
* @see DND#DROP_LINK
* @see DND#DROP_DEFAULT
*/
protected abstract int dragOverOperation(int operation, IContainer dropContainer);
/**
* Implementation of the actual drop of {@code dropObject} to {@code dropContainer}.
*
* @param dropObject - object to drop.
* @param dropContainer - container where to drop the object.
* @param operation - drop operation.
*
* @see DropTargetListener#drop(DropTargetEvent)
*/
protected abstract void dropToContainer(Object dropObject, IContainer dropContainer,
int operation);
/**
* Defines if a transfer data is supported by the implementer.
*
* @see org.eclipse.swt.dnd.Transfer#isSupportedType
*
* @param transferData - data type to examine
* @return whether the given data type is supported by this listener
*/
public boolean isSupportedType(TransferData transferData) {
return getTransfer().isSupportedType(transferData);
}
/**
* This function is called only the listener is able to handle provided data type.
* By default {@code isEnabled} returns {@code true} but subclasses are free to
* override.
*
* @param event - the information associated with the drag event.
* @return {@code true}
*
* @see DropTargetEvent
*/
public boolean isEnabled(DropTargetEvent event) {
return true;
}
/**
* Implementation of {@code DropTargetListener#dragEnter} to support
* dropping into container area.
*
* @param event - the information associated with the drag event
*
* @see DropTargetEvent
*/
public void dragEnter(DropTargetEvent event) {
lastDragOverContainer = null;
lastDragOverOperation = DND.DROP_NONE;
if (isSupportedType(event.currentDataType)) {
originallyRequestedOperation = event.detail;
event.detail = dragEnterOperation(originallyRequestedOperation);
} else {
event.detail = DND.DROP_NONE;
originallyRequestedOperation = DND.DROP_NONE;
}
}
/**
* Implementation of {@code DropTargetListener#dragOperationChanged} to support
* dropping into container area.
*
* @param event - the information associated with the drag event
*
* @see DropTargetEvent
*/
public void dragOperationChanged(DropTargetEvent event) {
originallyRequestedOperation = event.detail;
event.detail = dragOverOperationCached(originallyRequestedOperation,
determineDropContainer(event));
}
/**
* Implementation of {@code DropTargetListener#dragOver} to support
* dropping into container area.
*
* @param event - the information associated with the drag event
*
* @see DropTargetEvent
*/
public void dragOver(DropTargetEvent event) {
event.detail = dragOverOperationCached(originallyRequestedOperation,
determineDropContainer(event));
if (originallyRequestedOperation != DND.DROP_NONE) {
// let user discover items even if event.detail is DND.DROP_NONE
// since the original operation could be applicable to other items
event.feedback = DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
if (event.detail != DND.DROP_NONE) {
event.feedback = event.feedback | DND.FEEDBACK_SELECT;
}
} else {
event.feedback = DND.FEEDBACK_NONE;
}
}
/**
* Implementation of {@code DropTargetListener#dragLeave} to support
* dropping into container area.
*
* @param event - the information associated with the drag event
*
* @see DropTargetEvent
*/
public void dragLeave(DropTargetEvent event) {
// no action
}
/**
* Implementation of {@code DropTargetListener#dropAccept} to support
* dropping into container area.
*
* @param event - the information associated with the drag event
*
* @see DropTargetEvent
*/
public void dropAccept(DropTargetEvent event) {
// no action
}
/**
* Implementation of {@code DropTargetListener#drop} to support
* dropping into container area.
*
* @param event - the information associated with the drag event
*
* @see DropTargetEvent
*/
public void drop(DropTargetEvent event) {
IContainer dropContainer = determineDropContainer(event);
if (dropContainer != null) {
event.detail = dragOverOperationCached(event.detail, dropContainer);
dropToContainer(event.data, dropContainer, event.detail);
} else {
event.detail = DND.DROP_NONE;
}
}
/**
* This method provides caching of potentially long running and called on each
* mouse move {@link dragOverOperation}.
*
* @param operation - incoming operation.
* @param dropContainer - container where drop is going to be.
* @return changed operation. The return must be one of
* org.eclipse.swt.dnd.DND operations such as {@link DND#DROP_NONE},
* {@link DND#DROP_COPY}, {@link DND#DROP_MOVE},
* {@link DND#DROP_LINK}
*
*
* @see DropTargetListener#dragOver(DropTargetEvent)
*/
private int dragOverOperationCached(int operation, IContainer dropContainer) {
if (dropContainer != lastDragOverContainer || operation != lastDragOverOperation) {
lastDragOverOperation = dragOverOperation(operation, dropContainer);
lastDragOverContainer = dropContainer;
}
return lastDragOverOperation;
}
/**
* Returns the drop target passed by {@code event.item}.
*
* @param event - the information associated with the drop event
*/
private static Object determineDropTarget(DropTargetEvent event) {
return event.item == null ? null : event.item.getData();
}
/**
* Find which container area the mouse cursor is currently in.
*
* @param event - the information associated with the drop event
* @return the container of the current mouse location.
*/
public static IContainer determineDropContainer(DropTargetEvent event) {
Object dropTarget = determineDropTarget(event);
if (dropTarget instanceof IMakeTarget) {
return ((IMakeTarget) dropTarget).getContainer();
} else if (dropTarget instanceof IContainer) {
return (IContainer) dropTarget;
}
return null;
}
}

View file

@ -0,0 +1,129 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.dnd;
import org.eclipse.jface.util.TransferDragSourceListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.TransferData;
/**
* This abstract class provides a convenience frame for DragSourceListener to support
* dragging of selected items in a view.
* <p>
* There is similar implementation in plugin {@code org.eclipse.cdt.ui} -
* {@code org.eclipse.cdt.internal.ui.dnd.BasicSelectionTransferDragAdapter}.
*
* @see org.eclipse.swt.dnd.DropTargetListener
*
*/
public abstract class AbstractSelectionDragAdapter implements TransferDragSourceListener {
private final ISelectionProvider fProvider;
/**
* Constructor setting selection provider.
* @param provider - selection provider.
*/
public AbstractSelectionDragAdapter(ISelectionProvider provider) {
fProvider= provider;
}
/**
* Checks if the elements contained in the given selection can be dragged.
* If {@code false} {@link #dragStart} method won't initiate the drag.
*
* @param selection - the selected elements to be dragged.
* @return {@code true} if the selection can be dragged.
*/
protected abstract boolean isDragable(ISelection selection);
/**
* A custom action executed during drag initialization. Executed from
* {@link #dragStart}.
*
* @param selection - the selected elements to be dragged.
*/
protected abstract void dragInit(ISelection selection);
/**
* Prepare the selection to be passed via {@code Transfer} agent. Used by
* {@link #dragSetData}.
*
* @param selection - the selected elements to be dragged.
* @return data to be passed. Can be any type the specific transfer supports.
*/
protected abstract Object prepareDataForTransfer(ISelection selection);
/**
* A custom action to gracefully finish the drag. Executed by {@link #dragFinished}.
*/
protected abstract void dragDone();
/**
* Defines if a transfer data is supported by the implementer.
*
* @see org.eclipse.swt.dnd.Transfer#isSupportedType
*
* @param transferData - data type to examine
* @return {@code true} if the given data type is supported by this listener
*/
public boolean isSupportedType(TransferData transferData) {
return getTransfer().isSupportedType(transferData);
}
/**
* Start of the action to drag the widget.
*
* @see org.eclipse.swt.dnd.DragSourceListener#dragStart
*
* @param event the information associated with the drag event
*/
public void dragStart(DragSourceEvent event) {
ISelection selection= fProvider.getSelection();
if (isDragable(selection)) {
dragInit(selection);
} else {
dragDone();
event.doit = false;
}
}
/**
* Attach to the event the data from the drag source.
*
* @see org.eclipse.swt.dnd.DragSourceListener#dragSetData
* @see org.eclipse.swt.dnd.DragSourceEvent
*
* @param event the information associated with the drag event
*/
public void dragSetData(DragSourceEvent event) {
// Define data type so a listener could examine it with isSupportedType().
// The selection is not passed using event by the LocalSelectionTransfer internally.
if (isSupportedType(event.dataType)) {
event.data= prepareDataForTransfer(fProvider.getSelection());
}
}
/**
* The function is called upon the completion of the drop. Cleanup is performed.
* @see org.eclipse.swt.dnd.DragSourceListener#dragFinished
*
* @param event the information associated with the drag event
*/
public void dragFinished(DragSourceEvent event) {
dragDone();
event.doit = false;
}
}

View file

@ -0,0 +1,167 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.dnd;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.core.MakeTargetManager;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.widgets.Shell;
/**
* {@code FileTransferDropTargetListener} handles dropping of files to Make
* Target View. {@link FileTransfer} is used as the transfer agent. The files
* passed are treated as make targets.
*
* @see AbstractContainerAreaDropAdapter
* @see org.eclipse.swt.dnd.DropTargetListener
*/
public class FileTransferDropTargetListener extends AbstractContainerAreaDropAdapter {
private final Viewer fViewer;
/**
* Constructor setting a viewer such as TreeViewer to pull selection from later on.
* @param viewer - the viewer providing shell for UI.
*/
public FileTransferDropTargetListener(Viewer viewer) {
fViewer = viewer;
}
/**
* @return the {@link Transfer} type that this listener can accept a
* drop operation for.
*/
public Transfer getTransfer() {
return FileTransfer.getInstance();
}
/**
* Initial drag operation. Only {@link DND#DROP_COPY} is supported for
* dropping files to Make Target View, same as for {@code dragOverOperation}.
*
* @param operation - incoming operation.
* @return changed operation.
*/
@Override
public int dragEnterOperation(int operation) {
return dragOverOperation(operation, null);
}
/**
* Operation of dragging over a drop target. Only {@link DND#DROP_COPY} is
* supported for dropping files to Make Target View.
*
* @param operation - incoming operation.
* @return changed operation.
*/
@Override
public int dragOverOperation(int operation, IContainer dropContainer) {
// This class is intended only for drag/drop between eclipse instances,
// so DND_COPY always set and we don't bother checking if the target is the source
if (operation!=DND.DROP_NONE) {
return DND.DROP_COPY;
}
return operation;
}
/**
* Implementation of the actual drop of {@code dropObject} to {@code dropContainer}.
*
* @param dropObject - object to drop.
* @param dropContainer - container where to drop the object.
* @param operation - drop operation.
*/
@Override
public void dropToContainer(Object dropObject, IContainer dropContainer, int operation) {
if (dropObject instanceof String[] && ((String[])dropObject).length>0 && dropContainer!=null) {
Shell shell = fViewer.getControl().getShell();
createFileTargetsUI((String[])dropObject, dropContainer, operation, shell);
}
}
/**
* Creates make targets array from filenames array. These will be loose
* targets not connected to global make target list managed by
* {@link MakeTargetManager}.
*
* @param filenames - array of filenames. Each filename expected to be an
* actual file otherwise a user gets a warning popup.
* @param dropContainer - a container where the targets are being created.
* @param shell - a shell to display warnings to user. If null, no warnings
* are displayed.
* @return array of make targets.
*/
private static IMakeTarget[] prepareMakeTargetsFromFiles(String[] filenames,
IContainer dropContainer, Shell shell) {
List<IMakeTarget> makeTargetsList = new ArrayList<IMakeTarget>(filenames.length);
int errorCount = 0;
int nonFileCount = 0;
for (String filepath : filenames) {
IPath path = new Path(filepath);
File file = path.toFile();
if (file.isFile()) {
String name = path.lastSegment();
try {
String buildCommand = MakeTargetDndUtil.getProjectBuildCommand(dropContainer.getProject());
makeTargetsList.add(MakeTargetDndUtil.createMakeTarget(name, filepath, buildCommand, dropContainer));
} catch (CoreException e) {
errorCount++;
MakeUIPlugin.log(e);
}
} else {
nonFileCount++;
}
}
if (shell != null) {
if (errorCount > 0) {
MessageDialog.openError(shell, MakeUIPlugin.getResourceString("MakeTargetDnD.title.createError"), //$NON-NLS-1$
MakeUIPlugin.getResourceString("MakeTargetDnD.message.createError")); //$NON-NLS-1$
}
if (nonFileCount > 0) {
MessageDialog.openInformation(shell, MakeUIPlugin.getResourceString("MakeTargetDnD.title.createInfo"), //$NON-NLS-1$
MakeUIPlugin.getResourceString("MakeTargetDnD.message.createNonFileTargetAttempt")); //$NON-NLS-1$
}
}
return makeTargetsList.toArray(new IMakeTarget[makeTargetsList.size()]);
}
/**
* Creates make targets from array of filenames in Make Target View. Each
* file will be a separate target in the view.
*
* @param filenames - array of filenames. Each filename expected to be an
* actual file otherwise a user gets a warning popup.
* @param dropContainer - a container where the targets are being created.
* @param operation - drop/paste operation.
* @param shell - a shell to display warnings to the user.
*/
public static void createFileTargetsUI(String[] filenames, IContainer dropContainer, int operation, Shell shell) {
IMakeTarget[] makeTargets = prepareMakeTargetsFromFiles(filenames, dropContainer, shell);
MakeTargetDndUtil.copyTargets(makeTargets, dropContainer, operation, shell);
}
}

View file

@ -0,0 +1,85 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.dnd;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
/**
* {@code LocalTransferDragSourceListener} supports dragging of selected objects from
* Make Target View. {@link LocalSelectionTransfer} is used as a transfer agent.
*
* @see AbstractSelectionDragAdapter
* @see org.eclipse.swt.dnd.DragSourceListener
*/
public class LocalTransferDragSourceListener extends AbstractSelectionDragAdapter {
/**
* Constructor setting selection provider.
* @param provider - selection provider.
*/
public LocalTransferDragSourceListener(ISelectionProvider provider) {
super(provider);
}
/**
* @return the {@link Transfer} type that this listener can accept a
* drop operation for.
*/
public Transfer getTransfer() {
return LocalSelectionTransfer.getInstance();
}
/**
* Checks if the elements contained in the given selection can be dragged.
*
* @param selection - the selected elements to be dragged.
* @return {@code true} if the selection can be dragged.
*/
@Override
public boolean isDragable(ISelection selection) {
return MakeTargetDndUtil.isDragable(selection);
}
/**
* Pick the selected elements to be passed by {@link LocalSelectionTransfer}.
*
* @param selection - the selected elements to be dragged.
*/
@Override
public void dragInit(ISelection selection) {
LocalSelectionTransfer.getInstance().setSelection(selection);
}
/**
* Provide the selection to attach to the drag event.
*
* @param selection - not used. The selection is taken from {@link LocalSelectionTransfer}.
* @return data to be passed.
*/
@Override
public Object prepareDataForTransfer(ISelection selection) {
return LocalSelectionTransfer.getInstance().getSelection();
}
/**
* Cleanup upon the completion of the drop.
*/
@Override
public void dragDone() {
LocalSelectionTransfer.getInstance().setSelection(null);
LocalSelectionTransfer.getInstance().setSelectionSetTime(0);
}
}

View file

@ -0,0 +1,231 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.dnd;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
/**
* {@code LocalTransferDropTargetListener} supports dropping of dragged selection to
* Make Target View. {@link LocalSelectionTransfer} is used as a transfer agent.
*
* @see AbstractContainerAreaDropAdapter
* @see org.eclipse.swt.dnd.DropTargetListener
*/
public class LocalTransferDropTargetListener extends AbstractContainerAreaDropAdapter {
Viewer fViewer;
/**
* Constructor setting a viewer such as TreeViewer.
*
* @param viewer - to provide shell for UI interaction.
*/
public LocalTransferDropTargetListener(Viewer viewer) {
fViewer = viewer;
}
/**
* @return the {@link Transfer} type that this listener can accept a
* drop operation for.
*/
public Transfer getTransfer() {
return LocalSelectionTransfer.getInstance();
}
/**
* Get selection from {@link LocalSelectionTransfer}.
*
* @return selection as {@link IStructuredSelection}.
*/
private IStructuredSelection getSelection() {
ISelection selection = LocalSelectionTransfer.getInstance().getSelection();
if (selection instanceof IStructuredSelection) {
return (IStructuredSelection) selection;
}
return null;
}
/**
* Initial drag operation. Adjusted to be the least of user initiated
* operation and best supported operation for a given selection. The
* operation will be indicated by mouse cursor.
*
* @param operation - incoming operation.
* @return changed operation.
*/
@Override
public int dragEnterOperation(int operation) {
int bestOperation = determineBestOperation(getSelection(), null);
if (bestOperation > operation) {
bestOperation = operation;
}
return bestOperation;
}
/**
* Operation on dragging over target . Adjusted to be the least of user
* initiated operation and best supported operation for a given selection
* considering drop container. The operation will be indicated by mouse
* cursor.
*
* @param operation - incoming operation.
* @param dropContainer - container where drop is going to be.
* @return changed operation.
*/
@Override
public int dragOverOperation(int operation, IContainer dropContainer) {
int bestOperation = DND.DROP_NONE;
if (dropContainer != null) {
bestOperation = determineBestOperation(getSelection(), dropContainer);
if (bestOperation > operation) {
bestOperation = operation;
}
}
return bestOperation;
}
/**
* Implementation of the actual drop of {@code dropObject} to {@code dropContainer}.
*
* @param dropObject - object to drop.
* @param dropContainer - container where to drop the object.
* @param operation - drop operation.
*/
@Override
public void dropToContainer(Object dropObject, IContainer dropContainer, int operation) {
if (dropObject instanceof IStructuredSelection && dropContainer != null) {
IMakeTarget[] makeTargets = prepareMakeTargetsFromSelection((IStructuredSelection)dropObject, dropContainer);
MakeTargetDndUtil.copyTargets(makeTargets, dropContainer, operation, fViewer.getControl().getShell());
}
}
/**
* Check if this item is a file or convertible to file.
*
* @param element - an item to examine.
* @return true if convertible to file.
*/
private static boolean isConvertibleToFile(Object element) {
if (element instanceof IAdaptable) {
IAdaptable a = (IAdaptable)element;
if (a.getAdapter(IFile.class)!=null) {
return true;
}
}
return false;
}
/**
* Calculate which operations are available for dropping the selection to
* the target. {@code IMakeTarget} can be moved but files can only be
* copied. The selection should contain only {@code IMakeTarget} or items
* convertible to files.
*
* @param selection - data being dragged.
* @param dropContainer - container where drop is targeted.
*
* @return the most advanced operation available. The return must be one of
* {@link org.eclipse.swt.dnd.DND} operations.
*
* @see DND#DROP_NONE
* @see DND#DROP_COPY
* @see DND#DROP_MOVE
* @see DND#DROP_LINK
*/
private int determineBestOperation(IStructuredSelection selection, IContainer dropContainer) {
int bestOperation = DND.DROP_NONE;
if (selection != null) {
List<?> items = selection.toList();
for (Object item : items) {
if (item instanceof IMakeTarget) {
// Looking for a target which is not being copying/moving to itself
IContainer container = ((IMakeTarget)item).getContainer();
// dropContainer==null means disregard the container
if (dropContainer==null || !dropContainer.equals(container)) {
if (bestOperation < DND.DROP_MOVE) {
bestOperation = DND.DROP_MOVE;
}
}
} else if (isConvertibleToFile(item)) {
// Files can be copied
if (bestOperation < DND.DROP_COPY) {
bestOperation = DND.DROP_COPY;
}
} else {
// if any item is not drop-able selection is not drop-able
bestOperation = DND.DROP_NONE;
break;
}
}
}
return bestOperation;
}
/**
* Provide the list of make targets made out of selected elements. This method assumes
* {@code IMakeTarget} or items adaptable to files in the selection.
*
* @param selection - selected items.
* @param dropContainer - container where make targets will belong to.
* @return an array of {@code IMakeTarget}s.
*/
private static IMakeTarget[] prepareMakeTargetsFromSelection(IStructuredSelection selection, IContainer dropContainer) {
List<?> elements = selection.toList();
List<IMakeTarget> makeTargetsList= new ArrayList<IMakeTarget>(elements.size());
for (Object element : elements) {
if (element instanceof IMakeTarget) {
IMakeTarget makeTarget = (IMakeTarget)element;
if (!makeTarget.getContainer().equals(dropContainer)) {
makeTargetsList.add(makeTarget);
}
continue;
} else if (isConvertibleToFile(element)) {
IAdaptable a = (IAdaptable)element;
IFile file = (IFile)a.getAdapter(IFile.class);
String fileName = file.getName();
String fileLocation = file.getLocation().toString();
if (fileName!=null) {
try {
String buildCommand = MakeTargetDndUtil.getProjectBuildCommand(dropContainer.getProject());
IMakeTarget makeTarget = MakeTargetDndUtil.createMakeTarget(fileName, fileLocation,
buildCommand, dropContainer);
makeTargetsList.add(makeTarget);
} catch (CoreException e) {
// log any problem then ignore it
MakeUIPlugin.log(e);
}
}
}
}
if (makeTargetsList.size()>0) {
return makeTargetsList.toArray(new IMakeTarget[makeTargetsList.size()]);
}
return null;
}
}

View file

@ -0,0 +1,388 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.dnd;
import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.IMakeTargetManager;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.core.MakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.widgets.Shell;
/**
* A collection of various functions for Make Target View drag and drop support.
*/
public class MakeTargetDndUtil {
private static final int ANSWER_YES_ID = 0;
private static final int ANSWER_YES_TO_ALL_ID = 1;
private static final int ANSWER_NO_ID = 2;
private static final int ANSWER_NO_TO_ALL_ID = 3;
private static final int ANSWER_CANCEL_ID = 4;
/**
* The previous answer to the question of overwriting all targets.
*/
protected static int lastUserAnswer = ANSWER_YES_ID;
/**
* Default build command.
*/
public static final String DEFAULT_BUILD_COMMAND = "make"; //$NON-NLS-1$
/**
* @return build command from project settings.
*/
public static String getProjectBuildCommand(IProject project) {
IMakeTargetManager targetManager = MakeCorePlugin.getDefault().getTargetManager();
String[] targetBuilders = targetManager.getTargetBuilders(project);
if (targetBuilders==null || targetBuilders.length==0) {
return DEFAULT_BUILD_COMMAND;
}
String builderId = targetManager.getBuilderID(targetBuilders[0]);
String buildCommand = DEFAULT_BUILD_COMMAND;
try {
IMakeBuilderInfo buildInfo = MakeCorePlugin.createBuildInfo(project, builderId);
buildCommand = buildInfo.getBuildCommand().toString().trim();
} catch (CoreException e) {
// keep default value
}
return buildCommand;
}
/**
* Determine if the selection is allowed to be dragged from Make Target
* View. It should be homogeneous having {@code IMakeTrget}s only and no
* duplicate names are allowed. Make targets could be selected from
* different folders.
*
* @param selection - make targets selection.
* @return {@code true} if the selection is allowed to be dragged.
*/
public static boolean isDragable(ISelection selection) {
if (selection instanceof IStructuredSelection) {
List<?> selectedElements = ((IStructuredSelection) selection).toList();
if (selectedElements.size() == 0) {
return false;
}
List<String> names = new ArrayList<String>(selectedElements.size());
for (Object element : selectedElements) {
if (!(element instanceof IMakeTarget)) {
return false;
}
String makeTargetName = ((IMakeTarget) element).getName();
for (String name : names) {
if (makeTargetName == null || makeTargetName.equals(name)) {
return false;
}
}
names.add(makeTargetName);
}
return true;
}
return false;
}
/**
* Perform action of copying or moving or dropping make targets to specified
* container. This action displays a progress bar if user copies more than 1
* target.
*
* @param makeTargets - array of make targets to copy.
* @param container - where to copy the selection.
* @param operation - copying operation. Should be one of
* {@link org.eclipse.swt.dnd.DND} operations.
* @param shell - shell to display a progress bar.
*
* @see DND#DROP_NONE
* @see DND#DROP_COPY
* @see DND#DROP_MOVE
* @see DND#DROP_LINK
* @see DND#DROP_DEFAULT
*/
public static void copyTargets(IMakeTarget[] makeTargets, IContainer container, int operation,
Shell shell) {
if (makeTargets == null || makeTargets.length == 0 || container == null) {
return;
}
lastUserAnswer = ANSWER_YES_ID;
if (makeTargets.length == 1) {
try {
// Do not slow down generating modal window for a single target
copyOneTarget(makeTargets[0], container, operation, shell);
} catch (CoreException e) {
// log any problem then ignore it
MakeUIPlugin.log(e);
}
} else if (makeTargets.length > 1) {
copyTargetsWithProgressIndicator(makeTargets, container, operation, shell);
}
}
/**
* Copy/move one make target to the specified container.
*
* @param makeTarget - make target.
* @param container - container to copy/move to.
* @param operation - copying operation. Should be one of
* {@link org.eclipse.swt.dnd.DND} operations.
* @param shell - shell to display user warnings.
* @throws CoreException on the failure of {@link IMakeTargetManager} or
* {@link IMakeTarget} operation.
*
* @see DND#DROP_NONE
* @see DND#DROP_COPY
* @see DND#DROP_MOVE
* @see DND#DROP_LINK
* @see DND#DROP_DEFAULT
*/
public static void copyOneTarget(IMakeTarget makeTarget, IContainer container,
final int operation, Shell shell) throws CoreException {
IMakeTargetManager makeTargetManager = MakeCorePlugin.getDefault().getTargetManager();
IMakeTarget exists = makeTargetManager.findTarget(container, makeTarget.getName());
if (exists != null) {
int userAnswer = overwriteMakeTargetDialog(makeTarget.getName(), shell);
if (userAnswer == ANSWER_YES_ID || userAnswer == ANSWER_YES_TO_ALL_ID) {
copyTargetData(makeTarget, exists);
if (operation == DND.DROP_MOVE) {
makeTargetManager.removeTarget(makeTarget);
}
} else if (userAnswer == ANSWER_NO_ID || userAnswer == ANSWER_NO_TO_ALL_ID) {
// no action
}
} else {
makeTargetManager.addTarget(container, cloneTarget(makeTarget, container.getProject()));
if (operation == DND.DROP_MOVE) {
makeTargetManager.removeTarget(makeTarget);
}
}
}
/**
* Copy/move make targets to a given container. Displays progress bar.
*
* @param makeTargets - array of make targets to copy.
* @param container - container to copy/move to.
* @param operation - copying operation. Should be one of
* {@link org.eclipse.swt.dnd.DND} operations.
* @param shell - shell to display a progress bar.
*
* @see DND#DROP_NONE
* @see DND#DROP_COPY
* @see DND#DROP_MOVE
* @see DND#DROP_LINK
* @see DND#DROP_DEFAULT
*
*/
private static void copyTargetsWithProgressIndicator(final IMakeTarget[] makeTargets,
final IContainer container, final int operation, final Shell shell) {
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
boolean isMove = operation == DND.DROP_MOVE;
String textHeader = isMove ? MakeUIPlugin.getResourceString("MakeTargetDnD.moving") //$NON-NLS-1$
: MakeUIPlugin.getResourceString("MakeTargetDnD.copying"); //$NON-NLS-1$
String textAction = isMove ? MakeUIPlugin
.getResourceString("MakeTargetDnD.moving.one") //$NON-NLS-1$
: MakeUIPlugin.getResourceString("MakeTargetDnD.copying.one"); //$NON-NLS-1$
monitor.beginTask(textHeader + ' ' + container.getName(), makeTargets.length - 1);
for (IMakeTarget makeTarget : makeTargets) {
if (makeTarget != null) {
monitor.subTask(textAction + ' ' + makeTarget.getName());
try {
copyOneTarget(makeTarget, container, operation, shell);
} catch (CoreException e) {
// log failures but ignore all targets which failed
MakeUIPlugin.log(e);
}
if (lastUserAnswer == ANSWER_CANCEL_ID) {
break;
}
}
monitor.worked(1);
if (monitor.isCanceled()) {
break;
}
}
monitor.done();
lastUserAnswer = ANSWER_YES_ID;
}
};
IRunnableContext context = new ProgressMonitorDialog(shell);
try {
context.run(false, true, runnable);
} catch (InvocationTargetException e) {
MakeUIPlugin.log(e);
} catch (InterruptedException e) {
MakeUIPlugin.log(e);
}
}
/**
* Overwrite Make Target dialog.
*
* @param name - name of make target to display to a user.
* @param shell - shell where to display the dialog.
*
* @return user's answer.
*/
private static int overwriteMakeTargetDialog(String name, Shell shell) {
if (lastUserAnswer == ANSWER_YES_TO_ALL_ID || lastUserAnswer == ANSWER_NO_TO_ALL_ID) {
return lastUserAnswer;
}
String labels[] = new String[] { IDialogConstants.YES_LABEL,
IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL,
IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL, };
String title = MakeUIPlugin.getResourceString("MakeTargetDnD.title.overwriteTargetConfirm"); //$NON-NLS-1$
String question = MessageFormat.format(MakeUIPlugin
.getResourceString("MakeTargetDnD.message.overwriteTargetConfirm"), //$NON-NLS-1$
new Object[] { name });
MessageDialog dialog = new MessageDialog(shell, title, null, question,
MessageDialog.QUESTION, labels, 0);
try {
dialog.open();
lastUserAnswer = dialog.getReturnCode();
} catch (SWTException e) {
MakeUIPlugin.log(e);
lastUserAnswer = ANSWER_CANCEL_ID;
}
if (lastUserAnswer == SWT.DEFAULT) {
// A window close returns SWT.DEFAULT, which has to be
// mapped to a cancel
lastUserAnswer = ANSWER_CANCEL_ID;
}
return lastUserAnswer;
}
/**
* Creating a copy of IMakeTarget in a different project.
*
* @param makeTarget - make target.
* @param project - project where to assign the make target.
* @return newly created make target.
* @throws CoreException if there is a problem with creating or copying the
* target.
*/
private static IMakeTarget cloneTarget(IMakeTarget makeTarget, IProject project)
throws CoreException {
IMakeTargetManager makeTargetManager = MakeCorePlugin.getDefault().getTargetManager();
String[] ids = makeTargetManager.getTargetBuilders(project);
String builderId = ids[0];
IMakeTarget newMakeTarget = makeTargetManager.createTarget(project, makeTarget.getName(),
builderId);
copyTargetData(makeTarget, newMakeTarget);
return newMakeTarget;
}
/**
* Populate destination make target with data from source make target.
*
* @param source - source make target.
* @param destination - destination make target.
* @throws CoreException if there is a problem populating the target.
*
* @see MakeTarget
*/
private static void copyTargetData(IMakeTarget source, IMakeTarget destination)
throws CoreException {
// IMakeTarget attributes
// destination.project and destination.targetBuilderID are not changed
destination.setRunAllBuilders(source.runAllBuilders());
destination.setAppendProjectEnvironment(source.appendProjectEnvironment());
destination.setBuildAttribute(IMakeTarget.BUILD_TARGET,
source.getBuildAttribute(IMakeTarget.BUILD_TARGET, "")); //$NON-NLS-1$
// IMakeCommonBuildInfo attributes
// Ignore IMakeCommonBuildInfo.BUILD_LOCATION in order not to pick
// location of another project (or another folder)
destination.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND,
source.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, DEFAULT_BUILD_COMMAND));
destination.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS,
source.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); //$NON-NLS-1$
destination.setStopOnError(source.isStopOnError());
destination.setUseDefaultBuildCmd(source.isDefaultBuildCmd());
destination.setEnvironment(source.getEnvironment());
destination.setAppendEnvironment(source.appendEnvironment());
// setErrorParsers() is not supported in MakeTarget yet
}
/**
* Create @{code MakeTarget} from basic data elements available during
* copy/paste or drag/drop operations. The other data will be set to default.
*
* @param name - name of make target being created.
* @param targetStr - build target.
* @param command - make command. ("make" by default).
* @param container - container where to place the target.
* @return newly created {@link IMakeTarget}.
* @throws CoreException if there was a problem creating new make target.
*/
public static IMakeTarget createMakeTarget(String name, String targetStr, String command,
IContainer container) throws CoreException {
IMakeTargetManager makeTargetManager = MakeCorePlugin.getDefault().getTargetManager();
IProject project = container.getProject();
String[] ids = makeTargetManager.getTargetBuilders(project);
String builderId = ids[0];
// IMakeTarget attributes
IMakeTarget newMakeTarget = makeTargetManager.createTarget(project, name, builderId);
if (targetStr != null) {
newMakeTarget.setBuildAttribute(IMakeTarget.BUILD_TARGET, targetStr);
}
// IMakeCommonBuildInfo attributes
String projectBuildCommand = getProjectBuildCommand(project);
if (command != null && command.length() > 0 && !command.equals(projectBuildCommand)) {
newMakeTarget.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, command);
newMakeTarget.setUseDefaultBuildCmd(false);
} else {
newMakeTarget.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, projectBuildCommand);
newMakeTarget.setUseDefaultBuildCmd(true);
}
return newMakeTarget;
}
}

View file

@ -0,0 +1,169 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.dnd;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.dnd.MakeTargetTransferData.MakeTargetData;
import org.eclipse.swt.dnd.ByteArrayTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.dnd.TransferData;
/**
* This class can be used to transfer an instance of
* {@link MakeTargetTransferData} between two parts in a workbench in a drag and
* drop or clipboard copy/paste operation.
*
* @see ByteArrayTransfer
* @see Transfer
* @see org.eclipse.swt.dnd.DropTarget
* @see org.eclipse.swt.dnd.DragSource
*/
public class MakeTargetTransfer extends ByteArrayTransfer {
private static final String TYPE_NAME = "make-target-transfer-format";//$NON-NLS-1$
private static final int TYPEID = registerType(TYPE_NAME);
/**
* Singleton instance.
*/
private static MakeTargetTransfer instance = new MakeTargetTransfer();
/**
* Creates a new transfer object.
*/
private MakeTargetTransfer() {
super();
}
/**
* @return the singleton instance.
*/
public static MakeTargetTransfer getInstance() {
return instance;
}
/**
* @return ids of the data types that can be converted using this transfer
* agent.
*
* @see Transfer#getTypeIds()
*/
@Override
protected int[] getTypeIds() {
return new int[] { TYPEID };
}
/**
* @return the list of type names that can be converted using this transfer
* agent.
*
* @see Transfer#getTypeNames()
*/
@Override
protected String[] getTypeNames() {
return new String[] { TYPE_NAME };
}
/**
* Converts a java representation of data to a platform specific
* representation of the data.
*
* @param object - a java representation of the data to be converted.
* @param transferData - an empty TransferData object; this object will be
* filled in on return with the platform specific representation of
* the data.
*
* @exception org.eclipse.swt.SWTException {@code ERROR_INVALID_DATA} - if
* object doesn't contain data in a valid format or {@code null}.
*
* @see Transfer#javaToNative(Object object, TransferData transferData)
*/
@Override
protected void javaToNative(Object object, TransferData transferData) {
if (object instanceof MakeTargetTransferData) {
MakeTargetTransferData realData = (MakeTargetTransferData) object;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(out);
dataOut.writeInt(realData.getMakeTargetDataList().size());
for (MakeTargetData mtd : realData.getMakeTargetDataList()) {
dataOut.writeUTF(mtd.getName());
dataOut.writeBoolean(mtd.runAllBuilders());
dataOut.writeBoolean(mtd.appendProjectEnvironment());
dataOut.writeUTF(mtd.getBuildTarget());
dataOut.writeUTF(mtd.getBuildCommand());
dataOut.writeUTF(mtd.getBuildArguments());
dataOut.writeBoolean(mtd.isStopOnError());
dataOut.writeBoolean(mtd.isDefaultBuildCmd());
dataOut.writeBoolean(mtd.appendEnvironment());
}
dataOut.close();
super.javaToNative(out.toByteArray(), transferData);
} catch (IOException e) {
MakeUIPlugin.log(e);
}
}
}
/**
* Converts a platform specific representation of data to a java
* representation.
*
* @param transferData - the platform specific representation of the data to
* be converted.
*
* @return a java representation of the converted data if the conversion was
* successful; otherwise {@code null}. If transferData is {@code
* null} then {@code null} is returned. The type of Object that is
* returned is dependent on the {@link Transfer} subclass.
*
* @see Transfer#nativeToJava(TransferData transferData)
*/
@Override
protected Object nativeToJava(TransferData transferData) {
byte[] bytes = (byte[]) super.nativeToJava(transferData);
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
DataInputStream dataIn = new DataInputStream(in);
try {
MakeTargetTransferData mttd = new MakeTargetTransferData();
int size = dataIn.readInt();
for (int i = 0; i < size; i++) {
String name = dataIn.readUTF();
boolean runAllBuilders = dataIn.readBoolean();
boolean appendProjectEnvironment = dataIn.readBoolean();
String buildTarget = dataIn.readUTF();
String buildCommand = dataIn.readUTF();
String buildArguments = dataIn.readUTF();
boolean stopOnError = dataIn.readBoolean();
boolean useDefaultBuildCmd = dataIn.readBoolean();
boolean appendEnvironment = dataIn.readBoolean();
mttd.addMakeTarget(name, runAllBuilders, appendProjectEnvironment, buildTarget,
buildCommand, buildArguments, stopOnError, useDefaultBuildCmd, appendEnvironment);
}
return mttd;
} catch (IOException e) {
MakeUIPlugin.log(e);
}
return null;
}
}

View file

@ -0,0 +1,212 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.dnd;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.IMakeTargetManager;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
/**
* {@code MakeTargetTransferData} serves for transferring data during a drag and
* drop operation between different plug-ins. This object contains an extension
* identifier and a block of bytes. When the drop occurs, the data is
* interpreted by an action defined in the specified extension.
* <p>
* Clients using MakeTargetTransfer should create an instance to contain the
* drop data.
* </p>
*
* @see IMakeTarget
*/
public class MakeTargetTransferData {
class MakeTargetData {
private final String name;
// IMakeTarget attributes
private final boolean runAllBuilders;
private final boolean appendProjectEnvironment;
private final String buildTarget;
// IMakeCommonBuildInfo attributes
private final String buildCommand;
private final String buildArguments;
private final boolean stopOnError;
private final boolean useDefaultBuildCmd;
private final boolean appendEnvironment;
/**
* Constructor to populate the transfer data record with
* {@link IMakeTarget} data.
*
* @param name - make target name.
* @param runAllBuilders - make target runAllBuilders flag.
* @param appendProjectEnvironment - make target
* appendProjectEnvironment flag.
* @param buildTarget - make target buildTarget.
* @param buildCommand - make target buildCommand.
* @param buildArguments - make target buildArguments.
* @param stopOnError - make target stopOnError flag.
* @param useDefaultBuildCmd - make target useDefaultBuildCmd flag.
* @param appendEnvironment - make target appendEnvironment flag.
*/
MakeTargetData(String name, boolean runAllBuilders, boolean appendProjectEnvironment,
String buildTarget, String buildCommand, String buildArguments, boolean stopOnError,
boolean useDefaultBuildCmd, boolean appendEnvironment) {
this.name = name;
this.runAllBuilders = runAllBuilders;
this.appendProjectEnvironment = appendProjectEnvironment;
this.buildTarget = buildTarget;
this.buildCommand = buildCommand;
this.buildArguments = buildArguments;
this.stopOnError = stopOnError;
this.useDefaultBuildCmd = useDefaultBuildCmd;
this.appendEnvironment = appendEnvironment;
}
boolean runAllBuilders() {
return runAllBuilders;
}
boolean appendProjectEnvironment() {
return appendProjectEnvironment;
}
String getBuildTarget() {
return buildTarget;
}
String getBuildCommand() {
return buildCommand;
}
String getBuildArguments() {
return buildArguments;
}
boolean isStopOnError() {
return stopOnError;
}
boolean isDefaultBuildCmd() {
return useDefaultBuildCmd;
}
boolean appendEnvironment() {
return appendEnvironment;
}
String getName() {
return name;
}
}
private final List<MakeTargetData> makeTargetData;
/**
* Default constructor.
*
*/
public MakeTargetTransferData() {
makeTargetData = new ArrayList<MakeTargetData>();
}
/**
* Method to add make target to the target list in preparation to transfer.
*
* @param target - make target being added.
*/
public void addMakeTarget(IMakeTarget target) {
addMakeTarget(target.getName(),
target.runAllBuilders(),
target.appendProjectEnvironment(),
target.getBuildAttribute(IMakeTarget.BUILD_TARGET, ""), //$NON-NLS-1$
target.getBuildAttribute(IMakeTarget.BUILD_COMMAND, ""), //$NON-NLS-1$
target.getBuildAttribute(IMakeTarget.BUILD_ARGUMENTS, ""), //$NON-NLS-1$
target.isStopOnError(),
target.isDefaultBuildCmd(),
target.appendEnvironment());
}
/**
* Add another target to the list of make target transfer records.
*
* @param name - make target name.
* @param runAllBuilders - make target runAllBuilders flag.
* @param appendProjectEnvironment - make target appendProjectEnvironment flag.
* @param buildTarget - make target buildTarget.
* @param buildCommand - make target buildCommand.
* @param buildArguments - make target buildArguments.
* @param stopOnError - make target stopOnError flag.
* @param useDefaultBuildCmd - make target useDefaultBuildCmd flag.
* @param appendEnvironment - make target appendEnvironment flag.
*/
public void addMakeTarget(String name, boolean runAllBuilders,
boolean appendProjectEnvironment, String buildTarget, String buildCommand,
String buildArguments, boolean stopOnError, boolean useDefaultBuildCmd,
boolean appendEnvironment) {
makeTargetData.add(new MakeTargetData(name, runAllBuilders, appendProjectEnvironment,
buildTarget, buildCommand, buildArguments, stopOnError, useDefaultBuildCmd,
appendEnvironment));
}
/**
* Create an array of make targets from transfer records. Creating of actual {@link IMakeTarget}s
* requires supplying a project where they will be assigned by {@link IMakeTargetManager}.
*
* @param project - project to assign the targets.
* @return the array of created {@link IMakeTarget}s
*
* @see IMakeTarget
* @see IMakeTargetManager
*/
public IMakeTarget[] createMakeTargets(IProject project) {
IMakeTargetManager makeTargetManager = MakeCorePlugin.getDefault().getTargetManager();
ArrayList<IMakeTarget> makeTargets = new ArrayList<IMakeTarget>(makeTargetData.size());
String[] ids = makeTargetManager.getTargetBuilders(project);
String builderId = ids[0];
for (MakeTargetData element : makeTargetData) {
try {
IMakeTarget target = makeTargetManager.createTarget(project, element.getName(), builderId);
target.setRunAllBuilders(element.runAllBuilders());
target.setAppendProjectEnvironment(element.appendProjectEnvironment());
target.setBuildAttribute(IMakeTarget.BUILD_TARGET, element.getBuildTarget());
target.setBuildAttribute(IMakeTarget.BUILD_COMMAND, element.getBuildCommand());
target.setBuildAttribute(IMakeTarget.BUILD_ARGUMENTS, element.getBuildArguments());
target.setStopOnError(element.isStopOnError());
target.setUseDefaultBuildCmd(element.isDefaultBuildCmd());
target.setAppendEnvironment(element.appendEnvironment());
makeTargets.add(target);
} catch (CoreException e) {
MakeUIPlugin.log(e);
}
}
return makeTargets.toArray(new IMakeTarget[makeTargets.size()]);
}
/**
* @return list of make target transfer records for {@link MakeTargetTransfer}.
*/
List<MakeTargetData> getMakeTargetDataList() {
return makeTargetData;
}
}

View file

@ -0,0 +1,98 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.dnd;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
/**
* {@code MakeTargetTransferDragSourceListener} supports dragging of selected
* make targets from Make Target View. {@link TextTransfer} is used as the
* transfer agent and provides for drag/drop and copy/paste between different
* eclipse sessions.
*
* @see AbstractSelectionDragAdapter
* @see org.eclipse.swt.dnd.DragSourceListener
*/
public class MakeTargetTransferDragSourceListener extends AbstractSelectionDragAdapter {
/**
* Constructor setting selection provider.
* @param provider - selection provider.
*/
public MakeTargetTransferDragSourceListener(ISelectionProvider provider) {
super(provider);
}
/**
* @return the {@link Transfer} type that this listener can accept a
* drop operation for.
*/
public Transfer getTransfer() {
return MakeTargetTransfer.getInstance();
}
/**
* Checks if the elements contained in the given selection can be dragged.
*
* @param selection - the selected elements to be dragged.
* @return {@code true} if the selection can be dragged.
*/
@Override
public boolean isDragable(ISelection selection) {
return MakeTargetDndUtil.isDragable(selection);
}
/**
* A custom action executed during drag initialization.
*
* @param selection - the selected elements to be dragged.
*/
@Override
public void dragInit(ISelection selection) {
// no special action is required
}
/**
* Prepare the selection to be passed via drag and drop actions.
*
* @param selection - the selected elements to be dragged.
* @return selected make targets converted to {@link MakeTargetTransferData}
* in order to be transfered.
*/
@Override
public Object prepareDataForTransfer(ISelection selection) {
if (selection instanceof IStructuredSelection) {
MakeTargetTransferData makeTargetTransferData = new MakeTargetTransferData();
for (Object selectionItem : ((IStructuredSelection)selection).toList()) {
if (selectionItem instanceof IMakeTarget) {
makeTargetTransferData.addMakeTarget((IMakeTarget)selectionItem);
}
}
return makeTargetTransferData;
}
return null;
}
/**
* A custom action to finish the drag.
*/
@Override
public void dragDone() {
// no special action is required
}
}

View file

@ -0,0 +1,107 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.dnd;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.core.resources.IContainer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.widgets.Shell;
/**
* {@code MakeTargetTransferDropTargetListener} handles drop of make targets
* onto Make Target View. {@link MakeTargetTransfer} is used as the transfer agent and
* provides for drag/drop and copy/paste between different eclipse sessions.
*
* @see AbstractContainerAreaDropAdapter
* @see org.eclipse.swt.dnd.DropTargetListener
*/
public class MakeTargetTransferDropTargetListener extends AbstractContainerAreaDropAdapter {
private final Viewer fViewer;
/**
* Constructor setting a viewer such as TreeViewer to pull selection from later on.
* @param viewer - the viewer providing shell for UI.
*/
public MakeTargetTransferDropTargetListener(Viewer viewer) {
fViewer = viewer;
}
/**
* @return the {@link Transfer} type that this listener can accept a
* drop operation for.
*/
public Transfer getTransfer() {
return MakeTargetTransfer.getInstance();
}
/**
* Initial drag operation. Only {@link DND#DROP_COPY} is supported for
* dropping files to Make Target View, same as for {@code dragOverOperation}.
*
* @param operation - incoming operation.
* @return changed operation.
*/
@Override
public int dragEnterOperation(int operation) {
return dragOverOperation(operation, null);
}
/**
* Operation of dragging over a drop target. Only {@link DND#DROP_COPY} is
* supported for dropping files to Make Target View.
*
* @param operation - incoming operation.
* @return changed operation.
*/
@Override
public int dragOverOperation(int operation, IContainer dropContainer) {
// This class is intended only for drag/drop between eclipse instances,
// so DND_COPY always set and we don't bother checking if the target is the source
if (operation!=DND.DROP_NONE) {
return DND.DROP_COPY;
}
return operation;
}
/**
* Implementation of the actual drop of {@code dropObject} to {@code dropContainer}.
*
* @param dropObject - object to drop.
* @param dropContainer - container where to drop the object.
* @param operation - drop operation.
*/
@Override
public void dropToContainer(Object dropObject, IContainer dropContainer, int operation) {
if (dropObject instanceof MakeTargetTransferData && dropContainer != null) {
createTransferTargetsUI((MakeTargetTransferData)dropObject, dropContainer,
operation, fViewer.getControl().getShell());
}
}
/**
* Creates make targets received by {@link MakeTargetTransfer} in Make Target View.
*
* @param makeTargetTransferData - incoming data.
* @param dropContainer - a container where the targets are being created.
* @param operation - drop/paste operation.
* @param shell - a shell to display warnings to the user.
*/
public static void createTransferTargetsUI(MakeTargetTransferData makeTargetTransferData, IContainer dropContainer,
int operation, Shell shell) {
IMakeTarget[] makeTargets = makeTargetTransferData.createMakeTargets(dropContainer.getProject());
MakeTargetDndUtil.copyTargets(makeTargets, dropContainer, operation, shell);
}
}

View file

@ -0,0 +1,121 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.dnd;
import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
/**
* {@code TextTransferDragSourceListener} supports dragging of selected make
* targets from Make Target View. The targets converted to make commands in
* order to be presented as plain text. Each command will be one line of text.
* {@link TextTransfer} is used as the transfer agent.
*
* @see AbstractSelectionDragAdapter
* @see org.eclipse.swt.dnd.DragSourceListener
*/
public class TextTransferDragSourceListener extends AbstractSelectionDragAdapter {
/**
* Constructor setting selection provider.
* @param provider - selection provider.
*/
public TextTransferDragSourceListener(ISelectionProvider provider) {
super(provider);
}
/**
* @return the {@link Transfer} type that this listener can accept a
* drop operation for.
*/
public Transfer getTransfer() {
return TextTransfer.getInstance();
}
/**
* Checks if the elements contained in the given selection can be dragged.
*
* @param selection - the selected elements to be dragged.
* @return {@code true} if the selection can be dragged.
*/
@Override
protected boolean isDragable(ISelection selection) {
return MakeTargetDndUtil.isDragable(selection);
}
/**
* A custom action executed during drag initialization.
*
* @param selection - the selected elements to be dragged.
*/
@Override
protected void dragInit(ISelection selection) {
// no special action is required
}
/**
* Prepare the selection to be passed via drag and drop actions.
*
* @param selection - the selected elements to be dragged.
* @return data to be passed. The data is a multiline string each line
* containing make target command.
*/
@Override
protected Object prepareDataForTransfer(ISelection selection) {
if (selection instanceof IStructuredSelection) {
return convertSelectedMakeTargetsToText((IStructuredSelection) selection);
}
return null;
}
/**
* A custom action to finish the drag.
*/
@Override
protected void dragDone() {
// no special action is required
}
/**
* Convert selected make targets to textual representation. Each make command
* is presented as a line in the resulting multiline text.
*
* @param selection - selected make targets in Make Target View.
* @return make targets as miltiline text.
*/
public static String convertSelectedMakeTargetsToText(IStructuredSelection selection) {
String targetsText=""; //$NON-NLS-1$
for (Object selectionItem : selection.toList()) {
if (selectionItem instanceof IMakeTarget) {
IMakeTarget makeTarget = (IMakeTarget)selectionItem;
String buildCommand;
if (makeTarget.isDefaultBuildCmd()) {
buildCommand = MakeTargetDndUtil.getProjectBuildCommand(makeTarget.getProject());
} else {
buildCommand =makeTarget.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND,
MakeTargetDndUtil.DEFAULT_BUILD_COMMAND);
}
targetsText = targetsText
+ buildCommand + ' '
+ makeTarget.getBuildAttribute(IMakeTarget.BUILD_TARGET, "") //$NON-NLS-1$
+ System.getProperty("line.separator"); //$NON-NLS-1$
}
}
return targetsText;
}
}

View file

@ -0,0 +1,188 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.dnd;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.widgets.Shell;
/**
* {@code TextTransferDropTargetListener} handles dropping of selected text to
* Make Target View. Each line of miltiline text passed is treated as separate
* make target command. {@link TextTransfer} is used as the transfer agent.
*
* @see AbstractContainerAreaDropAdapter
* @see org.eclipse.swt.dnd.DropTargetListener
*/
public class TextTransferDropTargetListener extends AbstractContainerAreaDropAdapter {
Viewer fViewer;
/**
* Constructor setting a viewer such as TreeViewer to pull selection from later on.
* @param viewer - the viewer providing shell for UI.
*/
public TextTransferDropTargetListener(Viewer viewer) {
fViewer = viewer;
}
/**
* @return the {@link Transfer} type that this listener can accept a
* drop operation for.
*/
public Transfer getTransfer() {
return TextTransfer.getInstance();
}
/**
* Initial drag operation. Only {@link DND#DROP_COPY} is supported for
* dropping text to Make Target View, same as for {@code dragOverOperation}.
*
* @param operation - incoming operation.
* @return changed operation.
*/
@Override
public int dragEnterOperation(int operation) {
return dragOverOperation(operation, null);
}
/**
* Operation of dragging over a drop target. Only {@link DND#DROP_COPY} is
* supported for dropping text to Make Target View.
*
* @param operation - incoming operation.
* @return changed operation.
*/
@Override
public int dragOverOperation(int operation, IContainer dropContainer) {
// This class is intended only for drag/drop between eclipse instances,
// so DND_COPY always set and we don't bother checking if the target is the source
if (operation!=DND.DROP_NONE) {
return DND.DROP_COPY;
}
return operation;
}
/**
* Implementation of the actual drop of {@code dropObject} to {@code dropContainer}.
*
* @param dropObject - object to drop.
* @param dropContainer - container where to drop the object.
* @param operation - drop operation.
*/
@Override
public void dropToContainer(Object dropObject, IContainer dropContainer, int operation) {
if (dropObject instanceof String && ((String)dropObject).length()>0 && dropContainer != null) {
createMultilineTargetsUI((String)dropObject, dropContainer, operation,
fViewer.getControl().getShell());
}
}
/**
* Convert multiline text to array of {@code IMakeTarget}s. Each line is
* interpreted as one separate make command.
*
* @param multilineText - input text.
* @param container - container where the targets will belong.
* @return resulting array of {@code IMakeTarget}s.
*/
private static IMakeTarget[] prepareMakeTargetsFromString(String multilineText, IContainer container) {
if (container!=null) {
String[] lines = multilineText.split("[\n\r]"); //$NON-NLS-1$
List<IMakeTarget> makeTargets = new ArrayList<IMakeTarget>(lines.length);
for (String command : lines) {
command = command.trim();
if (command.length() > 0) {
String name = command;
String buildCommand = command;
String buildTarget = null;
String defaultBuildCommand = MakeTargetDndUtil.getProjectBuildCommand(container.getProject());
if (command.startsWith(defaultBuildCommand+" ")) { //$NON-NLS-1$
buildCommand = defaultBuildCommand;
buildTarget = command.substring(defaultBuildCommand.length()+1).trim();
name = buildTarget;
}
try {
makeTargets.add(MakeTargetDndUtil.createMakeTarget(name, buildTarget, buildCommand, container));
} catch (CoreException e) {
// Ignore failed targets
MakeUIPlugin.log(e);
}
}
}
return makeTargets.toArray(new IMakeTarget[makeTargets.size()]);
}
return null;
}
/**
* Combined operation of creating make targets in Make Target View from
* multiline text. The method will ask a confirmation if user tries to drop
* more then 1 target to prevent easily made mistake of unintended copying
* of old contents of the clipboard.
*
* @param multilineText - input make target commands in textual form.
* @param dropContainer - container where add the targets.
* @param operation - operation such as copying or moving. Must be a
* {@link org.eclipse.swt.dnd.DND} operation.
* @param shell - a shell to display progress of operation to user.
*
* @see DND#DROP_NONE
* @see DND#DROP_COPY
* @see DND#DROP_MOVE
* @see DND#DROP_LINK
*/
public static void createMultilineTargetsUI(String multilineText, IContainer dropContainer,
int operation, Shell shell) {
IMakeTarget[] makeTargets = prepareMakeTargetsFromString(multilineText, dropContainer);
boolean confirmed = true;
if (makeTargets.length > 1) {
String title = MakeUIPlugin.getResourceString("MakeTargetDnD.title.createFromTextConfirm"); //$NON-NLS-1$
String question = MessageFormat.format(MakeUIPlugin.getResourceString("MakeTargetDnD.message.createFromTextConfirm"), //$NON-NLS-1$
new Object[] { new Integer(makeTargets.length) });
String topTargets = ""; //$NON-NLS-1$
for (int i=0;i<makeTargets.length;i++) {
// limit dimensions of the confirm dialog
final int HEIGHT_LIMIT = 20;
final int LENGTH_LIMIT = 200;
if (i > HEIGHT_LIMIT) {
topTargets = topTargets + "..."; //$NON-NLS-1$
break;
}
String name = makeTargets[i].getName();
if (name.length() > LENGTH_LIMIT) {
name = name.substring(0,LENGTH_LIMIT-3)+"..."; //$NON-NLS-1$
}
topTargets = topTargets + name + "\n"; //$NON-NLS-1$
}
confirmed = MessageDialog.openConfirm(shell, title, question + topTargets);
}
if (confirmed) {
MakeTargetDndUtil.copyTargets(makeTargets, dropContainer, operation, shell);
}
}
}

View file

@ -0,0 +1,113 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.ui.views;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.dnd.MakeTargetDndUtil;
import org.eclipse.cdt.make.internal.ui.dnd.MakeTargetTransfer;
import org.eclipse.cdt.make.internal.ui.dnd.MakeTargetTransferData;
import org.eclipse.cdt.make.internal.ui.dnd.TextTransferDragSourceListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.SelectionListenerAction;
/**
* Action to copy make targets from Make Target View to clipboard.
* {@link CopyTargetAction} can transfer targets as {@link IMakeTarget}s or
* plain text.
* <p>
* {@link CopyTargetAction} and {@link PasteTargetAction} are able to transfer
* targets inside Make Target View or between eclipse sessions.
*
*/
public class CopyTargetAction extends SelectionListenerAction {
private final Shell shell;
private final Clipboard clipboard;
private final PasteTargetAction pasteAction;
/**
* Constructor setting internal private fields and initializing the action.
*
* @param shell - the shell in which to show any dialogs.
* @param clipboard - system clipboard.
* @param pasteAction -associated paste action. May be {@code null}.
*/
protected CopyTargetAction(Shell shell, Clipboard clipboard, PasteTargetAction pasteAction) {
super(MakeUIPlugin.getResourceString("CopyTargetAction.label")); //$NON-NLS-1$
this.shell = shell;
this.clipboard = clipboard;
this.pasteAction = pasteAction;
ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
setToolTipText(MakeUIPlugin.getResourceString("CopyTargetAction.tooltip")); //$NON-NLS-1$
}
/**
* Updates enablement of this action in response to the given selection.
*/
@Override
protected boolean updateSelection(IStructuredSelection selection) {
if (!super.updateSelection(selection)) {
return false;
}
return MakeTargetDndUtil.isDragable(selection);
}
/**
* Perform actual action of copying of make targets to clipboard. Two
* transfer agents are initiated, {@link MakeTargetTransfer} and
* {@link TextTransfer}.
*/
@Override
public void run() {
IStructuredSelection selection = getStructuredSelection();
MakeTargetTransferData makeTargetTransferData = new MakeTargetTransferData();
for (Object selectionItem : selection.toList()) {
if (selectionItem instanceof IMakeTarget) {
makeTargetTransferData.addMakeTarget((IMakeTarget) selectionItem);
}
}
try {
clipboard.setContents(new Object[] { makeTargetTransferData,
TextTransferDragSourceListener.convertSelectedMakeTargetsToText(selection) },
new Transfer[] { MakeTargetTransfer.getInstance(), TextTransfer.getInstance() });
// update the enablement of the paste action
if (pasteAction != null && pasteAction.getStructuredSelection() != null) {
pasteAction.selectionChanged(pasteAction.getStructuredSelection());
}
} catch (SWTError e) {
MakeUIPlugin.errorDialog(shell,
MakeUIPlugin.getResourceString("CopyTargetAction.title.clipboardProblem"), //$NON-NLS-1$
MakeUIPlugin.getResourceString("CopyTargetAction.message.clipboardProblem"), //$NON-NLS-1$
e);
}
}
}

View file

@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Andrew Gvozdev (Quoin Inc.)
*******************************************************************************/
package org.eclipse.cdt.make.ui.views;
@ -14,6 +15,16 @@ import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.dnd.AbstractContainerAreaDropAdapter;
import org.eclipse.cdt.make.internal.ui.dnd.AbstractSelectionDragAdapter;
import org.eclipse.cdt.make.internal.ui.dnd.FileTransferDropTargetListener;
import org.eclipse.cdt.make.internal.ui.dnd.LocalTransferDragSourceListener;
import org.eclipse.cdt.make.internal.ui.dnd.LocalTransferDropTargetListener;
import org.eclipse.cdt.make.internal.ui.dnd.MakeTargetTransfer;
import org.eclipse.cdt.make.internal.ui.dnd.MakeTargetTransferDragSourceListener;
import org.eclipse.cdt.make.internal.ui.dnd.MakeTargetTransferDropTargetListener;
import org.eclipse.cdt.make.internal.ui.dnd.TextTransferDragSourceListener;
import org.eclipse.cdt.make.internal.ui.dnd.TextTransferDropTargetListener;
import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
import org.eclipse.cdt.make.ui.MakeContentProvider;
import org.eclipse.cdt.make.ui.MakeLabelProvider;
@ -31,6 +42,8 @@ import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.util.DelegatingDragAdapter;
import org.eclipse.jface.util.DelegatingDropAdapter;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@ -41,20 +54,32 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.TextActionHandler;
import org.eclipse.ui.part.DrillDownAdapter;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
public class MakeView extends ViewPart {
private Clipboard clipboard;
private BuildTargetAction buildTargetAction;
private EditTargetAction editTargetAction;
private DeleteTargetAction deleteTargetAction;
AddTargetAction addTargetAction;
private CopyTargetAction copyTargetAction;
private PasteTargetAction pasteTargetAction;
TreeViewer fViewer;
DrillDownAdapter drillDownAdapter;
private Action trimEmptyFolderAction;
@ -65,24 +90,27 @@ public class MakeView extends ViewPart {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.ui.IWorkbenchPart#setFocus()
*/
@Override
public void setFocus() {
fViewer.getTree().setFocus();
}
/*
* (non-Javadoc)
*
*
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
MakeUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(parent, IMakeHelpContextIds.MAKE_VIEW);
fViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
fViewer.setUseHashlookup(true);
fViewer.setContentProvider(new MakeContentProvider());
fViewer.setLabelProvider(new MakeLabelProvider());
initDragAndDrop();
drillDownAdapter = new DrillDownAdapter(fViewer);
@ -100,6 +128,7 @@ public class MakeView extends ViewPart {
});
fViewer.getControl().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.character == SWT.DEL && event.stateMask == 0) {
handleDeleteKeyPressed();
@ -111,6 +140,7 @@ public class MakeView extends ViewPart {
fViewer.setLabelProvider(new MakeLabelProvider());
fViewer.setSorter(new ViewerSorter() {
@Override
public int category(Object element) {
if (element instanceof IResource) {
return 0;
@ -126,9 +156,53 @@ public class MakeView extends ViewPart {
contributeToActionBars();
}
/**
* Initialize drag and drop operations.
*/
private void initDragAndDrop() {
int opers= DND.DROP_COPY | DND.DROP_MOVE;
// LocalSelectionTransfer is used inside Make Target View
// TextTransfer is used to drag outside the View or eclipse
Transfer[] dragTransfers= {
LocalSelectionTransfer.getInstance(),
MakeTargetTransfer.getInstance(),
TextTransfer.getInstance(),
};
AbstractSelectionDragAdapter[] dragListeners = {
new LocalTransferDragSourceListener(fViewer),
new MakeTargetTransferDragSourceListener(fViewer),
new TextTransferDragSourceListener(fViewer),
};
DelegatingDragAdapter delegatingDragAdapter = new DelegatingDragAdapter();
for (AbstractSelectionDragAdapter dragListener : dragListeners) {
delegatingDragAdapter.addDragSourceListener(dragListener);
}
fViewer.addDragSupport(opers, dragTransfers, delegatingDragAdapter);
Transfer[] dropTransfers= {
LocalSelectionTransfer.getInstance(),
MakeTargetTransfer.getInstance(),
FileTransfer.getInstance(),
TextTransfer.getInstance(),
};
AbstractContainerAreaDropAdapter[] dropListeners = {
new LocalTransferDropTargetListener(fViewer),
new MakeTargetTransferDropTargetListener(fViewer),
new FileTransferDropTargetListener(fViewer),
new TextTransferDropTargetListener(fViewer),
};
DelegatingDropAdapter delegatingDropAdapter = new DelegatingDropAdapter();
for (AbstractContainerAreaDropAdapter dropListener : dropListeners) {
delegatingDropAdapter.addDropTargetListener(dropListener);
}
fViewer.addDropSupport(opers | DND.DROP_DEFAULT, dropTransfers, delegatingDropAdapter);
}
/**
* Returns setting for this control.
*
*
* @return Settings.
*/
IDialogSettings getSettings() {
@ -150,7 +224,7 @@ public class MakeView extends ViewPart {
setChecked(getSettings().getBoolean(FILTER_EMPTY_FOLDERS));
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_FILTER); //$NON-NLS-1$
fViewer.addFilter(new ViewerFilter() {
//Check the make targets of the specified container, and if they don't exist, run
//Check the make targets of the specified container, and if they don't exist, run
//through the children looking for the first match that we can find that contains
//a make target.
private boolean hasMakeTargets(IFolder container) throws CoreException {
@ -183,7 +257,8 @@ public class MakeView extends ViewPart {
return haveTargets[0];
}
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (isChecked() && element instanceof IFolder) {
try {
@ -197,6 +272,7 @@ public class MakeView extends ViewPart {
});
}
@Override
public void run() {
fViewer.refresh();
getSettings().put(FILTER_EMPTY_FOLDERS, isChecked());
@ -204,16 +280,27 @@ public class MakeView extends ViewPart {
}
private void makeActions() {
buildTargetAction = new BuildTargetAction(fViewer.getControl().getShell());
addTargetAction = new AddTargetAction(fViewer.getControl().getShell());
deleteTargetAction = new DeleteTargetAction(fViewer.getControl().getShell());
editTargetAction = new EditTargetAction(fViewer.getControl().getShell());
Shell shell = fViewer.getControl().getShell();
clipboard = new Clipboard(shell.getDisplay());
buildTargetAction = new BuildTargetAction(shell);
addTargetAction = new AddTargetAction(shell);
copyTargetAction = new CopyTargetAction(shell, clipboard, pasteTargetAction);
pasteTargetAction = new PasteTargetAction(shell, clipboard);
deleteTargetAction = new DeleteTargetAction(shell);
editTargetAction = new EditTargetAction(shell);
trimEmptyFolderAction = new FilterEmtpyFoldersAction();
}
private void contributeToActionBars() {
IActionBars bars = getViewSite().getActionBars();
fillLocalPullDown(bars.getMenuManager());
fillLocalToolBar(bars.getToolBarManager());
IActionBars actionBars = getViewSite().getActionBars();
fillLocalPullDown(actionBars.getMenuManager());
fillLocalToolBar(actionBars.getToolBarManager());
TextActionHandler textActionHandler = new TextActionHandler(actionBars); // hooks handlers
textActionHandler.setCopyAction(copyTargetAction);
textActionHandler.setPasteAction(pasteTargetAction);
textActionHandler.setDeleteAction(deleteTargetAction);
}
private void fillLocalToolBar(IToolBarManager toolBar) {
@ -243,6 +330,8 @@ public class MakeView extends ViewPart {
protected void fillContextMenu(IMenuManager manager) {
manager.add(buildTargetAction);
manager.add(addTargetAction);
manager.add(copyTargetAction);
manager.add(pasteTargetAction);
manager.add(deleteTargetAction);
manager.add(editTargetAction);
manager.add(new Separator());
@ -270,5 +359,20 @@ public class MakeView extends ViewPart {
buildTargetAction.selectionChanged(sel);
deleteTargetAction.selectionChanged(sel);
editTargetAction.selectionChanged(sel);
copyTargetAction.selectionChanged(sel);
pasteTargetAction.selectionChanged(sel);
}
/**
* @see org.eclipse.ui.part.WorkbenchPart#dispose()
*/
@Override
public void dispose() {
if (clipboard != null) {
clipboard.dispose();
clipboard = null;
}
super.dispose();
}
}

View file

@ -0,0 +1,119 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Andrew Gvozdev.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.)- Initial implementation
*******************************************************************************/
package org.eclipse.cdt.make.ui.views;
import java.util.List;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.dnd.FileTransferDropTargetListener;
import org.eclipse.cdt.make.internal.ui.dnd.MakeTargetTransfer;
import org.eclipse.cdt.make.internal.ui.dnd.MakeTargetTransferData;
import org.eclipse.cdt.make.internal.ui.dnd.MakeTargetTransferDropTargetListener;
import org.eclipse.cdt.make.internal.ui.dnd.TextTransferDropTargetListener;
import org.eclipse.core.resources.IContainer;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.SelectionListenerAction;
/**
* Action to paste make targets from clipboard to Make Target View.
* {@link PasteTargetAction} can accept several kinds of clipboard transfers
* including make targets, plain text or files .
* <p>
* {@link CopyTargetAction} and {@link PasteTargetAction} are able to transfer
* targets inside Make Target View or between eclipse sessions.
*
*/
public class PasteTargetAction extends SelectionListenerAction {
private final Shell shell;
private final Clipboard clipboard;
/**
* Constructor setting internal private fields and initializing the action.
*
* @param shell - the shell in which to show any dialogs.
* @param clipboard - system clipboard.
*/
protected PasteTargetAction(Shell shell, Clipboard clipboard) {
super(MakeUIPlugin.getResourceString("PasteTargetAction.label")); //$NON-NLS-1$
this.shell = shell;
this.clipboard = clipboard;
ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
setToolTipText(MakeUIPlugin.getResourceString("PasteTargetAction.tooltip")); //$NON-NLS-1$
}
/**
* Updates enablement of this action in response to the given selection.
*/
@Override
protected boolean updateSelection(IStructuredSelection selection) {
if (!super.updateSelection(selection)) {
return false;
}
if (selection.size() == 1 && (selection.getFirstElement() instanceof IContainer)) {
return true;
}
return false;
}
/**
* Perform actual action of pasting of make targets from clipboard. An appropriate
* transfer agent is used depending on the clipboard content data type.
*/
@Override
public void run() {
List<?> resources = getSelectedResources();
if (resources.size() != 1 || !(resources.get(0) instanceof IContainer)) {
return;
}
IContainer dropContainer = (IContainer) resources.get(0);
Object clipboardContent;
clipboardContent = clipboard.getContents(MakeTargetTransfer.getInstance());
if (clipboardContent instanceof MakeTargetTransferData) {
MakeTargetTransferDropTargetListener.createTransferTargetsUI(
(MakeTargetTransferData) clipboardContent, dropContainer, DND.DROP_COPY, shell);
return;
}
clipboardContent = clipboard.getContents(FileTransfer.getInstance());
if (clipboardContent instanceof String[]) {
FileTransferDropTargetListener.createFileTargetsUI((String[]) clipboardContent,
dropContainer, DND.DROP_COPY, shell);
return;
}
clipboardContent = clipboard.getContents(TextTransfer.getInstance());
if (clipboardContent instanceof String) {
TextTransferDropTargetListener.createMultilineTargetsUI((String) clipboardContent,
dropContainer, DND.DROP_COPY, shell);
return;
}
}
}