1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 23:15:24 +02:00

[124421] - applied clean-up patch

This commit is contained in:
Alena Laskavaia 2009-02-03 14:56:01 +00:00
parent b742f53981
commit dd74a6f0eb
6 changed files with 89 additions and 89 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2007 QNX Software Systems and others. * Copyright (c) 2000, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -31,8 +31,8 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
public class BuildTargetDialog extends Dialog { public class BuildTargetDialog extends Dialog {
TargetListViewerPart targetPart; private final TargetListViewerPart targetPart;
IContainer fContainer; private final IContainer fContainer;
public BuildTargetDialog(Shell parent, IContainer container) { public BuildTargetDialog(Shell parent, IContainer container) {
super(parent); super(parent);
@ -49,11 +49,13 @@ public class BuildTargetDialog extends Dialog {
return targetPart.getSelectedTarget(); return targetPart.getSelectedTarget();
} }
@Override
protected void configureShell(Shell newShell) { protected void configureShell(Shell newShell) {
super.configureShell(newShell); super.configureShell(newShell);
newShell.setText(MakeUIPlugin.getResourceString("BuildTargetDialog.title.buildTarget")); //$NON-NLS-1$ newShell.setText(MakeUIPlugin.getResourceString("BuildTargetDialog.title.buildTarget")); //$NON-NLS-1$
} }
@Override
protected void createButtonsForButtonBar(Composite parent) { protected void createButtonsForButtonBar(Composite parent) {
// create Build and Cancel buttons by default // create Build and Cancel buttons by default
createButton(parent, IDialogConstants.OK_ID, MakeUIPlugin.getResourceString("BuildTargetDialog.button.build"), true); //$NON-NLS-1$ createButton(parent, IDialogConstants.OK_ID, MakeUIPlugin.getResourceString("BuildTargetDialog.button.build"), true); //$NON-NLS-1$
@ -61,6 +63,7 @@ public class BuildTargetDialog extends Dialog {
getButton(IDialogConstants.OK_ID).setEnabled(targetPart.getSelectedTarget() != null); getButton(IDialogConstants.OK_ID).setEnabled(targetPart.getSelectedTarget() != null);
} }
@Override
protected Control createDialogArea(Composite parent) { protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent); Composite composite = (Composite) super.createDialogArea(parent);
((GridLayout) composite.getLayout()).numColumns = 2; ((GridLayout) composite.getLayout()).numColumns = 2;
@ -88,6 +91,7 @@ public class BuildTargetDialog extends Dialog {
return composite; return composite;
} }
@Override
protected void okPressed() { protected void okPressed() {
IMakeTarget selected = targetPart.getSelectedTarget(); IMakeTarget selected = targetPart.getSelectedTarget();
super.okPressed(); super.okPressed();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2007 QNX Software Systems and others. * Copyright (c) 2000, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -44,7 +44,7 @@ import org.eclipse.swt.widgets.Text;
public class MakeTargetDialog extends Dialog { public class MakeTargetDialog extends Dialog {
protected MessageLine fStatusLine; private MessageLine fStatusLine;
private static final String TARGET_PREFIX = "TargetBlock"; //$NON-NLS-1$ private static final String TARGET_PREFIX = "TargetBlock"; //$NON-NLS-1$
private static final String TARGET_NAME_LABEL = TARGET_PREFIX + ".target.label"; //$NON-NLS-1$ private static final String TARGET_NAME_LABEL = TARGET_PREFIX + ".target.label"; //$NON-NLS-1$
@ -68,11 +68,11 @@ public class MakeTargetDialog extends Dialog {
private Button defButton; private Button defButton;
private Text targetText; private Text targetText;
private IMakeTargetManager fTargetManager; private final IMakeTargetManager fTargetManager;
private IContainer fContainer; private final IContainer fContainer;
private IPath buildCommand; private IPath buildCommand;
private String defaultBuildCommand; private final String defaultBuildCommand;
private boolean isDefaultCommand; private boolean isDefaultCommand;
private boolean isStopOnError; private boolean isStopOnError;
private boolean runAllBuilders = true; private boolean runAllBuilders = true;
@ -108,7 +108,7 @@ public class MakeTargetDialog extends Dialog {
} catch (CoreException e) { } catch (CoreException e) {
// ignore exception since no update action was initiated by user yet // ignore exception since no update action was initiated by user yet
} }
} }
} }
@ -116,12 +116,12 @@ public class MakeTargetDialog extends Dialog {
setStatusLine(); setStatusLine();
updateButtons(); updateButtons();
} }
} }
/** /**
* This constructor is called on "Edit Make Target" action. * This constructor is called on "Edit Make Target" action.
* *
* @param parentShell - shell to display the dialog. * @param parentShell - shell to display the dialog.
* @param target - make target to edit. * @param target - make target to edit.
* @throws CoreException * @throws CoreException
@ -142,7 +142,7 @@ public class MakeTargetDialog extends Dialog {
/** /**
* This constructor is called on "Add Make Target" action and from * This constructor is called on "Add Make Target" action and from
* the other constructor where some initialized values can be overwritten. * the other constructor where some initialized values can be overwritten.
* *
* @param parentShell - shell to display the dialog. * @param parentShell - shell to display the dialog.
* @param container - container where to create the target. * @param container - container where to create the target.
* @throws CoreException * @throws CoreException
@ -169,6 +169,7 @@ public class MakeTargetDialog extends Dialog {
setShellStyle(getShellStyle() | SWT.RESIZE); setShellStyle(getShellStyle() | SWT.RESIZE);
} }
@Override
protected void configureShell(Shell newShell) { protected void configureShell(Shell newShell) {
newShell.setText(getTitle()); newShell.setText(getTitle());
super.configureShell(newShell); super.configureShell(newShell);
@ -185,9 +186,10 @@ public class MakeTargetDialog extends Dialog {
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/ */
@Override
protected Control createDialogArea(Composite parent) { protected Control createDialogArea(Composite parent) {
Composite composite = (Composite)super.createDialogArea(parent); Composite composite = (Composite)super.createDialogArea(parent);
initializeDialogUnits(composite); initializeDialogUnits(composite);
@ -229,6 +231,7 @@ public class MakeTargetDialog extends Dialog {
stopOnErrorButton.setText(MakeUIPlugin.getResourceString(MAKE_SETTING_STOP_ERROR)); stopOnErrorButton.setText(MakeUIPlugin.getResourceString(MAKE_SETTING_STOP_ERROR));
stopOnErrorButton.addSelectionListener(new SelectionAdapter() { stopOnErrorButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
updateButtons(); updateButtons();
} }
@ -246,6 +249,7 @@ public class MakeTargetDialog extends Dialog {
runAllBuildersButton.setText(MakeUIPlugin.getResourceString("SettingsBlock.makeSetting.runAllBuilders")); //$NON-NLS-1$ runAllBuildersButton.setText(MakeUIPlugin.getResourceString("SettingsBlock.makeSetting.runAllBuilders")); //$NON-NLS-1$
runAllBuildersButton.addSelectionListener(new SelectionAdapter() { runAllBuildersButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
updateButtons(); updateButtons();
} }
@ -267,6 +271,7 @@ public class MakeTargetDialog extends Dialog {
defButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_CMD_USE_BUILDER_SETTINGS)); defButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_CMD_USE_BUILDER_SETTINGS));
defButton.addSelectionListener(new SelectionAdapter() { defButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
if (defButton.getSelection() == true) { if (defButton.getSelection() == true) {
commandText.setText(defaultBuildCommand); commandText.setText(defaultBuildCommand);
@ -308,14 +313,14 @@ public class MakeTargetDialog extends Dialog {
GridData gd = new GridData(GridData.FILL_HORIZONTAL); GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = convertWidthInCharsToPixels(50); gd.widthHint = convertWidthInCharsToPixels(50);
group.setLayoutData(gd); group.setLayoutData(gd);
sameAsNameCheck = new Button(group, SWT.CHECK); sameAsNameCheck = new Button(group, SWT.CHECK);
gd = new GridData(); gd = new GridData();
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
sameAsNameCheck.setLayoutData(gd); sameAsNameCheck.setLayoutData(gd);
sameAsNameCheck.setText(MakeUIPlugin.getResourceString("SettingsBlock.makeSetting.sameAsTarget")); //$NON-NLS-1$ sameAsNameCheck.setText(MakeUIPlugin.getResourceString("SettingsBlock.makeSetting.sameAsTarget")); //$NON-NLS-1$
/* Add a listener to the target name text to update the targetText */ /* Add a listener to the target name text to update the targetText */
targetNameText.addModifyListener(new ModifyListener() { targetNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
if (sameAsNameCheck.getSelection()) { if (sameAsNameCheck.getSelection()) {
@ -323,7 +328,7 @@ public class MakeTargetDialog extends Dialog {
} }
} }
}); });
Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(BUILD_ARGUMENT_LABEL)); Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(BUILD_ARGUMENT_LABEL));
((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING; ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false; ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
@ -336,8 +341,9 @@ public class MakeTargetDialog extends Dialog {
updateButtons(); updateButtons();
} }
}); });
sameAsNameCheck.addSelectionListener(new SelectionAdapter() { sameAsNameCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
sameAsNameSelected(); sameAsNameSelected();
} }
@ -354,6 +360,7 @@ public class MakeTargetDialog extends Dialog {
} }
} }
@Override
protected void createButtonsForButtonBar(Composite parent) { protected void createButtonsForButtonBar(Composite parent) {
if (fTarget == null || !MakeCorePlugin.getDefault().getTargetManager().targetExists(fTarget)) { if (fTarget == null || !MakeCorePlugin.getDefault().getTargetManager().targetExists(fTarget)) {
createButton(parent, IDialogConstants.OK_ID, MakeUIPlugin.getResourceString("MakeTargetDialog.button.create"), true); //$NON-NLS-1$ createButton(parent, IDialogConstants.OK_ID, MakeUIPlugin.getResourceString("MakeTargetDialog.button.create"), true); //$NON-NLS-1$
@ -390,18 +397,24 @@ public class MakeTargetDialog extends Dialog {
} }
protected boolean targetHasChanged() { protected boolean targetHasChanged() {
if (initializing || fTarget == null || !MakeCorePlugin.getDefault().getTargetManager().targetExists(fTarget)) if (initializing || fTarget == null || !MakeCorePlugin.getDefault().getTargetManager().targetExists(fTarget)) {
return true; return true;
if (isStopOnError != isStopOnError()) }
if (isStopOnError != isStopOnError()) {
return true; return true;
if (runAllBuilders != runAllBuilders()) }
if (runAllBuilders != runAllBuilders()) {
return true; return true;
if (isDefaultCommand != useDefaultBuildCmd()) }
if (isDefaultCommand != useDefaultBuildCmd()) {
return true; return true;
if (!targetName.equals(getTargetName())) }
if (!targetName.equals(getTargetName())) {
return true; return true;
if (!targetString.equals(getTarget())) }
if (!targetString.equals(getTarget())) {
return true; return true;
}
if (!isDefaultCommand) { if (!isDefaultCommand) {
StringBuffer cmd = new StringBuffer(buildCommand.toOSString()).append(buildArguments); StringBuffer cmd = new StringBuffer(buildCommand.toOSString()).append(buildArguments);
if (!getBuildLine().equals(cmd.toString())) { if (!getBuildLine().equals(cmd.toString())) {
@ -439,8 +452,9 @@ public class MakeTargetDialog extends Dialog {
private String getBuildLine() { private String getBuildLine() {
if (commandText != null) { if (commandText != null) {
String cmd = commandText.getText(); String cmd = commandText.getText();
if (cmd != null) if (cmd != null) {
return cmd.trim(); return cmd.trim();
}
} }
return null; return null;
} }
@ -453,6 +467,7 @@ public class MakeTargetDialog extends Dialog {
return targetNameText.getText().trim(); return targetNameText.getText().trim();
} }
@Override
protected void okPressed() { protected void okPressed() {
IMakeTarget target = fTarget; IMakeTarget target = fTarget;
try { try {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2006 QNX Software Systems and others. * Copyright (c) 2000, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -17,16 +17,13 @@ import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog; import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog;
import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.actions.SelectionListenerAction; import org.eclipse.ui.actions.SelectionListenerAction;
public class AddTargetAction extends SelectionListenerAction { public class AddTargetAction extends SelectionListenerAction {
private final Shell shell;
Shell shell;
IResource resource;
public AddTargetAction(Shell shell) { public AddTargetAction(Shell shell) {
super(MakeUIPlugin.getResourceString("AddTargetAction.label")); //$NON-NLS-1$ super(MakeUIPlugin.getResourceString("AddTargetAction.label")); //$NON-NLS-1$
@ -36,6 +33,7 @@ public class AddTargetAction extends SelectionListenerAction {
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_ADD); //$NON-NLS-1$ MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_ADD); //$NON-NLS-1$
} }
@Override
public void run() { public void run() {
if (canAdd()) { if (canAdd()) {
try { try {
@ -48,16 +46,14 @@ public class AddTargetAction extends SelectionListenerAction {
} }
@Override
protected boolean updateSelection(IStructuredSelection selection) { protected boolean updateSelection(IStructuredSelection selection) {
return super.updateSelection(selection) && canAdd(); return super.updateSelection(selection) && canAdd();
} }
private boolean canAdd() { private boolean canAdd() {
List elements = getStructuredSelection().toList(); List<?> elements = getStructuredSelection().toList();
if (elements.size() > 1 || elements.size() < 1) { if (elements.size()==1 && (elements.get(0) instanceof IContainer)) {
return false;
}
if (elements.get(0) instanceof IContainer) {
return true; return true;
} }
return false; return false;

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2006 QNX Software Systems and others. * Copyright (c) 2000, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,22 +11,18 @@
package org.eclipse.cdt.make.ui.views; package org.eclipse.cdt.make.ui.views;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.make.core.IMakeTarget; import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIImages; import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.TargetBuild; import org.eclipse.cdt.make.ui.TargetBuild;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.actions.SelectionListenerAction; import org.eclipse.ui.actions.SelectionListenerAction;
public class BuildTargetAction extends SelectionListenerAction { public class BuildTargetAction extends SelectionListenerAction {
private final Shell shell;
Shell shell;
IResource resource;
public BuildTargetAction(Shell shell) { public BuildTargetAction(Shell shell) {
super(MakeUIPlugin.getResourceString("BuildTargetAction.label")); //$NON-NLS-1$ super(MakeUIPlugin.getResourceString("BuildTargetAction.label")); //$NON-NLS-1$
@ -36,32 +32,30 @@ public class BuildTargetAction extends SelectionListenerAction {
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_BUILD); //$NON-NLS-1$ MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_BUILD); //$NON-NLS-1$
} }
@Override
public void run() { public void run() {
if (canBuild()) { if (canBuild()) {
IMakeTarget[] targets = (IMakeTarget[]) getSelectedElements().toArray(new IMakeTarget[0]); IMakeTarget[] targets = getSelectedElements().toArray(new IMakeTarget[0]);
TargetBuild.buildTargets(shell, targets); TargetBuild.buildTargets(shell, targets);
} }
} }
@Override
protected boolean updateSelection(IStructuredSelection selection) { protected boolean updateSelection(IStructuredSelection selection) {
return super.updateSelection(selection) && canBuild(); return super.updateSelection(selection) && canBuild();
} }
private boolean canBuild() { private boolean canBuild() {
List elements = getSelectedElements(); List<?> elements = getSelectedElements();
if (elements.size() > 0) { for (Object element : elements) {
Iterator iterator = elements.iterator(); if (! (element instanceof IMakeTarget)) {
while (iterator.hasNext()) { return false;
if (!(iterator.next() instanceof IMakeTarget)) {
return false;
}
} }
return true;
} }
return false; return elements.size()>0;
} }
private List getSelectedElements() { private List<?> getSelectedElements() {
return getStructuredSelection().toList(); return getStructuredSelection().toList();
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2006 QNX Software Systems and others. * Copyright (c) 2000, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,7 +12,6 @@ package org.eclipse.cdt.make.ui.views;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.make.core.IMakeTarget; import org.eclipse.cdt.make.core.IMakeTarget;
@ -20,7 +19,6 @@ import org.eclipse.cdt.make.core.IMakeTargetManager;
import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIImages; import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
@ -28,9 +26,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.actions.SelectionListenerAction; import org.eclipse.ui.actions.SelectionListenerAction;
public class DeleteTargetAction extends SelectionListenerAction { public class DeleteTargetAction extends SelectionListenerAction {
private final Shell shell;
Shell shell;
IResource resource;
public DeleteTargetAction(Shell shell) { public DeleteTargetAction(Shell shell) {
super(MakeUIPlugin.getResourceString("DeleteTargetAction.label")); //$NON-NLS-1$ super(MakeUIPlugin.getResourceString("DeleteTargetAction.label")); //$NON-NLS-1$
@ -47,38 +43,41 @@ public class DeleteTargetAction extends SelectionListenerAction {
* if the deletion should be abandoned * if the deletion should be abandoned
*/ */
boolean confirmDelete() { boolean confirmDelete() {
List targets = getTargetsToDelete(); List<?> targets = getSelectedElements();
String title; String title;
String msg; String msg;
if (targets.size() == 1) { if (targets.size() == 1) {
title = MakeUIPlugin.getResourceString("DeleteTargetAction.title.confirmDeletion"); //$NON-NLS-1$ title = MakeUIPlugin.getResourceString("DeleteTargetAction.title.confirmDeletion"); //$NON-NLS-1$
IMakeTarget target = (IMakeTarget) targets.get(0); IMakeTarget target = (IMakeTarget) targets.get(0);
msg = MessageFormat.format(MakeUIPlugin.getResourceString("DeleteTargetAction.message.confirmDeleteion"), new Object[] { target.getName()}); //$NON-NLS-1$ msg = MessageFormat.format(MakeUIPlugin.getResourceString("DeleteTargetAction.message.confirmDeleteion"), //$NON-NLS-1$
new Object[] { target.getName()});
} else { } else {
title = MakeUIPlugin.getResourceString("DeleteTargetAction.title.confirmMultipleDeletion"); //$NON-NLS-1$ title = MakeUIPlugin.getResourceString("DeleteTargetAction.title.confirmMultipleDeletion"); //$NON-NLS-1$
msg = msg = MessageFormat.format(MakeUIPlugin.getResourceString("DeleteTargetAction.message.confirmMultipleDeletion"), //$NON-NLS-1$
MessageFormat.format( new Object[] { new Integer(targets.size())});
MakeUIPlugin.getResourceString("DeleteTargetAction.message.confirmMultipleDeletion"), //$NON-NLS-1$
new Object[] { new Integer(targets.size())});
} }
return MessageDialog.openQuestion(shell, title, msg); return MessageDialog.openQuestion(shell, title, msg);
} }
@Override
public void run() { public void run() {
if (!canDelete() || confirmDelete() == false) if (!canDelete() || confirmDelete() == false) {
return; return;
List targets = getTargetsToDelete(); }
IMakeTargetManager manager = MakeCorePlugin.getDefault().getTargetManager(); IMakeTargetManager manager = MakeCorePlugin.getDefault().getTargetManager();
Iterator iter = targets.iterator();
try { try {
while (iter.hasNext()) { for (Object target : getSelectedElements()) {
manager.removeTarget((IMakeTarget) iter.next()); if (target instanceof IMakeTarget) {
manager.removeTarget((IMakeTarget) target);
}
} }
} catch (CoreException e) { } catch (CoreException e) {
MakeUIPlugin.errorDialog(shell, MakeUIPlugin.getResourceString("DeleteTargetAction.exception.removeError"), MakeUIPlugin.getResourceString("DeleteTargetAction.exception.errorDeletingBuildTarget"), e); //$NON-NLS-1$ //$NON-NLS-2$ MakeUIPlugin.errorDialog(shell, MakeUIPlugin.getResourceString("DeleteTargetAction.exception.removeError"), //$NON-NLS-1$
MakeUIPlugin.getResourceString("DeleteTargetAction.exception.errorDeletingBuildTarget"), e); //$NON-NLS-1$
} }
} }
@Override
protected boolean updateSelection(IStructuredSelection selection) { protected boolean updateSelection(IStructuredSelection selection) {
return super.updateSelection(selection) && canDelete(); return super.updateSelection(selection) && canDelete();
} }
@ -86,7 +85,7 @@ public class DeleteTargetAction extends SelectionListenerAction {
/** /**
* @return * @return
*/ */
private List getTargetsToDelete() { private List<?> getSelectedElements() {
return getStructuredSelection().toList(); return getStructuredSelection().toList();
} }
@ -94,17 +93,13 @@ public class DeleteTargetAction extends SelectionListenerAction {
* @return * @return
*/ */
private boolean canDelete() { private boolean canDelete() {
List elements = getStructuredSelection().toList(); List<?> elements = getSelectedElements();
if (elements.size() > 0) { for (Object element : elements) {
Iterator iterator = elements.iterator(); if (! (element instanceof IMakeTarget)) {
while (iterator.hasNext()) { return false;
if (!(iterator.next() instanceof IMakeTarget)) {
return false;
}
} }
return true;
} }
return false; return elements.size()>0;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2006 QNX Software Systems and others. * Copyright (c) 2000, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -17,16 +17,13 @@ import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIImages; import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog; import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.actions.SelectionListenerAction; import org.eclipse.ui.actions.SelectionListenerAction;
public class EditTargetAction extends SelectionListenerAction { public class EditTargetAction extends SelectionListenerAction {
private final Shell shell;
Shell shell;
IResource resource;
public EditTargetAction(Shell shell) { public EditTargetAction(Shell shell) {
super(MakeUIPlugin.getResourceString("EditTargetAction.label")); //$NON-NLS-1$ super(MakeUIPlugin.getResourceString("EditTargetAction.label")); //$NON-NLS-1$
@ -36,6 +33,7 @@ public class EditTargetAction extends SelectionListenerAction {
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_EDIT); //$NON-NLS-1$ MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_EDIT); //$NON-NLS-1$
} }
@Override
public void run() { public void run() {
if (canRename()) { if (canRename()) {
MakeTargetDialog dialog; MakeTargetDialog dialog;
@ -48,16 +46,14 @@ public class EditTargetAction extends SelectionListenerAction {
} }
} }
@Override
protected boolean updateSelection(IStructuredSelection selection) { protected boolean updateSelection(IStructuredSelection selection) {
return super.updateSelection(selection) && canRename(); return super.updateSelection(selection) && canRename();
} }
private boolean canRename() { private boolean canRename() {
List elements = getStructuredSelection().toList(); List<?> elements = getStructuredSelection().toList();
if (elements.size() > 1 || elements.size() < 1) { if (elements.size()==1 && (elements.get(0) instanceof IMakeTarget)) {
return false;
}
if (elements.get(0) instanceof IMakeTarget) {
return true; return true;
} }
return false; return false;