geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r330554 - in /geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections: DynamicTableSection.java SecuritySection.java
Date Thu, 03 Nov 2005 14:17:53 GMT
Author: sppatel
Date: Thu Nov  3 06:17:49 2005
New Revision: 330554

URL: http://svn.apache.org/viewcvs?rev=330554&view=rev
Log:
add remove button selection listener

Modified:
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/DynamicTableSection.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/SecuritySection.java

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/DynamicTableSection.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/DynamicTableSection.java?rev=330554&r1=330553&r2=330554&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/DynamicTableSection.java
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/DynamicTableSection.java
Thu Nov  3 06:17:49 2005
@@ -52,288 +52,294 @@
 
 public abstract class DynamicTableSection extends AbstractSectionPart {
 
-    private Image image;
+	private Image image;
 
-    protected Table table;
+	protected Table table;
 
-    protected TableViewer tableViewer;
+	protected TableViewer tableViewer;
 
-    private ImageDescriptor defaultImgDesc = GeronimoUIPlugin
-            .imageDescriptorFromPlugin("org.apache.geronimo.ui",
-                    "icons/obj16/geronimo.gif");
-
-    public DynamicTableSection(Section section) {
-        super(section);
-    }
-
-    /**
-     * @param plan
-     * @param parent
-     * @param toolkit
-     * @param style
-     * 
-     * Subclasses should call create() in constructor
-     */
-    public DynamicTableSection(EObject plan, Composite parent,
-            FormToolkit toolkit, int style) {
-        super(parent, toolkit, style, plan);
-    }
-
-    public void create() {
-        if (isValid()) {
-            createClient();
-        }
-    }
-
-    private boolean isValid() {
-        return getEFactory() != null && getEReference() != null
-                && getTableColumnEAttributes() != null
-                && getTableColumnNames() != null;
-    }
-
-    public void createClient() {
-
-        getSection().setText(getTitle());
-        getSection().setDescription(getDescription());
-        getSection().setLayoutData(getSectionLayoutData());
-
-        Composite composite = createTableComposite(getSection());
-        getSection().setClient(composite);
-        createTable(composite);
-        fillTableItems();
-
-        tableViewer = new TableViewer(table);
-
-        if (getTableColumnNames().length > 0) {
-            tableViewer.setColumnProperties(getTableColumnNames());
-        }
-
-        Composite buttonComp = createButtonComposite(composite);
-        createAddButton(toolkit, buttonComp);
-        createRemoveButton(toolkit, buttonComp);
-        createEditButton(toolkit, buttonComp);
-
-    }
-
-    protected Composite createTableComposite(Composite parent) {
-        Composite composite = toolkit.createComposite(parent);
-        composite.setLayout(getSectionCompositeLayout());
-        composite.setLayoutData(getTableCompositeLayoutData());
-        return composite;
-    }
-
-    protected GridData getSectionLayoutData() {
-        return new GridData(SWT.FILL, SWT.FILL, false, false);
-    }
-
-    protected GridData getTableCompositeLayoutData() {
-        return new GridData(SWT.FILL, SWT.FILL, false, false);
-    }
-
-    protected GridLayout getSectionCompositeLayout() {
-        GridLayout layout = new GridLayout();
-        layout.numColumns = 2;
-        layout.marginHeight = 5;
-        layout.marginWidth = 10;
-        layout.verticalSpacing = 5;
-        layout.horizontalSpacing = 15;
-        return layout;
-    }
-
-    protected void fillTableItems() {
-        EList list = (EList) plan.eGet(getEReference());
-
-        for (int j = 0; j < list.size(); j++) {
-            TableItem item = new TableItem(table, SWT.NONE);
-            String[] tableTextData = getTableText((EObject) list.get(j));
-            item.setImage(getImage());
-            item.setText(tableTextData);
-            item.setData((EObject) list.get(j));
-        }
-    }
-
-    protected void createTable(Composite composite) {
-        table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION
-                | SWT.V_SCROLL | SWT.SINGLE);
-        if (isHeaderVisible()) {
-            table.setHeaderVisible(true);
-        }
-
-        GridData data = new GridData(SWT.FILL, SWT.FILL, false, false);
-        data.heightHint = 60;
-        data.widthHint = 400;
-        table.setLayoutData(data);
-
-        TableLayout tableLayout = new TableLayout();
-        table.setLayout(tableLayout);
-
-        for (int i = 0; i < getTableColumnNames().length; i++) {
-            tableLayout.addColumnData(new ColumnWeightData(35));
-            TableColumn tableColumn = new TableColumn(table, SWT.NONE);
-            tableColumn.setText(getTableColumnNames()[i]);
-        }
-
-    }
-
-    protected Composite createButtonComposite(Composite parent) {  
-        Composite buttonComp = new Composite(parent, SWT.NONE);
-        GridLayout layout = new GridLayout();
-        layout.horizontalSpacing = 2;
-        layout.verticalSpacing = 2;
-        layout.marginWidth = 0;
-        layout.marginHeight = 0;
-        layout.numColumns = 1;
-        buttonComp.setLayout(layout);
-        buttonComp.setBackground(toolkit.getColors().getBackground());
-        buttonComp
-                .setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
-        return buttonComp;
-    }
-
-    protected void createRemoveButton(FormToolkit toolkit, Composite buttonComp) {
-        Button del = toolkit
-                .createButton(buttonComp, Messages.remove, SWT.NONE);
-        del.addSelectionListener(new SelectionAdapter() {
-            public void widgetSelected(SelectionEvent e) {
-                int[] selectedIndices = table.getSelectionIndices();
-                for (int i = 0; i < selectedIndices.length; i++) {
-                    TableItem tableItem = table.getItem(selectedIndices[i]);
-                    EObject type = (EObject) (tableItem.getData());
-                    table.remove(selectedIndices[i]);
-                    EcoreUtil.remove(type);
-                    markDirty();
-                }
-            }
-        });
-        del.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-    }
-
-    protected void createAddButton(FormToolkit toolkit, Composite buttonComp) {
-        Button add = toolkit.createButton(buttonComp, Messages.add, SWT.NONE);
-
-        add.addSelectionListener(new SelectionAdapter() {
-            public void widgetSelected(SelectionEvent e) {
-                Wizard wizard = getWizard();
-                if (wizard != null) {
-                    WizardDialog dialog = new WizardDialog(Display.getCurrent()
-                            .getActiveShell(), wizard);
-
-                    dialog.open();
-
-                    if (dialog.getReturnCode() == Dialog.OK) {
-                        markDirty();
-                    }
-                }
-            }
-        });
-
-        add.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-    }
-
-    protected void createEditButton(FormToolkit toolkit, Composite buttonComp) {
-        Button add = toolkit.createButton(buttonComp, Messages.edit, SWT.NONE);
-
-        add.addSelectionListener(new SelectionAdapter() {
-            public void widgetSelected(SelectionEvent e) {
-                Object o = ((StructuredSelection) getTableViewer()
-                        .getSelection()).getFirstElement();
-                if (o != null) {
-                    Wizard wizard = getWizard();
-                    if (wizard != null) {
-                        if (wizard instanceof DynamicAddEditWizard) {
-                            ((DynamicAddEditWizard) wizard)
-                                    .setEObject((EObject) o);
-                        }
-                        WizardDialog dialog = new WizardDialog(Display
-                                .getCurrent().getActiveShell(), wizard);
-                        dialog.open();
-                        if (dialog.getReturnCode() == Dialog.OK) {
-                            markDirty();
-                        }
-                    }
-                }
-            }
-        });
-
-        add.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-    }
-
-    public String[] getTableText(EObject eObject) {
-        List tableText = new ArrayList();
-        for (int i = 0; i < getTableColumnEAttributes().length; i++) {
-            if (getTableColumnEAttributes()[i].getEContainingClass().equals(
-                    eObject.eClass())) {
-                String value = (String) eObject
-                        .eGet(getTableColumnEAttributes()[i]);
-                if (value != null) {
-                    tableText.add(value);
-                } else {
-                    tableText.add("");
-                }
-            }
-        }
-        return (String[]) tableText.toArray(new String[tableText.size()]);
-    }
-
-    public Image getImage() {
-        if (image == null) {
-            ImageDescriptor descriptor = getImageDescriptor();
-            if (descriptor == null)
-                descriptor = defaultImgDesc;
-            image = descriptor.createImage();
-        }
-        return image;
-    }
-
-    public ImageDescriptor getImageDescriptor() {
-        return defaultImgDesc;
-    }
-
-    public TableViewer getTableViewer() {
-        return tableViewer;
-    }
-
-    public EObject getPlan() {
-        return plan;
-    }
-
-    public boolean isHeaderVisible() {
-        return true;
-    }
-
-    /**
-     * @return
-     */
-    abstract public String getTitle();
-
-    /**
-     * @return
-     */
-    abstract public String getDescription();
-
-    /**
-     * @return
-     */
-    abstract public EFactory getEFactory();
-
-    /**
-     * @return
-     */
-    abstract public EReference getEReference();
-
-    /**
-     * @return
-     */
-    abstract public String[] getTableColumnNames();
-
-    /**
-     * @return
-     */
-    abstract public EAttribute[] getTableColumnEAttributes();
-
-    /**
-     * @return
-     */
-    abstract public Wizard getWizard();
+	private ImageDescriptor defaultImgDesc = GeronimoUIPlugin
+			.imageDescriptorFromPlugin("org.apache.geronimo.ui",
+					"icons/obj16/geronimo.gif");
+
+	Button addButton;
+
+	Button editButton;
+
+	Button removeButton;
+
+	public DynamicTableSection(Section section) {
+		super(section);
+	}
+
+	/**
+	 * @param plan
+	 * @param parent
+	 * @param toolkit
+	 * @param style
+	 * 
+	 * Subclasses should call create() in constructor
+	 */
+	public DynamicTableSection(EObject plan, Composite parent,
+			FormToolkit toolkit, int style) {
+		super(parent, toolkit, style, plan);
+	}
+
+	public void create() {
+		if (isValid()) {
+			createClient();
+		}
+	}
+
+	private boolean isValid() {
+		return getEFactory() != null && getEReference() != null
+				&& getTableColumnEAttributes() != null
+				&& getTableColumnNames() != null;
+	}
+
+	public void createClient() {
+
+		getSection().setText(getTitle());
+		getSection().setDescription(getDescription());
+		getSection().setLayoutData(getSectionLayoutData());
+
+		Composite composite = createTableComposite(getSection());
+		getSection().setClient(composite);
+		createTable(composite);
+		fillTableItems();
+
+		tableViewer = new TableViewer(table);
+
+		if (getTableColumnNames().length > 0) {
+			tableViewer.setColumnProperties(getTableColumnNames());
+		}
+
+		Composite buttonComp = createButtonComposite(composite);
+		createAddButton(toolkit, buttonComp);
+		createRemoveButton(toolkit, buttonComp);
+		createEditButton(toolkit, buttonComp);
+
+	}
+
+	protected Composite createTableComposite(Composite parent) {
+		Composite composite = toolkit.createComposite(parent);
+		composite.setLayout(getSectionCompositeLayout());
+		composite.setLayoutData(getTableCompositeLayoutData());
+		return composite;
+	}
+
+	protected GridData getSectionLayoutData() {
+		return new GridData(SWT.FILL, SWT.FILL, false, false);
+	}
+
+	protected GridData getTableCompositeLayoutData() {
+		return new GridData(SWT.FILL, SWT.FILL, false, false);
+	}
+
+	protected GridLayout getSectionCompositeLayout() {
+		GridLayout layout = new GridLayout();
+		layout.numColumns = 2;
+		layout.marginHeight = 5;
+		layout.marginWidth = 10;
+		layout.verticalSpacing = 5;
+		layout.horizontalSpacing = 15;
+		return layout;
+	}
+
+	protected void fillTableItems() {
+		EList list = (EList) plan.eGet(getEReference());
+
+		for (int j = 0; j < list.size(); j++) {
+			TableItem item = new TableItem(table, SWT.NONE);
+			String[] tableTextData = getTableText((EObject) list.get(j));
+			item.setImage(getImage());
+			item.setText(tableTextData);
+			item.setData((EObject) list.get(j));
+		}
+	}
+
+	protected void createTable(Composite composite) {
+		table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION
+				| SWT.V_SCROLL | SWT.SINGLE);
+		if (isHeaderVisible()) {
+			table.setHeaderVisible(true);
+		}
+
+		GridData data = new GridData(SWT.FILL, SWT.FILL, false, false);
+		data.heightHint = 60;
+		data.widthHint = 400;
+		table.setLayoutData(data);
+
+		TableLayout tableLayout = new TableLayout();
+		table.setLayout(tableLayout);
+
+		for (int i = 0; i < getTableColumnNames().length; i++) {
+			tableLayout.addColumnData(new ColumnWeightData(35));
+			TableColumn tableColumn = new TableColumn(table, SWT.NONE);
+			tableColumn.setText(getTableColumnNames()[i]);
+		}
+
+	}
+
+	protected Composite createButtonComposite(Composite parent) {
+		Composite buttonComp = new Composite(parent, SWT.NONE);
+		GridLayout layout = new GridLayout();
+		layout.horizontalSpacing = 2;
+		layout.verticalSpacing = 2;
+		layout.marginWidth = 0;
+		layout.marginHeight = 0;
+		layout.numColumns = 1;
+		buttonComp.setLayout(layout);
+		buttonComp.setBackground(toolkit.getColors().getBackground());
+		buttonComp
+				.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+		return buttonComp;
+	}
+
+	protected void createRemoveButton(FormToolkit toolkit, Composite buttonComp) {
+		removeButton = toolkit
+				.createButton(buttonComp, Messages.remove, SWT.NONE);
+		removeButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				int[] selectedIndices = table.getSelectionIndices();
+				for (int i = 0; i < selectedIndices.length; i++) {
+					TableItem tableItem = table.getItem(selectedIndices[i]);
+					EObject type = (EObject) (tableItem.getData());
+					table.remove(selectedIndices[i]);
+					EcoreUtil.remove(type);
+					markDirty();
+				}
+			}
+		});
+		removeButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+	}
+
+	protected void createAddButton(FormToolkit toolkit, Composite buttonComp) {
+		addButton = toolkit.createButton(buttonComp, Messages.add, SWT.NONE);
+
+		addButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				Wizard wizard = getWizard();
+				if (wizard != null) {
+					WizardDialog dialog = new WizardDialog(Display.getCurrent()
+							.getActiveShell(), wizard);
+
+					dialog.open();
+
+					if (dialog.getReturnCode() == Dialog.OK) {
+						markDirty();
+					}
+				}
+			}
+		});
+
+		addButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+	}
+
+	protected void createEditButton(FormToolkit toolkit, Composite buttonComp) {
+		editButton = toolkit.createButton(buttonComp, Messages.edit, SWT.NONE);
+
+		editButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				Object o = ((StructuredSelection) getTableViewer()
+						.getSelection()).getFirstElement();
+				if (o != null) {
+					Wizard wizard = getWizard();
+					if (wizard != null) {
+						if (wizard instanceof DynamicAddEditWizard) {
+							((DynamicAddEditWizard) wizard)
+									.setEObject((EObject) o);
+						}
+						WizardDialog dialog = new WizardDialog(Display
+								.getCurrent().getActiveShell(), wizard);
+						dialog.open();
+						if (dialog.getReturnCode() == Dialog.OK) {
+							markDirty();
+						}
+					}
+				}
+			}
+		});
+
+		editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+	}
+
+	public String[] getTableText(EObject eObject) {
+		List tableText = new ArrayList();
+		for (int i = 0; i < getTableColumnEAttributes().length; i++) {
+			if (getTableColumnEAttributes()[i].getEContainingClass().equals(
+					eObject.eClass())) {
+				String value = (String) eObject
+						.eGet(getTableColumnEAttributes()[i]);
+				if (value != null) {
+					tableText.add(value);
+				} else {
+					tableText.add("");
+				}
+			}
+		}
+		return (String[]) tableText.toArray(new String[tableText.size()]);
+	}
+
+	public Image getImage() {
+		if (image == null) {
+			ImageDescriptor descriptor = getImageDescriptor();
+			if (descriptor == null)
+				descriptor = defaultImgDesc;
+			image = descriptor.createImage();
+		}
+		return image;
+	}
+
+	public ImageDescriptor getImageDescriptor() {
+		return defaultImgDesc;
+	}
+
+	public TableViewer getTableViewer() {
+		return tableViewer;
+	}
+
+	public EObject getPlan() {
+		return plan;
+	}
+
+	public boolean isHeaderVisible() {
+		return true;
+	}
+
+	/**
+	 * @return
+	 */
+	abstract public String getTitle();
+
+	/**
+	 * @return
+	 */
+	abstract public String getDescription();
+
+	/**
+	 * @return
+	 */
+	abstract public EFactory getEFactory();
+
+	/**
+	 * @return
+	 */
+	abstract public EReference getEReference();
+
+	/**
+	 * @return
+	 */
+	abstract public String[] getTableColumnNames();
+
+	/**
+	 * @return
+	 */
+	abstract public EAttribute[] getTableColumnEAttributes();
+
+	/**
+	 * @return
+	 */
+	abstract public Wizard getWizard();
 
 }

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/SecuritySection.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/SecuritySection.java?rev=330554&r1=330553&r2=330554&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/SecuritySection.java
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/SecuritySection.java
Thu Nov  3 06:17:49 2005
@@ -32,6 +32,7 @@
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
@@ -50,6 +51,9 @@
 public class SecuritySection extends DynamicTableSection {
 
     public EReference securityERef;
+    
+    Text roleNameText;
+    Text roleDescriptionText;
 
     /**
      * @param plan
@@ -156,7 +160,7 @@
                 false));
         roleNameLabel.setEnabled(true);
 
-        Text roleNameText = toolkit.createText(detail, "", SWT.BORDER);
+        roleNameText = toolkit.createText(detail, "", SWT.BORDER);
         roleNameText
                 .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
         roleNameText.setEnabled(true);
@@ -167,15 +171,21 @@
                 false, false));
         roleDescriptionLabel.setEnabled(true);
 
-        Text roleDescriptionText = toolkit.createText(detail, "", SWT.MULTI
+        roleDescriptionText = toolkit.createText(detail, "", SWT.MULTI
                 | SWT.BORDER);
         GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
         data.heightHint = 50;
         roleDescriptionText.setLayoutData(data);
         roleDescriptionText.setEnabled(true);
 
-        table.addSelectionListener(new TableSelectionListener(roleNameText,
-                roleDescriptionText));
+        table.addSelectionListener(new TableSelectionListener());
+        
+        removeButton.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                roleNameText.setText("");
+                roleDescriptionText.setText("");
+            }
+        });
 
     }
 
@@ -217,25 +227,16 @@
 
     class TableSelectionListener implements SelectionListener {
 
-        Text roleName;
-
-        Text description;
-
-        public TableSelectionListener(Text roleName, Text description) {
-            this.roleName = roleName;
-            this.description = description;
-        }
-
         public void widgetSelected(SelectionEvent e) {
             TableItem item = (TableItem) e.item;
             RoleType roleType = (RoleType) item.getData();
-            roleName.setText(roleType.getRoleName());
+            roleNameText.setText(roleType.getRoleName());
 
             if (!roleType.getDescription().isEmpty()) {
-                description.setText(((DescriptionType) roleType
+                roleDescriptionText.setText(((DescriptionType) roleType
                         .getDescription().get(0)).getLang());
             } else {
-                description.setText("");
+            	roleDescriptionText.setText("");
             }
         }
 



Mime
View raw message