[yocto] [RFC 11/17] plugins/sdk.ide: Add UI method to delete a profile
Timo Mueller
mail at timomueller.eu
Thu Jan 24 07:12:35 PST 2013
From: Timo Mueller <timo.mueller at bmw-carit.de>
A profile is removed from the list, when the delete button is
clicked. The deletion has to be confirmed by the user. Deleting the
standard profile is not allowed.
Signed-off-by: Timo Mueller <timo.mueller at bmw-carit.de>
---
.../src/org/yocto/sdk/ide/YoctoProfileSetting.java | 34 ++++++++++++++++++++++
.../org/yocto/sdk/ide/YoctoSDKMessages.properties | 4 +++
2 files changed, 38 insertions(+)
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java
index 6a38fb1..cd44b92 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java
@@ -12,6 +12,7 @@ package org.yocto.sdk.ide;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
@@ -24,6 +25,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Listener;
+import org.yocto.sdk.ide.preferences.PreferenceConstants;
import org.yocto.sdk.ide.preferences.ProfileNameInputValidator;
public class YoctoProfileSetting {
@@ -33,6 +35,10 @@ public class YoctoProfileSetting {
private static final String NEW_DIALOG_MESSAGE = "Preferences.Profile.New.Dialog.Message";
private static final String RENAME_PROFILE_TITLE = "Preferences.Profile.Rename.Title";
private static final String REMOVE_PROFILE_TITLE = "Preferences.Profile.Remove.Title";
+ private static final String REMOVE_DIALOG_TITLE = "Preferences.Profile.Remove.Dialog.Title";
+ private static final String REMOVE_DIALOG_MESSAGE = "Preferences.Profile.Remove.Dialog.Message";
+ private static final String MODIFY_STANDARD_TITLE = "Preferences.Profile.Standard.Modification.Title";
+ private static final String MODIFY_STANDARD_MESSAGE = "Preferences.Profile.Standard.Modification.Message";
private Combo sdkConfigsCombo;
private Button btnConfigRename;
@@ -127,6 +133,34 @@ public class YoctoProfileSetting {
btnConfigRemove = new Button(storeYoctoConfigurationsGroup, SWT.PUSH | SWT.LEAD);
btnConfigRemove.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false, 3, 1));
btnConfigRemove.setText(YoctoSDKMessages.getString(REMOVE_PROFILE_TITLE));
+ btnConfigRemove.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ saveChangesOnCurrentProfile();
+ int selectionIndex = sdkConfigsCombo.getSelectionIndex();
+ String selectedItem = sdkConfigsCombo.getItem(selectionIndex);
+
+ if (selectedItem.equals(PreferenceConstants.STANDARD_PROFILE_NAME)) {
+ MessageDialog.openInformation(null,
+ YoctoSDKMessages.getString(MODIFY_STANDARD_TITLE),
+ YoctoSDKMessages.getString(MODIFY_STANDARD_MESSAGE));
+ return;
+ }
+
+ boolean deleteConfirmed =
+ MessageDialog.openConfirm(null,
+ YoctoSDKMessages.getString(REMOVE_DIALOG_TITLE),
+ YoctoSDKMessages.getFormattedString(REMOVE_DIALOG_MESSAGE, selectedItem));
+
+ if (!deleteConfirmed) {
+ return;
+ }
+
+ sdkConfigsCombo.select(0);
+ sdkConfigsCombo.remove(selectionIndex);
+ profileElement.remove(selectedItem);
+ }
+ });
}
private void createRenameButton(Group storeYoctoConfigurationsGroup)
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
index 6876663..cd52348 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
@@ -57,6 +57,10 @@ Preferences.Profile.New.Dialog.Title = Create a new target profile
Preferences.Profile.New.Dialog.Message = Please input a profile name.
Preferences.Profile.Rename.Title = Rename
Preferences.Profile.Remove.Title = Remove
+Preferences.Profile.Remove.Dialog.Title = Remove target profile
+Preferences.Profile.Remove.Dialog.Message = Do you really want to the remove the target profile "{0}"?\nProjects using this target profile will be reconfigured to use the standard profile.
+Preferences.Profile.Standard.Modification.Title = Modify standard target profile
+Preferences.Profile.Standard.Modification.Message = Standard target profile cannot be removed or renamed.
Console.SDK.Name = Yocto Project Console
--
1.7.11.7
More information about the yocto
mailing list