From dd74a6f0ebb85a8c09fcfe66c6d371ccd5ad2250 Mon Sep 17 00:00:00 2001 From: Alena Laskavaia Date: Tue, 3 Feb 2009 14:56:01 +0000 Subject: [PATCH] [124421] - applied clean-up patch --- .../make/ui/dialogs/BuildTargetDialog.java | 10 +++- .../cdt/make/ui/dialogs/MakeTargetDialog.java | 57 ++++++++++++------- .../cdt/make/ui/views/AddTargetAction.java | 16 ++---- .../cdt/make/ui/views/BuildTargetAction.java | 28 ++++----- .../cdt/make/ui/views/DeleteTargetAction.java | 51 ++++++++--------- .../cdt/make/ui/views/EditTargetAction.java | 16 ++---- 6 files changed, 89 insertions(+), 89 deletions(-) diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java index 48e6e64734a..8d6cf88e656 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,8 +31,8 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; public class BuildTargetDialog extends Dialog { - TargetListViewerPart targetPart; - IContainer fContainer; + private final TargetListViewerPart targetPart; + private final IContainer fContainer; public BuildTargetDialog(Shell parent, IContainer container) { super(parent); @@ -49,11 +49,13 @@ public class BuildTargetDialog extends Dialog { return targetPart.getSelectedTarget(); } + @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(MakeUIPlugin.getResourceString("BuildTargetDialog.title.buildTarget")); //$NON-NLS-1$ } + @Override protected void createButtonsForButtonBar(Composite parent) { // create Build and Cancel buttons by default 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); } + @Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); ((GridLayout) composite.getLayout()).numColumns = 2; @@ -88,6 +91,7 @@ public class BuildTargetDialog extends Dialog { return composite; } + @Override protected void okPressed() { IMakeTarget selected = targetPart.getSelectedTarget(); super.okPressed(); diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java index 61ac1306e80..4582cbe4b10 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -44,7 +44,7 @@ import org.eclipse.swt.widgets.Text; 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_NAME_LABEL = TARGET_PREFIX + ".target.label"; //$NON-NLS-1$ @@ -68,11 +68,11 @@ public class MakeTargetDialog extends Dialog { private Button defButton; private Text targetText; - private IMakeTargetManager fTargetManager; - private IContainer fContainer; + private final IMakeTargetManager fTargetManager; + private final IContainer fContainer; private IPath buildCommand; - private String defaultBuildCommand; + private final String defaultBuildCommand; private boolean isDefaultCommand; private boolean isStopOnError; private boolean runAllBuilders = true; @@ -108,7 +108,7 @@ public class MakeTargetDialog extends Dialog { } catch (CoreException e) { // ignore exception since no update action was initiated by user yet } - + } } @@ -116,12 +116,12 @@ public class MakeTargetDialog extends Dialog { setStatusLine(); updateButtons(); } - + } /** * This constructor is called on "Edit Make Target" action. - * + * * @param parentShell - shell to display the dialog. * @param target - make target to edit. * @throws CoreException @@ -142,7 +142,7 @@ public class MakeTargetDialog extends Dialog { /** * This constructor is called on "Add Make Target" action and from * the other constructor where some initialized values can be overwritten. - * + * * @param parentShell - shell to display the dialog. * @param container - container where to create the target. * @throws CoreException @@ -169,6 +169,7 @@ public class MakeTargetDialog extends Dialog { setShellStyle(getShellStyle() | SWT.RESIZE); } + @Override protected void configureShell(Shell newShell) { newShell.setText(getTitle()); super.configureShell(newShell); @@ -185,9 +186,10 @@ public class MakeTargetDialog extends Dialog { } /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) */ + @Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite)super.createDialogArea(parent); initializeDialogUnits(composite); @@ -229,6 +231,7 @@ public class MakeTargetDialog extends Dialog { stopOnErrorButton.setText(MakeUIPlugin.getResourceString(MAKE_SETTING_STOP_ERROR)); stopOnErrorButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { updateButtons(); } @@ -246,6 +249,7 @@ public class MakeTargetDialog extends Dialog { runAllBuildersButton.setText(MakeUIPlugin.getResourceString("SettingsBlock.makeSetting.runAllBuilders")); //$NON-NLS-1$ runAllBuildersButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { updateButtons(); } @@ -267,6 +271,7 @@ public class MakeTargetDialog extends Dialog { defButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_CMD_USE_BUILDER_SETTINGS)); defButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { if (defButton.getSelection() == true) { commandText.setText(defaultBuildCommand); @@ -308,14 +313,14 @@ public class MakeTargetDialog extends Dialog { GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = convertWidthInCharsToPixels(50); group.setLayoutData(gd); - + sameAsNameCheck = new Button(group, SWT.CHECK); gd = new GridData(); gd.horizontalSpan = 2; sameAsNameCheck.setLayoutData(gd); 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() { public void modifyText(ModifyEvent e) { if (sameAsNameCheck.getSelection()) { @@ -323,7 +328,7 @@ public class MakeTargetDialog extends Dialog { } } }); - + Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(BUILD_ARGUMENT_LABEL)); ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING; ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false; @@ -336,8 +341,9 @@ public class MakeTargetDialog extends Dialog { updateButtons(); } }); - + sameAsNameCheck.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { sameAsNameSelected(); } @@ -354,6 +360,7 @@ public class MakeTargetDialog extends Dialog { } } + @Override protected void createButtonsForButtonBar(Composite parent) { if (fTarget == null || !MakeCorePlugin.getDefault().getTargetManager().targetExists(fTarget)) { 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() { - if (initializing || fTarget == null || !MakeCorePlugin.getDefault().getTargetManager().targetExists(fTarget)) + if (initializing || fTarget == null || !MakeCorePlugin.getDefault().getTargetManager().targetExists(fTarget)) { return true; - if (isStopOnError != isStopOnError()) + } + if (isStopOnError != isStopOnError()) { return true; - if (runAllBuilders != runAllBuilders()) + } + if (runAllBuilders != runAllBuilders()) { return true; - if (isDefaultCommand != useDefaultBuildCmd()) + } + if (isDefaultCommand != useDefaultBuildCmd()) { return true; - if (!targetName.equals(getTargetName())) + } + if (!targetName.equals(getTargetName())) { return true; - if (!targetString.equals(getTarget())) + } + if (!targetString.equals(getTarget())) { return true; + } if (!isDefaultCommand) { StringBuffer cmd = new StringBuffer(buildCommand.toOSString()).append(buildArguments); if (!getBuildLine().equals(cmd.toString())) { @@ -439,8 +452,9 @@ public class MakeTargetDialog extends Dialog { private String getBuildLine() { if (commandText != null) { String cmd = commandText.getText(); - if (cmd != null) + if (cmd != null) { return cmd.trim(); + } } return null; } @@ -453,6 +467,7 @@ public class MakeTargetDialog extends Dialog { return targetNameText.getText().trim(); } + @Override protected void okPressed() { IMakeTarget target = fTarget; try { diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/AddTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/AddTargetAction.java index 6236a5de3a3..526b0d46da5 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/AddTargetAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/AddTargetAction.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * 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.ui.dialogs.MakeTargetDialog; import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.actions.SelectionListenerAction; public class AddTargetAction extends SelectionListenerAction { - - Shell shell; - IResource resource; + private final Shell shell; public AddTargetAction(Shell shell) { 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$ } + @Override public void run() { if (canAdd()) { try { @@ -48,16 +46,14 @@ public class AddTargetAction extends SelectionListenerAction { } + @Override protected boolean updateSelection(IStructuredSelection selection) { return super.updateSelection(selection) && canAdd(); } private boolean canAdd() { - List elements = getStructuredSelection().toList(); - if (elements.size() > 1 || elements.size() < 1) { - return false; - } - if (elements.get(0) instanceof IContainer) { + List elements = getStructuredSelection().toList(); + if (elements.size()==1 && (elements.get(0) instanceof IContainer)) { return true; } return false; diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java index 2f01f59d388..3f8bc787b91 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,22 +11,18 @@ package org.eclipse.cdt.make.ui.views; -import java.util.Iterator; import java.util.List; import org.eclipse.cdt.make.core.IMakeTarget; import org.eclipse.cdt.make.internal.ui.MakeUIImages; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; import org.eclipse.cdt.make.ui.TargetBuild; -import org.eclipse.core.resources.IResource; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.actions.SelectionListenerAction; public class BuildTargetAction extends SelectionListenerAction { - - Shell shell; - IResource resource; + private final Shell shell; public BuildTargetAction(Shell shell) { 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$ } + @Override public void run() { if (canBuild()) { - IMakeTarget[] targets = (IMakeTarget[]) getSelectedElements().toArray(new IMakeTarget[0]); + IMakeTarget[] targets = getSelectedElements().toArray(new IMakeTarget[0]); TargetBuild.buildTargets(shell, targets); } } + @Override protected boolean updateSelection(IStructuredSelection selection) { return super.updateSelection(selection) && canBuild(); } private boolean canBuild() { - List elements = getSelectedElements(); - if (elements.size() > 0) { - Iterator iterator = elements.iterator(); - while (iterator.hasNext()) { - if (!(iterator.next() instanceof IMakeTarget)) { - return false; - } + List elements = getSelectedElements(); + for (Object element : elements) { + if (! (element instanceof IMakeTarget)) { + return false; } - return true; } - return false; + return elements.size()>0; } - private List getSelectedElements() { + private List getSelectedElements() { return getStructuredSelection().toList(); } } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java index bc3197c6a4d..bdbce6a0941 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * 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.util.Iterator; import java.util.List; 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.internal.ui.MakeUIImages; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; -import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; @@ -28,9 +26,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.actions.SelectionListenerAction; public class DeleteTargetAction extends SelectionListenerAction { - - Shell shell; - IResource resource; + private final Shell shell; public DeleteTargetAction(Shell shell) { super(MakeUIPlugin.getResourceString("DeleteTargetAction.label")); //$NON-NLS-1$ @@ -47,38 +43,41 @@ public class DeleteTargetAction extends SelectionListenerAction { * if the deletion should be abandoned */ boolean confirmDelete() { - List targets = getTargetsToDelete(); + List targets = getSelectedElements(); String title; String msg; if (targets.size() == 1) { title = MakeUIPlugin.getResourceString("DeleteTargetAction.title.confirmDeletion"); //$NON-NLS-1$ 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 { title = MakeUIPlugin.getResourceString("DeleteTargetAction.title.confirmMultipleDeletion"); //$NON-NLS-1$ - msg = - MessageFormat.format( - MakeUIPlugin.getResourceString("DeleteTargetAction.message.confirmMultipleDeletion"), //$NON-NLS-1$ - new Object[] { new Integer(targets.size())}); + msg = MessageFormat.format(MakeUIPlugin.getResourceString("DeleteTargetAction.message.confirmMultipleDeletion"), //$NON-NLS-1$ + new Object[] { new Integer(targets.size())}); } return MessageDialog.openQuestion(shell, title, msg); } + @Override public void run() { - if (!canDelete() || confirmDelete() == false) + if (!canDelete() || confirmDelete() == false) { return; - List targets = getTargetsToDelete(); + } IMakeTargetManager manager = MakeCorePlugin.getDefault().getTargetManager(); - Iterator iter = targets.iterator(); try { - while (iter.hasNext()) { - manager.removeTarget((IMakeTarget) iter.next()); + for (Object target : getSelectedElements()) { + if (target instanceof IMakeTarget) { + manager.removeTarget((IMakeTarget) target); + } } } 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) { return super.updateSelection(selection) && canDelete(); } @@ -86,7 +85,7 @@ public class DeleteTargetAction extends SelectionListenerAction { /** * @return */ - private List getTargetsToDelete() { + private List getSelectedElements() { return getStructuredSelection().toList(); } @@ -94,17 +93,13 @@ public class DeleteTargetAction extends SelectionListenerAction { * @return */ private boolean canDelete() { - List elements = getStructuredSelection().toList(); - if (elements.size() > 0) { - Iterator iterator = elements.iterator(); - while (iterator.hasNext()) { - if (!(iterator.next() instanceof IMakeTarget)) { - return false; - } + List elements = getSelectedElements(); + for (Object element : elements) { + if (! (element instanceof IMakeTarget)) { + return false; } - return true; } - return false; + return elements.size()>0; } } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/EditTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/EditTargetAction.java index 1ca0f554a00..9a3ffc44d7d 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/EditTargetAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/EditTargetAction.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * 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.MakeUIPlugin; import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog; -import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.actions.SelectionListenerAction; public class EditTargetAction extends SelectionListenerAction { - - Shell shell; - IResource resource; + private final Shell shell; public EditTargetAction(Shell shell) { 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$ } + @Override public void run() { if (canRename()) { MakeTargetDialog dialog; @@ -48,16 +46,14 @@ public class EditTargetAction extends SelectionListenerAction { } } + @Override protected boolean updateSelection(IStructuredSelection selection) { return super.updateSelection(selection) && canRename(); } private boolean canRename() { - List elements = getStructuredSelection().toList(); - if (elements.size() > 1 || elements.size() < 1) { - return false; - } - if (elements.get(0) instanceof IMakeTarget) { + List elements = getStructuredSelection().toList(); + if (elements.size()==1 && (elements.get(0) instanceof IMakeTarget)) { return true; } return false;