diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2015-03-26 14:32:47 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2015-03-26 14:32:47 -0230 |
commit | 454c03e66a16a6d733163e67e317fbf565b5cdbf (patch) | |
tree | 7ecc45eecd24a65bf5bc81af2a48621d80b58caf /eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties | |
parent | Updated .gitignore files (diff) | |
download | ice-454c03e66a16a6d733163e67e317fbf565b5cdbf.tar.bz2 ice-454c03e66a16a6d733163e67e317fbf565b5cdbf.tar.xz ice-454c03e66a16a6d733163e67e317fbf565b5cdbf.zip |
ICE-6396 Move eclipse plugin to its own repo
Diffstat (limited to 'eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties')
4 files changed, 0 insertions, 1295 deletions
diff --git a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/ProjectProperties.java b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/ProjectProperties.java deleted file mode 100644 index 00a6dc40b42..00000000000 --- a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/ProjectProperties.java +++ /dev/null @@ -1,447 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This plug-in is provided to you under the terms and conditions -// of the Eclipse Public License Version 1.0 ("EPL"). A copy of -// the EPL is available at http://www.eclipse.org/legal/epl-v10.html. -// -// ********************************************************************** - -package com.zeroc.slice2javaplugin.properties; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -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.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.ContainerSelectionDialog; - -import com.zeroc.slice2javaplugin.Activator; -import com.zeroc.slice2javaplugin.builder.Slice2JavaBuilder; -import com.zeroc.slice2javaplugin.internal.Configuration; - -public class ProjectProperties extends PropertyPage -{ - public ProjectProperties() - { - super(true); - setTitle("Slice2Java Settings"); - noDefaultAndApplyButton(); - } - - public void performApply() - { - super.performApply(); - } - - public boolean performOk() - { - final IProject project = getProject(); - - try - { - _config.setGeneratedDir(_generatedDir.getText()); - _config.setSliceSourceDirs(Arrays.asList(_sourceDirectories.getItems())); - _config.setIncludes(Arrays.asList(_includes.getItems())); - _config.setDefines(Configuration.toList(_defines.getText())); - _config.setMeta(Configuration.toList(_meta.getText())); - _config.setStream(_stream.getSelection()); - _config.setTie(_tie.getSelection()); - _config.setIce(_ice.getSelection()); - _config.setUnderscore(_underscore.getSelection()); - _config.setConsole(_console.getSelection()); - _config.setExtraArguments(_extraArguments.getText()); - if(_config.getAddJars()) - { - java.util.List<String> jars = new ArrayList<String>(); - jars.add(_config.getJarName("Ice")); - if(_freezeJar.getSelection()) - { - jars.add(_config.getJarName("Freeze")); - } - if(_glacier2Jar.getSelection()) - { - jars.add(_config.getJarName("Glacier2")); - } - if(_iceBoxJar.getSelection()) - { - jars.add(_config.getJarName("IceBox")); - } - if(_iceStormJar.getSelection()) - { - jars.add(_config.getJarName("IceStorm")); - } - if(_iceGridJar.getSelection()) - { - jars.add(_config.getJarName("IceGrid")); - } - if(_icePatch2Jar.getSelection()) - { - jars.add(_config.getJarName("IcePatch2")); - } - _config.setJars(jars); - } - - if(_config.write()) - { - // The configuration properties were changed. We need to rebuild - // the slice files. - Job job = new Job("Rebuild") - { - protected IStatus run(IProgressMonitor monitor) - { - try - { - project.build(IncrementalProjectBuilder.FULL_BUILD, Slice2JavaBuilder.BUILDER_ID, null, - monitor); - } - catch(CoreException e) - { - return new Status(Status.ERROR, Activator.PLUGIN_ID, 0, "rebuild failed", e); - } - return Status.OK_STATUS; - } - }; - job.setPriority(Job.BUILD); - job.schedule(); // start as soon as possible - } - } - catch(CoreException e) - { - return false; - } - catch(IOException e) - { - ErrorDialog.openError(getShell(), "Error", "Error saving preferences", new Status(Status.ERROR, - Activator.PLUGIN_ID, 0, null, e)); - return false; - } - return true; - } - - protected void createPostOptions(Composite composite) - { - _jarsGroup = new Group(composite, SWT.NONE); - _jarsGroup.setText("Add references to the following JAR files:"); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 7; - - _jarsGroup.setLayout(gridLayout); - _jarsGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - - _freezeJar = new Button(_jarsGroup, SWT.CHECK); - _freezeJar.setText("Freeze"); - - _glacier2Jar = new Button(_jarsGroup, SWT.CHECK); - _glacier2Jar.setText("Glacier2"); - - _iceBoxJar = new Button(_jarsGroup, SWT.CHECK); - _iceBoxJar.setText("IceBox"); - - _iceGridJar = new Button(_jarsGroup, SWT.CHECK); - _iceGridJar.setText("IceGrid"); - - _icePatch2Jar = new Button(_jarsGroup, SWT.CHECK); - _icePatch2Jar.setText("IcePatch2"); - - _iceStormJar = new Button(_jarsGroup, SWT.CHECK); - _iceStormJar.setText("IceStorm"); - } - - /** - * @see PreferencePage#createContents(Composite) - */ - protected Control createContents(Composite parent) - { - // Composite composite = new Composite(parent, SWT.NONE); - - TabFolder tabFolder = new TabFolder(parent, SWT.NONE); - { - TabItem tabItem = new TabItem(tabFolder, SWT.NONE); - tabItem.setText("Source"); - Control source = createSource(tabFolder); - tabItem.setControl(source); - } - { - TabItem tabItem = new TabItem(tabFolder, SWT.NONE); - tabItem.setText("Options"); - Control source = createOptions(tabFolder); - tabItem.setControl(source); - } - tabFolder.pack(); - - loadPrefs(); - - return tabFolder; - } - - private void loadPrefs() - { - IProject project = getProject(); - _config = new Configuration(project); - - _generatedDir.setText(_config.getGeneratedDir()); - for(Iterator<String> iter = _config.getSliceSourceDirs().iterator(); iter.hasNext();) - { - _sourceDirectories.add(iter.next()); - } - for(Iterator<String> iter = _config.getBareIncludes().iterator(); iter.hasNext();) - { - _includes.add(iter.next()); - } - for(Iterator<String> iter = _config.getJars().iterator(); iter.hasNext();) - { - String jarFile = iter.next(); - if(jarFile.equals(_config.getJarName("Freeze"))) - { - _freezeJar.setSelection(true); - } - else if(jarFile.equals(_config.getJarName("Glacier2"))) - { - _glacier2Jar.setSelection(true); - } - else if(jarFile.equals(_config.getJarName("IceBox"))) - { - _iceBoxJar.setSelection(true); - } - else if(jarFile.equals(_config.getJarName("IceGrid"))) - { - _iceGridJar.setSelection(true); - } - else if(jarFile.equals(_config.getJarName("IcePatch2"))) - { - _icePatch2Jar.equals(true); - } - else if(jarFile.equals(_config.getJarName("IceStorm"))) - { - _iceStormJar.setSelection(true); - } - } - _defines.setText(Configuration.fromList(_config.getDefines())); - _meta.setText(Configuration.fromList(_config.getMeta())); - _stream.setSelection(_config.getStream()); - _tie.setSelection(_config.getTie()); - _ice.setSelection(_config.getIce()); - _underscore.setSelection(_config.getUnderscore()); - _console.setSelection(_config.getConsole()); - _extraArguments.setText(_config.getExtraArguments()); - - // - // Android projects don't support Freeze. - // - _freezeJar.setEnabled(!_config.isAndroidProject()); - - checkValid(); - } - - private void checkValid() - { - IProject project = getProject(); - IFolder folder = project.getFolder(_generatedDir.getText()); - if(!folder.exists()) - { - setErrorMessage("Generated folder does not exist"); - setValid(false); - return; - } - setValid(true); - setErrorMessage(null); - } - - private Control createSource(Composite parent) - { - Composite composite = new Composite(parent, SWT.NONE); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - composite.setLayout(gridLayout); - - Group sourceGroup = new Group(composite, SWT.NONE); - sourceGroup.setText("Location of Slice Source Files"); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - sourceGroup.setLayout(gridLayout); - sourceGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite c1 = new Composite(sourceGroup, SWT.NONE); - - gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - c1.setLayout(gridLayout); - c1.setLayoutData(new GridData(GridData.FILL_BOTH)); - - _sourceDirectories = new List(c1, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER); - _sourceDirectories.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite c2 = new Composite(c1, SWT.NONE); - - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - c2.setLayout(gridLayout); - - Button but1 = new Button(c2, SWT.PUSH); - but1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - but1.setText("Add Folder"); - but1.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - IProject project = getProject(); - - SourceSelectionDialog dialog = new SourceSelectionDialog(getShell(), project, "Select Source Location"); - String[] items = _sourceDirectories.getItems(); - IFolder[] resources = new IFolder[items.length]; - for(int i = 0; i < items.length; ++i) - { - resources[i] = project.getFolder(items[i]); - } - dialog.setInitialSelections(resources); - if(dialog.open() == ContainerSelectionDialog.OK) - { - Object[] selection = dialog.getResult(); - for(int i = 0; i < selection.length; ++i) - { - IFolder path = (IFolder) selection[i]; - _sourceDirectories.add(path.getProjectRelativePath().toString()); - } - } - } - }); - - Button but2 = new Button(c2, SWT.PUSH); - but2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - but2.setText("Remove"); - but2.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - _sourceDirectories.remove(_sourceDirectories.getSelectionIndices()); - } - }); - - Group gclGroup = new Group(composite, SWT.NONE); - gclGroup.setText("Generated Code Location"); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - gclGroup.setLayout(gridLayout); - gclGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite tc = new Composite(gclGroup, SWT.NONE); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - tc.setLayout(gridLayout); - tc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Label l = new Label(tc, SWT.WRAP); - l.setForeground(new Color(null, 255, 0, 0)); - l.setText("This subdirectory is used by the plug-in to manage the source files generated from " - + "your Slice definitions. It should not be used for any other purpose. " - + "Files added manually are removed during project rebuilds."); - - GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.widthHint = 400; - l.setLayoutData(gridData); - - Composite c = new Composite(tc, SWT.NONE); - - GridLayout gridLayout2 = new GridLayout(); - gridLayout2.numColumns = 2; - gridLayout2.marginLeft = 0; - gridLayout2.marginTop = 0; - gridLayout2.marginBottom = 0; - c.setLayout(gridLayout2); - - c.setLayoutData(new GridData(GridData.FILL_BOTH)); - - _generatedDir = new Text(c, SWT.BORDER | SWT.READ_ONLY); - gridData = new GridData(GridData.FILL_HORIZONTAL); - // gridData.horizontalSpan = 2; - _generatedDir.setLayoutData(gridData); - - Button but3 = new Button(c, SWT.PUSH); - but3.setText("Browse"); - but3.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - IProject project = getProject(); - - SourceSelectionDialog dialog = new SourceSelectionDialog(getShell(), project, - "Select Generated Code Location"); - dialog.setMultiple(false); - if(dialog.open() == ContainerSelectionDialog.OK) - { - Object[] selection = dialog.getResult(); - if(selection.length == 1) - { - IFolder path = (IFolder) selection[0]; - String oldPath = _generatedDir.getText(); - String newPath = path.getProjectRelativePath().toString(); - if(oldPath.equals(newPath)) - { - return; - } - try - { - if(path.members().length > 0) - { - ErrorDialog.openError(getShell(), "Error", - "Generated code location should be an empty folder", new Status(Status.ERROR, - Activator.PLUGIN_ID, "The chosen directory '" - + path.getFullPath().toOSString() + "' is not empty.")); - return; - } - } - catch(CoreException ex) - { - ErrorDialog.openError(getShell(), "Error", ex.toString(), new Status(Status.ERROR, - Activator.PLUGIN_ID, 0, "Failed to set generated code location.", ex)); - return; - } - _generatedDir.setText(newPath); - } - } - } - }); - - return composite; - } - - private Button _freezeJar; - private Button _glacier2Jar; - private Button _iceBoxJar; - private Button _iceGridJar; - private Button _icePatch2Jar; - private Button _iceStormJar; - - private Text _generatedDir; - private List _sourceDirectories; - private Group _jarsGroup; -} diff --git a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/PropertyPage.java b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/PropertyPage.java deleted file mode 100644 index 41c8547ffce..00000000000 --- a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/PropertyPage.java +++ /dev/null @@ -1,484 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This plug-in is provided to you under the terms and conditions -// of the Eclipse Public License Version 1.0 ("EPL"). A copy of -// the EPL is available at http://www.eclipse.org/legal/epl-v10.html. -// -// ********************************************************************** - -package com.zeroc.slice2javaplugin.properties; - - -import java.io.IOException; -import java.util.Arrays; -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -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.Control; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Text; - -import com.zeroc.slice2javaplugin.Activator; -import com.zeroc.slice2javaplugin.builder.Slice2JavaBuilder; -import com.zeroc.slice2javaplugin.internal.Configuration; - -public abstract class PropertyPage extends org.eclipse.ui.dialogs.PropertyPage -{ - public PropertyPage(boolean projectPage) - { - super(); - _projectPage = projectPage; - noDefaultAndApplyButton(); - } - - public void performApply() - { - super.performApply(); - } - - protected Control createIncludes(Composite parent) - { - Composite composite = new Composite(parent, SWT.NONE); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - composite.setLayout(gridLayout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - _includes = new List(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER); - _includes.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite c2 = new Composite(composite, SWT.NONE); - - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - c2.setLayout(gridLayout); - - Button but1 = new Button(c2, SWT.PUSH); - but1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - but1.setText("Add"); - but1.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - IProject project = getProject(); - DirectoryDialog dialog = new DirectoryDialog(getShell()); - String dir = dialog.open(); - if(dir != null) - { - IPath projectLocation = project.getLocation(); - IPath includeLocation = new Path(dir); - String dev1 = projectLocation.getDevice(); - if(dev1 == null) - { - dev1 = ""; - } - String dev2 = includeLocation.getDevice(); - if(dev2 == null) - { - dev2 = ""; - } - IPath result; - - // If the directories are on different devices, then we have - // no choice but to use an absolute path. - if(!dev1.equals(dev2)) - { - result = includeLocation; - } - else - { - - // Convert the absolute path to a relative path. - int n = projectLocation.matchingFirstSegments(includeLocation); - result = includeLocation.removeFirstSegments(n); - - IPath up = new Path(".."); - for(n = projectLocation.segmentCount() - n; n > 0; --n) - { - result = up.append(result); - } - // The devices must match, so remove it. - result = result.setDevice(null); - } - _includes.add(result.toString()); - } - } - }); - Button but2 = new Button(c2, SWT.PUSH); - but2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - but2.setText("Remove"); - but2.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - _includes.remove(_includes.getSelectionIndices()); - } - }); - Button but3 = new Button(c2, SWT.PUSH); - but3.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - but3.setText("Up"); - but3.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - int index = _includes.getSelectionIndex(); - if(index > 0) - { - String[] items = _includes.getItems(); - String tmp = items[index-1]; - items[index-1] = items[index]; - items[index] = tmp; - _includes.setItems(items); - _includes.setSelection(index-1); - } - } - }); - Button but4 = new Button(c2, SWT.PUSH); - but4.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - but4.setText("Down"); - but4.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - int index = _includes.getSelectionIndex(); - if(index != -1) - { - String[] items = _includes.getItems(); - if(index != items.length-1) - { - String tmp = items[index+1]; - items[index+1] = items[index]; - items[index] = tmp; - _includes.setItems(items); - _includes.setSelection(index+1); - } - } - } - }); - - return composite; - } - - private String semiFilter(String text) - { - java.util.List<String> l = Arrays.asList(text.split(";")); - StringBuffer sb = new StringBuffer(); - for(Iterator<String> p = l.iterator(); p.hasNext();) - { - String n = p.next().trim(); - if(n.length() > 0) - { - if(sb.length() != 0) - { - sb.append(';'); - } - sb.append(n); - } - } - return sb.toString(); - } - - protected Control createDefines(Composite parent) - { - Composite composite = new Composite(parent, SWT.NONE); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - gridLayout.marginLeft = 0; - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - composite.setLayout(gridLayout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label l = new Label(composite, SWT.WRAP); - l.setText("Enter macros (';' separated). For example, enter FOO;BAR to define -DFOO -DBAR."); - GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.widthHint = 400; - l.setLayoutData(gridData); - - _defines = new Text(composite, SWT.BORDER); - _defines.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - _defines.addFocusListener(new FocusListener() - { - public void focusGained(FocusEvent e) - { - } - - public void focusLost(FocusEvent e) - { - Text t = (Text)e.widget; - String f = t.getText(); - String filtered = semiFilter(f); - if(!f.equals(filtered)) - { - t.setText(filtered); - } - } - }); - - return composite; - } - - protected Control createMeta(Composite parent) - { - Composite composite = new Composite(parent, SWT.NONE); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - gridLayout.marginLeft = 0; - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - composite.setLayout(gridLayout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label l = new Label(composite, SWT.WRAP); - l.setText("Enter metadata (';' separated). For example, enter as:package:com.acme to define --meta=as:package:com.acme."); - GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.widthHint = 400; - l.setLayoutData(gridData); - - _meta = new Text(composite, SWT.BORDER); - _meta.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - _meta.addFocusListener(new FocusListener() - { - public void focusGained(FocusEvent e) - { - } - - public void focusLost(FocusEvent e) - { - Text t = (Text)e.widget; - String f = t.getText(); - String filtered = semiFilter(f); - if(!f.equals(filtered)) - { - t.setText(filtered); - } - } - }); - - return composite; - } - - protected void createPreOptions(Composite parent) - { - } - - protected void createPostOptions(Composite parent) - { - } - - protected Control createOptions(Composite parent) - { - Composite composite = new Composite(parent, SWT.NONE); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - composite.setLayout(gridLayout); - - createPreOptions(composite); - - Group includesGroup = new Group(composite, SWT.NONE); - includesGroup.setText("Location of Include Files"); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - includesGroup.setLayout(gridLayout); - includesGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - - createIncludes(includesGroup); - - Group definesGroup = new Group(composite, SWT.NONE); - definesGroup.setText("Preprocessor Definitions"); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - definesGroup.setLayout(gridLayout); - definesGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - - createDefines(definesGroup); - - Group metaGroup = new Group(composite, SWT.NONE); - metaGroup.setText("Metadata Definitions"); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - metaGroup.setLayout(gridLayout); - metaGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - - createMeta(metaGroup); - - Group optionsGroup = new Group(composite, SWT.NONE); - - gridLayout = new GridLayout(); - gridLayout.numColumns = 5; - optionsGroup.setText("Options"); - optionsGroup.setLayout(gridLayout); - optionsGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - - _stream = new Button(optionsGroup, SWT.CHECK); - _stream.setText("Enable streaming"); - _tie = new Button(optionsGroup, SWT.CHECK); - _tie.setText("Enable tie"); - _ice = new Button(optionsGroup, SWT.CHECK); - _ice.setText("Enable ice"); - if(_projectPage) - { - _console = new Button(optionsGroup, SWT.CHECK); - _console.setText("Enable console"); - } - _underscore = new Button(optionsGroup, SWT.CHECK); - _underscore.setText("Enable underscore"); - - Group extraArgumentsGroup = new Group(composite, SWT.NONE); - extraArgumentsGroup.setText("Extra Compiler Arguments"); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - extraArgumentsGroup.setLayout(gridLayout); - extraArgumentsGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - createExtraArguments(extraArgumentsGroup); - - createPostOptions(composite); - - return composite; - } - - public Control createExtraArguments(Composite parent) - { - Composite composite = new Composite(parent, SWT.NONE); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - gridLayout.marginLeft = 0; - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - composite.setLayout(gridLayout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label l = new Label(composite, SWT.WRAP); - l.setText("Enter extra arguments for the Slice compiler, such as --checksum=foo.Bar.SliceChecksums. " + - "These arguments are appended to the compiler command line."); - GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.widthHint = 400; - l.setLayoutData(gridData); - - _extraArguments = new Text(composite, SWT.BORDER); - _extraArguments.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - return composite; - } - - protected IProject getProject() - { - IAdaptable a = getElement(); - if(a instanceof IProject) - { - return (IProject)a; - } - else if(a instanceof IJavaProject) - { - return ((IJavaProject) a).getProject(); - } - else if(a instanceof IResource) - { - return ((IResource)a).getProject(); - } - else - { - assert(false); - return null; - } - } - - protected IResource getResource() - { - IAdaptable a = getElement(); - if(a instanceof IResource) - { - return (IResource)a; - } - else - { - assert(false); - return null; - } - } - - protected boolean configSaveAndRebuild() - { - final IProject project = getProject(); - try - { - if(_config.write()) - { - // The configuration properties were changed. We need to rebuild - // the slice files. - Job job = new Job("Rebuild") - { - protected IStatus run(IProgressMonitor monitor) - { - try - { - project.build(IncrementalProjectBuilder.FULL_BUILD, Slice2JavaBuilder.BUILDER_ID, null, - monitor); - } - catch(CoreException e) - { - return new Status(Status.ERROR, Activator.PLUGIN_ID, 0, "rebuild failed", e); - } - return Status.OK_STATUS; - } - }; - job.setPriority(Job.BUILD); - job.schedule(); // start as soon as possible - } - } - catch(CoreException e) - { - return false; - } - catch(IOException e) - { - ErrorDialog.openError(getShell(), "Error", "Error saving preferences", - new Status(Status.ERROR, Activator.PLUGIN_ID, 0, null, e)); - return false; - } - return true; - } - - protected Configuration _config; - protected Button _console; - protected List _includes; - - protected Text _defines; - protected Button _stream; - protected Button _tie; - protected Button _ice; - protected Button _underscore; - protected Text _meta; - protected Text _extraArguments; - protected boolean _projectPage; -} diff --git a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/SliceFilePropertyPage.java b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/SliceFilePropertyPage.java deleted file mode 100644 index 49df6181c0b..00000000000 --- a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/SliceFilePropertyPage.java +++ /dev/null @@ -1,110 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This plug-in is provided to you under the terms and conditions -// of the Eclipse Public License Version 1.0 ("EPL"). A copy of -// the EPL is available at http://www.eclipse.org/legal/epl-v10.html. -// -// ********************************************************************** - -package com.zeroc.slice2javaplugin.properties; - -import java.util.Arrays; -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; -import org.eclipse.swt.widgets.Text; - -import com.zeroc.slice2javaplugin.internal.Configuration; - -public class SliceFilePropertyPage extends PropertyPage -{ - public SliceFilePropertyPage() - { - super(false); - setTitle("Slice2as Settings"); - } - - protected void createPreOptions(Composite parent) - { - Composite composite = new Composite(parent, SWT.NONE); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - gridLayout.marginLeft = 0; - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - composite.setLayout(gridLayout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Label l = new Label(composite, SWT.WRAP); - l.setText("File:"); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - l.setLayoutData(gridData); - - Text pathValueText = new Text(composite, SWT.WRAP | SWT.READ_ONLY); - pathValueText.setText(getResource().getFullPath().toString()); - pathValueText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - } - - protected Control createContents(Composite parent) - { - TabFolder tabFolder = new TabFolder(parent, SWT.NONE); - { - TabItem tabItem = new TabItem(tabFolder, SWT.NONE); - - - Control source = createOptions(tabFolder); - tabItem.setText("Options"); - tabItem.setControl(source); - } - - tabFolder.pack(); - loadPrefs(); - return tabFolder; - } - - public boolean performOk() - { - final IResource resource = getResource(); - _config.setIncludes(resource, Arrays.asList(_includes.getItems())); - _config.setDefines(resource, Configuration.toList(_defines.getText())); - _config.setStream(_stream.getSelection()); - _config.setMeta(resource, Configuration.toList(_meta.getText())); - _config.setTie(resource, _tie.getSelection()); - _config.setIce(resource, _ice.getSelection()); - _config.setUnderscore(resource, _underscore.getSelection()); - _config.setExtraArguments(resource, _extraArguments.getText()); - return configSaveAndRebuild(); - } - - private void loadPrefs() - { - IProject project = getProject(); - IResource resource = getResource(); - _config = new Configuration(project); - - for(Iterator<String> iter = _config.getBareIncludes(resource).iterator(); iter.hasNext();) - { - _includes.add(iter.next()); - } - - _defines.setText(Configuration.fromList(_config.getDefines(resource))); - _meta.setText(Configuration.fromList(_config.getMeta(resource))); - _stream.setSelection(_config.getStream()); - _tie.setSelection(_config.getTie(resource)); - _ice.setSelection(_config.getIce(resource)); - _underscore.setSelection(_config.getUnderscore(resource)); - _extraArguments.setText(_config.getExtraArguments(resource)); - } -} diff --git a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/SourceSelectionDialog.java b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/SourceSelectionDialog.java deleted file mode 100644 index 2c7c6119863..00000000000 --- a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/SourceSelectionDialog.java +++ /dev/null @@ -1,254 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This plug-in is provided to you under the terms and conditions -// of the Eclipse Public License Version 1.0 ("EPL"). A copy of -// the EPL is available at http://www.eclipse.org/legal/epl-v10.html. -// -// ********************************************************************** - -package com.zeroc.slice2javaplugin.properties; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTreeViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TreeSelection; -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; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.ui.dialogs.SelectionDialog; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -class SourceSelectionDialog extends SelectionDialog -{ - // Do we allow multiple selections? - private boolean multiple = true; - - // the root element to populate the viewer with - private IProject root; - - // the visual selection widget group - private CheckboxTreeViewer selectionGroup; - - // constants - private final static int SIZING_SELECTION_WIDGET_WIDTH = 400; - - private final static int SIZING_SELECTION_WIDGET_HEIGHT = 300; - - /** - * Creates a resource selection dialog rooted at the given element. - * - * @param parentShell - * the parent shell - * @param rootElement - * the root element to populate this dialog with - * @param message - * the message to be displayed at the top of this dialog, or - * <code>null</code> to display a default message - */ - public SourceSelectionDialog(Shell parentShell, IProject project, String message) - { - super(parentShell); - setTitle("Source Folder Selection"); - root = project; - if(message != null) - { - setMessage(message); - } - else - { - setMessage("Select source folder:"); - } - } - - public void setMultiple(boolean m) - { - multiple = m; - } - - /* - * (non-Javadoc) Method declared in Window. - */ - protected void configureShell(Shell shell) - { - super.configureShell(shell); - //PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IIDEHelpContextIds.RESOURCE_SELECTION_DIALOG); - } - - public void create() - { - super.create(); - initializeDialog(); - } - - /* - * (non-Javadoc) Method declared on Dialog. - */ - protected Control createDialogArea(Composite parent) - { - // page group - Composite composite = (Composite) super.createDialogArea(parent); - - // create the input element, which has the root resource - // as its only child - ArrayList<IProject> input = new ArrayList<IProject>(); - input.add(root); - - createMessageArea(composite); - - Tree tree = new Tree(composite, ((multiple) ? SWT.CHECK : SWT.SINGLE) | SWT.BORDER); - GridData data = new GridData(GridData.FILL_BOTH); - data.widthHint = SIZING_SELECTION_WIDGET_WIDTH; - data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT; - tree.setLayoutData(data); - tree.setFont(parent.getFont()); - - selectionGroup = new CheckboxTreeViewer(tree); - selectionGroup.setContentProvider(getResourceProvider(IResource.FILE | IResource.PROJECT)); - selectionGroup.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider()); - selectionGroup.setInput(input); - - selectionGroup.expandToLevel(2); - - return composite; - } - - /** - * Returns a content provider for <code>IResource</code>s that returns only - * children of the given resource type. - */ - private ITreeContentProvider getResourceProvider(final int resourceType) - { - return new WorkbenchContentProvider() - { - @SuppressWarnings("unchecked") - public Object[] getChildren(Object o) - { - if(o instanceof IContainer) - { - IResource[] members = null; - try - { - members = ((IContainer) o).members(); - } - catch(CoreException e) - { - // just return an empty set of children - return new Object[0]; - } - - // filter out the desired resource types - ArrayList<Object> results = new ArrayList<Object>(); - for(int i = 0; i < members.length; i++) - { - if(members[i] instanceof IFolder) - { - results.add(members[i]); - } - } - return results.toArray(); - } - // input element case - if(o instanceof ArrayList) - { - return ((ArrayList<Object>) o).toArray(); - } - return new Object[0]; - } - }; - } - - /** - * Initializes this dialog's controls. - */ - private void initializeDialog() - { - getOkButton().setEnabled(false); - if(multiple) - { - selectionGroup.addCheckStateListener(new ICheckStateListener() - { - public void checkStateChanged(CheckStateChangedEvent event) - { - if(!event.getChecked() && selectionGroup.getGrayed(event.getElement())) - { - selectionGroup.setChecked(event.getElement(), true); - } - else - { - int count = selectionGroup.getCheckedElements().length - getInitialElementSelections().size(); - getOkButton().setEnabled(count > 0); - } - } - }); - - for(Iterator<?> iter = getInitialElementSelections().iterator(); iter.hasNext(); ) - { - IResource cur = (IResource)iter.next(); - selectionGroup.setGrayChecked(cur, true); - } - } - else - { - selectionGroup.addSelectionChangedListener(new ISelectionChangedListener() - { - public void selectionChanged(SelectionChangedEvent event) - { - getOkButton().setEnabled(true); - } - }); - } - } - - /** - * The <code>ResourceSelectionDialog</code> implementation of this - * <code>Dialog</code> method builds a list of the selected resources for - * later retrieval by the client and closes this dialog. - */ - protected void okPressed() - { - /* - * Iterator resultEnum = selectionGroup.getAllCheckedListItems(); - * ArrayList list = new ArrayList(); while (resultEnum.hasNext()) { - * list.add(resultEnum.next()); } setResult(list); - */ - ArrayList<Object> list = new ArrayList<Object>(); - if(multiple) - { - Object[] objs = selectionGroup.getCheckedElements(); - for(int i = 0; i < objs.length; ++i) - { - if(!selectionGroup.getGrayed(objs[i])) - { - list.add(objs[i]); - } - } - } - else - { - TreeSelection obj = (TreeSelection)selectionGroup.getSelection(); - if(!obj.isEmpty()) - { - list.add(obj.getFirstElement()); - } - } - setResult(list); - super.okPressed(); - } -} |