1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Fix for 181391, improvements to export index UI.

This commit is contained in:
Markus Schorn 2007-04-10 16:07:34 +00:00
parent 2922ae70fd
commit 99ea19c361
6 changed files with 370 additions and 48 deletions

View file

@ -11,23 +11,31 @@
package org.eclipse.cdt.internal.ui.wizards.indexwizards;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.osgi.util.NLS;
public class Messages {
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.wizards.indexwizards.messages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
public static String StringVariableSelectionDialog_columnArgument;
public static String StringVariableSelectionDialog_columnDescription;
public static String StringVariableSelectionDialog_message;
public static String StringVariableSelectionDialog_title;
public static String TeamProjectIndexExportWizard_title;
public static String TeamProjectIndexExportWizardPage_description;
public static String TeamProjectIndexExportWizardPage_deselectAll;
public static String TeamProjectIndexExportWizardPage_destinationLabel;
public static String TeamProjectIndexExportWizardPage_destinationMessage;
public static String TeamProjectIndexExportWizardPage_errorDlgTitle;
public static String TeamProjectIndexExportWizardPage_errorExporting;
public static String TeamProjectIndexExportWizardPage_labelProjectTable;
public static String TeamProjectIndexExportWizardPage_noProjectError;
public static String TeamProjectIndexExportWizardPage_selectAll;
public static String TeamProjectIndexExportWizardPage_title;
public static String TeamProjectIndexExportWizardPage_variableButton;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

View file

@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.indexwizards;
import org.eclipse.core.variables.IStringVariable;
import org.eclipse.jface.viewers.LabelProvider;
/**
* Copied from org.eclipse.debug.ui
* @since 4.0
*/
public class StringVariableLabelProvider extends LabelProvider {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
public String getText(Object element) {
if (element instanceof IStringVariable) {
IStringVariable variable = (IStringVariable)element;
return variable.getName();
}
return super.getText(element);
}
}

View file

@ -0,0 +1,197 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.indexwizards;
import org.eclipse.core.variables.IDynamicVariable;
import org.eclipse.core.variables.IStringVariable;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.cdt.ui.CUIPlugin;
/**
* Copied from org.eclipse.debug.ui
* @since 4.0
*/
public class StringVariableSelectionDialog extends ElementListSelectionDialog {
// variable description
private Text fDescriptionText;
// the argument value
private Text fArgumentText;
private String fArgumentValue;
/**
* Constructs a new string substitution variable selection dialog.
*
* @param parent parent shell
*/
public StringVariableSelectionDialog(Shell parent) {
super(parent, new StringVariableLabelProvider());
setShellStyle(getShellStyle() | SWT.RESIZE);
setTitle(Messages.StringVariableSelectionDialog_title);
setMessage(Messages.StringVariableSelectionDialog_message);
setMultipleSelection(false);
setElements(VariablesPlugin.getDefault().getStringVariableManager().getVariables());
}
/**
* Returns the variable expression the user generated from this
* dialog, or <code>null</code> if none.
*
* @return variable expression the user generated from this
* dialog, or <code>null</code> if none
*/
public String getVariableExpression() {
Object[] selected = getResult();
if (selected != null && selected.length == 1) {
IStringVariable variable = (IStringVariable)selected[0];
StringBuffer buffer = new StringBuffer();
buffer.append("${"); //$NON-NLS-1$
buffer.append(variable.getName());
if (fArgumentValue != null && fArgumentValue.length() > 0) {
buffer.append(":"); //$NON-NLS-1$
buffer.append(fArgumentValue);
}
buffer.append("}"); //$NON-NLS-1$
return buffer.toString();
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
protected Control createDialogArea(Composite parent) {
Control control = super.createDialogArea(parent);
createArgumentArea((Composite)control);
return control;
}
/**
* Creates an area to display a description of the selected variable
* and a button to configure the variable's argument.
*
* @param parent parent widget
*/
private void createArgumentArea(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.makeColumnsEqualWidth = false;
layout.marginHeight = 0;
layout.marginWidth = 0;
container.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
container.setLayoutData(gd);
container.setFont(parent.getFont());
Label desc = new Label(container, SWT.NONE);
desc.setFont(parent.getFont());
desc.setText(Messages.StringVariableSelectionDialog_columnArgument);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
desc.setLayoutData(gd);
Composite args = new Composite(container, SWT.NONE);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
args.setLayout(layout);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
args.setLayoutData(gd);
args.setFont(container.getFont());
fArgumentText = new Text(args, SWT.BORDER);
fArgumentText.setFont(container.getFont());
gd = new GridData(GridData.FILL_HORIZONTAL);
fArgumentText.setLayoutData(gd);
desc = new Label(container, SWT.NONE);
desc.setFont(parent.getFont());
desc.setText(Messages.StringVariableSelectionDialog_columnDescription);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
desc.setLayoutData(gd);
fDescriptionText = new Text(container, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
fDescriptionText.setFont(container.getFont());
fDescriptionText.setEditable(false);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
gd.heightHint = 50;
fDescriptionText.setLayoutData(gd);
}
/**
* Update variable description and argument button enablement.
*
* @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#handleSelectionChanged()
*/
protected void handleSelectionChanged() {
super.handleSelectionChanged();
Object[] objects = getSelectedElements();
boolean argEnabled = false;
String text = null;
if (objects.length == 1) {
IStringVariable variable = (IStringVariable)objects[0];
if (variable instanceof IDynamicVariable) {
argEnabled = ((IDynamicVariable)variable).supportsArgument();
}
text = variable.getDescription();
}
if (text == null) {
text = ""; //$NON-NLS-1$
}
fArgumentText.setEnabled(argEnabled);
fDescriptionText.setText(text);
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
protected void okPressed() {
fArgumentValue = fArgumentText.getText().trim();
super.okPressed();
}
/**
* Returns the name of the section that this dialog stores its settings in
*
* @return String
*/
private String getDialogSettingsSectionName() {
return CUIPlugin.PLUGIN_ID + ".STRING_VARIABLE_SELECTION_DIALOG_SECTION"; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
*/
protected IDialogSettings getDialogBoundsSettings() {
IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
IDialogSettings section = settings.getSection(getDialogSettingsSectionName());
if (section == null) {
section = settings.addNewSection(getDialogSettingsSectionName());
}
return section;
}
}

View file

@ -47,7 +47,7 @@ public class TeamProjectIndexExportWizard extends Wizard implements IExportWizar
public void init(IWorkbench workbench, IStructuredSelection selection) {
fSelection= selection;
setWindowTitle(Messages.getString("TeamProjectIndexExportWizard.title")); //$NON-NLS-1$
setWindowTitle(Messages.TeamProjectIndexExportWizard_title);
setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_EXPORTINDEX);
setNeedsProgressMonitor(true);
}

View file

@ -23,19 +23,25 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.WizardDataTransferPage;
@ -72,8 +78,8 @@ public class TeamProjectIndexExportWizardPage extends WizardDataTransferPage im
*/
public TeamProjectIndexExportWizardPage(IStructuredSelection selection) {
this("indexExportPage", selection); //$NON-NLS-1$
setTitle(Messages.getString("TeamProjectIndexExportWizardPage.title")); //$NON-NLS-1$
setDescription(Messages.getString("TeamProjectIndexExportWizardPage.description")); //$NON-NLS-1$
setTitle(Messages.TeamProjectIndexExportWizardPage_title);
setDescription(Messages.TeamProjectIndexExportWizardPage_description);
}
public void createControl(Composite parent) {
@ -86,9 +92,7 @@ public class TeamProjectIndexExportWizardPage extends WizardDataTransferPage im
composite.setFont(parent.getFont());
createResourcesGroup(composite);
// createButtonsGroup(composite);
createDestinationGroup(composite);
// createOptionsGroup(composite);
restoreWidgetValues();
if (fInitialSelection != null) {
@ -109,28 +113,83 @@ public class TeamProjectIndexExportWizardPage extends WizardDataTransferPage im
*
* @param parent the parent control
*/
protected final void createResourcesGroup(Composite parent) {
private final void createResourcesGroup(Composite parent) {
Composite resourcesGroup = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
resourcesGroup.setLayout(layout);
resourcesGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
resourcesGroup.setLayout(new GridLayout());
resourcesGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
resourcesGroup.setFont(parent.getFont());
new Label(resourcesGroup, SWT.NONE).setText(Messages.TeamProjectIndexExportWizardPage_labelProjectTable);
Table table= new Table(resourcesGroup, SWT.CHECK | SWT.BORDER);
table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
table.setLayoutData(new GridData(GridData.FILL_BOTH));
fProjectViewer= new CheckboxTableViewer(table);
fProjectViewer.setContentProvider(new ListContentProvider());
fProjectViewer.setLabelProvider(new CElementLabelProvider());
ICheckStateListener listener = new ICheckStateListener() {
ICheckStateListener checkListener = new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
updateWidgetEnablements();
}
};
fProjectViewer.addCheckStateListener(listener);
fProjectViewer.addCheckStateListener(checkListener);
// top level group
Composite buttonComposite = new Composite(resourcesGroup, SWT.NONE);
buttonComposite.setFont(parent.getFont());
GridLayout layout = new GridLayout(2, true);
layout.marginHeight= layout.marginWidth= 0;
buttonComposite.setLayout(layout);
buttonComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
| GridData.HORIZONTAL_ALIGN_FILL));
Button selectButton = createButton(buttonComposite,
IDialogConstants.SELECT_ALL_ID, Messages.TeamProjectIndexExportWizardPage_selectAll, false);
SelectionAdapter listener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
fProjectViewer.setAllChecked(true);
}
};
selectButton.addSelectionListener(listener);
Button deselectButton = createButton(buttonComposite,
IDialogConstants.DESELECT_ALL_ID, Messages.TeamProjectIndexExportWizardPage_deselectAll, false);
listener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
fProjectViewer.setAllChecked(false);
}
};
deselectButton.addSelectionListener(listener);
initProjects();
}
private Button createButton(Composite parent, int id, String label,
boolean defaultButton) {
Button button = new Button(parent, SWT.PUSH);
GridData buttonData = new GridData(GridData.FILL_HORIZONTAL);
button.setLayoutData(buttonData);
button.setData(new Integer(id));
button.setText(label);
button.setFont(parent.getFont());
if (defaultButton) {
Shell shell = parent.getShell();
if (shell != null) {
shell.setDefaultButton(button);
}
button.setFocus();
}
button.setFont(parent.getFont());
setButtonLayoutData(button);
return button;
}
private void initProjects() {
ArrayList input = new ArrayList();
ICProject[] projects;
@ -178,31 +237,47 @@ public class TeamProjectIndexExportWizardPage extends WizardDataTransferPage im
private void createDestinationGroup(Composite parent) {
GridData gd;
Font font = parent.getFont();
// destination specification group
Composite destinationSelectionGroup = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
destinationSelectionGroup.setLayout(layout);
destinationSelectionGroup.setLayout(new GridLayout(2, false));
destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
destinationSelectionGroup.setFont(font);
Label destinationLabel = new Label(destinationSelectionGroup, SWT.NONE);
destinationLabel.setText(Messages.getString("TeamProjectIndexExportWizardPage.destinationLabel")); //$NON-NLS-1$
destinationLabel.setText(Messages.TeamProjectIndexExportWizardPage_destinationLabel);
destinationLabel.setFont(font);
destinationLabel.setLayoutData(gd= new GridData());
gd.horizontalSpan= 2;
// destination name entry field
fDestinationField = new Text(destinationSelectionGroup, SWT.BORDER);
fDestinationField.addListener(SWT.Modify, this);
fDestinationField.addListener(SWT.Selection, this);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = SIZING_TEXT_FIELD_WIDTH;
fDestinationField.setLayoutData(data);
fDestinationField.setFont(font);
fDestinationField.setLayoutData(gd= new GridData());
gd.grabExcessHorizontalSpace= true;
gd.horizontalAlignment= GridData.FILL;
gd.widthHint = SIZING_TEXT_FIELD_WIDTH;
Button button= createButton(destinationSelectionGroup, IDialogConstants.CLIENT_ID, Messages.TeamProjectIndexExportWizardPage_variableButton, false);
SelectionAdapter listener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
onInsertVariable();
}
};
button.addSelectionListener(listener);
new Label(parent, SWT.NONE); // vertical spacer
}
protected void onInsertVariable() {
StringVariableSelectionDialog dlg= new StringVariableSelectionDialog(getShell());
if (dlg.open() == Window.OK) {
String var= dlg.getVariableExpression();
fDestinationField.insert(var);
}
}
public boolean finish() {
ICProject[] projectsToExport= getCheckedElements();
@ -223,7 +298,7 @@ public class TeamProjectIndexExportWizardPage extends WizardDataTransferPage im
private boolean executeExportOperation(final ICProject[] projects) {
final String dest= getDestinationValue();
final MultiStatus status= new MultiStatus(CUIPlugin.PLUGIN_ID,
0, Messages.getString("TeamProjectIndexExportWizardPage.errorWhileExporting"), null); //$NON-NLS-1$
0, Messages.TeamProjectIndexExportWizardPage_errorExporting, null);
IRunnableWithProgress op= new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
@ -275,7 +350,7 @@ public class TeamProjectIndexExportWizardPage extends WizardDataTransferPage im
protected boolean validateDestinationGroup() {
String destinationValue = getDestinationValue();
if (destinationValue.length() == 0) {
setMessage(Messages.getString("TeamProjectIndexExportWizardPage.noDestination")); //$NON-NLS-1$
setMessage(Messages.TeamProjectIndexExportWizardPage_destinationMessage);
return false;
}
@ -288,7 +363,7 @@ public class TeamProjectIndexExportWizardPage extends WizardDataTransferPage im
boolean isValid = true;
Object[] projectsToExport = getCheckedElements();
if (projectsToExport.length == 0){
setErrorMessage(Messages.getString("TeamProjectIndexExportWizardPage.noSelection")); //$NON-NLS-1$
setErrorMessage(Messages.TeamProjectIndexExportWizardPage_noProjectError);
isValid = false;
} else {
setErrorMessage(null);
@ -311,7 +386,7 @@ public class TeamProjectIndexExportWizardPage extends WizardDataTransferPage im
}
protected String getErrorDialogTitle() {
return Messages.getString("TeamProjectIndexExportWizardPage.errorDlgTitle"); //$NON-NLS-1$
return Messages.TeamProjectIndexExportWizardPage_errorDlgTitle;
}
protected boolean allowNewContainerName() {

View file

@ -8,11 +8,19 @@
# Contributors:
# Markus Schorn (Wind River Systems)
###############################################################################
TeamProjectIndexExportWizard.title=Export
TeamProjectIndexExportWizardPage.title=C/C++ index
TeamProjectIndexExportWizardPage.description=Export C/C++ index for use in other workspaces.
TeamProjectIndexExportWizardPage.destinationLabel=Export destination:
TeamProjectIndexExportWizardPage.errorWhileExporting=Errors occurred while exporting index
TeamProjectIndexExportWizardPage.noDestination=Enter a destination archive file.
TeamProjectIndexExportWizardPage.noSelection=At least one project must be selected.
TeamProjectIndexExportWizardPage.errorDlgTitle=Export C/C++ Index
TeamProjectIndexExportWizard_title=Export
TeamProjectIndexExportWizardPage_title=Export Team Shared Index
TeamProjectIndexExportWizardPage_description=Export C/C++ index for use in other workspaces.
TeamProjectIndexExportWizardPage_labelProjectTable=Select the projects to export the index for:
TeamProjectIndexExportWizardPage_selectAll=&Select All
TeamProjectIndexExportWizardPage_deselectAll=&Deselect All
TeamProjectIndexExportWizardPage_destinationLabel=Export destination:
TeamProjectIndexExportWizardPage_variableButton=Insert Variable...
TeamProjectIndexExportWizardPage_errorExporting=Errors occurred while exporting index
TeamProjectIndexExportWizardPage_destinationMessage=Enter a destination archive file.
TeamProjectIndexExportWizardPage_noProjectError=At least one project must be selected.
TeamProjectIndexExportWizardPage_errorDlgTitle=Export C/C++ Index
StringVariableSelectionDialog_title=Select Variable
StringVariableSelectionDialog_message=&Choose a variable (? = any character, * = any string):
StringVariableSelectionDialog_columnArgument=&Argument:
StringVariableSelectionDialog_columnDescription=&Variable Description: