mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Some fixes for the managed build environment and macros UI. All UI issues that seemed to randomly appear previously should be gone now
This commit is contained in:
parent
9688b97f43
commit
ec7b5fa286
2 changed files with 450 additions and 294 deletions
|
@ -19,10 +19,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
@ -58,11 +55,22 @@ import org.eclipse.jface.dialogs.Dialog;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.preference.JFacePreferences;
|
import org.eclipse.jface.preference.JFacePreferences;
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
|
import org.eclipse.jface.viewers.ColumnLayoutData;
|
||||||
|
import org.eclipse.jface.viewers.ColumnPixelData;
|
||||||
|
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||||
import org.eclipse.jface.viewers.IColorProvider;
|
import org.eclipse.jface.viewers.IColorProvider;
|
||||||
|
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||||
import org.eclipse.jface.viewers.IFontProvider;
|
import org.eclipse.jface.viewers.IFontProvider;
|
||||||
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.ITableFontProvider;
|
import org.eclipse.jface.viewers.ITableFontProvider;
|
||||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||||
|
import org.eclipse.jface.viewers.TableLayout;
|
||||||
|
import org.eclipse.jface.viewers.TableViewer;
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.jface.viewers.ViewerSorter;
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.KeyEvent;
|
import org.eclipse.swt.events.KeyEvent;
|
||||||
|
@ -75,10 +83,14 @@ import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.layout.FormAttachment;
|
import org.eclipse.swt.layout.FormAttachment;
|
||||||
import org.eclipse.swt.layout.FormData;
|
import org.eclipse.swt.layout.FormData;
|
||||||
import org.eclipse.swt.layout.FormLayout;
|
import org.eclipse.swt.layout.FormLayout;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Button;
|
import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Table;
|
||||||
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* displays the environment for the given context
|
* displays the environment for the given context
|
||||||
|
@ -137,9 +149,11 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
//and the changes are not applied to the User Variable Supplier
|
//and the changes are not applied to the User Variable Supplier
|
||||||
private boolean fModified = false;
|
private boolean fModified = false;
|
||||||
//holds the visible state.
|
//holds the visible state.
|
||||||
private boolean fVisible = false;
|
// private boolean fVisible = false;
|
||||||
//specifies whether the "show parent level variables" checkbox should be created
|
//specifies whether the "show parent level variables" checkbox should be created
|
||||||
private boolean fShowParentViewCheckBox = true;
|
private boolean fShowParentViewCheckBox = true;
|
||||||
|
|
||||||
|
private boolean fIsEditable = true;
|
||||||
//inexistent context
|
//inexistent context
|
||||||
private static final Object fInexistentContext = new Object();
|
private static final Object fInexistentContext = new Object();
|
||||||
//the context for which the variables are displayed
|
//the context for which the variables are displayed
|
||||||
|
@ -154,10 +168,29 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
|
|
||||||
//the user defined variable supplier
|
//the user defined variable supplier
|
||||||
private UserDefinedEnvironmentSupplier fUserSupplier;
|
private UserDefinedEnvironmentSupplier fUserSupplier;
|
||||||
//editable list that displayes user-defined variables
|
//editable table viewer
|
||||||
private ListDialogField fEditableList;
|
private TableViewer fEditableTable;
|
||||||
//non-editable list that holds all variables other than user-defined ones
|
//noneditable table viewer
|
||||||
private ListDialogField fNonEditableList;
|
private TableViewer fNonEditableTable;
|
||||||
|
|
||||||
|
private static final String[] fEditableTableColumnProps = new String[] {
|
||||||
|
"editable name", //$NON-NLS-1$
|
||||||
|
"editable value", //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] fNonEditableTableColumnProps = new String[] {
|
||||||
|
"noneditable name", //$NON-NLS-1$
|
||||||
|
"noneditable value", //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] fTableColumnNames = new String[] {
|
||||||
|
ManagedBuilderUIMessages.getResourceString(HEADER_NAME),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(HEADER_VALUE),
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final ColumnLayoutData[] fTableColumnLayouts = {new ColumnPixelData(150), new ColumnPixelData(250)};
|
||||||
|
|
||||||
|
|
||||||
//the set of names of the incorrestly defined variables
|
//the set of names of the incorrestly defined variables
|
||||||
private Set fIncorrectlyDefinedVariablesNames = new HashSet();
|
private Set fIncorrectlyDefinedVariablesNames = new HashSet();
|
||||||
|
|
||||||
|
@ -171,7 +204,12 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
private Composite fParent;
|
private Composite fParent;
|
||||||
//status label
|
//status label
|
||||||
private Label fStatusLabel;
|
private Label fStatusLabel;
|
||||||
|
//buttons
|
||||||
|
private Button fNewButton;
|
||||||
|
private Button fEditButton;
|
||||||
|
private Button fUndefButton;
|
||||||
|
private Button fDeleteButton;
|
||||||
|
|
||||||
private class SystemContextInfo extends DefaultContextInfo{
|
private class SystemContextInfo extends DefaultContextInfo{
|
||||||
protected SystemContextInfo(Object context){
|
protected SystemContextInfo(Object context){
|
||||||
super(context);
|
super(context);
|
||||||
|
@ -215,9 +253,7 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
*/
|
*/
|
||||||
public IEnvironmentVariableSupplier[] getSuppliers(Object context){
|
public IEnvironmentVariableSupplier[] getSuppliers(Object context){
|
||||||
IEnvironmentVariableSupplier suppliers[] = super.getSuppliers(context);
|
IEnvironmentVariableSupplier suppliers[] = super.getSuppliers(context);
|
||||||
if(fParentContextInfo == null){
|
|
||||||
int i = 0;
|
|
||||||
}
|
|
||||||
if(suppliers == null || suppliers.length == 0)
|
if(suppliers == null || suppliers.length == 0)
|
||||||
return suppliers;
|
return suppliers;
|
||||||
if(!(suppliers[0] instanceof UserDefinedEnvironmentSupplier))
|
if(!(suppliers[0] instanceof UserDefinedEnvironmentSupplier))
|
||||||
|
@ -267,37 +303,24 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ListAdapter implements IListAdapter, IDialogFieldListener {
|
private class EnvironmentContentProvider implements IStructuredContentProvider{
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter#customButtonPressed(org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField, int)
|
public Object[] getElements(Object inputElement) {
|
||||||
*/
|
return (Object[])inputElement;
|
||||||
public void customButtonPressed(ListDialogField field, int index) {
|
|
||||||
if(field == fEditableList)
|
|
||||||
handleCustomButtonPressed(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public void dispose() {
|
||||||
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter#selectionChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField)
|
// TODO Auto-generated method stub
|
||||||
*/
|
|
||||||
public void selectionChanged(ListDialogField field) {
|
|
||||||
handleSelectionChanged(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField)
|
|
||||||
*/
|
|
||||||
public void doubleClicked(ListDialogField field) {
|
|
||||||
if (isEditable(field) && field.getSelectedElements().size() == 1)
|
|
||||||
handleCustomButtonPressed(IDX_BUTTON_EDIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||||
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField)
|
// TODO Auto-generated method stub
|
||||||
*/
|
|
||||||
public void dialogFieldChanged(DialogField field) {
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class EnvironmentLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider , ITableFontProvider, IColorProvider{
|
private class EnvironmentLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider , ITableFontProvider, IColorProvider{
|
||||||
private boolean fUser;
|
private boolean fUser;
|
||||||
public EnvironmentLabelProvider(boolean user){
|
public EnvironmentLabelProvider(boolean user){
|
||||||
|
@ -427,78 +450,41 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
super(title);
|
super(title);
|
||||||
super.setContainer(parent);
|
super.setContainer(parent);
|
||||||
|
|
||||||
ListAdapter adapter = new ListAdapter();
|
fIsEditable = editable;
|
||||||
|
fShowParentViewCheckBox = showParentViewCheckBox;
|
||||||
if(editable){
|
|
||||||
String[] buttons= new String[] {
|
|
||||||
ManagedBuilderUIMessages.getResourceString(BUTTON_NEW),
|
|
||||||
ManagedBuilderUIMessages.getResourceString(BUTTON_EDIT),
|
|
||||||
ManagedBuilderUIMessages.getResourceString(BUTTON_UNDEF),
|
|
||||||
ManagedBuilderUIMessages.getResourceString(BUTTON_DELETE),
|
|
||||||
};
|
|
||||||
|
|
||||||
fEditableList= new ListDialogField(adapter, buttons, new EnvironmentLabelProvider(true));
|
|
||||||
fEditableList.setDialogFieldListener(adapter);
|
|
||||||
|
|
||||||
String[] columnsHeaders= new String[] {
|
|
||||||
ManagedBuilderUIMessages.getResourceString(HEADER_NAME),
|
|
||||||
ManagedBuilderUIMessages.getResourceString(HEADER_VALUE),
|
|
||||||
};
|
|
||||||
|
|
||||||
fEditableList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
|
|
||||||
fEditableList.setViewerSorter(new ViewerSorter());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//create non-editable list
|
|
||||||
fNonEditableList= new ListDialogField(adapter, null, new EnvironmentLabelProvider(false));
|
|
||||||
fNonEditableList.setDialogFieldListener(adapter);
|
|
||||||
|
|
||||||
String[] columnsHeaders= new String[] {
|
|
||||||
ManagedBuilderUIMessages.getResourceString(HEADER_NAME),
|
|
||||||
ManagedBuilderUIMessages.getResourceString(HEADER_VALUE),
|
|
||||||
};
|
|
||||||
|
|
||||||
fNonEditableList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
|
|
||||||
fNonEditableList.setViewerSorter(new ViewerSorter());
|
|
||||||
|
|
||||||
fShowParentViewCheckBox = showParentViewCheckBox;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* returns the map containing the user-defined variables
|
* returns the map containing the user-defined variables
|
||||||
*/
|
*/
|
||||||
private Map getUserVariables(){
|
private Map getUserVariables(){
|
||||||
if(fUserSupplier == null)
|
|
||||||
return null;
|
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
|
if(fUserSupplier != null) {
|
||||||
if(!fDeleteAll){
|
if(!fDeleteAll){
|
||||||
IBuildEnvironmentVariable vars[] = fUserSupplier.getVariables(fContext);
|
IBuildEnvironmentVariable vars[] = fUserSupplier.getVariables(fContext);
|
||||||
if(vars != null) {
|
if(vars != null) {
|
||||||
for(int i = 0; i < vars.length; i++){
|
for(int i = 0; i < vars.length; i++){
|
||||||
String name = vars[i].getName();
|
String name = vars[i].getName();
|
||||||
|
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
|
||||||
|
name = name.toUpperCase();
|
||||||
|
map.put(name,vars[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator iter = getDeletedUserVariableNames().iterator();
|
||||||
|
while(iter.hasNext()){
|
||||||
|
map.remove((String)iter.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
iter = getAddedUserVariables().values().iterator();
|
||||||
|
while(iter.hasNext()){
|
||||||
|
IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)iter.next();
|
||||||
|
String name = var.getName();
|
||||||
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
|
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
|
||||||
name = name.toUpperCase();
|
name = name.toUpperCase();
|
||||||
map.put(name,vars[i]);
|
map.put(name,var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator iter = getDeletedUserVariableNames().iterator();
|
|
||||||
while(iter.hasNext()){
|
|
||||||
map.remove((String)iter.next());
|
|
||||||
}
|
|
||||||
|
|
||||||
iter = getAddedUserVariables().values().iterator();
|
|
||||||
while(iter.hasNext()){
|
|
||||||
IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)iter.next();
|
|
||||||
String name = var.getName();
|
|
||||||
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
|
|
||||||
name = name.toUpperCase();
|
|
||||||
map.put(name,var);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -632,22 +618,20 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
/*
|
/*
|
||||||
* called when the user variable selection was changed
|
* called when the user variable selection was changed
|
||||||
*/
|
*/
|
||||||
private void handleSelectionChanged(ListDialogField field){
|
private void handleSelectionChanged(SelectionChangedEvent event){
|
||||||
if(isEditable(field)){
|
int size = ((IStructuredSelection)event.getSelection()).size();
|
||||||
List selectedElements= field.getSelectedElements();
|
fEditButton.setEnabled(size == 1);
|
||||||
field.enableButton(IDX_BUTTON_EDIT, selectedElements.size() == 1);
|
fUndefButton.setEnabled(size > 0);
|
||||||
field.enableButton(IDX_BUTTON_UNDEF, selectedElements.size() > 0);
|
fDeleteButton.setEnabled(size > 0);
|
||||||
field.enableButton(IDX_BUTTON_DELETE, selectedElements.size() > 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* answers whether the list values can be edited
|
* answers whether the list values can be edited
|
||||||
*/
|
*/
|
||||||
private boolean isEditable(ListDialogField field) {
|
/* private boolean isEditable(ListDialogField field) {
|
||||||
return field == fEditableList;
|
return field == fEditableList;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
* called when a custom button was pressed
|
* called when a custom button was pressed
|
||||||
*/
|
*/
|
||||||
|
@ -709,10 +693,10 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
* returnes the selected user-defined variables
|
* returnes the selected user-defined variables
|
||||||
*/
|
*/
|
||||||
private IBuildEnvironmentVariable[] getSelectedUserVariables(){
|
private IBuildEnvironmentVariable[] getSelectedUserVariables(){
|
||||||
if(fEditableList == null)
|
if(fEditableTable == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List list = fEditableList.getSelectedElements();
|
List list = ((IStructuredSelection)fEditableTable.getSelection()).toList();
|
||||||
return (IBuildEnvironmentVariable[])list.toArray(new IBuildEnvironmentVariable[list.size()]);
|
return (IBuildEnvironmentVariable[])list.toArray(new IBuildEnvironmentVariable[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,30 +806,28 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
* apdates a user-defined variables table
|
* apdates a user-defined variables table
|
||||||
*/
|
*/
|
||||||
private void updateUserVariables(){
|
private void updateUserVariables(){
|
||||||
if(fEditableList == null || fContext == fInexistentContext)
|
if(fEditableTable == null || fContext == fInexistentContext)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fEditableList.selectFirstElement();
|
// fEditableList.selectFirstElement();
|
||||||
handleSelectionChanged(fEditableList);
|
// handleSelectionChanged(fEditableList);
|
||||||
|
|
||||||
List list = null;
|
|
||||||
if(fUserSupplier != null) {
|
if(fUserSupplier != null) {
|
||||||
Collection vars = getUserVariables().values();
|
Collection vars = getUserVariables().values();
|
||||||
Iterator iter = vars.iterator();
|
Iterator iter = vars.iterator();
|
||||||
|
|
||||||
list = new ArrayList(vars.size());
|
List list = new ArrayList(vars.size());
|
||||||
while(iter.hasNext()){
|
while(iter.hasNext()){
|
||||||
IBuildEnvironmentVariable userVar = (IBuildEnvironmentVariable)iter.next();
|
IBuildEnvironmentVariable userVar = (IBuildEnvironmentVariable)iter.next();
|
||||||
IBuildEnvironmentVariable sysVar = getSystemVariable(userVar.getName(),true);
|
if(userVar != null){
|
||||||
IBuildEnvironmentVariable var = EnvVarOperationProcessor.performOperation(sysVar,userVar);
|
IBuildEnvironmentVariable sysVar = getSystemVariable(userVar.getName(),true);
|
||||||
if(var != null)
|
IBuildEnvironmentVariable var = EnvVarOperationProcessor.performOperation(sysVar,userVar);
|
||||||
list.add(var);
|
if(var != null)
|
||||||
|
list.add(var);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(list != null)
|
fEditableTable.setInput(list.toArray(new IBuildEnvironmentVariable[list.size()]));
|
||||||
fEditableList.setElements(list);
|
|
||||||
else
|
|
||||||
fEditableList.removeAllElements();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,22 +835,19 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
* apdates a system-defined variables table
|
* apdates a system-defined variables table
|
||||||
*/
|
*/
|
||||||
private void updateSystemVariables(){
|
private void updateSystemVariables(){
|
||||||
if(fNonEditableList == null || fContext == fInexistentContext)
|
if(fNonEditableTable == null || fContext == fInexistentContext)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List list = null;
|
List list = new ArrayList();
|
||||||
IBuildEnvironmentVariable vars[] = getSystemVariables(fShowParentVariables);
|
IBuildEnvironmentVariable vars[] = getSystemVariables(fShowParentVariables);
|
||||||
if(vars != null && vars.length != 0){
|
if(vars != null && vars.length != 0){
|
||||||
list = new ArrayList(vars.length);
|
|
||||||
for(int i = 0; i < vars.length; i++){
|
for(int i = 0; i < vars.length; i++){
|
||||||
list.add(vars[i]);
|
if(vars[i] != null)
|
||||||
|
list.add(vars[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(list != null)
|
fNonEditableTable.setInput(list.toArray(new IBuildEnvironmentVariable[list.size()]));
|
||||||
fNonEditableList.setElements(list);
|
|
||||||
else
|
|
||||||
fNonEditableList.removeAllElements();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -908,7 +887,7 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
|
|
||||||
Composite composite= new Composite(parent, SWT.NULL);
|
Composite composite= new Composite(parent, SWT.NULL);
|
||||||
composite.setLayout(layout);
|
composite.setLayout(layout);
|
||||||
if(fEditableList != null){
|
if(fIsEditable){
|
||||||
Label nameLabel = new Label(composite, SWT.LEFT);
|
Label nameLabel = new Label(composite, SWT.LEFT);
|
||||||
nameLabel.setFont(composite.getFont());
|
nameLabel.setFont(composite.getFont());
|
||||||
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(USER_VAR));
|
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(USER_VAR));
|
||||||
|
@ -917,19 +896,9 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
fd.left = new FormAttachment(0,0);
|
fd.left = new FormAttachment(0,0);
|
||||||
nameLabel.setLayoutData(fd);
|
nameLabel.setLayoutData(fd);
|
||||||
|
|
||||||
listControl= fEditableList.getListControl(composite);
|
listControl= createTableControl(composite, true);
|
||||||
fEditableList.getTableViewer().getTable().addKeyListener(new KeyListener(){
|
|
||||||
public void keyPressed(KeyEvent e){
|
|
||||||
if(e.keyCode == SWT.DEL)
|
|
||||||
handleCustomButtonPressed(IDX_BUTTON_DELETE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void keyReleased(KeyEvent e){
|
buttonsControl = createButtonsControl(composite);
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
buttonsControl= fEditableList.getButtonBox(composite);
|
|
||||||
|
|
||||||
fd = new FormData();
|
fd = new FormData();
|
||||||
fd.top = new FormAttachment(nameLabel,0);
|
fd.top = new FormAttachment(nameLabel,0);
|
||||||
|
@ -949,7 +918,7 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
nameLabel.setFont(composite.getFont());
|
nameLabel.setFont(composite.getFont());
|
||||||
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(SYSTEM_VAR));
|
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(SYSTEM_VAR));
|
||||||
fd = new FormData();
|
fd = new FormData();
|
||||||
if(fEditableList != null)
|
if(fIsEditable)
|
||||||
fd.top = new FormAttachment(listControl,2);
|
fd.top = new FormAttachment(listControl,2);
|
||||||
else
|
else
|
||||||
fd.top = new FormAttachment(0,2);
|
fd.top = new FormAttachment(0,2);
|
||||||
|
@ -984,7 +953,7 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
listControl= fNonEditableList.getListControl(composite);
|
listControl= createTableControl(composite,false);
|
||||||
fd = new FormData();
|
fd = new FormData();
|
||||||
fd.top = new FormAttachment(nameLabel,0);
|
fd.top = new FormAttachment(nameLabel,0);
|
||||||
fd.left = new FormAttachment(0,0);
|
fd.left = new FormAttachment(0,0);
|
||||||
|
@ -1003,11 +972,129 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
this.setControl(composite);
|
this.setControl(composite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Control createTableControl(Composite parent, boolean editable){
|
||||||
|
Composite listControl= new Composite(parent, SWT.NONE);
|
||||||
|
TableViewer tableViewer;
|
||||||
|
GridLayout gl = new GridLayout();
|
||||||
|
gl.marginHeight = 0;
|
||||||
|
gl.marginWidth = 0;
|
||||||
|
gl.numColumns = 1;
|
||||||
|
listControl.setLayout(gl);
|
||||||
|
tableViewer = new TableViewer(listControl, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
|
||||||
|
| SWT.FULL_SELECTION);
|
||||||
|
|
||||||
|
Table table = tableViewer.getTable();
|
||||||
|
TableLayout tableLayout = new TableLayout();
|
||||||
|
for (int i = 0; i < fTableColumnNames.length; i++) {
|
||||||
|
tableLayout.addColumnData(fTableColumnLayouts[i]);
|
||||||
|
TableColumn tc = new TableColumn(table, SWT.NONE, i);
|
||||||
|
tc.setResizable(fTableColumnLayouts[i].resizable);
|
||||||
|
tc.setText(fTableColumnNames[i]);
|
||||||
|
}
|
||||||
|
table.setLayout(tableLayout);
|
||||||
|
table.setHeaderVisible(true);
|
||||||
|
GridData gd = new GridData(GridData.FILL_BOTH);
|
||||||
|
tableViewer.getControl().setLayoutData(gd);
|
||||||
|
tableViewer.setContentProvider(new EnvironmentContentProvider());
|
||||||
|
tableViewer.setLabelProvider(new EnvironmentLabelProvider(editable));
|
||||||
|
tableViewer.setSorter(new ViewerSorter());
|
||||||
|
|
||||||
|
if(editable){
|
||||||
|
tableViewer.setColumnProperties(fEditableTableColumnProps);
|
||||||
|
fEditableTable = tableViewer;
|
||||||
|
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||||
|
public void selectionChanged(SelectionChangedEvent event) {
|
||||||
|
handleSelectionChanged(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
|
||||||
|
|
||||||
|
public void doubleClick(DoubleClickEvent event) {
|
||||||
|
if (!fEditableTable.getSelection().isEmpty()) {
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_EDIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
table.addKeyListener(new KeyListener(){
|
||||||
|
public void keyPressed(KeyEvent e){
|
||||||
|
if(e.keyCode == SWT.DEL)
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_DELETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keyReleased(KeyEvent e){
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
tableViewer.setColumnProperties(fNonEditableTableColumnProps);
|
||||||
|
fNonEditableTable = tableViewer;
|
||||||
|
}
|
||||||
|
return listControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Control createButtonsControl(Composite parent){
|
||||||
|
Composite buttonsControl = new Composite(parent, SWT.NONE);
|
||||||
|
GridLayout gl = new GridLayout();
|
||||||
|
gl.marginHeight = 0;
|
||||||
|
gl.marginWidth = 0;
|
||||||
|
gl.numColumns = 1;
|
||||||
|
buttonsControl.setLayout(gl);
|
||||||
|
|
||||||
|
GridData gd;
|
||||||
|
fNewButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_NEW),null);
|
||||||
|
fNewButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent event) {
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_NEW);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.heightHint = SWTUtil.getButtonHeigthHint(fNewButton);
|
||||||
|
gd.widthHint = SWTUtil.getButtonWidthHint(fNewButton);
|
||||||
|
fNewButton.setLayoutData(gd);
|
||||||
|
|
||||||
|
|
||||||
|
fEditButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_EDIT),null);
|
||||||
|
fEditButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent event) {
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_EDIT);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.heightHint = SWTUtil.getButtonHeigthHint(fEditButton);
|
||||||
|
gd.widthHint = SWTUtil.getButtonWidthHint(fEditButton);
|
||||||
|
fEditButton.setLayoutData(gd);
|
||||||
|
|
||||||
|
|
||||||
|
fUndefButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_UNDEF),null);
|
||||||
|
fUndefButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent event) {
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_UNDEF);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.heightHint = SWTUtil.getButtonHeigthHint(fUndefButton);
|
||||||
|
gd.widthHint = SWTUtil.getButtonWidthHint(fUndefButton);
|
||||||
|
fUndefButton.setLayoutData(gd);
|
||||||
|
|
||||||
|
fDeleteButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_DELETE),null);
|
||||||
|
fDeleteButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent event) {
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_DELETE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.heightHint = SWTUtil.getButtonHeigthHint(fDeleteButton);
|
||||||
|
gd.widthHint = SWTUtil.getButtonWidthHint(fDeleteButton);
|
||||||
|
fDeleteButton.setLayoutData(gd);
|
||||||
|
return buttonsControl;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
|
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
|
||||||
*/
|
*/
|
||||||
public void setVisible(boolean visible){
|
public void setVisible(boolean visible){
|
||||||
fVisible = visible;
|
// fVisible = visible;
|
||||||
// if(visible)
|
// if(visible)
|
||||||
// updateValues();
|
// updateValues();
|
||||||
super.setVisible(visible);
|
super.setVisible(visible);
|
||||||
|
@ -1058,7 +1145,6 @@ public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateState(BuildMacroException e){
|
private void updateState(BuildMacroException e){
|
||||||
ICOptionContainer container = getContainer();
|
|
||||||
fIncorrectlyDefinedVariablesNames.clear();
|
fIncorrectlyDefinedVariablesNames.clear();
|
||||||
|
|
||||||
if(e != null){
|
if(e != null){
|
||||||
|
|
|
@ -19,10 +19,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
|
||||||
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacro;
|
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacro;
|
||||||
|
@ -51,11 +48,22 @@ import org.eclipse.jface.dialogs.Dialog;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.preference.JFacePreferences;
|
import org.eclipse.jface.preference.JFacePreferences;
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
|
import org.eclipse.jface.viewers.ColumnLayoutData;
|
||||||
|
import org.eclipse.jface.viewers.ColumnPixelData;
|
||||||
|
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||||
import org.eclipse.jface.viewers.IColorProvider;
|
import org.eclipse.jface.viewers.IColorProvider;
|
||||||
|
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||||
import org.eclipse.jface.viewers.IFontProvider;
|
import org.eclipse.jface.viewers.IFontProvider;
|
||||||
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.ITableFontProvider;
|
import org.eclipse.jface.viewers.ITableFontProvider;
|
||||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||||
|
import org.eclipse.jface.viewers.TableLayout;
|
||||||
|
import org.eclipse.jface.viewers.TableViewer;
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.jface.viewers.ViewerSorter;
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.KeyEvent;
|
import org.eclipse.swt.events.KeyEvent;
|
||||||
|
@ -68,10 +76,14 @@ import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.layout.FormAttachment;
|
import org.eclipse.swt.layout.FormAttachment;
|
||||||
import org.eclipse.swt.layout.FormData;
|
import org.eclipse.swt.layout.FormData;
|
||||||
import org.eclipse.swt.layout.FormLayout;
|
import org.eclipse.swt.layout.FormLayout;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Button;
|
import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Table;
|
||||||
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* displays the build macros for the given context
|
* displays the build macros for the given context
|
||||||
|
@ -145,9 +157,12 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
//and the changes are not applied to the User Macro Supplier
|
//and the changes are not applied to the User Macro Supplier
|
||||||
private boolean fModified = false;
|
private boolean fModified = false;
|
||||||
//holds the visible state.
|
//holds the visible state.
|
||||||
private boolean fVisible = false;
|
// private boolean fVisible = false;
|
||||||
//specifies whether the "show parent context macros" checkbox should be created
|
//specifies whether the "show parent context macros" checkbox should be created
|
||||||
private boolean fShowParentViewCheckBox = true;
|
private boolean fShowParentViewCheckBox = true;
|
||||||
|
|
||||||
|
private boolean fIsEditable = true;
|
||||||
|
|
||||||
//inexistent context
|
//inexistent context
|
||||||
private static final Object fInexistentContext = new Object();
|
private static final Object fInexistentContext = new Object();
|
||||||
//the context tyte for which the macros are displayed
|
//the context tyte for which the macros are displayed
|
||||||
|
@ -166,11 +181,11 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
|
|
||||||
//the user defined macro supplier
|
//the user defined macro supplier
|
||||||
private UserDefinedMacroSupplier fUserSupplier;
|
private UserDefinedMacroSupplier fUserSupplier;
|
||||||
//editable list that displayes user-defined macros
|
//editable table viewer
|
||||||
private ListDialogField fEditableList;
|
private TableViewer fEditableTable;
|
||||||
//non-editable list that holds all macros other than user-defined ones
|
//noneditable table viewer
|
||||||
private ListDialogField fNonEditableList;
|
private TableViewer fNonEditableTable;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* widgets
|
* widgets
|
||||||
*/
|
*/
|
||||||
|
@ -180,6 +195,31 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
private Composite fParent;
|
private Composite fParent;
|
||||||
//status label
|
//status label
|
||||||
private Label fStatusLabel;
|
private Label fStatusLabel;
|
||||||
|
//buttons
|
||||||
|
private Button fNewButton;
|
||||||
|
private Button fEditButton;
|
||||||
|
private Button fDeleteButton;
|
||||||
|
|
||||||
|
|
||||||
|
private static final String[] fEditableTableColumnProps = new String[] {
|
||||||
|
"editable name", //$NON-NLS-1$
|
||||||
|
"editable type", //$NON-NLS-1$
|
||||||
|
"editable value", //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] fNonEditableTableColumnProps = new String[] {
|
||||||
|
"noneditable name", //$NON-NLS-1$
|
||||||
|
"noneditable type", //$NON-NLS-1$
|
||||||
|
"noneditable value", //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] fTableColumnNames = new String[] {
|
||||||
|
ManagedBuilderUIMessages.getResourceString(HEADER_NAME),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(HEADER_TYPE),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(HEADER_VALUE),
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final ColumnLayoutData[] fTableColumnLayouts = {new ColumnPixelData(100), new ColumnPixelData(100), new ColumnPixelData(250)};
|
||||||
|
|
||||||
|
|
||||||
private class MacroUIMacroSubstitutor extends DefaultMacroSubstitutor{
|
private class MacroUIMacroSubstitutor extends DefaultMacroSubstitutor{
|
||||||
|
@ -288,9 +328,6 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
*/
|
*/
|
||||||
public IBuildMacroSupplier[] getSuppliers(int contextType, Object contextData){
|
public IBuildMacroSupplier[] getSuppliers(int contextType, Object contextData){
|
||||||
IBuildMacroSupplier suppliers[] = super.getSuppliers(contextType,contextData);
|
IBuildMacroSupplier suppliers[] = super.getSuppliers(contextType,contextData);
|
||||||
if(fParentContextInfo == null){
|
|
||||||
int i = 0;
|
|
||||||
}
|
|
||||||
if(suppliers == null || suppliers.length == 0)
|
if(suppliers == null || suppliers.length == 0)
|
||||||
return suppliers;
|
return suppliers;
|
||||||
if(!(suppliers[0] instanceof UserDefinedMacroSupplier))
|
if(!(suppliers[0] instanceof UserDefinedMacroSupplier))
|
||||||
|
@ -340,36 +377,24 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ListAdapter implements IListAdapter, IDialogFieldListener {
|
private class MacroContentProvider implements IStructuredContentProvider{
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter#customButtonPressed(org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField, int)
|
public Object[] getElements(Object inputElement) {
|
||||||
*/
|
return (Object[])inputElement;
|
||||||
public void customButtonPressed(ListDialogField field, int index) {
|
|
||||||
if(field == fEditableList)
|
|
||||||
handleCustomButtonPressed(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public void dispose() {
|
||||||
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter#selectionChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField)
|
// TODO Auto-generated method stub
|
||||||
*/
|
|
||||||
public void selectionChanged(ListDialogField field) {
|
|
||||||
handleSelectionChanged(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField)
|
|
||||||
*/
|
|
||||||
public void doubleClicked(ListDialogField field) {
|
|
||||||
if (isEditable(field) && field.getSelectedElements().size() == 1)
|
|
||||||
handleCustomButtonPressed(IDX_BUTTON_EDIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||||
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField)
|
// TODO Auto-generated method stub
|
||||||
*/
|
|
||||||
public void dialogFieldChanged(DialogField field) {
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class MacroLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider , ITableFontProvider, IColorProvider{
|
private class MacroLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider , ITableFontProvider, IColorProvider{
|
||||||
private boolean fUser;
|
private boolean fUser;
|
||||||
|
@ -528,74 +553,36 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
super(title);
|
super(title);
|
||||||
super.setContainer(parent);
|
super.setContainer(parent);
|
||||||
|
|
||||||
ListAdapter adapter = new ListAdapter();
|
fShowParentViewCheckBox = showParentViewCheckBox;
|
||||||
|
fIsEditable = editable;
|
||||||
if(editable){
|
|
||||||
String[] buttons= new String[] {
|
|
||||||
ManagedBuilderUIMessages.getResourceString(BUTTON_NEW),
|
|
||||||
ManagedBuilderUIMessages.getResourceString(BUTTON_EDIT),
|
|
||||||
ManagedBuilderUIMessages.getResourceString(BUTTON_DELETE),
|
|
||||||
};
|
|
||||||
|
|
||||||
fEditableList= new ListDialogField(adapter, buttons, new MacroLabelProvider(true));
|
|
||||||
fEditableList.setDialogFieldListener(adapter);
|
|
||||||
|
|
||||||
String[] columnsHeaders= new String[] {
|
|
||||||
ManagedBuilderUIMessages.getResourceString(HEADER_NAME),
|
|
||||||
ManagedBuilderUIMessages.getResourceString(HEADER_TYPE),
|
|
||||||
ManagedBuilderUIMessages.getResourceString(HEADER_VALUE),
|
|
||||||
};
|
|
||||||
|
|
||||||
fEditableList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
|
|
||||||
fEditableList.setViewerSorter(new ViewerSorter());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//create non-editable list
|
|
||||||
fNonEditableList= new ListDialogField(adapter, null, new MacroLabelProvider(false));
|
|
||||||
fNonEditableList.setDialogFieldListener(adapter);
|
|
||||||
|
|
||||||
String[] columnsHeaders= new String[] {
|
|
||||||
ManagedBuilderUIMessages.getResourceString(HEADER_NAME),
|
|
||||||
ManagedBuilderUIMessages.getResourceString(HEADER_TYPE),
|
|
||||||
ManagedBuilderUIMessages.getResourceString(HEADER_VALUE),
|
|
||||||
};
|
|
||||||
|
|
||||||
fNonEditableList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
|
|
||||||
fNonEditableList.setViewerSorter(new ViewerSorter());
|
|
||||||
|
|
||||||
fShowParentViewCheckBox = showParentViewCheckBox;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* returns the map containing the user-defined macros
|
* returns the map containing the user-defined macros
|
||||||
*/
|
*/
|
||||||
private Map getUserMacros(){
|
private Map getUserMacros(){
|
||||||
if(fUserSupplier == null)
|
|
||||||
return null;
|
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
|
if(fUserSupplier != null) {
|
||||||
if(!fDeleteAll){
|
if(!fDeleteAll){
|
||||||
IBuildMacro macros[] = fUserSupplier.getMacros(fContextType,fContextData);
|
IBuildMacro macros[] = fUserSupplier.getMacros(fContextType,fContextData);
|
||||||
if(macros != null) {
|
if(macros != null) {
|
||||||
for(int i = 0; i < macros.length; i++){
|
for(int i = 0; i < macros.length; i++){
|
||||||
String name = macros[i].getName();
|
String name = macros[i].getName();
|
||||||
map.put(name,macros[i]);
|
map.put(name,macros[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator iter = getDeletedUserMacroNames().iterator();
|
||||||
|
while(iter.hasNext()){
|
||||||
|
map.remove((String)iter.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
iter = getAddedUserMacros().values().iterator();
|
||||||
|
while(iter.hasNext()){
|
||||||
|
IBuildMacro macro = (IBuildMacro)iter.next();
|
||||||
|
String name = macro.getName();
|
||||||
|
map.put(name,macro);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Iterator iter = getDeletedUserMacroNames().iterator();
|
|
||||||
while(iter.hasNext()){
|
|
||||||
map.remove((String)iter.next());
|
|
||||||
}
|
|
||||||
|
|
||||||
iter = getAddedUserMacros().values().iterator();
|
|
||||||
while(iter.hasNext()){
|
|
||||||
IBuildMacro macro = (IBuildMacro)iter.next();
|
|
||||||
String name = macro.getName();
|
|
||||||
map.put(name,macro);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
|
@ -756,21 +743,12 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
/*
|
/*
|
||||||
* called when the user macro selection was changed
|
* called when the user macro selection was changed
|
||||||
*/
|
*/
|
||||||
private void handleSelectionChanged(ListDialogField field){
|
private void handleSelectionChanged(SelectionChangedEvent event){
|
||||||
if(isEditable(field)){
|
int size = ((IStructuredSelection)event.getSelection()).size();
|
||||||
List selectedElements= field.getSelectedElements();
|
fEditButton.setEnabled(size == 1);
|
||||||
field.enableButton(IDX_BUTTON_EDIT, selectedElements.size() == 1);
|
fDeleteButton.setEnabled(size > 0);
|
||||||
field.enableButton(IDX_BUTTON_DELETE, selectedElements.size() > 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* answers whether the list values can be edited
|
|
||||||
*/
|
|
||||||
private boolean isEditable(ListDialogField field) {
|
|
||||||
return field == fEditableList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* called when a custom button was pressed
|
* called when a custom button was pressed
|
||||||
*/
|
*/
|
||||||
|
@ -824,10 +802,10 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
* returnes the selected user-defined macros
|
* returnes the selected user-defined macros
|
||||||
*/
|
*/
|
||||||
private IBuildMacro[] getSelectedUserMacros(){
|
private IBuildMacro[] getSelectedUserMacros(){
|
||||||
if(fEditableList == null)
|
if(fEditableTable == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List list = fEditableList.getSelectedElements();
|
List list = ((IStructuredSelection)fEditableTable.getSelection()).toList();
|
||||||
return (IBuildMacro[])list.toArray(new IBuildMacro[list.size()]);
|
return (IBuildMacro[])list.toArray(new IBuildMacro[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,7 +882,6 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateState(BuildMacroException e){
|
private void updateState(BuildMacroException e){
|
||||||
ICOptionContainer container = getContainer();
|
|
||||||
fIncorrectlyDefinedMacrosNames.clear();
|
fIncorrectlyDefinedMacrosNames.clear();
|
||||||
|
|
||||||
if(e != null){
|
if(e != null){
|
||||||
|
@ -926,16 +903,17 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
* apdates a user-defined macros table
|
* apdates a user-defined macros table
|
||||||
*/
|
*/
|
||||||
private void updateUserMacros(){
|
private void updateUserMacros(){
|
||||||
if(fEditableList == null || fContextType == 0)
|
if(fEditableTable == null || fContextType == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fEditableList.selectFirstElement();
|
Collection values = getUserMacros().values();
|
||||||
handleSelectionChanged(fEditableList);
|
ArrayList list = new ArrayList(values.size());
|
||||||
|
for(Iterator iter = values.iterator(); iter.hasNext();){
|
||||||
if(fUserSupplier != null)
|
Object next = iter.next();
|
||||||
fEditableList.setElements(new ArrayList(getUserMacros().values()));
|
if(next != null)
|
||||||
else
|
list.add(next);
|
||||||
fEditableList.removeAllElements();
|
}
|
||||||
|
fEditableTable.setInput(list.toArray(new IBuildMacro[list.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -943,22 +921,19 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
* apdates a system-defined macros table
|
* apdates a system-defined macros table
|
||||||
*/
|
*/
|
||||||
private void updateSystemMacros(){
|
private void updateSystemMacros(){
|
||||||
if(fNonEditableList == null || fContextType == 0)
|
if(fNonEditableTable == null || fContextType == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List list = null;
|
ArrayList list = new ArrayList();
|
||||||
IBuildMacro macros[] = getSystemMacros(fShowParentMacros);
|
IBuildMacro macros[] = getSystemMacros(fShowParentMacros);
|
||||||
if(macros != null && macros.length != 0){
|
if(macros != null && macros.length != 0){
|
||||||
list = new ArrayList(macros.length);
|
|
||||||
for(int i = 0; i < macros.length; i++){
|
for(int i = 0; i < macros.length; i++){
|
||||||
list.add(macros[i]);
|
if(macros[i] != null)
|
||||||
|
list.add(macros[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(list != null)
|
fNonEditableTable.setInput(list.toArray(new IBuildMacro[list.size()]));
|
||||||
fNonEditableList.setElements(list);
|
|
||||||
else
|
|
||||||
fNonEditableList.removeAllElements();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -998,7 +973,7 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
Composite composite= new Composite(parent, SWT.NULL);
|
Composite composite= new Composite(parent, SWT.NULL);
|
||||||
composite.setLayout(layout);
|
composite.setLayout(layout);
|
||||||
|
|
||||||
if(fEditableList != null){
|
if(fIsEditable){
|
||||||
Label nameLabel = new Label(composite, SWT.LEFT);
|
Label nameLabel = new Label(composite, SWT.LEFT);
|
||||||
nameLabel.setFont(composite.getFont());
|
nameLabel.setFont(composite.getFont());
|
||||||
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(USER_MACROS));
|
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(USER_MACROS));
|
||||||
|
@ -1007,19 +982,9 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
fd.left = new FormAttachment(0,0);
|
fd.left = new FormAttachment(0,0);
|
||||||
nameLabel.setLayoutData(fd);
|
nameLabel.setLayoutData(fd);
|
||||||
|
|
||||||
listControl= fEditableList.getListControl(composite);
|
listControl= createTableControl(composite,true);
|
||||||
fEditableList.getTableViewer().getTable().addKeyListener(new KeyListener(){
|
|
||||||
public void keyPressed(KeyEvent e){
|
|
||||||
if(e.keyCode == SWT.DEL)
|
|
||||||
handleCustomButtonPressed(IDX_BUTTON_DELETE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void keyReleased(KeyEvent e){
|
buttonsControl= createButtonsControl(composite);
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
buttonsControl= fEditableList.getButtonBox(composite);
|
|
||||||
|
|
||||||
fd = new FormData();
|
fd = new FormData();
|
||||||
fd.top = new FormAttachment(nameLabel,0);
|
fd.top = new FormAttachment(nameLabel,0);
|
||||||
|
@ -1039,7 +1004,7 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
nameLabel.setFont(composite.getFont());
|
nameLabel.setFont(composite.getFont());
|
||||||
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(SYSTEM_MACROS));
|
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(SYSTEM_MACROS));
|
||||||
fd = new FormData();
|
fd = new FormData();
|
||||||
if(fEditableList != null)
|
if(fIsEditable)
|
||||||
fd.top = new FormAttachment(listControl,2);
|
fd.top = new FormAttachment(listControl,2);
|
||||||
else
|
else
|
||||||
fd.top = new FormAttachment(0,2);
|
fd.top = new FormAttachment(0,2);
|
||||||
|
@ -1074,7 +1039,7 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
listControl= fNonEditableList.getListControl(composite);
|
listControl= createTableControl(composite,false);
|
||||||
fd = new FormData();
|
fd = new FormData();
|
||||||
fd.top = new FormAttachment(nameLabel,0);
|
fd.top = new FormAttachment(nameLabel,0);
|
||||||
fd.left = new FormAttachment(0,0);
|
fd.left = new FormAttachment(0,0);
|
||||||
|
@ -1092,11 +1057,116 @@ public class MacrosBlock extends AbstractCOptionPage {
|
||||||
this.setControl(composite);
|
this.setControl(composite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Control createTableControl(Composite parent, boolean editable){
|
||||||
|
Composite listControl= new Composite(parent, SWT.NONE);
|
||||||
|
TableViewer tableViewer;
|
||||||
|
GridLayout gl = new GridLayout();
|
||||||
|
gl.marginHeight = 0;
|
||||||
|
gl.marginWidth = 0;
|
||||||
|
gl.numColumns = 1;
|
||||||
|
listControl.setLayout(gl);
|
||||||
|
tableViewer = new TableViewer(listControl, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
|
||||||
|
| SWT.FULL_SELECTION);
|
||||||
|
|
||||||
|
Table table = tableViewer.getTable();
|
||||||
|
TableLayout tableLayout = new TableLayout();
|
||||||
|
for (int i = 0; i < fTableColumnNames.length; i++) {
|
||||||
|
tableLayout.addColumnData(fTableColumnLayouts[i]);
|
||||||
|
TableColumn tc = new TableColumn(table, SWT.NONE, i);
|
||||||
|
tc.setResizable(fTableColumnLayouts[i].resizable);
|
||||||
|
tc.setText(fTableColumnNames[i]);
|
||||||
|
}
|
||||||
|
table.setLayout(tableLayout);
|
||||||
|
table.setHeaderVisible(true);
|
||||||
|
GridData gd = new GridData(GridData.FILL_BOTH);
|
||||||
|
tableViewer.getControl().setLayoutData(gd);
|
||||||
|
tableViewer.setContentProvider(new MacroContentProvider());
|
||||||
|
tableViewer.setLabelProvider(new MacroLabelProvider(editable));
|
||||||
|
tableViewer.setSorter(new ViewerSorter());
|
||||||
|
|
||||||
|
if(editable){
|
||||||
|
tableViewer.setColumnProperties(fEditableTableColumnProps);
|
||||||
|
fEditableTable = tableViewer;
|
||||||
|
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||||
|
public void selectionChanged(SelectionChangedEvent event) {
|
||||||
|
handleSelectionChanged(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
|
||||||
|
|
||||||
|
public void doubleClick(DoubleClickEvent event) {
|
||||||
|
if (!fEditableTable.getSelection().isEmpty()) {
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_EDIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
table.addKeyListener(new KeyListener(){
|
||||||
|
public void keyPressed(KeyEvent e){
|
||||||
|
if(e.keyCode == SWT.DEL)
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_DELETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keyReleased(KeyEvent e){
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
tableViewer.setColumnProperties(fNonEditableTableColumnProps);
|
||||||
|
fNonEditableTable = tableViewer;
|
||||||
|
}
|
||||||
|
return listControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Control createButtonsControl(Composite parent){
|
||||||
|
Composite buttonsControl = new Composite(parent, SWT.NONE);
|
||||||
|
GridLayout gl = new GridLayout();
|
||||||
|
gl.marginHeight = 0;
|
||||||
|
gl.marginWidth = 0;
|
||||||
|
gl.numColumns = 1;
|
||||||
|
buttonsControl.setLayout(gl);
|
||||||
|
|
||||||
|
GridData gd;
|
||||||
|
fNewButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_NEW),null);
|
||||||
|
fNewButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent event) {
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_NEW);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.heightHint = SWTUtil.getButtonHeigthHint(fNewButton);
|
||||||
|
gd.widthHint = SWTUtil.getButtonWidthHint(fNewButton);
|
||||||
|
fNewButton.setLayoutData(gd);
|
||||||
|
|
||||||
|
fEditButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_EDIT),null);
|
||||||
|
fEditButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent event) {
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_EDIT);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.heightHint = SWTUtil.getButtonHeigthHint(fEditButton);
|
||||||
|
gd.widthHint = SWTUtil.getButtonWidthHint(fEditButton);
|
||||||
|
fEditButton.setLayoutData(gd);
|
||||||
|
|
||||||
|
fDeleteButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_DELETE),null);
|
||||||
|
fDeleteButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent event) {
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_DELETE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.heightHint = SWTUtil.getButtonHeigthHint(fDeleteButton);
|
||||||
|
gd.widthHint = SWTUtil.getButtonWidthHint(fDeleteButton);
|
||||||
|
fDeleteButton.setLayoutData(gd);
|
||||||
|
return buttonsControl;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
|
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
|
||||||
*/
|
*/
|
||||||
public void setVisible(boolean visible){
|
public void setVisible(boolean visible){
|
||||||
fVisible = visible;
|
// fVisible = visible;
|
||||||
// if(visible)
|
// if(visible)
|
||||||
// updateValues();
|
// updateValues();
|
||||||
super.setVisible(visible);
|
super.setVisible(visible);
|
||||||
|
|
Loading…
Add table
Reference in a new issue