ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1190201 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui: ./ preferences/
Date Fri, 28 Oct 2011 08:25:23 GMT
Author: hibou
Date: Fri Oct 28 08:25:22 2011
New Revision: 1190201

URL: http://svn.apache.org/viewvc?rev=1190201&view=rev
Log:
Improve the property file's paths editor

Added:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/FileListEditor.java
  (with props)
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditorDialog.java
  (with props)
Modified:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvySettingsTab.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditor.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsEditor.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/SettingsPreferencePage.java

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java?rev=1190201&r1=1190200&r2=1190201&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java
Fri Oct 28 08:25:22 2011
@@ -39,7 +39,6 @@ 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.Link;
 import org.eclipse.swt.widgets.TableColumn;
 
 public class ConfTableViewer extends Composite {

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/FileListEditor.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/FileListEditor.java?rev=1190201&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/FileListEditor.java
(added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/FileListEditor.java
Fri Oct 28 08:25:22 2011
@@ -0,0 +1,195 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivyde.eclipse.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+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.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.Label;
+
+public class FileListEditor extends Composite {
+
+    private ListViewer filelist;
+
+    private List/* <String> */files = new ArrayList();
+
+    private Button add;
+
+    private Button remove;
+
+    private Button up;
+
+    private Button down;
+
+    public FileListEditor(Composite parent, int style,  String label, final String labelPopup,
+            final IJavaProject project, final String defaultExtension) {
+        super(parent, style);
+        setLayout(new GridLayout(3, false));
+
+        Label l = new Label(this, SWT.NONE);
+        l.setText(label);
+        l.setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, false, false));
+
+        filelist = new ListViewer(this, SWT.BORDER);
+        filelist.getList().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
true));
+        filelist.setContentProvider(ArrayContentProvider.getInstance());
+        filelist.setLabelProvider(new LabelProvider());
+        filelist.addSelectionChangedListener(new ISelectionChangedListener() {
+            public void selectionChanged(SelectionChangedEvent event) {
+                remove.setEnabled(!event.getSelection().isEmpty());
+                updateUpDownEnableButtons(true);
+            }
+        });
+
+        Composite buttons = new Composite(this, SWT.NONE);
+        buttons.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, true));
+        // CheckStyle:MagicNumber| OFF
+        GridLayout layout = new GridLayout(1, false);
+        // CheckStyle:MagicNumber| ON
+        layout.marginHeight = 0;
+        layout.marginWidth = 0;
+        buttons.setLayout(layout);
+
+        add = new Button(buttons, SWT.PUSH);
+        add.setText("Add");
+        add.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+        add.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                PathEditorDialog dialog = new PathEditorDialog(getShell(), labelPopup, project,
+                        defaultExtension);
+                if (dialog.open() == Window.OK) {
+                    if (!files.contains(dialog.getFile())) {
+                        files.add(dialog.getFile());
+                        filelist.refresh();
+                    }
+                }
+            }
+        });
+
+        remove = new Button(buttons, SWT.PUSH);
+        remove.setText("Remove");
+        remove.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+        remove.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                List selection = ((IStructuredSelection) filelist.getSelection()).toList();
+                files.removeAll(selection);
+                filelist.refresh();
+                remove.setEnabled(false);
+            }
+        });
+
+        up = new Button(buttons, SWT.PUSH);
+        up.setText("Up");
+        up.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+        up.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                int i = getSelectedConfigurationIndex();
+                String f = (String) files.get(i);
+                files.set(i, files.get(i - 1));
+                files.set(i - 1, f);
+                filelist.refresh();
+                updateUpDownEnableButtons(true);
+            }
+        });
+
+        down = new Button(buttons, SWT.PUSH);
+        down.setText("Down");
+        down.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+        down.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                int i = getSelectedConfigurationIndex();
+                String f = (String) files.get(i);
+                files.set(i, files.get(i + 1));
+                files.set(i + 1, f);
+                filelist.refresh();
+                updateUpDownEnableButtons(true);
+            }
+        });
+    }
+
+    private int getSelectedConfigurationIndex() {
+        IStructuredSelection selection = (IStructuredSelection) filelist.getSelection();
+        String file = (String) selection.getFirstElement();
+        for (int i = 0; i < files.size(); i++) {
+            if (files.get(i) == file) {
+                return i;
+            }
+        }
+        return -1;
+    }
+
+    private void updateUpDownEnableButtons(boolean enabled) {
+        boolean selected = filelist.getList().getSelectionCount() != 0;
+        int i = getSelectedConfigurationIndex();
+        up.setEnabled(enabled && selected && i > 0);
+        down.setEnabled(enabled && selected && i < files.size() - 1);
+    }
+
+    public void init(List/* <String> */files) {
+        this.files = files;
+        filelist.setInput(files);
+        remove.setEnabled(false);
+    }
+
+    public List getFiles() {
+        return files;
+    }
+
+    protected void addVariable(String variable) {
+        // TODO Auto-generated method stub
+        filelist.refresh();
+    }
+
+    protected void setFile(String file) {
+        if (!files.contains(file)) {
+            files.add(file);
+            filelist.refresh();
+        }
+    }
+
+    protected void setWorkspaceLoc(String workspaceLoc) {
+        if (!files.contains(workspaceLoc)) {
+            files.add(workspaceLoc);
+            filelist.refresh();
+        }
+    }
+
+    public void setEnabled(boolean enabled) {
+        super.setEnabled(enabled);
+        filelist.getList().setEnabled(enabled);
+        remove.setEnabled(enabled && !filelist.getSelection().isEmpty());
+        add.setEnabled(enabled);
+        updateUpDownEnableButtons(enabled);
+    }
+
+}

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/FileListEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/FileListEditor.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/FileListEditor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvySettingsTab.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvySettingsTab.java?rev=1190201&r1=1190200&r2=1190201&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvySettingsTab.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvySettingsTab.java
Fri Oct 28 08:25:22 2011
@@ -89,7 +89,7 @@ public class IvySettingsTab {
         configComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
 
         settingsEditor = new SettingsEditor(configComposite, SWT.NONE);
-        settingsEditor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false,
3, 1));
+        settingsEditor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true,
3, 1));
         settingsEditor.addListener(new SettingsEditorListener() {
             public void settingsEditorUpdated(IvySettingsSetup setup) {
                 settingsUpdated();

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditor.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditor.java?rev=1190201&r1=1190200&r2=1190201&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditor.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditor.java
Fri Oct 28 08:25:22 2011
@@ -41,7 +41,7 @@ import org.eclipse.ui.dialogs.ElementTre
 import org.eclipse.ui.model.BaseWorkbenchContentProvider;
 import org.eclipse.ui.model.WorkbenchLabelProvider;
 
-public abstract class PathEditor extends Composite {
+public class PathEditor extends Composite {
 
     private Text text;
 

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditorDialog.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditorDialog.java?rev=1190201&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditorDialog.java
(added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditorDialog.java
Fri Oct 28 08:25:22 2011
@@ -0,0 +1,66 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivyde.eclipse.ui;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+public class PathEditorDialog extends Dialog {
+
+    private String label;
+
+    private IJavaProject project;
+
+    private String defaultExtension;
+
+    private PathEditor editor;
+
+    private String file;
+
+    protected PathEditorDialog(Shell parentShell, String label, IJavaProject project,
+            String defaultExtension) {
+        super(parentShell);
+        setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX);
+        this.label = label;
+        this.project = project;
+        this.defaultExtension = defaultExtension;
+    }
+
+    protected Control createDialogArea(Composite parent) {
+        Control dialogArea = super.createDialogArea(parent);
+        editor = new PathEditor((Composite) dialogArea, SWT.NONE, label, project, defaultExtension);
+        GridData layoutData = new GridData(GridData.FILL, GridData.FILL, true, true);
+        layoutData.widthHint = 500;
+        editor.setLayoutData(layoutData);
+        return dialogArea;
+    }
+
+    protected void okPressed() {
+        file = editor.getText().getText();
+        super.okPressed();
+    }
+    
+    public String getFile() {
+        return file;
+    }
+}

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditorDialog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditorDialog.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/PathEditorDialog.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsEditor.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsEditor.java?rev=1190201&r1=1190200&r2=1190201&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsEditor.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsEditor.java
Fri Oct 28 08:25:22 2011
@@ -25,7 +25,6 @@ import java.util.List;
 
 import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
-import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
 import org.apache.ivyde.eclipse.cpcontainer.IvySettingsSetup;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jface.fieldassist.DecoratedField;
@@ -58,7 +57,7 @@ public class SettingsEditor extends Comp
 
     private FieldDecoration errorDecoration;
 
-    private PathEditor propFilesEditor;
+    private FileListEditor propFilesEditor;
 
     private DecoratedField settingsTextDeco;
 
@@ -145,30 +144,15 @@ public class SettingsEditor extends Comp
         };
         settingsEditor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
 
-        propFilesEditor = new PathEditor(this, SWT.NONE, "Property files:", null, "*.properties")
{
-
-            protected void textUpdated() {
-                settingsPathUpdated();
-            }
-
-            protected void setFile(String file) {
-                getText().insert(file);
-                textUpdated();
-            }
-
-            protected void setWorkspaceLoc(String workspaceLoc) {
-                getText().insert(workspaceLoc);
-                textUpdated();
-            }
-        };
-        propFilesEditor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+        propFilesEditor = new FileListEditor(this, SWT.NONE, "Property files:", "Property
file:", null, "*.properties");
+        propFilesEditor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
     }
 
     public IvySettingsSetup getIvySettingsSetup() {
         IvySettingsSetup setup = new IvySettingsSetup();
         setup.setIvySettingsPath(settingsEditor.getText().getText());
         setup.setLoadSettingsOnDemand(loadOnDemandButton.getSelection());
-        setup.setPropertyFiles(IvyClasspathUtil.split(propFilesEditor.getText().getText()));
+        setup.setPropertyFiles(propFilesEditor.getFiles());
         return setup;
     }
 
@@ -240,7 +224,7 @@ public class SettingsEditor extends Comp
 
     public void init(IvySettingsSetup setup) {
         settingsEditor.getText().setText(setup.getRawIvySettingsPath());
-        propFilesEditor.getText().setText(IvyClasspathUtil.concat(setup.getRawPropertyFiles()));
+        propFilesEditor.init(setup.getRawPropertyFiles());
         loadOnDemandButton.setSelection(setup.isLoadSettingsOnDemand());
     }
 

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/SettingsPreferencePage.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/SettingsPreferencePage.java?rev=1190201&r1=1190200&r2=1190201&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/SettingsPreferencePage.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/SettingsPreferencePage.java
Fri Oct 28 08:25:22 2011
@@ -51,7 +51,7 @@ public class SettingsPreferencePage exte
         composite.setLayout(new GridLayout());
 
         settingsEditor = new SettingsEditor(composite, SWT.NONE);
-        settingsEditor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+        settingsEditor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
         // CheckStyle:MagicNumber| ON
 
         initPreferences();



Mime
View raw message