|
From: Dan C. <cor...@us...> - 2010-01-17 17:12:15
|
Update of /cvsroot/jcommander/plugins/org.jcommander.ui.app/src/org/jcommander/ui/app/actions In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv11561/src/org/jcommander/ui/app/actions Modified Files: ChooseProfile.java Log Message: Added support for a new cmd line parameter: -profile nc/wc and a new property definition -Dorg.jcommander.profile nc/wc This was needed for bypassing the first dialog when starting the application with an empty workspace. SWTBot can not handle the dialog until the workbench is fully started. See ID: 2932702 Index: ChooseProfile.java =================================================================== RCS file: /cvsroot/jcommander/plugins/org.jcommander.ui.app/src/org/jcommander/ui/app/actions/ChooseProfile.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ChooseProfile.java 6 Aug 2006 09:11:26 -0000 1.5 --- ChooseProfile.java 17 Jan 2010 17:12:06 -0000 1.6 *************** *** 1,27 **** package org.jcommander.ui.app.actions; ! import org.eclipse.core.runtime.*; ! import org.eclipse.jface.action.*; ! import org.eclipse.jface.preference.*; ! import org.eclipse.jface.resource.*; ! import org.eclipse.jface.viewers.*; ! import org.eclipse.swt.*; ! import org.eclipse.swt.events.*; ! import org.eclipse.swt.layout.*; ! import org.eclipse.swt.widgets.*; ! import org.eclipse.ui.*; ! import org.jcommander.ui.app.*; ! import org.jcommander.ui.app.dialogs.*; ! import org.jcommander.ui.filepanel.*; ! import org.jcommander.ui.logger.*; ! import org.jcommander.ui.utils.*; public class ChooseProfile implements IWorkbenchWindowActionDelegate { protected IWorkbenchWindow window; public void dispose() { // TODO Auto-generated method stub - } --- 1,45 ---- package org.jcommander.ui.app.actions; ! import org.eclipse.core.runtime.Platform; ! import org.eclipse.jface.action.IAction; ! import org.eclipse.jface.preference.IPreferenceStore; ! import org.eclipse.jface.resource.ImageDescriptor; ! import org.eclipse.jface.viewers.ISelection; ! import org.eclipse.swt.SWT; ! import org.eclipse.swt.events.SelectionAdapter; ! import org.eclipse.swt.events.SelectionEvent; ! import org.eclipse.swt.layout.FillLayout; ! import org.eclipse.swt.widgets.Shell; ! import org.eclipse.ui.IWorkbenchWindow; ! import org.eclipse.ui.IWorkbenchWindowActionDelegate; ! import org.jcommander.ui.app.AppPlugin; ! import org.jcommander.ui.app.dialogs.ProfileChooserComposite; ! import org.jcommander.ui.filepanel.FilePanelPlugin; ! import org.jcommander.ui.logger.LoggerPlugin; ! import org.jcommander.ui.utils.WindowUtils; public class ChooseProfile implements IWorkbenchWindowActionDelegate { protected IWorkbenchWindow window; + private String profileToUse; + /** + * Do not show the dialog box, just select the specified profile. + * @param profileToUse use one of {@link FilePanelPlugin#PROFILE_NORTON_COMMANDER} or + * {@link FilePanelPlugin#PROFILE_WINDOWS_EXPLORER} + */ + public ChooseProfile(String profileToUse) { + this.profileToUse = profileToUse; + } + + /** + * Show a dialog and let the user select the profile to use. + */ + public ChooseProfile() { + + } + public void dispose() { // TODO Auto-generated method stub } *************** *** 31,34 **** --- 49,66 ---- public void run(IAction action) { + if(null != profileToUse) { + if(FilePanelPlugin.PROFILE_NORTON_COMMANDER.equalsIgnoreCase(profileToUse)) { + configureStoreForNc(); + } else if(FilePanelPlugin.PROFILE_WINDOWS_EXPLORER.equalsIgnoreCase(profileToUse)) { + configureStoreForWe(); + } else { + showDialog(); + } + } else { + showDialog(); + } + } + + private void showDialog() { int shellStyle = SWT.TITLE | SWT.CLOSE | SWT.BORDER | SWT.RESIZE | SWT.APPLICATION_MODAL; *************** *** 39,43 **** ImageDescriptor imgDesc = AppPlugin.imageDescriptorFromPlugin(AppPlugin.PLUGIN_ID, "icons/small_icon.png"); dialog.setImage(imgDesc.createImage(dialog.getDisplay())); ! dialog.setText("Choose Layout Profile"); dialog.setLayout(new FillLayout()); --- 71,75 ---- ImageDescriptor imgDesc = AppPlugin.imageDescriptorFromPlugin(AppPlugin.PLUGIN_ID, "icons/small_icon.png"); dialog.setImage(imgDesc.createImage(dialog.getDisplay())); ! dialog.setText("Choose Layout Profile"); dialog.setLayout(new FillLayout()); *************** *** 62,83 **** composite.getOkButton().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { - IPreferenceStore store = FilePanelPlugin.getDefault().getPreferenceStore(); - if(composite.getWeRadioButton().getSelection()) { ! store.setValue(FilePanelPlugin.SHOW_FUNCTION_BAR_KEY, false); ! store.setValue(FilePanelPlugin.SHOW_FILE_DETAILS, false); ! store.setValue(FilePanelPlugin.SHOW_DIRECTORY_TREE, true); ! store.setValue(FilePanelPlugin.HIDE_RIGHT_PANEL, true); ! store.setValue(FilePanelPlugin.SHOW_EXT_NAMES, true); } else { ! store.setValue(FilePanelPlugin.SHOW_FUNCTION_BAR_KEY, true); ! store.setValue(FilePanelPlugin.SHOW_FILE_DETAILS, true); ! store.setValue(FilePanelPlugin.SHOW_DIRECTORY_TREE, false); ! store.setValue(FilePanelPlugin.HIDE_RIGHT_PANEL, false); ! store.setValue(FilePanelPlugin.SHOW_EXT_NAMES, false); } dialog.dispose(); ! } }); --- 94,105 ---- composite.getOkButton().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if(composite.getWeRadioButton().getSelection()) { ! configureStoreForWe(); } else { ! configureStoreForNc(); } dialog.dispose(); ! } }); *************** *** 102,105 **** --- 124,151 ---- } + /** + * Configure the store for Norton Commander use style. + */ + private void configureStoreForNc() { + IPreferenceStore store = FilePanelPlugin.getDefault().getPreferenceStore(); + store.setValue(FilePanelPlugin.SHOW_FUNCTION_BAR_KEY, true); + store.setValue(FilePanelPlugin.SHOW_FILE_DETAILS, true); + store.setValue(FilePanelPlugin.SHOW_DIRECTORY_TREE, false); + store.setValue(FilePanelPlugin.HIDE_RIGHT_PANEL, false); + store.setValue(FilePanelPlugin.SHOW_EXT_NAMES, false); + } + + /** + * Configure the store for Windows Explorer use style. + */ + private void configureStoreForWe() { + IPreferenceStore store = FilePanelPlugin.getDefault().getPreferenceStore(); + store.setValue(FilePanelPlugin.SHOW_FUNCTION_BAR_KEY, false); + store.setValue(FilePanelPlugin.SHOW_FILE_DETAILS, false); + store.setValue(FilePanelPlugin.SHOW_DIRECTORY_TREE, true); + store.setValue(FilePanelPlugin.HIDE_RIGHT_PANEL, true); + store.setValue(FilePanelPlugin.SHOW_EXT_NAMES, true); + } + public void selectionChanged(IAction action, ISelection selection) { // TODO Auto-generated method stub |