Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 122423 Details for
Bug 256910
target platform: the next wave
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Editor Work in Progress
clipboard.txt (text/plain), 177.40 KB, created by
Curtis Windatt
on 2009-01-13 11:36:28 EST
(
hide
)
Description:
Editor Work in Progress
Filename:
MIME Type:
Creator:
Curtis Windatt
Created:
2009-01-13 11:36:28 EST
Size:
177.40 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui >Index: src/org/eclipse/pde/internal/ui/editor/target/OverviewPage.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/target/OverviewPage.java,v >retrieving revision 1.16 >diff -u -r1.16 OverviewPage.java >--- src/org/eclipse/pde/internal/ui/editor/target/OverviewPage.java 16 Jan 2008 17:08:09 -0000 1.16 >+++ src/org/eclipse/pde/internal/ui/editor/target/OverviewPage.java 13 Jan 2009 16:34:30 -0000 >@@ -1,117 +1,98 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import org.eclipse.jface.action.IStatusLineManager; >-import org.eclipse.pde.internal.ui.*; >-import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >-import org.eclipse.pde.internal.ui.editor.PDEFormPage; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.SWTException; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.forms.IManagedForm; >-import org.eclipse.ui.forms.editor.FormEditor; >-import org.eclipse.ui.forms.events.HyperlinkEvent; >-import org.eclipse.ui.forms.events.IHyperlinkListener; >-import org.eclipse.ui.forms.widgets.*; >- >-public class OverviewPage extends PDEFormPage implements IHyperlinkListener { >- >- public static final String PAGE_ID = "overview"; //$NON-NLS-1$ >- >- public OverviewPage(FormEditor editor) { >- super(editor, PAGE_ID, PDEUIMessages.OverviewPage_title); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm) >- */ >- protected void createFormContent(IManagedForm managedForm) { >- super.createFormContent(managedForm); >- ScrolledForm form = managedForm.getForm(); >- FormToolkit toolkit = managedForm.getToolkit(); >- form.setText(PDEUIMessages.OverviewPage_title); >- form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_TARGET_DEFINITION)); >- fillBody(managedForm, toolkit); >- PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.TARGET_OVERVIEW_PAGE); >- } >- >- private void fillBody(IManagedForm managedForm, FormToolkit toolkit) { >- Composite body = managedForm.getForm().getBody(); >- body.setLayout(FormLayoutFactory.createFormGridLayout(true, 2)); >- >- managedForm.addPart(new TargetDefinitionSection(this, body)); >- managedForm.addPart(new LocationsSection(this, body)); >- createContentsSection(body, toolkit); >- createEnvironmentSection(body, toolkit); >- } >- >- private void createContentsSection(Composite parent, FormToolkit toolkit) { >- Section section = createSection(parent, toolkit, PDEUIMessages.OverviewPage_contentTitle); >- createText(section, PDEUIMessages.OverviewPage_contentDescription, toolkit); >- } >- >- private void createEnvironmentSection(Composite parent, FormToolkit toolkit) { >- Section section = createSection(parent, toolkit, PDEUIMessages.OverviewPage_environmentTitle); >- createText(section, PDEUIMessages.OverviewPage_environmentDescription, toolkit); >- } >- >- private Section createSection(Composite parent, FormToolkit toolkit, String title) { >- Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR); >- section.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING; >- section.setText(title); >- section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1)); >- section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); >- return section; >- } >- >- private FormText createText(Section section, String content, FormToolkit toolkit) { >- Composite container = toolkit.createComposite(section, SWT.NONE); >- container.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 1)); >- section.setClient(container); >- FormText text = toolkit.createFormText(container, true); >- try { >- text.setText(content, true, false); >- } catch (SWTException e) { >- text.setText(e.getMessage(), false, false); >- } >- TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB); >- data.maxWidth = 250; >- text.setLayoutData(data); >- text.addHyperlinkListener(this); >- return text; >- } >- >- public void linkActivated(HyperlinkEvent e) { >- String href = (String) e.getHref(); >- if (href.equals("content")) //$NON-NLS-1$ >- getEditor().setActivePage(ContentPage.PAGE_ID); >- else if (href.equals("environment")) //$NON-NLS-1$ >- getEditor().setActivePage(EnvironmentPage.PAGE_ID); >- } >- >- public void linkEntered(HyperlinkEvent e) { >- IStatusLineManager mng = getEditor().getEditorSite().getActionBars().getStatusLineManager(); >- mng.setMessage(e.getLabel()); >- } >- >- public void linkExited(HyperlinkEvent e) { >- IStatusLineManager mng = getEditor().getEditorSite().getActionBars().getStatusLineManager(); >- mng.setMessage(null); >- } >- >- protected String getHelpResource() { >- return "/org.eclipse.pde.doc.user/guide/tools/editors/target_definition_editor/overview.htm"; //$NON-NLS-1$ >- } >- >-} >+/******************************************************************************* >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.target; >+ >+import org.eclipse.jface.action.IStatusLineManager; >+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+import org.eclipse.pde.internal.ui.*; >+import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.forms.IManagedForm; >+import org.eclipse.ui.forms.editor.FormPage; >+import org.eclipse.ui.forms.events.HyperlinkEvent; >+import org.eclipse.ui.forms.events.IHyperlinkListener; >+import org.eclipse.ui.forms.widgets.*; >+ >+public class OverviewPage extends FormPage { >+ >+ public static final String PAGE_ID = "overview"; //$NON-NLS-1$ >+ >+ public OverviewPage(TargetEditor editor) { >+ super(editor, PAGE_ID, PDEUIMessages.OverviewPage_title); >+ } >+ >+ public ITargetDefinition getTarget() { >+ return ((TargetEditor) getEditor()).getTarget(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm) >+ */ >+ protected void createFormContent(IManagedForm managedForm) { >+ super.createFormContent(managedForm); >+ ScrolledForm form = managedForm.getForm(); >+ FormToolkit toolkit = managedForm.getToolkit(); >+ form.setText(PDEUIMessages.OverviewPage_title); >+ form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_TARGET_DEFINITION)); >+ toolkit.decorateFormHeading(form.getForm()); >+ fillBody(managedForm, toolkit); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.TARGET_OVERVIEW_PAGE); >+ } >+ >+ private void fillBody(IManagedForm managedForm, FormToolkit toolkit) { >+ Composite body = managedForm.getForm().getBody(); >+ body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1)); >+ managedForm.addPart(new TargetDefinitionSection(this, body)); >+ createEnvironmentSection(body, toolkit); >+ } >+ >+ private void createEnvironmentSection(Composite parent, FormToolkit toolkit) { >+ Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR); >+ section.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING; >+ section.setText(PDEUIMessages.OverviewPage_environmentTitle); >+ section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1)); >+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); >+ >+ Composite container = toolkit.createComposite(section, SWT.NONE); >+ container.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 1)); >+ section.setClient(container); >+ FormText text = toolkit.createFormText(container, true); >+ text.setText(PDEUIMessages.OverviewPage_environmentDescription, true, false); >+ >+ TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB); >+ data.maxWidth = 250; >+ text.setLayoutData(data); >+ text.addHyperlinkListener(new IHyperlinkListener() { >+ public void linkActivated(HyperlinkEvent e) { >+ getEditor().setActivePage(EnvironmentPage.PAGE_ID); >+ } >+ >+ public void linkEntered(HyperlinkEvent e) { >+ IStatusLineManager mng = getEditor().getEditorSite().getActionBars().getStatusLineManager(); >+ mng.setMessage(e.getLabel()); >+ } >+ >+ public void linkExited(HyperlinkEvent e) { >+ IStatusLineManager mng = getEditor().getEditorSite().getActionBars().getStatusLineManager(); >+ mng.setMessage(null); >+ } >+ }); >+ } >+ >+ // TODO Hook up help toolbar action >+// protected String getHelpResource() { >+// return "/org.eclipse.pde.doc.user/guide/tools/editors/target_definition_editor/overview.htm"; //$NON-NLS-1$ >+// } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/target/TargetDefinitionSection.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/target/TargetDefinitionSection.java,v >retrieving revision 1.14 >diff -u -r1.14 TargetDefinitionSection.java >--- src/org/eclipse/pde/internal/ui/editor/target/TargetDefinitionSection.java 16 Jan 2008 17:08:09 -0000 1.14 >+++ src/org/eclipse/pde/internal/ui/editor/target/TargetDefinitionSection.java 13 Jan 2009 16:34:30 -0000 >@@ -1,268 +1,105 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import org.eclipse.debug.ui.StringVariableSelectionDialog; >-import org.eclipse.jface.window.Window; >-import org.eclipse.pde.core.IModelChangedEvent; >-import org.eclipse.pde.internal.core.itarget.*; >-import org.eclipse.pde.internal.ui.PDEPlugin; >-import org.eclipse.pde.internal.ui.PDEUIMessages; >-import org.eclipse.pde.internal.ui.editor.*; >-import org.eclipse.pde.internal.ui.parts.FormEntry; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.dnd.Clipboard; >-import org.eclipse.swt.events.SelectionAdapter; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.widgets.*; >-import org.eclipse.ui.IActionBars; >-import org.eclipse.ui.forms.IFormColors; >-import org.eclipse.ui.forms.widgets.*; >- >-public class TargetDefinitionSection extends PDESection { >- >- private FormEntry fNameEntry; >- private FormEntry fPath; >- private Button fUseDefault; >- private Button fCustomPath; >- private Button fFileSystem; >- private Button fVariable; >- private static int NUM_COLUMNS = 5; >- >- public TargetDefinitionSection(PDEFormPage page, Composite parent) { >- super(page, parent, ExpandableComposite.TITLE_BAR); >- createClient(getSection(), page.getEditor().getToolkit()); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDESection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit) >- */ >- protected void createClient(Section section, FormToolkit toolkit) { >- section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1)); >- Composite client = toolkit.createComposite(section); >- client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, NUM_COLUMNS)); >- >- IActionBars actionBars = getPage().getPDEEditor().getEditorSite().getActionBars(); >- >- createNameEntry(client, toolkit, actionBars); >- >- createLocation(client, toolkit, actionBars); >- >- toolkit.paintBordersFor(client); >- section.setClient(client); >- section.setText(PDEUIMessages.TargetDefinitionSection_title); >- GridData data = new GridData(); >- data.horizontalSpan = 2; >- data.grabExcessHorizontalSpace = true; >- data.horizontalAlignment = SWT.FILL; >- section.setLayoutData(data); >- // Register to be notified when the model changes >- getModel().addModelChangedListener(this); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.forms.AbstractFormPart#dispose() >- */ >- public void dispose() { >- ITargetModel model = getModel(); >- if (model != null) { >- model.removeModelChangedListener(this); >- } >- super.dispose(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent) >- */ >- public void modelChanged(IModelChangedEvent e) { >- // No need to call super, handling world changed event here >- if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) { >- handleModelEventWorldChanged(e); >- } >- } >- >- /** >- * @param event >- */ >- private void handleModelEventWorldChanged(IModelChangedEvent event) { >- // Perform the refresh >- refresh(); >- // Note: A deferred selection event is fired from radio buttons when >- // their value is toggled, the user switches to another page, and the >- // user switches back to the same page containing the radio buttons >- // This appears to be a result of a SWT bug. >- // If the radio button is the last widget to have focus when leaving >- // the page, an event will be fired when entering the page again. >- // An event is not fired if the radio button does not have focus. >- // The solution is to redirect focus to a stable widget. >- getPage().setLastFocusControl(fNameEntry.getText()); >- } >- >- private void createNameEntry(Composite client, FormToolkit toolkit, IActionBars actionBars) { >- fNameEntry = new FormEntry(client, toolkit, PDEUIMessages.TargetDefinitionSection_name, null, false); >- fNameEntry.setFormEntryListener(new FormEntryAdapter(this, actionBars) { >- public void textValueChanged(FormEntry entry) { >- getTarget().setName(entry.getValue()); >- } >- }); >- GridData gd = (GridData) fNameEntry.getText().getLayoutData(); >- gd.horizontalSpan = 4; >- fNameEntry.setEditable(isEditable()); >- } >- >- private void createLocation(Composite client, FormToolkit toolkit, IActionBars actionBars) { >- Label label = toolkit.createLabel(client, PDEUIMessages.TargetDefinitionSection_targetLocation); >- label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); >- >- fUseDefault = toolkit.createButton(client, PDEUIMessages.TargetDefinitionSection_sameAsHost, SWT.RADIO); >- GridData gd = new GridData(); >- gd.horizontalSpan = 5; >- gd.horizontalIndent = 15; >- fUseDefault.setLayoutData(gd); >- fUseDefault.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (fUseDefault.getSelection()) { >- fPath.getText().setEditable(false); >- fPath.setValue("", true); //$NON-NLS-1$ >- fFileSystem.setEnabled(false); >- fVariable.setEnabled(false); >- getLocationInfo().setDefault(true); >- } >- } >- }); >- >- fCustomPath = toolkit.createButton(client, PDEUIMessages.TargetDefinitionSection_location, SWT.RADIO); >- gd = new GridData(); >- gd.horizontalIndent = 15; >- fCustomPath.setLayoutData(gd); >- fCustomPath.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (fCustomPath.getSelection()) { >- ILocationInfo info = getLocationInfo(); >- fPath.getText().setEditable(true); >- fPath.setValue(info.getPath(), true); >- fFileSystem.setEnabled(true); >- fVariable.setEnabled(true); >- info.setDefault(false); >- } >- } >- }); >- >- fPath = new FormEntry(client, toolkit, null, null, false); >- fPath.getText().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- fPath.setFormEntryListener(new FormEntryAdapter(this, actionBars) { >- public void textValueChanged(FormEntry entry) { >- getLocationInfo().setPath(fPath.getValue()); >- } >- }); >- >- fFileSystem = toolkit.createButton(client, PDEUIMessages.TargetDefinitionSection_fileSystem, SWT.PUSH); >- fFileSystem.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- handleBrowseFileSystem(); >- } >- }); >- >- fVariable = toolkit.createButton(client, PDEUIMessages.TargetDefinitionSection_variables, SWT.PUSH); >- fVariable.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- handleInsertVariable(); >- } >- }); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean) >- */ >- public void commit(boolean onSave) { >- fNameEntry.commit(); >- fPath.commit(); >- super.commit(onSave); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDESection#cancelEdit() >- */ >- public void cancelEdit() { >- fNameEntry.cancelEdit(); >- fPath.cancelEdit(); >- super.cancelEdit(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.forms.AbstractFormPart#refresh() >- */ >- public void refresh() { >- ITarget target = getTarget(); >- fNameEntry.setValue(target.getName(), true); >- ILocationInfo info = getLocationInfo(); >- fUseDefault.setSelection(info.useDefault()); >- fCustomPath.setSelection(!info.useDefault()); >- String path = (info.useDefault()) ? "" : info.getPath(); //$NON-NLS-1$ >- fPath.setValue(path, true); >- fPath.getText().setEditable(!info.useDefault()); >- fFileSystem.setEnabled(!info.useDefault()); >- fVariable.setEnabled(!info.useDefault()); >- super.refresh(); >- } >- >- public boolean canPaste(Clipboard clipboard) { >- Display d = getSection().getDisplay(); >- Control c = d.getFocusControl(); >- if (c instanceof Text) >- return true; >- return false; >- } >- >- protected void handleBrowseFileSystem() { >- DirectoryDialog dialog = new DirectoryDialog(getSection().getShell()); >- String text = fPath.getValue(); >- if (text.length() == 0) >- text = TargetEditor.LAST_PATH; >- dialog.setFilterPath(text); >- dialog.setText(PDEUIMessages.BaseBlock_dirSelection); >- dialog.setMessage(PDEUIMessages.BaseBlock_dirChoose); >- String result = dialog.open(); >- if (result != null) { >- fPath.setValue(result); >- getLocationInfo().setPath(result); >- TargetEditor.LAST_PATH = result; >- } >- } >- >- private void handleInsertVariable() { >- StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(PDEPlugin.getActiveWorkbenchShell()); >- if (dialog.open() == Window.OK) { >- fPath.getText().insert(dialog.getVariableExpression()); >- // have to setValue to make sure getValue reflects the actual text in the Text object. >- fPath.setValue(fPath.getText().getText()); >- getLocationInfo().setPath(fPath.getText().getText()); >- } >- } >- >- private ILocationInfo getLocationInfo() { >- ILocationInfo info = getTarget().getLocationInfo(); >- if (info == null) { >- info = getModel().getFactory().createLocation(); >- getTarget().setLocationInfo(info); >- } >- return info; >- } >- >- private ITarget getTarget() { >- return getModel().getTarget(); >- } >- >- private ITargetModel getModel() { >- return (ITargetModel) getPage().getPDEEditor().getAggregateModel(); >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.target; >+ >+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+import org.eclipse.pde.internal.ui.parts.FormEntry; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.forms.SectionPart; >+import org.eclipse.ui.forms.editor.FormPage; >+import org.eclipse.ui.forms.widgets.*; >+ >+public class TargetDefinitionSection extends SectionPart { >+ >+ private FormEntry fNameEntry; >+ private TargetEditor fEditor; >+ >+ public TargetDefinitionSection(FormPage page, Composite parent) { >+ super(parent, page.getManagedForm().getToolkit(), ExpandableComposite.TITLE_BAR); >+ fEditor = (TargetEditor) page.getEditor(); >+ createClient(getSection(), page.getEditor().getToolkit()); >+ } >+ >+ private ITargetDefinition getTarget() { >+ return fEditor.getTarget(); >+ } >+ >+ protected void createClient(Section section, FormToolkit toolkit) { >+ section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1)); >+ section.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING; >+ >+ Composite client = toolkit.createComposite(section); >+ client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1)); >+ client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL)); >+ >+ Composite entryContainer = toolkit.createComposite(client); >+ entryContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ entryContainer.setLayout(FormLayoutFactory.createClearGridLayout(false, 2)); >+ fNameEntry = new FormEntry(entryContainer, toolkit, PDEUIMessages.TargetDefinitionSection_name, null, false); >+ fNameEntry.setValue(getTarget().getName()); >+ fNameEntry.setFormEntryListener(new TargetFormEntryAdapter(this) { >+ public void textValueChanged(FormEntry entry) { >+ getTarget().setName(entry.getValue()); >+ } >+ }); >+ toolkit.paintBordersFor(entryContainer); >+ >+ FormText text = toolkit.createFormText(client, true); >+ text.setText(PDEUIMessages.OverviewPage_contentDescription, true, false); >+ GridData data = new GridData(GridData.FILL_HORIZONTAL); >+ data.horizontalSpan = 2; >+ text.setLayoutData(data); >+ >+// Composite tableContainer = toolkit.createComposite(client); >+// tableContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+// tableContainer.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); >+ TargetContentTable table = TargetContentTable.createTableInForm(client, toolkit); >+ table.setInput(getTarget()); >+ >+ toolkit.paintBordersFor(client); >+ GridData sectionData = new GridData(GridData.FILL_BOTH); >+ sectionData.horizontalSpan = 2; >+ section.setLayoutData(sectionData); >+// section.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING; >+ section.setText(PDEUIMessages.TargetDefinitionSection_title); >+ section.setDescription("Target definition description?"); >+ section.setClient(client); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean) >+ */ >+ public void commit(boolean onSave) { >+ fNameEntry.commit(); >+ super.commit(onSave); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.AbstractFormPart#refresh() >+ */ >+ public void refresh() { >+// ITarget target = getTarget(); >+ fNameEntry.setValue(getTarget().getName(), true); >+// ILocationInfo info = getLocationInfo(); >+// fUseDefault.setSelection(info.useDefault()); >+// fCustomPath.setSelection(!info.useDefault()); >+// String path = (info.useDefault()) ? "" : info.getPath(); //$NON-NLS-1$ >+// fPath.setValue(path, true); >+// fPath.getText().setEditable(!info.useDefault()); >+// fFileSystem.setEnabled(!info.useDefault()); >+// fVariable.setEnabled(!info.useDefault()); >+ super.refresh(); >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/target/JRESection.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/target/JRESection.java,v >retrieving revision 1.14 >diff -u -r1.14 JRESection.java >--- src/org/eclipse/pde/internal/ui/editor/target/JRESection.java 8 Jul 2008 16:53:27 -0000 1.14 >+++ src/org/eclipse/pde/internal/ui/editor/target/JRESection.java 13 Jan 2009 16:34:30 -0000 >@@ -1,246 +1,199 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import java.util.TreeSet; >-import org.eclipse.jdt.launching.JavaRuntime; >-import org.eclipse.jdt.launching.environments.IExecutionEnvironment; >-import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager; >-import org.eclipse.pde.core.IModelChangedEvent; >-import org.eclipse.pde.internal.core.itarget.*; >-import org.eclipse.pde.internal.core.util.VMUtil; >-import org.eclipse.pde.internal.ui.PDEUIMessages; >-import org.eclipse.pde.internal.ui.editor.*; >-import org.eclipse.pde.internal.ui.parts.ComboPart; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.*; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.widgets.Button; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.ui.dialogs.PreferencesUtil; >-import org.eclipse.ui.forms.widgets.FormToolkit; >-import org.eclipse.ui.forms.widgets.Section; >- >-public class JRESection extends PDESection { >- >- private Button fDefaultJREButton; >- private Button fNamedJREButton; >- private Button fExecEnvButton; >- private ComboPart fNamedJREsCombo; >- private ComboPart fExecEnvsCombo; >- private TreeSet fExecEnvChoices; >- private boolean fBlockChanges; >- private Button fConfigureJREButton; >- >- private static String JRE_PREF_PAGE_ID = "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"; //$NON-NLS-1$ >- private static String EE_PREF_PAGE_ID = "org.eclipse.jdt.debug.ui.jreProfiles"; //$NON-NLS-1$ >- >- public JRESection(PDEFormPage page, Composite parent) { >- super(page, parent, Section.DESCRIPTION); >- createClient(getSection(), page.getEditor().getToolkit()); >- } >- >- protected void createClient(Section section, FormToolkit toolkit) { >- section.setText(PDEUIMessages.JRESection_title); >- section.setDescription(PDEUIMessages.JRESection_description); >- section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); >- GridData data = new GridData(GridData.FILL_HORIZONTAL); >- data.verticalAlignment = SWT.TOP; >- data.horizontalSpan = 2; >- section.setLayoutData(data); >- >- Composite client = toolkit.createComposite(section); >- client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 3)); >- >- initializeValues(); >- >- fDefaultJREButton = toolkit.createButton(client, PDEUIMessages.JRESection_defaultJRE, SWT.RADIO); >- GridData gd = new GridData(); >- gd.horizontalSpan = 3; >- fDefaultJREButton.setLayoutData(gd); >- fDefaultJREButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- updateWidgets(); >- if (!fBlockChanges) >- getRuntimeInfo().setDefaultJRE(); >- } >- }); >- >- fNamedJREButton = toolkit.createButton(client, PDEUIMessages.JRESection_JREName, SWT.RADIO); >- fNamedJREButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- updateWidgets(); >- if (!fBlockChanges) >- getRuntimeInfo().setNamedJRE(fNamedJREsCombo.getSelection()); >- } >- }); >- >- fNamedJREsCombo = new ComboPart(); >- fNamedJREsCombo.createControl(client, toolkit, SWT.SINGLE | SWT.BORDER); >- fNamedJREsCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- String[] installs = VMUtil.getVMInstallNames(); >- fNamedJREsCombo.setItems(installs); >- fNamedJREsCombo.addModifyListener(new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- if (!fBlockChanges) >- getRuntimeInfo().setNamedJRE(fNamedJREsCombo.getSelection()); >- } >- }); >- >- fConfigureJREButton = toolkit.createButton(client, PDEUIMessages.JRESection_jrePreference, SWT.PUSH); >- fConfigureJREButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- openPreferencePage(JRE_PREF_PAGE_ID); >- } >- }); >- >- fExecEnvButton = toolkit.createButton(client, PDEUIMessages.JRESection_ExecutionEnv, SWT.RADIO); >- fExecEnvButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- updateWidgets(); >- if (!fBlockChanges) >- getRuntimeInfo().setExecutionEnvJRE(fExecEnvsCombo.getSelection()); >- } >- }); >- >- fExecEnvsCombo = new ComboPart(); >- fExecEnvsCombo.createControl(client, toolkit, SWT.SINGLE | SWT.BORDER); >- fExecEnvsCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- fExecEnvsCombo.setItems((String[]) fExecEnvChoices.toArray(new String[fExecEnvChoices.size()])); >- fExecEnvsCombo.addModifyListener(new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- if (!fBlockChanges) >- getRuntimeInfo().setExecutionEnvJRE(fExecEnvsCombo.getSelection()); >- } >- }); >- >- Button configureEEButton = toolkit.createButton(client, PDEUIMessages.JRESection_eePreference, SWT.PUSH); >- configureEEButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- openPreferencePage(EE_PREF_PAGE_ID); >- } >- }); >- configureEEButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); >- >- section.setClient(client); >- >- // Register to be notified when the model changes >- getModel().addModelChangedListener(this); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent) >- */ >- public void modelChanged(IModelChangedEvent e) { >- // No need to call super, handling world changed event here >- if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) { >- handleModelEventWorldChanged(e); >- } >- } >- >- /** >- * @param event >- */ >- private void handleModelEventWorldChanged(IModelChangedEvent event) { >- // Perform the refresh >- refresh(); >- // Note: A deferred selection event is fired from radio buttons when >- // their value is toggled, the user switches to another page, and the >- // user switches back to the same page containing the radio buttons >- // This appears to be a result of a SWT bug. >- // If the radio button is the last widget to have focus when leaving >- // the page, an event will be fired when entering the page again. >- // An event is not fired if the radio button does not have focus. >- // The solution is to redirect focus to a stable widget. >- getPage().setLastFocusControl(fConfigureJREButton); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.forms.AbstractFormPart#dispose() >- */ >- public void dispose() { >- ITargetModel model = getModel(); >- if (model != null) { >- model.removeModelChangedListener(this); >- } >- super.dispose(); >- } >- >- protected void initializeValues() { >- fExecEnvChoices = new TreeSet(); >- IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); >- IExecutionEnvironment[] envs = manager.getExecutionEnvironments(); >- for (int i = 0; i < envs.length; i++) >- fExecEnvChoices.add(envs[i].getId()); >- } >- >- protected void updateWidgets() { >- fNamedJREsCombo.setEnabled(fNamedJREButton.getSelection()); >- fExecEnvsCombo.setEnabled(fExecEnvButton.getSelection()); >- } >- >- private ITargetJRE getRuntimeInfo() { >- ITargetJRE info = getTarget().getTargetJREInfo(); >- if (info == null) { >- info = getModel().getFactory().createJREInfo(); >- getTarget().setTargetJREInfo(info); >- } >- return info; >- } >- >- private ITarget getTarget() { >- return getModel().getTarget(); >- } >- >- private ITargetModel getModel() { >- return (ITargetModel) getPage().getPDEEditor().getAggregateModel(); >- } >- >- public void refresh() { >- fBlockChanges = true; >- ITargetJRE info = getRuntimeInfo(); >- >- int jreType = info.getJREType(); >- fDefaultJREButton.setSelection(jreType == ITargetJRE.TYPE_DEFAULT); >- fNamedJREButton.setSelection(jreType == ITargetJRE.TYPE_NAMED); >- fExecEnvButton.setSelection(jreType == ITargetJRE.TYPE_EXECUTION_ENV); >- >- String jreName = info.getJREName(); >- if (jreType == ITargetJRE.TYPE_NAMED) { >- if (fNamedJREsCombo.indexOf(jreName) < 0) >- fNamedJREsCombo.add(jreName); >- fNamedJREsCombo.select(fNamedJREsCombo.indexOf(jreName)); >- } else if (jreType == ITargetJRE.TYPE_EXECUTION_ENV) { >- if (fExecEnvsCombo.indexOf(jreName) < 0) >- fExecEnvsCombo.add(jreName); >- fExecEnvsCombo.select(fExecEnvsCombo.indexOf(jreName)); >- } >- >- if (fExecEnvsCombo.getSelectionIndex() == -1) >- fExecEnvsCombo.setText(fExecEnvChoices.first().toString()); >- >- if (fNamedJREsCombo.getSelectionIndex() == -1) >- fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName()); >- >- updateWidgets(); >- super.refresh(); >- fBlockChanges = false; >- } >- >- private void openPreferencePage(String pageID) { >- fBlockChanges = true; >- PreferencesUtil.createPreferenceDialogOn(getPage().getEditor().getEditorSite().getShell(), pageID, new String[] {pageID}, null).open(); >- // reset JRE select because either JDT preference page allows user to add/remove JREs >- fNamedJREsCombo.setItems(VMUtil.getVMInstallNames()); >- fBlockChanges = false; >- } >- >-} >+/******************************************************************************* >+ * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.target; >+ >+import org.eclipse.pde.internal.ui.editor.target.TargetEditor; >+ >+import java.util.TreeSet; >+import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jdt.launching.environments.IExecutionEnvironment; >+import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager; >+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+import org.eclipse.pde.internal.core.util.VMUtil; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+import org.eclipse.pde.internal.ui.parts.ComboPart; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.dialogs.PreferencesUtil; >+import org.eclipse.ui.forms.SectionPart; >+import org.eclipse.ui.forms.editor.FormPage; >+import org.eclipse.ui.forms.widgets.*; >+ >+public class JRESection extends SectionPart { >+ >+ private Button fDefaultJREButton; >+ private Button fNamedJREButton; >+ private Button fExecEnvButton; >+ private ComboPart fNamedJREsCombo; >+ private ComboPart fExecEnvsCombo; >+ private TreeSet fExecEnvChoices; >+ private boolean fBlockChanges; >+ private Button fConfigureJREButton; >+ private TargetEditor fEditor; >+ >+ private static String JRE_PREF_PAGE_ID = "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"; //$NON-NLS-1$ >+ private static String EE_PREF_PAGE_ID = "org.eclipse.jdt.debug.ui.jreProfiles"; //$NON-NLS-1$ >+ >+ public JRESection(FormPage page, Composite parent) { >+ super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR); >+ fEditor = (TargetEditor) page.getEditor(); >+ createClient(getSection(), page.getEditor().getToolkit()); >+ } >+ >+ private ITargetDefinition getTarget() { >+ return fEditor.getTarget(); >+ } >+ >+ protected void createClient(Section section, FormToolkit toolkit) { >+ section.setText(PDEUIMessages.JRESection_title); >+ section.setDescription(PDEUIMessages.JRESection_description); >+ section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); >+ GridData data = new GridData(GridData.FILL_HORIZONTAL); >+ data.verticalAlignment = SWT.TOP; >+ data.horizontalSpan = 2; >+ section.setLayoutData(data); >+ >+ Composite client = toolkit.createComposite(section); >+ client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 3)); >+ >+ initializeValues(); >+ >+ fDefaultJREButton = toolkit.createButton(client, PDEUIMessages.JRESection_defaultJRE, SWT.RADIO); >+ GridData gd = new GridData(); >+ gd.horizontalSpan = 3; >+ fDefaultJREButton.setLayoutData(gd); >+ fDefaultJREButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ updateWidgets(); >+ if (!fBlockChanges) { >+// TODO getRuntimeInfo().setDefaultJRE(); >+ } >+ } >+ }); >+ >+ fNamedJREButton = toolkit.createButton(client, PDEUIMessages.JRESection_JREName, SWT.RADIO); >+ fNamedJREButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ updateWidgets(); >+ if (!fBlockChanges) { >+// TODO getRuntimeInfo().setNamedJRE(fNamedJREsCombo.getSelection()); >+ } >+ } >+ }); >+ >+ fNamedJREsCombo = new ComboPart(); >+ fNamedJREsCombo.createControl(client, toolkit, SWT.SINGLE | SWT.BORDER); >+ fNamedJREsCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ String[] installs = VMUtil.getVMInstallNames(); >+ fNamedJREsCombo.setItems(installs); >+ fNamedJREsCombo.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+// if (!fBlockChanges) >+// TODO getRuntimeInfo().setNamedJRE(fNamedJREsCombo.getSelection()); >+ } >+ }); >+ >+ fConfigureJREButton = toolkit.createButton(client, PDEUIMessages.JRESection_jrePreference, SWT.PUSH); >+ fConfigureJREButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ openPreferencePage(JRE_PREF_PAGE_ID); >+ } >+ }); >+ >+ fExecEnvButton = toolkit.createButton(client, PDEUIMessages.JRESection_ExecutionEnv, SWT.RADIO); >+ fExecEnvButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ updateWidgets(); >+// if (!fBlockChanges) >+// TODO getRuntimeInfo().setExecutionEnvJRE(fExecEnvsCombo.getSelection()); >+ } >+ }); >+ >+ fExecEnvsCombo = new ComboPart(); >+ fExecEnvsCombo.createControl(client, toolkit, SWT.SINGLE | SWT.BORDER); >+ fExecEnvsCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ fExecEnvsCombo.setItems((String[]) fExecEnvChoices.toArray(new String[fExecEnvChoices.size()])); >+ fExecEnvsCombo.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+// if (!fBlockChanges) >+// TODO getRuntimeInfo().setExecutionEnvJRE(fExecEnvsCombo.getSelection()); >+ } >+ }); >+ >+ Button configureEEButton = toolkit.createButton(client, PDEUIMessages.JRESection_eePreference, SWT.PUSH); >+ configureEEButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ openPreferencePage(EE_PREF_PAGE_ID); >+ } >+ }); >+ configureEEButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); >+ >+ section.setClient(client); >+ >+ } >+ >+ protected void initializeValues() { >+ fExecEnvChoices = new TreeSet(); >+ IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); >+ IExecutionEnvironment[] envs = manager.getExecutionEnvironments(); >+ for (int i = 0; i < envs.length; i++) >+ fExecEnvChoices.add(envs[i].getId()); >+ } >+ >+ protected void updateWidgets() { >+ fNamedJREsCombo.setEnabled(fNamedJREButton.getSelection()); >+ fExecEnvsCombo.setEnabled(fExecEnvButton.getSelection()); >+ } >+ >+ public void refresh() { >+// fBlockChanges = true; >+// ITargetJRE info = getRuntimeInfo(); >+// >+// int jreType = info.getJREType(); >+// fDefaultJREButton.setSelection(jreType == ITargetJRE.TYPE_DEFAULT); >+// fNamedJREButton.setSelection(jreType == ITargetJRE.TYPE_NAMED); >+// fExecEnvButton.setSelection(jreType == ITargetJRE.TYPE_EXECUTION_ENV); >+// >+// String jreName = info.getJREName(); >+// if (jreType == ITargetJRE.TYPE_NAMED) { >+// if (fNamedJREsCombo.indexOf(jreName) < 0) >+// fNamedJREsCombo.add(jreName); >+// fNamedJREsCombo.select(fNamedJREsCombo.indexOf(jreName)); >+// } else if (jreType == ITargetJRE.TYPE_EXECUTION_ENV) { >+// if (fExecEnvsCombo.indexOf(jreName) < 0) >+// fExecEnvsCombo.add(jreName); >+// fExecEnvsCombo.select(fExecEnvsCombo.indexOf(jreName)); >+// } >+// >+// if (fExecEnvsCombo.getSelectionIndex() == -1) >+// fExecEnvsCombo.setText(fExecEnvChoices.first().toString()); >+// >+// if (fNamedJREsCombo.getSelectionIndex() == -1) >+// fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName()); >+// >+// updateWidgets(); >+// super.refresh(); >+// fBlockChanges = false; >+ } >+ >+ private void openPreferencePage(String pageID) { >+ fBlockChanges = true; >+ PreferencesUtil.createPreferenceDialogOn(fEditor.getEditorSite().getShell(), pageID, new String[] {pageID}, null).open(); >+ // reset JRE select because either JDT preference page allows user to add/remove JREs >+ fNamedJREsCombo.setItems(VMUtil.getVMInstallNames()); >+ fBlockChanges = false; >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/target/LocationDialog.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/target/LocationDialog.java >diff -N src/org/eclipse/pde/internal/ui/editor/target/LocationDialog.java >--- src/org/eclipse/pde/internal/ui/editor/target/LocationDialog.java 26 May 2008 19:19:55 -0000 1.13 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,200 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import org.eclipse.core.runtime.*; >-import org.eclipse.debug.ui.StringVariableSelectionDialog; >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.jface.dialogs.StatusDialog; >-import org.eclipse.jface.window.Window; >-import org.eclipse.pde.core.plugin.TargetPlatform; >-import org.eclipse.pde.internal.core.itarget.*; >-import org.eclipse.pde.internal.ui.*; >-import org.eclipse.pde.internal.ui.util.SWTUtil; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.*; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.*; >-import org.eclipse.ui.PlatformUI; >- >-public class LocationDialog extends StatusDialog { >- >- private Text fPath; >- private ITarget fTarget; >- private IAdditionalLocation fLocation; >- private IStatus fOkStatus; >- private IStatus fErrorStatus; >- >- public LocationDialog(Shell parent, ITarget target, IAdditionalLocation location) { >- super(parent); >- fTarget = target; >- fLocation = location; >- } >- >- /* >- * @see org.eclipse.jface.window.Window#configureShell(Shell) >- */ >- protected void configureShell(Shell shell) { >- super.configureShell(shell); >- PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IHelpContextIds.TARGET_LOCATION_DIALOG); >- } >- >- protected Control createDialogArea(Composite parent) { >- Composite container = new Composite(parent, SWT.NULL); >- GridLayout layout = new GridLayout(); >- layout.numColumns = 4; >- layout.marginHeight = layout.marginWidth = 10; >- container.setLayout(layout); >- GridData gd = new GridData(GridData.FILL_BOTH); >- container.setLayoutData(gd); >- >- createEntry(container); >- >- ModifyListener listener = new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- dialogChanged(); >- } >- }; >- fPath.addModifyListener(listener); >- setTitle(PDEUIMessages.LocationDialog_title); >- Dialog.applyDialogFont(container); >- >- dialogChanged(); >- >- return container; >- } >- >- protected void createEntry(Composite container) { >- Label label = new Label(container, SWT.NULL); >- label.setText(PDEUIMessages.LocationDialog_path); >- label.setLayoutData(new GridData()); >- >- fPath = new Text(container, SWT.SINGLE | SWT.BORDER); >- GridData gd = new GridData(GridData.FILL_HORIZONTAL); >- gd.horizontalSpan = 3; >- fPath.setLayoutData(gd); >- >- if (fLocation != null) { >- fPath.setText(fLocation.getPath()); >- } >- >- label = new Label(container, SWT.NONE); >- gd = new GridData(GridData.FILL_HORIZONTAL); >- gd.horizontalSpan = 2; >- label.setLayoutData(gd); >- >- Button fs = new Button(container, SWT.PUSH); >- fs.setText(PDEUIMessages.LocationDialog_fileSystem); >- fs.setLayoutData(new GridData()); >- fs.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- handleBrowseFileSystem(); >- } >- }); >- SWTUtil.setButtonDimensionHint(fs); >- >- Button var = new Button(container, SWT.PUSH); >- var.setText(PDEUIMessages.LocationDialog_variables); >- var.setLayoutData(new GridData()); >- var.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- handleInsertVariable(); >- } >- }); >- SWTUtil.setButtonDimensionHint(var); >- } >- >- private IStatus createErrorStatus(String message) { >- return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), IStatus.OK, message, null); >- } >- >- private void dialogChanged() { >- IStatus status = null; >- if (fPath.getText().length() == 0) >- status = getEmptyErrorStatus(); >- else { >- if (hasPath(fPath.getText())) >- status = createErrorStatus(PDEUIMessages.LocationDialog_locationExists); >- } >- if (status == null) >- status = getOKStatus(); >- updateStatus(status); >- } >- >- private IStatus getOKStatus() { >- if (fOkStatus == null) >- fOkStatus = new Status(IStatus.OK, PDEPlugin.getPluginId(), IStatus.OK, "", //$NON-NLS-1$ >- null); >- return fOkStatus; >- } >- >- private IStatus getEmptyErrorStatus() { >- if (fErrorStatus == null) >- fErrorStatus = createErrorStatus(PDEUIMessages.LocationDialog_emptyPath); >- return fErrorStatus; >- } >- >- protected boolean hasPath(String path) { >- Path checkPath = new Path(path); >- Path currentPath = (fLocation != null) ? new Path(fLocation.getPath()) : null; >- if (checkPath.equals(currentPath)) >- return false; >- IAdditionalLocation[] locs = fTarget.getAdditionalDirectories(); >- for (int i = 0; i < locs.length; i++) { >- if (new Path(locs[i].getPath()).equals(checkPath)) >- return true; >- } >- return isTargetLocation(checkPath); >- } >- >- private boolean isTargetLocation(Path path) { >- ILocationInfo info = fTarget.getLocationInfo(); >- if (info.useDefault()) { >- Path home = new Path(TargetPlatform.getDefaultLocation()); >- return home.equals(path); >- } >- return new Path(info.getPath()).equals(path); >- } >- >- protected void handleBrowseFileSystem() { >- DirectoryDialog dialog = new DirectoryDialog(getShell()); >- String text = fPath.getText(); >- if (text.length() == 0) >- text = TargetEditor.LAST_PATH; >- dialog.setFilterPath(text); >- dialog.setText(PDEUIMessages.BaseBlock_dirSelection); >- dialog.setMessage(PDEUIMessages.BaseBlock_dirChoose); >- String result = dialog.open(); >- if (result != null) { >- fPath.setText(result); >- TargetEditor.LAST_PATH = result; >- } >- } >- >- private void handleInsertVariable() { >- StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); >- if (dialog.open() == Window.OK) { >- fPath.insert(dialog.getVariableExpression()); >- } >- } >- >- protected void okPressed() { >- boolean add = fLocation == null; >- if (add) { >- fLocation = fTarget.getModel().getFactory().createAdditionalLocation(); >- } >- fLocation.setPath(fPath.getText()); >- if (add) >- fTarget.addAdditionalDirectories(new IAdditionalLocation[] {fLocation}); >- super.okPressed(); >- } >-} >Index: src/org/eclipse/pde/internal/ui/editor/target/ContentSection.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/target/ContentSection.java >diff -N src/org/eclipse/pde/internal/ui/editor/target/ContentSection.java >--- src/org/eclipse/pde/internal/ui/editor/target/ContentSection.java 19 Oct 2008 19:43:04 -0000 1.26 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,668 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- * Bartosz Michalik <bartosz.michalik@gmail.com> - bug 187646 >- * Les Jones <lesojones@gmail.com> - bug 190717 >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import org.eclipse.pde.internal.ui.dialogs.FeatureSelectionDialog; >- >-import java.util.*; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.runtime.*; >-import org.eclipse.jdt.core.IJavaProject; >-import org.eclipse.jface.action.*; >-import org.eclipse.jface.viewers.*; >-import org.eclipse.jface.window.Window; >-import org.eclipse.osgi.service.resolver.BundleDescription; >-import org.eclipse.pde.core.IModelChangedEvent; >-import org.eclipse.pde.core.plugin.IPluginModelBase; >-import org.eclipse.pde.core.plugin.PluginRegistry; >-import org.eclipse.pde.internal.core.PDECore; >-import org.eclipse.pde.internal.core.TargetPlatformHelper; >-import org.eclipse.pde.internal.core.ifeature.IFeature; >-import org.eclipse.pde.internal.core.ifeature.IFeatureModel; >-import org.eclipse.pde.internal.core.itarget.*; >-import org.eclipse.pde.internal.core.plugin.ExternalPluginModelBase; >-import org.eclipse.pde.internal.ui.*; >-import org.eclipse.pde.internal.ui.editor.*; >-import org.eclipse.pde.internal.ui.editor.feature.FeatureEditor; >-import org.eclipse.pde.internal.ui.editor.plugin.ManifestEditor; >-import org.eclipse.pde.internal.ui.elements.DefaultTableProvider; >-import org.eclipse.pde.internal.ui.parts.ConditionalListSelectionDialog; >-import org.eclipse.pde.internal.ui.parts.TablePart; >-import org.eclipse.pde.internal.ui.search.dependencies.DependencyCalculator; >-import org.eclipse.pde.internal.ui.util.PersistablePluginObject; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.CTabFolder; >-import org.eclipse.swt.custom.CTabItem; >-import org.eclipse.swt.events.SelectionAdapter; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.widgets.*; >-import org.eclipse.ui.*; >-import org.eclipse.ui.actions.ActionFactory; >-import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; >-import org.eclipse.ui.forms.IFormColors; >-import org.eclipse.ui.forms.widgets.FormToolkit; >-import org.eclipse.ui.forms.widgets.Section; >- >-public class ContentSection extends TableSection { >- >- class ContentProvider extends DefaultTableProvider { >- public Object[] getElements(Object parent) { >- ITarget target = getTarget(); >- if (fLastTab == 0) >- return target.getPlugins(); >- return target.getFeatures(); >- } >- } >- >- private static final String[] TAB_LABELS = new String[2]; >- static { >- TAB_LABELS[0] = PDEUIMessages.ContentSection_plugins; >- TAB_LABELS[1] = PDEUIMessages.ContentSection_features; >- } >- >- private static final String[] BUTTONS = new String[5]; >- static { >- BUTTONS[0] = PDEUIMessages.ContentSection_add; >- BUTTONS[1] = PDEUIMessages.ContentSection_remove; >- BUTTONS[2] = PDEUIMessages.ContentSection_removeAll; >- BUTTONS[3] = PDEUIMessages.ContentSection_workingSet; >- BUTTONS[4] = PDEUIMessages.ContentSection_required; >- } >- >- private TableViewer fContentViewer; >- private CTabFolder fTabFolder; >- private int fLastTab; >- private Button fUseAllPlugins; >- private Button fUseSelectedPlugins; >- private Image[] fTabImages; >- private Button fIncludeOptionalButton; >- public static final QualifiedName OPTIONAL_PROPERTY = new QualifiedName(IPDEUIConstants.PLUGIN_ID, "target.includeOptional"); //$NON-NLS-1$ >- >- public ContentSection(PDEFormPage page, Composite parent) { >- super(page, parent, Section.DESCRIPTION, BUTTONS); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDESection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit) >- */ >- protected void createClient(Section section, FormToolkit toolkit) { >- section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); >- Composite client = toolkit.createComposite(section); >- client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2)); >- client.setLayoutData(new GridData(GridData.FILL_BOTH)); >- >- // create radio buttons >- SelectionAdapter radioListener = new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- getTarget().setUseAllPlugins(fUseAllPlugins.getSelection()); >- } >- }; >- >- fUseAllPlugins = toolkit.createButton(client, PDEUIMessages.ContentSection_allTarget, SWT.RADIO); >- fUseAllPlugins.addSelectionListener(radioListener); >- GridData gd = new GridData(); >- gd.horizontalSpan = 2; >- fUseAllPlugins.setLayoutData(gd); >- >- fUseSelectedPlugins = toolkit.createButton(client, PDEUIMessages.ContentSection_selectedOnly, SWT.RADIO); >- gd = new GridData(); >- gd.horizontalSpan = 2; >- gd.verticalIndent = 5; >- fUseSelectedPlugins.setLayoutData(gd); >- >- // create tab folder widget >- fTabFolder = new CTabFolder(client, SWT.FLAT | SWT.TOP); >- gd = new GridData(GridData.FILL_HORIZONTAL); >- gd.heightHint = 2; >- gd.horizontalSpan = 2; >- gd.horizontalIndent = 15; >- fTabFolder.setLayoutData(gd); >- toolkit.adapt(fTabFolder, true, true); >- toolkit.getColors().initializeSectionToolBarColors(); >- Color selectedColor = toolkit.getColors().getColor(IFormColors.TB_BG); >- fTabFolder.setSelectionBackground(new Color[] {selectedColor, toolkit.getColors().getBackground()}, new int[] {100}, true); >- fTabFolder.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- refresh(); >- } >- }); >- >- createTabs(); >- >- // create table widget >- createViewerPartControl(client, SWT.MULTI, 2, toolkit); >- >- TablePart tablePart = getTablePart(); >- GridData data = (GridData) tablePart.getControl().getLayoutData(); >- data.grabExcessVerticalSpace = true; >- data.grabExcessHorizontalSpace = true; >- data.horizontalIndent = 15; >- fContentViewer = tablePart.getTableViewer(); >- fContentViewer.setContentProvider(new ContentProvider()); >- fContentViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); >- fContentViewer.setComparator(new ViewerComparator() { >- public int compare(Viewer viewer, Object e1, Object e2) { >- if (e1 instanceof ITargetPlugin) { >- ITargetPlugin p1 = (ITargetPlugin) e1; >- ITargetPlugin p2 = (ITargetPlugin) e2; >- return super.compare(viewer, p1.getId(), p2.getId()); >- } // else >- ITargetFeature f1 = (ITargetFeature) e1; >- ITargetFeature f2 = (ITargetFeature) e2; >- return super.compare(viewer, f1.getId(), f2.getId()); >- } >- }); >- fContentViewer.setInput(PDECore.getDefault().getModelManager()); >- fContentViewer.addSelectionChangedListener(new ISelectionChangedListener() { >- public void selectionChanged(SelectionChangedEvent event) { >- updateEnablement(); >- } >- }); >- >- createOptionalDependenciesButton(client); >- >- toolkit.paintBordersFor(client); >- section.setClient(client); >- section.setText(PDEUIMessages.ContentSection_targetContent); >- section.setDescription(PDEUIMessages.ContentSection_targetContentDesc); >- section.setLayoutData(new GridData(GridData.FILL_BOTH)); >- updateEnablement(); >- getModel().addModelChangedListener(this); >- } >- >- private void createOptionalDependenciesButton(Composite client) { >- if (isEditable()) { >- fIncludeOptionalButton = new Button(client, SWT.CHECK); >- fIncludeOptionalButton.setText(PDEUIMessages.ContentSection_includeOptional); >- // initialize value >- IEditorInput input = getPage().getEditorInput(); >- if (input instanceof IFileEditorInput) { >- IFile file = ((IFileEditorInput) input).getFile(); >- try { >- fIncludeOptionalButton.setSelection("true".equals(file.getPersistentProperty(OPTIONAL_PROPERTY))); //$NON-NLS-1$ >- } catch (CoreException e) { >- } >- } >- fIncludeOptionalButton.setEnabled(!getTarget().useAllPlugins()); >- // create listener to save value when the checkbox is changed >- fIncludeOptionalButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- IEditorInput input = getPage().getEditorInput(); >- if (input instanceof IFileEditorInput) { >- IFile file = ((IFileEditorInput) input).getFile(); >- try { >- file.setPersistentProperty(OPTIONAL_PROPERTY, fIncludeOptionalButton.getSelection() ? "true" : null); //$NON-NLS-1$ >- } catch (CoreException e1) { >- } >- } >- } >- }); >- } >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#buttonSelected(int) >- */ >- protected void buttonSelected(int index) { >- switch (index) { >- case 0 : >- handleAdd(); >- break; >- case 1 : >- handleDelete(); >- break; >- case 2 : >- handleRemoveAll(); >- break; >- case 3 : >- handleAddWorkingSet(); >- break; >- case 4 : >- handleAddRequired(getTarget().getPlugins(), fIncludeOptionalButton.getSelection()); >- } >- } >- >- private void createTabs() { >- fTabImages = new Image[] {PDEPluginImages.DESC_PLUGIN_OBJ.createImage(), PDEPluginImages.DESC_FEATURE_OBJ.createImage()}; >- for (int i = 0; i < TAB_LABELS.length; i++) { >- CTabItem item = new CTabItem(fTabFolder, SWT.NULL); >- item.setText(TAB_LABELS[i]); >- item.setImage(fTabImages[i]); >- } >- fLastTab = 0; >- fTabFolder.setSelection(fLastTab); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.forms.AbstractFormPart#refresh() >- */ >- public void refresh() { >- fLastTab = fTabFolder.getSelectionIndex(); >- fContentViewer.refresh(); >- updateEnablement(); >- super.refresh(); >- } >- >- protected void updateEnablement() { >- boolean useAllPlugins = getTarget().useAllPlugins(); >- fUseAllPlugins.setSelection(useAllPlugins); >- fUseSelectedPlugins.setSelection(!useAllPlugins); >- TablePart table = getTablePart(); >- boolean itemsSelected = !fContentViewer.getSelection().isEmpty(); >- boolean hasItems = fContentViewer.getTable().getItemCount() > 0; >- table.setEnabled(!useAllPlugins); >- table.setButtonEnabled(0, isEditable() && !useAllPlugins); >- table.setButtonEnabled(1, isEditable() && !useAllPlugins && itemsSelected); >- table.setButtonEnabled(2, isEditable() && !useAllPlugins && hasItems); >- boolean pluginTab = (fLastTab == 0); >- table.setButtonEnabled(3, isEditable() && pluginTab && !useAllPlugins); >- table.setButtonEnabled(4, isEditable() && pluginTab && !useAllPlugins && hasItems); >- >- // Fix for defect 190717 >- // Only show the working set and required buttons on the plugin tab >- // (retaining the existing enablement logic in the rare case the >- // platform doesn't support control.visible=false; I can't imagine >- // how this would happen, but better to be safe?) >- table.setButtonVisible(3, pluginTab); >- table.setButtonVisible(4, pluginTab); >- >- } >- >- protected boolean canPaste(Object target, Object[] objects) { >- for (int i = 0; i < objects.length; i++) { >- if (objects[i] instanceof ITargetPlugin && fLastTab == 0 || objects[i] instanceof ITargetFeature && fLastTab == 1) >- return true; >- } >- return false; >- } >- >- private ITarget getTarget() { >- return getModel().getTarget(); >- } >- >- private ITargetModel getModel() { >- return (ITargetModel) getPage().getPDEEditor().getAggregateModel(); >- } >- >- private void handleAdd() { >- if (fLastTab == 0) >- handleAddPlugin(); >- else >- handleAddFeature(); >- updateEnablement(); >- } >- >- private void handleAddPlugin() { >- ConditionalListSelectionDialog dialog = new ConditionalListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), PDEPlugin.getDefault().getLabelProvider(), PDEUIMessages.ContentSection_addDialogButtonLabel); >- >- TreeMap map = getBundles(); >- dialog.setElements(map.values().toArray()); >- dialog.setConditionalElements(getWorkspaceBundles(map).values().toArray()); >- dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title); >- dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message); >- dialog.setMultipleSelection(true); >- dialog.create(); >- PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IHelpContextIds.PLUGIN_SELECTION); >- if (dialog.open() == Window.OK) { >- Object[] bundles = dialog.getResult(); >- ITarget target = getTarget(); >- ITargetModelFactory factory = getModel().getFactory(); >- ITargetPlugin[] plugins = new ITargetPlugin[bundles.length]; >- for (int i = 0; i < bundles.length; i++) { >- String id = ((BundleDescription) bundles[i]).getSymbolicName(); >- ITargetPlugin plugin = factory.createPlugin(); >- plugin.setId(id); >- plugins[i] = plugin; >- } >- target.addPlugins(plugins); >- fContentViewer.setSelection(new StructuredSelection(plugins[plugins.length - 1])); >- } >- } >- >- private TreeMap getBundles() { >- TreeMap map = new TreeMap(); >- ITarget target = getTarget(); >- IPluginModelBase[] models = PluginRegistry.getExternalModels(); >- for (int i = 0; i < models.length; i++) { >- BundleDescription desc = ((ExternalPluginModelBase) models[i]).getBundleDescription(); >- String id = desc.getSymbolicName(); >- if (!target.containsPlugin(id)) >- map.put(id, desc); >- } >- return map; >- } >- >- protected TreeMap getWorkspaceBundles(TreeMap used) { >- TreeMap map = new TreeMap(); >- ITarget target = getTarget(); >- IPluginModelBase[] models = PluginRegistry.getWorkspaceModels(); >- for (int i = 0; i < models.length; i++) { >- BundleDescription desc = models[i].getBundleDescription(); >- String id = desc.getSymbolicName(); >- if (id != null && !target.containsPlugin(id) && !used.containsKey(id)) >- map.put(id, desc); >- } >- return map; >- } >- >- private void handleAddFeature() { >- IFeatureModel[] allModels = PDECore.getDefault().getFeatureModelManager().getModels(); >- ArrayList newModels = new ArrayList(); >- ITarget target = getTarget(); >- for (int i = 0; i < allModels.length; i++) { >- if (!target.containsFeature(allModels[i].getFeature().getId())) >- newModels.add(allModels[i]); >- } >- IFeatureModel[] candidateModels = (IFeatureModel[]) newModels.toArray(new IFeatureModel[newModels.size()]); >- FeatureSelectionDialog dialog = new FeatureSelectionDialog(getSection().getShell(), candidateModels, true); >- if (dialog.open() == Window.OK) { >- Object[] models = dialog.getResult(); >- ITargetModelFactory factory = getModel().getFactory(); >- ITargetFeature[] features = new ITargetFeature[models.length]; >- for (int i = 0; i < models.length; ++i) { >- IFeature feature = ((IFeatureModel) models[i]).getFeature(); >- String id = feature.getId(); >- ITargetFeature tfeature = factory.createFeature(); >- tfeature.setId(id); >- features[i] = tfeature; >- } >- target.addFeatures(features); >- fContentViewer.setSelection(new StructuredSelection(features[features.length - 1])); >- } >- } >- >- private void handleDelete() { >- IStructuredSelection ssel = (IStructuredSelection) fContentViewer.getSelection(); >- if (ssel.size() > 0) { >- Object[] objects = ssel.toArray(); >- ITarget target = getTarget(); >- if (fLastTab == 0) { >- ITargetPlugin[] plugins = new ITargetPlugin[objects.length]; >- System.arraycopy(objects, 0, plugins, 0, objects.length); >- target.removePlugins(plugins); >- } else { >- ITargetFeature[] features = new ITargetFeature[objects.length]; >- System.arraycopy(objects, 0, features, 0, objects.length); >- target.removeFeatures(features); >- } >- } >- updateEnablement(); >- } >- >- private void handleRemoveAll() { >- TableItem[] items = fContentViewer.getTable().getItems(); >- ITarget target = getTarget(); >- if (fLastTab == 0) { >- ITargetPlugin[] plugins = new ITargetPlugin[items.length]; >- for (int i = 0; i < plugins.length; i++) >- plugins[i] = (ITargetPlugin) items[i].getData(); >- target.removePlugins(plugins); >- } else { >- ITargetFeature[] features = new ITargetFeature[items.length]; >- for (int i = 0; i < features.length; i++) >- features[i] = (ITargetFeature) items[i].getData(); >- target.removeFeatures(features); >- } >- updateEnablement(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.TableSection#handleDoubleClick(org.eclipse.jface.viewers.IStructuredSelection) >- */ >- protected void handleDoubleClick(IStructuredSelection selection) { >- handleOpen(selection); >- } >- >- private void handleOpen(IStructuredSelection selection) { >- Object object = selection.getFirstElement(); >- if (object instanceof ITargetPlugin) { >- ManifestEditor.openPluginEditor(((ITargetPlugin) object).getId()); >- } else if (object instanceof ITargetFeature) { >- handleOpenFeature((ITargetFeature) object); >- } >- } >- >- private void handleOpenFeature(ITargetFeature feature) { >- IFeatureModel model = PDECore.getDefault().getFeatureModelManager().findFeatureModel(feature.getId()); >- FeatureEditor.openFeatureEditor(model); >- } >- >- private void handleAddWorkingSet() { >- IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); >- IWorkingSetSelectionDialog dialog = manager.createWorkingSetSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), true); >- if (dialog.open() == Window.OK) { >- IWorkingSet[] workingSets = dialog.getSelection(); >- ITarget target = getTarget(); >- ITargetModelFactory factory = target.getModel().getFactory(); >- HashSet plugins = new HashSet(); >- for (int i = 0; i < workingSets.length; i++) { >- IAdaptable[] elements = workingSets[i].getElements(); >- for (int j = 0; j < elements.length; j++) { >- IPluginModelBase model = findModel(elements[j]); >- if (model != null) { >- ITargetPlugin plugin = factory.createPlugin(); >- plugin.setId(model.getPluginBase().getId()); >- plugins.add(plugin); >- } >- } >- } >- target.addPlugins((ITargetPlugin[]) plugins.toArray(new ITargetPlugin[plugins.size()])); >- } >- updateEnablement(); >- } >- >- private IPluginModelBase findModel(IAdaptable object) { >- if (object instanceof IJavaProject) >- object = ((IJavaProject) object).getProject(); >- if (object instanceof IProject) >- return PluginRegistry.findModel((IProject) object); >- if (object instanceof PersistablePluginObject) { >- return PluginRegistry.findModel(((PersistablePluginObject) object).getPluginID()); >- } >- return null; >- } >- >- public static void handleAddRequired(ITargetPlugin[] plugins, boolean includeOptional) { >- if (plugins.length == 0) >- return; >- >- ArrayList list = new ArrayList(plugins.length); >- for (int i = 0; i < plugins.length; i++) { >- list.add(TargetPlatformHelper.getState().getBundle(plugins[i].getId(), null)); >- } >- DependencyCalculator calculator = new DependencyCalculator(includeOptional); >- calculator.findDependencies(list.toArray()); >- Collection dependencies = calculator.getBundleIDs(); >- >- ITarget target = plugins[0].getTarget(); >- ITargetModelFactory factory = target.getModel().getFactory(); >- ITargetPlugin[] pluginsToAdd = new ITargetPlugin[dependencies.size()]; >- int i = 0; >- Iterator iter = dependencies.iterator(); >- while (iter.hasNext()) { >- String id = iter.next().toString(); >- ITargetPlugin plugin = factory.createPlugin(); >- plugin.setId(id); >- pluginsToAdd[i++] = plugin; >- } >- target.addPlugins(pluginsToAdd); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent) >- */ >- public void modelChanged(IModelChangedEvent e) { >- if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) { >- handleModelEventWorldChanged(e); >- return; >- } >- Object[] objects = e.getChangedObjects(); >- if (e.getChangeType() == IModelChangedEvent.INSERT) { >- for (int i = 0; i < objects.length; i++) { >- if ((objects[i] instanceof ITargetPlugin && fLastTab == 0) || (objects[i] instanceof ITargetFeature && fLastTab == 1)) { >- fContentViewer.add(objects[i]); >- } >- } >- } else if (e.getChangeType() == IModelChangedEvent.REMOVE) { >- >- Table table = fContentViewer.getTable(); >- int index = table.getSelectionIndex(); >- >- for (int i = 0; i < objects.length; i++) { >- if ((objects[i] instanceof ITargetPlugin && fLastTab == 0) || (objects[i] instanceof ITargetFeature && fLastTab == 1)) { >- fContentViewer.remove(objects[i]); >- } >- } >- >- // Update Selection >- >- int count = table.getItemCount(); >- >- if (count == 0) { >- // Nothing to select >- } else if (index < count) { >- table.setSelection(index); >- } else { >- table.setSelection(count - 1); >- } >- >- } >- if (e.getChangedProperty() == ITarget.P_ALL_PLUGINS) { >- refresh(); >- fIncludeOptionalButton.setEnabled(!((Boolean) e.getNewValue()).booleanValue()); >- } >- } >- >- /** >- * @param event >- */ >- private void handleModelEventWorldChanged(IModelChangedEvent event) { >- // Reload input >- fContentViewer.setInput(PDECore.getDefault().getModelManager()); >- // Perform the refresh >- refresh(); >- } >- >- public boolean doGlobalAction(String actionId) { >- if (actionId.equals(ActionFactory.DELETE.getId())) { >- handleDelete(); >- return true; >- } >- if (actionId.equals(ActionFactory.CUT.getId())) { >- handleDelete(); >- return false; >- } >- if (actionId.equals(ActionFactory.PASTE.getId())) { >- doPaste(); >- return true; >- } >- if (actionId.equals(ActionFactory.SELECT_ALL.getId())) { >- handleSelectAll(); >- return true; >- } >- return false; >- } >- >- private void handleSelectAll() { >- fContentViewer.getTable().selectAll(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#fillContextMenu(org.eclipse.jface.action.IMenuManager) >- */ >- protected void fillContextMenu(IMenuManager manager) { >- IStructuredSelection ssel = (IStructuredSelection) fContentViewer.getSelection(); >- if (ssel == null) >- return; >- >- Action openAction = new Action(PDEUIMessages.ContentSection_open) { >- public void run() { >- handleDoubleClick((IStructuredSelection) fContentViewer.getSelection()); >- } >- }; >- openAction.setEnabled(isEditable() && ssel.size() == 1); >- manager.add(openAction); >- >- manager.add(new Separator()); >- >- Action removeAction = new Action(PDEUIMessages.ContentSection_remove) { >- public void run() { >- handleDelete(); >- } >- }; >- removeAction.setEnabled(isEditable() && ssel.size() > 0); >- manager.add(removeAction); >- >- Action removeAll = new Action(PDEUIMessages.ContentSection_removeAll) { >- public void run() { >- handleRemoveAll(); >- } >- }; >- removeAll.setEnabled(isEditable()); >- manager.add(removeAll); >- >- manager.add(new Separator()); >- >- getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager); >- } >- >- protected void doPaste(Object target, Object[] objects) { >- for (int i = 0; i < objects.length; i++) { >- if (objects[i] instanceof ITargetPlugin && fLastTab == 0) >- getTarget().addPlugin((ITargetPlugin) objects[i]); >- else if (objects[i] instanceof ITargetFeature && fLastTab == 1) >- getTarget().addFeature((ITargetFeature) objects[i]); >- } >- } >- >- protected void selectionChanged(IStructuredSelection selection) { >- getPage().getPDEEditor().setSelection(selection); >- } >- >- public boolean setFormInput(Object input) { >- if (input instanceof ITargetPlugin) { >- if (fTabFolder.getSelectionIndex() != 0) { >- fTabFolder.setSelection(0); >- refresh(); >- } >- fContentViewer.setSelection(new StructuredSelection(input), true); >- return true; >- } else if (input instanceof ITargetFeature) { >- if (fTabFolder.getSelectionIndex() != 1) { >- fTabFolder.setSelection(1); >- refresh(); >- } >- fContentViewer.setSelection(new StructuredSelection(input), true); >- return true; >- } >- return super.setFormInput(input); >- } >- >- public void dispose() { >- ITargetModel model = getModel(); >- if (model != null) >- model.removeModelChangedListener(this); >- if (fTabImages != null) >- for (int i = 0; i < fTabImages.length; i++) >- fTabImages[i].dispose(); >- super.dispose(); >- } >- >- protected boolean createCount() { >- return true; >- } >-} >Index: src/org/eclipse/pde/internal/ui/editor/target/ContentPage.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/target/ContentPage.java,v >retrieving revision 1.5 >diff -u -r1.5 ContentPage.java >--- src/org/eclipse/pde/internal/ui/editor/target/ContentPage.java 16 Jan 2008 17:08:09 -0000 1.5 >+++ src/org/eclipse/pde/internal/ui/editor/target/ContentPage.java 13 Jan 2009 16:34:29 -0000 >@@ -1,56 +1,51 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import org.eclipse.pde.internal.ui.*; >-import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >-import org.eclipse.pde.internal.ui.editor.PDEFormPage; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.forms.IManagedForm; >-import org.eclipse.ui.forms.editor.FormEditor; >-import org.eclipse.ui.forms.widgets.FormToolkit; >-import org.eclipse.ui.forms.widgets.ScrolledForm; >- >-public class ContentPage extends PDEFormPage { >- >- public static final String PAGE_ID = "content"; //$NON-NLS-1$ >- >- public ContentPage(FormEditor editor) { >- super(editor, PAGE_ID, PDEUIMessages.TargetContentPage_title); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm) >- */ >- protected void createFormContent(IManagedForm managedForm) { >- super.createFormContent(managedForm); >- ScrolledForm form = managedForm.getForm(); >- FormToolkit toolkit = managedForm.getToolkit(); >- form.setText(PDEUIMessages.TargetContentPage_title); >- form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_FEATURE_OBJ)); >- fillBody(managedForm, toolkit); >- PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.TARGET_OVERVIEW_PAGE); >- >- } >- >- private void fillBody(IManagedForm managedForm, FormToolkit toolkit) { >- Composite body = managedForm.getForm().getBody(); >- body.setLayout(FormLayoutFactory.createFormGridLayout(false, 1)); >- >- managedForm.addPart(new ContentSection(this, body)); >- } >- >- protected String getHelpResource() { >- return "/org.eclipse.pde.doc.user/guide/tools/editors/target_definition_editor/content.htm"; //$NON-NLS-1$ >- } >- >-} >+/******************************************************************************* >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.target; >+ >+import org.eclipse.pde.internal.ui.*; >+import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.forms.IManagedForm; >+import org.eclipse.ui.forms.editor.FormEditor; >+import org.eclipse.ui.forms.editor.FormPage; >+import org.eclipse.ui.forms.widgets.FormToolkit; >+import org.eclipse.ui.forms.widgets.ScrolledForm; >+ >+public class ContentPage extends FormPage { >+ >+ public static final String PAGE_ID = "content"; //$NON-NLS-1$ >+ >+ public ContentPage(FormEditor editor) { >+ super(editor, PAGE_ID, PDEUIMessages.TargetContentPage_title); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm) >+ */ >+ protected void createFormContent(IManagedForm managedForm) { >+ super.createFormContent(managedForm); >+ ScrolledForm form = managedForm.getForm(); >+ FormToolkit toolkit = managedForm.getToolkit(); >+ form.setText(PDEUIMessages.TargetContentPage_title); >+ form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_FEATURE_OBJ)); >+ fillBody(managedForm, toolkit); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.TARGET_OVERVIEW_PAGE); >+ >+ } >+ >+ private void fillBody(IManagedForm managedForm, FormToolkit toolkit) { >+ Composite body = managedForm.getForm().getBody(); >+ body.setLayout(FormLayoutFactory.createFormGridLayout(false, 1)); >+// managedForm.addPart(new ContentSection(this, body)); >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/target/EnvironmentSection.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/target/EnvironmentSection.java,v >retrieving revision 1.11 >diff -u -r1.11 EnvironmentSection.java >--- src/org/eclipse/pde/internal/ui/editor/target/EnvironmentSection.java 11 Mar 2008 00:21:20 -0000 1.11 >+++ src/org/eclipse/pde/internal/ui/editor/target/EnvironmentSection.java 13 Jan 2009 16:34:29 -0000 >@@ -1,304 +1,260 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import java.lang.reflect.InvocationTargetException; >-import java.util.TreeSet; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.jface.operation.IRunnableWithProgress; >-import org.eclipse.pde.core.IModelChangedEvent; >-import org.eclipse.pde.internal.core.itarget.*; >-import org.eclipse.pde.internal.ui.PDEPlugin; >-import org.eclipse.pde.internal.ui.PDEUIMessages; >-import org.eclipse.pde.internal.ui.editor.*; >-import org.eclipse.pde.internal.ui.parts.ComboPart; >-import org.eclipse.pde.internal.ui.util.LocaleUtil; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.CCombo; >-import org.eclipse.swt.events.*; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.*; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.forms.IFormColors; >-import org.eclipse.ui.forms.widgets.FormToolkit; >-import org.eclipse.ui.forms.widgets.Section; >- >-public class EnvironmentSection extends PDESection { >- >- private ComboPart fOSCombo; >- private ComboPart fWSCombo; >- private ComboPart fNLCombo; >- private ComboPart fArchCombo; >- >- private TreeSet fNLChoices; >- private TreeSet fOSChoices; >- private TreeSet fWSChoices; >- private TreeSet fArchChoices; >- private boolean LOCALES_INITIALIZED = false; >- >- public EnvironmentSection(PDEFormPage page, Composite parent) { >- super(page, parent, Section.DESCRIPTION); >- createClient(getSection(), page.getEditor().getToolkit()); >- } >- >- protected void createClient(Section section, FormToolkit toolkit) { >- section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); >- section.setText(PDEUIMessages.EnvironmentSection_title); >- section.setDescription(PDEUIMessages.EnvironmentSection_description); >- GridData data = new GridData(GridData.FILL_HORIZONTAL); >- data.verticalAlignment = SWT.TOP; >- data.horizontalSpan = 2; >- section.setLayoutData(data); >- >- Composite client = toolkit.createComposite(section); >- client.setLayout(FormLayoutFactory.createSectionClientGridLayout(true, 2)); >- client.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- >- Composite left = toolkit.createComposite(client); >- left.setLayout(new GridLayout(2, false)); >- GridLayout layout = FormLayoutFactory.createClearGridLayout(false, 2); >- layout.horizontalSpacing = layout.verticalSpacing = 5; >- left.setLayout(layout); >- left.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- >- IEnvironmentInfo orgEnv = getEnvironment(); >- initializeChoices(orgEnv); >- >- Label label = toolkit.createLabel(left, PDEUIMessages.EnvironmentSection_operationSystem); >- label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); >- >- fOSCombo = new ComboPart(); >- fOSCombo.createControl(left, toolkit, SWT.SINGLE | SWT.BORDER); >- fOSCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- fOSCombo.setItems((String[]) fOSChoices.toArray(new String[fOSChoices.size()])); >- >- label = toolkit.createLabel(left, PDEUIMessages.EnvironmentSection_windowingSystem); >- label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); >- >- fWSCombo = new ComboPart(); >- fWSCombo.createControl(left, toolkit, SWT.SINGLE | SWT.BORDER); >- fWSCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- fWSCombo.setItems((String[]) fWSChoices.toArray(new String[fWSChoices.size()])); >- >- Composite right = toolkit.createComposite(client); >- layout = FormLayoutFactory.createClearGridLayout(false, 2); >- layout.verticalSpacing = layout.horizontalSpacing = 5; >- right.setLayout(layout); >- right.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- >- label = toolkit.createLabel(right, PDEUIMessages.EnvironmentSection_architecture); >- label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); >- >- fArchCombo = new ComboPart(); >- fArchCombo.createControl(right, toolkit, SWT.SINGLE | SWT.BORDER); >- fArchCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- fArchCombo.setItems((String[]) fArchChoices.toArray(new String[fArchChoices.size()])); >- >- label = toolkit.createLabel(right, PDEUIMessages.EnvironmentSection_locale); >- label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); >- >- fNLCombo = new ComboPart(); >- fNLCombo.createControl(right, toolkit, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL); >- fNLCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- fNLCombo.setItems((String[]) fNLChoices.toArray(new String[fNLChoices.size()])); >- >- refresh(); >- >- fOSCombo.addModifyListener(new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- getEnvironment().setOS(getText(fOSCombo)); >- } >- }); >- fWSCombo.addModifyListener(new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- getEnvironment().setWS(getText(fWSCombo)); >- } >- }); >- fArchCombo.addModifyListener(new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- getEnvironment().setArch(getText(fArchCombo)); >- } >- }); >- fNLCombo.getControl().addFocusListener(new FocusAdapter() { >- public void focusGained(FocusEvent event) { >- // if we haven't gotten all the values for the NL's, display a busy cursor to the user while we find them. >- if (!LOCALES_INITIALIZED) { >- try { >- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { >- public void run(IProgressMonitor monitor) { >- initializeAllLocales(); >- LOCALES_INITIALIZED = true; >- } >- }); >- } catch (InvocationTargetException e) { >- PDEPlugin.log(e); >- } catch (InterruptedException e) { >- PDEPlugin.log(e); >- } >- } >- >- // first time through, we should have a max item count of 1. >- // On the first time through, we need to set the new values, and also attach the listener >- // If we attached the listener initially, when we call setItems(..), it would make the editor dirty (when the user didn't change anything) >- if (fNLCombo.getItemCount() < 3) { >- String current = fNLCombo.getSelection(); >- if (!fNLCombo.getControl().isDisposed()) { >- fNLCombo.setItems((String[]) fNLChoices.toArray(new String[fNLChoices.size()])); >- fNLCombo.setText(current); >- } >- >- fNLCombo.addModifyListener(new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- String value = getText(fNLCombo); >- int index = value.indexOf("-"); //$NON-NLS-1$ >- if (index > 0) >- value = value.substring(0, index); >- getEnvironment().setNL(value.trim()); >- } >- }); >- } >- >- } >- }); >- >- toolkit.paintBordersFor(client); >- section.setClient(client); >- >- // Register to be notified when the model changes >- getModel().addModelChangedListener(this); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent) >- */ >- public void modelChanged(IModelChangedEvent e) { >- // No need to call super, handling world changed event here >- if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) { >- handleModelEventWorldChanged(e); >- } >- } >- >- /** >- * @param event >- */ >- private void handleModelEventWorldChanged(IModelChangedEvent event) { >- // Perform the refresh >- refresh(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.forms.AbstractFormPart#dispose() >- */ >- public void dispose() { >- ITargetModel model = getModel(); >- if (model != null) { >- model.removeModelChangedListener(this); >- } >- super.dispose(); >- } >- >- private void initializeChoices(IEnvironmentInfo orgEnv) { >- fOSChoices = new TreeSet(); >- String[] os = Platform.knownOSValues(); >- for (int i = 0; i < os.length; i++) >- fOSChoices.add(os[i]); >- fOSChoices.add(""); //$NON-NLS-1$ >- String fileValue = orgEnv.getOS(); >- if (fileValue != null) >- fOSChoices.add(fileValue); >- >- fWSChoices = new TreeSet(); >- String[] ws = Platform.knownWSValues(); >- for (int i = 0; i < ws.length; i++) >- fWSChoices.add(ws[i]); >- fWSChoices.add(""); //$NON-NLS-1$ >- fileValue = orgEnv.getWS(); >- if (fileValue != null) >- fWSChoices.add(fileValue); >- >- fArchChoices = new TreeSet(); >- String[] arch = Platform.knownOSArchValues(); >- for (int i = 0; i < arch.length; i++) >- fArchChoices.add(arch[i]); >- fArchChoices.add(""); //$NON-NLS-1$ >- fileValue = orgEnv.getArch(); >- if (fileValue != null) >- fArchChoices.add(fileValue); >- >- fNLChoices = new TreeSet(); >- fNLChoices.add(""); //$NON-NLS-1$ >- } >- >- private void initializeAllLocales() { >- String[] nl = LocaleUtil.getLocales(); >- for (int i = 0; i < nl.length; i++) >- fNLChoices.add(nl[i]); >- String fileValue = getEnvironment().getNL(); >- if (fileValue != null) >- fNLChoices.add(LocaleUtil.expandLocaleName(fileValue)); >- LOCALES_INITIALIZED = true; >- } >- >- private String getText(ComboPart combo) { >- Control control = combo.getControl(); >- if (control instanceof Combo) >- return ((Combo) control).getText(); >- return ((CCombo) control).getText(); >- } >- >- private IEnvironmentInfo getEnvironment() { >- IEnvironmentInfo info = getTarget().getEnvironment(); >- if (info == null) { >- info = getModel().getFactory().createEnvironment(); >- getTarget().setEnvironment(info); >- } >- return info; >- } >- >- private ITarget getTarget() { >- return getModel().getTarget(); >- } >- >- private ITargetModel getModel() { >- return (ITargetModel) getPage().getPDEEditor().getAggregateModel(); >- } >- >- public void refresh() { >- IEnvironmentInfo orgEnv = getEnvironment(); >- String presetValue = (orgEnv.getOS() == null) ? "" : orgEnv.getOS(); //$NON-NLS-1$ >- fOSCombo.setText(presetValue); >- presetValue = (orgEnv.getWS() == null) ? "" : orgEnv.getWS(); //$NON-NLS-1$ >- fWSCombo.setText(presetValue); >- presetValue = (orgEnv.getArch() == null) ? "" : orgEnv.getArch(); //$NON-NLS-1$ >- fArchCombo.setText(presetValue); >- presetValue = (orgEnv.getNL() == null) ? "" : LocaleUtil.expandLocaleName(orgEnv.getNL()); //$NON-NLS-1$ >- fNLCombo.setText(presetValue); >- >- super.refresh(); >- } >- >- protected void updateChoices() { >- if (LOCALES_INITIALIZED) >- return; >- // prevent NPE Mike found, which we can't reproduce. Somehow we call initializeAllLocales before the ITargetModel exists. >- if (getModel() == null) >- return; >- // kick off thread in backgroud to find the NL values >- new Thread(new Runnable() { >- public void run() { >- initializeAllLocales(); >- } >- }).start(); >- } >- >-} >+/******************************************************************************* >+ * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.target; >+ >+import org.eclipse.pde.internal.ui.editor.target.TargetEditor; >+ >+import java.lang.reflect.InvocationTargetException; >+import java.util.TreeSet; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+import org.eclipse.pde.internal.ui.PDEPlugin; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+import org.eclipse.pde.internal.ui.parts.ComboPart; >+import org.eclipse.pde.internal.ui.util.LocaleUtil; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.CCombo; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.forms.IFormColors; >+import org.eclipse.ui.forms.SectionPart; >+import org.eclipse.ui.forms.editor.FormPage; >+import org.eclipse.ui.forms.widgets.*; >+ >+public class EnvironmentSection extends SectionPart { >+ >+ private ComboPart fOSCombo; >+ private ComboPart fWSCombo; >+ private ComboPart fNLCombo; >+ private ComboPart fArchCombo; >+ >+ private TreeSet fNLChoices; >+ private TreeSet fOSChoices; >+ private TreeSet fWSChoices; >+ private TreeSet fArchChoices; >+ private boolean LOCALES_INITIALIZED = false; >+ >+ private TargetEditor fEditor; >+ >+ public EnvironmentSection(FormPage page, Composite parent) { >+ super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR); >+ fEditor = (TargetEditor) page.getEditor(); >+ createClient(getSection(), page.getEditor().getToolkit()); >+ } >+ >+ private ITargetDefinition getTarget() { >+ return fEditor.getTarget(); >+ } >+ >+ protected void createClient(Section section, FormToolkit toolkit) { >+ section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); >+ section.setText(PDEUIMessages.EnvironmentSection_title); >+ section.setDescription(PDEUIMessages.EnvironmentSection_description); >+ GridData data = new GridData(GridData.FILL_HORIZONTAL); >+ data.verticalAlignment = SWT.TOP; >+ data.horizontalSpan = 2; >+ section.setLayoutData(data); >+ >+ Composite client = toolkit.createComposite(section); >+ client.setLayout(FormLayoutFactory.createSectionClientGridLayout(true, 2)); >+ client.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ >+ Composite left = toolkit.createComposite(client); >+ left.setLayout(new GridLayout(2, false)); >+ GridLayout layout = FormLayoutFactory.createClearGridLayout(false, 2); >+ layout.horizontalSpacing = layout.verticalSpacing = 5; >+ left.setLayout(layout); >+ left.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ >+ initializeChoices(); >+ >+ Label label = toolkit.createLabel(left, PDEUIMessages.EnvironmentSection_operationSystem); >+ label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); >+ >+ fOSCombo = new ComboPart(); >+ fOSCombo.createControl(left, toolkit, SWT.SINGLE | SWT.BORDER); >+ fOSCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ fOSCombo.setItems((String[]) fOSChoices.toArray(new String[fOSChoices.size()])); >+ >+ label = toolkit.createLabel(left, PDEUIMessages.EnvironmentSection_windowingSystem); >+ label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); >+ >+ fWSCombo = new ComboPart(); >+ fWSCombo.createControl(left, toolkit, SWT.SINGLE | SWT.BORDER); >+ fWSCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ fWSCombo.setItems((String[]) fWSChoices.toArray(new String[fWSChoices.size()])); >+ >+ Composite right = toolkit.createComposite(client); >+ layout = FormLayoutFactory.createClearGridLayout(false, 2); >+ layout.verticalSpacing = layout.horizontalSpacing = 5; >+ right.setLayout(layout); >+ right.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ >+ label = toolkit.createLabel(right, PDEUIMessages.EnvironmentSection_architecture); >+ label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); >+ >+ fArchCombo = new ComboPart(); >+ fArchCombo.createControl(right, toolkit, SWT.SINGLE | SWT.BORDER); >+ fArchCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ fArchCombo.setItems((String[]) fArchChoices.toArray(new String[fArchChoices.size()])); >+ >+ label = toolkit.createLabel(right, PDEUIMessages.EnvironmentSection_locale); >+ label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); >+ >+ fNLCombo = new ComboPart(); >+ fNLCombo.createControl(right, toolkit, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL); >+ fNLCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ fNLCombo.setItems((String[]) fNLChoices.toArray(new String[fNLChoices.size()])); >+ >+ refresh(); >+ >+ fOSCombo.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ getTarget().setOS(getText(fOSCombo)); >+ } >+ }); >+ fWSCombo.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ getTarget().setWS(getText(fWSCombo)); >+ } >+ }); >+ fArchCombo.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ getTarget().setArch(getText(fArchCombo)); >+ } >+ }); >+ fNLCombo.getControl().addFocusListener(new FocusAdapter() { >+ public void focusGained(FocusEvent event) { >+ // if we haven't gotten all the values for the NL's, display a busy cursor to the user while we find them. >+ if (!LOCALES_INITIALIZED) { >+ try { >+ PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) { >+ initializeAllLocales(); >+ LOCALES_INITIALIZED = true; >+ } >+ }); >+ } catch (InvocationTargetException e) { >+ PDEPlugin.log(e); >+ } catch (InterruptedException e) { >+ PDEPlugin.log(e); >+ } >+ } >+ >+ // first time through, we should have a max item count of 1. >+ // On the first time through, we need to set the new values, and also attach the listener >+ // If we attached the listener initially, when we call setItems(..), it would make the editor dirty (when the user didn't change anything) >+ if (fNLCombo.getItemCount() < 3) { >+ String current = fNLCombo.getSelection(); >+ if (!fNLCombo.getControl().isDisposed()) { >+ fNLCombo.setItems((String[]) fNLChoices.toArray(new String[fNLChoices.size()])); >+ fNLCombo.setText(current); >+ } >+ >+ fNLCombo.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ String value = getText(fNLCombo); >+ int index = value.indexOf("-"); //$NON-NLS-1$ >+ if (index > 0) >+ value = value.substring(0, index); >+ getTarget().setNL(value.trim()); >+ } >+ }); >+ } >+ >+ } >+ }); >+ >+ toolkit.paintBordersFor(client); >+ section.setClient(client); >+ } >+ >+ private void initializeChoices() { >+ ITargetDefinition target = getTarget(); >+ fOSChoices = new TreeSet(); >+ String[] os = Platform.knownOSValues(); >+ for (int i = 0; i < os.length; i++) >+ fOSChoices.add(os[i]); >+ fOSChoices.add(""); //$NON-NLS-1$ >+ String fileValue = target.getOS(); >+ if (fileValue != null) >+ fOSChoices.add(fileValue); >+ >+ fWSChoices = new TreeSet(); >+ String[] ws = Platform.knownWSValues(); >+ for (int i = 0; i < ws.length; i++) >+ fWSChoices.add(ws[i]); >+ fWSChoices.add(""); //$NON-NLS-1$ >+ fileValue = target.getWS(); >+ if (fileValue != null) >+ fWSChoices.add(fileValue); >+ >+ fArchChoices = new TreeSet(); >+ String[] arch = Platform.knownOSArchValues(); >+ for (int i = 0; i < arch.length; i++) >+ fArchChoices.add(arch[i]); >+ fArchChoices.add(""); //$NON-NLS-1$ >+ fileValue = target.getArch(); >+ if (fileValue != null) >+ fArchChoices.add(fileValue); >+ >+ fNLChoices = new TreeSet(); >+ fNLChoices.add(""); //$NON-NLS-1$ >+ } >+ >+ private void initializeAllLocales() { >+ String[] nl = LocaleUtil.getLocales(); >+ for (int i = 0; i < nl.length; i++) >+ fNLChoices.add(nl[i]); >+ String fileValue = getTarget().getNL(); >+ if (fileValue != null) >+ fNLChoices.add(LocaleUtil.expandLocaleName(fileValue)); >+ LOCALES_INITIALIZED = true; >+ } >+ >+ private String getText(ComboPart combo) { >+ Control control = combo.getControl(); >+ if (control instanceof Combo) >+ return ((Combo) control).getText(); >+ return ((CCombo) control).getText(); >+ } >+ >+ public void refresh() { >+ ITargetDefinition target = getTarget(); >+ String presetValue = (target.getOS() == null) ? "" : target.getOS(); //$NON-NLS-1$ >+ fOSCombo.setText(presetValue); >+ presetValue = (target.getWS() == null) ? "" : target.getWS(); //$NON-NLS-1$ >+ fWSCombo.setText(presetValue); >+ presetValue = (target.getArch() == null) ? "" : target.getArch(); //$NON-NLS-1$ >+ fArchCombo.setText(presetValue); >+ presetValue = (target.getNL() == null) ? "" : LocaleUtil.expandLocaleName(target.getNL()); //$NON-NLS-1$ >+ fNLCombo.setText(presetValue); >+ super.refresh(); >+ } >+ >+ protected void updateChoices() { >+ if (LOCALES_INITIALIZED) >+ return; >+ // kick off thread in background to find the NL values >+ new Thread(new Runnable() { >+ public void run() { >+ initializeAllLocales(); >+ } >+ }).start(); >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/target/TargetInputContextManager.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/target/TargetInputContextManager.java >diff -N src/org/eclipse/pde/internal/ui/editor/target/TargetInputContextManager.java >--- src/org/eclipse/pde/internal/ui/editor/target/TargetInputContextManager.java 16 Jan 2008 17:08:10 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,35 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import org.eclipse.pde.core.IBaseModel; >-import org.eclipse.pde.internal.ui.editor.PDEFormEditor; >-import org.eclipse.pde.internal.ui.editor.context.InputContext; >-import org.eclipse.pde.internal.ui.editor.context.InputContextManager; >- >-public class TargetInputContextManager extends InputContextManager { >- >- /** >- * @param editor >- */ >- public TargetInputContextManager(PDEFormEditor editor) { >- super(editor); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.context.InputContextManager#getAggregateModel() >- */ >- public IBaseModel getAggregateModel() { >- InputContext context = findContext(TargetInputContext.CONTEXT_ID); >- return (context != null) ? context.getModel() : null; >- } >- >-} >Index: src/org/eclipse/pde/internal/ui/editor/target/TargetEditorContributor.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/target/TargetEditorContributor.java >diff -N src/org/eclipse/pde/internal/ui/editor/target/TargetEditorContributor.java >--- src/org/eclipse/pde/internal/ui/editor/target/TargetEditorContributor.java 16 Jan 2008 17:08:10 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,21 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import org.eclipse.pde.internal.ui.editor.PDEFormEditorContributor; >- >-public class TargetEditorContributor extends PDEFormEditorContributor { >- >- public TargetEditorContributor() { >- super("Product"); //$NON-NLS-1$ >- } >- >-} >Index: src/org/eclipse/pde/internal/ui/editor/target/EnvironmentPage.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/target/EnvironmentPage.java,v >retrieving revision 1.11 >diff -u -r1.11 EnvironmentPage.java >--- src/org/eclipse/pde/internal/ui/editor/target/EnvironmentPage.java 16 Jan 2008 17:08:09 -0000 1.11 >+++ src/org/eclipse/pde/internal/ui/editor/target/EnvironmentPage.java 13 Jan 2009 16:34:29 -0000 >@@ -1,62 +1,52 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import org.eclipse.pde.internal.ui.*; >-import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >-import org.eclipse.pde.internal.ui.editor.PDEFormPage; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.forms.IManagedForm; >-import org.eclipse.ui.forms.editor.FormEditor; >-import org.eclipse.ui.forms.widgets.FormToolkit; >-import org.eclipse.ui.forms.widgets.ScrolledForm; >- >-public class EnvironmentPage extends PDEFormPage { >- >- private EnvironmentSection fEnvSection; >- >- public static final String PAGE_ID = "environment"; //$NON-NLS-1$ >- >- public EnvironmentPage(FormEditor editor) { >- super(editor, PAGE_ID, PDEUIMessages.EnvironmentPage_title); >- } >- >- protected void createFormContent(IManagedForm managedForm) { >- super.createFormContent(managedForm); >- ScrolledForm form = managedForm.getForm(); >- form.setText(PDEUIMessages.EnvironmentPage_title); >- form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_TARGET_ENVIRONMENT)); >- FormToolkit toolkit = managedForm.getToolkit(); >- fillBody(managedForm, toolkit); >- >- PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.ENVIRONMENT_PAGE); >- } >- >- private void fillBody(IManagedForm managedForm, FormToolkit toolkit) { >- Composite body = managedForm.getForm().getBody(); >- body.setLayout(FormLayoutFactory.createFormGridLayout(false, 2)); >- >- managedForm.addPart(fEnvSection = new EnvironmentSection(this, body)); >- managedForm.addPart(new JRESection(this, body)); >- managedForm.addPart(new ArgumentsSection(this, body)); >- managedForm.addPart(new ImplicitDependenciesSection(this, body)); >- } >- >- protected void updateChoices() { >- fEnvSection.updateChoices(); >- } >- >- protected String getHelpResource() { >- return "/org.eclipse.pde.doc.user/guide/tools/editors/target_definition_editor/environment.htm"; //$NON-NLS-1$ >- } >- >-} >+/******************************************************************************* >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.target; >+ >+import org.eclipse.pde.internal.ui.*; >+import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.forms.IManagedForm; >+import org.eclipse.ui.forms.editor.FormEditor; >+import org.eclipse.ui.forms.editor.FormPage; >+import org.eclipse.ui.forms.widgets.FormToolkit; >+import org.eclipse.ui.forms.widgets.ScrolledForm; >+ >+public class EnvironmentPage extends FormPage { >+ >+ public static final String PAGE_ID = "environment"; //$NON-NLS-1$ >+ >+ public EnvironmentPage(FormEditor editor) { >+ super(editor, PAGE_ID, PDEUIMessages.EnvironmentPage_title); >+ } >+ >+ protected void createFormContent(IManagedForm managedForm) { >+ super.createFormContent(managedForm); >+ ScrolledForm form = managedForm.getForm(); >+ form.setText(PDEUIMessages.EnvironmentPage_title); >+ form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_TARGET_ENVIRONMENT)); >+ FormToolkit toolkit = managedForm.getToolkit(); >+ fillBody(managedForm, toolkit); >+ toolkit.decorateFormHeading(form.getForm()); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.ENVIRONMENT_PAGE); >+ } >+ >+ private void fillBody(IManagedForm managedForm, FormToolkit toolkit) { >+ Composite body = managedForm.getForm().getBody(); >+ body.setLayout(FormLayoutFactory.createFormGridLayout(false, 2)); >+ >+ managedForm.addPart(new EnvironmentSection(this, body)); >+ managedForm.addPart(new JRESection(this, body)); >+ managedForm.addPart(new ArgumentsSection(this, body)); >+ managedForm.addPart(new ImplicitDependenciesSection(this, body)); >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/target/ImplicitDependenciesSection.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/target/ImplicitDependenciesSection.java,v >retrieving revision 1.11 >diff -u -r1.11 ImplicitDependenciesSection.java >--- src/org/eclipse/pde/internal/ui/editor/target/ImplicitDependenciesSection.java 16 Jan 2008 17:08:09 -0000 1.11 >+++ src/org/eclipse/pde/internal/ui/editor/target/ImplicitDependenciesSection.java 13 Jan 2009 16:34:30 -0000 >@@ -1,272 +1,253 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import java.util.*; >-import org.eclipse.jface.viewers.*; >-import org.eclipse.jface.window.Window; >-import org.eclipse.osgi.service.resolver.BundleDescription; >-import org.eclipse.pde.core.IModelChangedEvent; >-import org.eclipse.pde.core.plugin.IPluginModelBase; >-import org.eclipse.pde.core.plugin.PluginRegistry; >-import org.eclipse.pde.internal.core.itarget.*; >-import org.eclipse.pde.internal.ui.PDEPlugin; >-import org.eclipse.pde.internal.ui.PDEUIMessages; >-import org.eclipse.pde.internal.ui.editor.*; >-import org.eclipse.pde.internal.ui.editor.plugin.ManifestEditor; >-import org.eclipse.pde.internal.ui.elements.DefaultTableProvider; >-import org.eclipse.pde.internal.ui.parts.TablePart; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.ui.actions.ActionFactory; >-import org.eclipse.ui.dialogs.ElementListSelectionDialog; >-import org.eclipse.ui.forms.widgets.FormToolkit; >-import org.eclipse.ui.forms.widgets.Section; >- >-public class ImplicitDependenciesSection extends TableSection { >- >- private TableViewer fViewer; >- private static final int ADD_INDEX = 0; >- private static final int REMOVE_INDEX = 1; >- private static final int REMOVE_ALL_INDEX = 2; >- >- public ImplicitDependenciesSection(PDEFormPage page, Composite parent) { >- super(page, parent, Section.DESCRIPTION, new String[] {PDEUIMessages.ImplicitDependenicesSection_Add, PDEUIMessages.ImplicitDependenicesSection_Remove, PDEUIMessages.ImplicitDependenicesSection_RemoveAll}); >- } >- >- protected void createClient(Section section, FormToolkit toolkit) { >- section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); >- section.setText(PDEUIMessages.ImplicitDependenicesSection_Title); >- section.setDescription(PDEUIMessages.TargetImplicitPluginsTab_desc); >- Composite container = toolkit.createComposite(section); >- container.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2)); >- container.setLayoutData(new GridData(GridData.FILL_BOTH)); >- createViewerPartControl(container, SWT.MULTI, 2, toolkit); >- fViewer = getTablePart().getTableViewer(); >- fViewer.setContentProvider(new DefaultTableProvider() { >- public Object[] getElements(Object inputElement) { >- return getImplicitPluginsInfo().getPlugins(); >- } >- }); >- fViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); >- fViewer.setComparator(new ViewerComparator() { >- public int compare(Viewer viewer, Object e1, Object e2) { >- ITargetPlugin p1 = (ITargetPlugin) e1; >- ITargetPlugin p2 = (ITargetPlugin) e2; >- return super.compare(viewer, p1.getId(), p2.getId()); >- } >- }); >- fViewer.setInput(getTarget()); >- fViewer.addSelectionChangedListener(new ISelectionChangedListener() { >- public void selectionChanged(SelectionChangedEvent event) { >- updateButtons(); >- } >- }); >- >- toolkit.paintBordersFor(container); >- section.setClient(container); >- GridData gd = new GridData(GridData.FILL_BOTH); >- section.setLayoutData(gd); >- updateButtons(); >- getModel().addModelChangedListener(this); >- } >- >- public boolean doGlobalAction(String actionId) { >- if (actionId.equals(ActionFactory.DELETE.getId())) { >- handleRemove(); >- return true; >- } >- if (actionId.equals(ActionFactory.CUT.getId())) { >- // delete here and let the editor transfer >- // the selection to the clipboard >- handleRemove(); >- return false; >- } >- if (actionId.equals(ActionFactory.PASTE.getId())) { >- doPaste(); >- return true; >- } >- return false; >- } >- >- private void updateButtons() { >- TablePart part = getTablePart(); >- boolean empty = fViewer.getSelection().isEmpty(); >- part.setButtonEnabled(1, !empty); >- boolean hasElements = fViewer.getTable().getItemCount() > 0; >- part.setButtonEnabled(2, hasElements); >- } >- >- protected void buttonSelected(int index) { >- switch (index) { >- case ADD_INDEX : >- handleAdd(); >- break; >- case REMOVE_INDEX : >- handleRemove(); >- break; >- case REMOVE_ALL_INDEX : >- handleRemoveAll(); >- } >- } >- >- protected void handleAdd() { >- ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), PDEPlugin.getDefault().getLabelProvider()); >- >- dialog.setElements(getValidBundles()); >- dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title); >- dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message); >- dialog.setMultipleSelection(true); >- if (dialog.open() == Window.OK) { >- Object[] models = dialog.getResult(); >- ArrayList pluginsToAdd = new ArrayList(); >- ITargetModel model = getModel(); >- for (int i = 0; i < models.length; i++) { >- BundleDescription desc = (BundleDescription) models[i]; >- ITargetPlugin plugin = model.getFactory().createPlugin(); >- plugin.setId(desc.getSymbolicName()); >- plugin.setModel(model); >- pluginsToAdd.add(plugin); >- } >- getImplicitPluginsInfo().addPlugins((ITargetPlugin[]) pluginsToAdd.toArray(new ITargetPlugin[pluginsToAdd.size()])); >- updateButtons(); >- } >- } >- >- protected Object[] getValidBundles() { >- ITargetPlugin[] plugins = getImplicitPluginsInfo().getPlugins(); >- Set currentPlugins = new HashSet((4 / 3) * plugins.length + 1); >- for (int i = 0; i < plugins.length; i++) { >- currentPlugins.add(plugins[i].getId()); >- } >- >- IPluginModelBase[] models = PluginRegistry.getActiveModels(false); >- Set result = new HashSet((4 / 3) * models.length + 1); >- for (int i = 0; i < models.length; i++) { >- BundleDescription desc = models[i].getBundleDescription(); >- if (desc != null) { >- if (!currentPlugins.contains(desc.getSymbolicName())) >- result.add(desc); >- } >- } >- return result.toArray(); >- } >- >- protected void handleRemove() { >- Object[] src = ((IStructuredSelection) fViewer.getSelection()).toArray(); >- ITargetPlugin[] plugins = new ITargetPlugin[src.length]; >- System.arraycopy(src, 0, plugins, 0, src.length); >- getImplicitPluginsInfo().removePlugins(plugins); >- updateButtons(); >- } >- >- protected void handleRemoveAll() { >- IImplicitDependenciesInfo info = getImplicitPluginsInfo(); >- info.removePlugins(info.getPlugins()); >- updateButtons(); >- } >- >- private IImplicitDependenciesInfo getImplicitPluginsInfo() { >- IImplicitDependenciesInfo info = getTarget().getImplicitPluginsInfo(); >- if (info == null) { >- info = getModel().getFactory().createImplicitPluginInfo(); >- getTarget().setImplicitPluginsInfo(info); >- } >- return info; >- } >- >- private ITarget getTarget() { >- return getModel().getTarget(); >- } >- >- private ITargetModel getModel() { >- return (ITargetModel) getPage().getPDEEditor().getAggregateModel(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent) >- */ >- public void modelChanged(IModelChangedEvent e) { >- if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) { >- handleModelEventWorldChanged(e); >- return; >- } >- if (e.getChangeType() == IModelChangedEvent.CHANGE && e.getChangedProperty().equals(IImplicitDependenciesInfo.P_IMPLICIT_PLUGINS)) { >- ITargetPlugin[] plugins = (ITargetPlugin[]) e.getOldValue(); >- for (int i = 0; i < plugins.length; i++) >- fViewer.remove(plugins[i]); >- plugins = (ITargetPlugin[]) e.getNewValue(); >- for (int i = 0; i < plugins.length; i++) >- fViewer.add(plugins[i]); >- } >- } >- >- /** >- * @param event >- */ >- private void handleModelEventWorldChanged(IModelChangedEvent event) { >- // Reload input >- fViewer.setInput(getTarget()); >- // Perform the refresh >- refresh(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.forms.AbstractFormPart#refresh() >- */ >- public void refresh() { >- fViewer.refresh(); >- updateButtons(); >- super.refresh(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.TableSection#handleDoubleClick(org.eclipse.jface.viewers.IStructuredSelection) >- */ >- protected void handleDoubleClick(IStructuredSelection selection) { >- handleOpen(selection); >- } >- >- private void handleOpen(IStructuredSelection selection) { >- Object object = selection.getFirstElement(); >- ManifestEditor.openPluginEditor(((ITargetPlugin) object).getId()); >- } >- >- protected boolean canPaste(Object target, Object[] objects) { >- for (int i = 0; i < objects.length; i++) { >- if (!(objects[i] instanceof ITargetPlugin)) >- return false; >- } >- return true; >- } >- >- protected void doPaste(Object target, Object[] objects) { >- for (int i = 0; i < objects.length; i++) { >- if (objects[i] instanceof ITargetPlugin) >- getImplicitPluginsInfo().addPlugin((ITargetPlugin) objects[i]); >- } >- } >- >- protected void selectionChanged(IStructuredSelection selection) { >- getPage().getPDEEditor().setSelection(selection); >- } >- >- public void dispose() { >- ITargetModel model = getModel(); >- if (model != null) >- model.removeModelChangedListener(this); >- } >- >- protected boolean createCount() { >- return true; >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.target; >+ >+import org.eclipse.pde.internal.ui.editor.target.TargetEditor; >+ >+import org.eclipse.jface.viewers.*; >+import org.eclipse.pde.internal.core.itarget.ITargetPlugin; >+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+import org.eclipse.pde.internal.ui.PDEPlugin; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+import org.eclipse.pde.internal.ui.editor.plugin.ManifestEditor; >+import org.eclipse.pde.internal.ui.elements.DefaultTableProvider; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.forms.IFormColors; >+import org.eclipse.ui.forms.SectionPart; >+import org.eclipse.ui.forms.editor.FormPage; >+import org.eclipse.ui.forms.widgets.*; >+ >+public class ImplicitDependenciesSection extends SectionPart { >+ >+ private TableViewer fViewer; >+ private TargetEditor fEditor; >+ private Button fAdd; >+ private Button fRemove; >+ private Button fRemoveAll; >+ private Label fCount; >+ >+ public ImplicitDependenciesSection(FormPage page, Composite parent) { >+ super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR); >+ fEditor = (TargetEditor) page.getEditor(); >+ createClient(getSection(), page.getEditor().getToolkit()); >+ } >+ >+ private ITargetDefinition getTarget() { >+ return fEditor.getTarget(); >+ } >+ >+ protected void createClient(Section section, FormToolkit toolkit) { >+ section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); >+ section.setText(PDEUIMessages.ImplicitDependenicesSection_Title); >+ section.setDescription(PDEUIMessages.TargetImplicitPluginsTab_desc); >+ Composite container = toolkit.createComposite(section); >+ container.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2)); >+ container.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ >+ createTableViewer(toolkit, container); >+ >+ Composite buttonComp = toolkit.createComposite(container); >+ GridLayout layout = new GridLayout(); >+ layout.marginWidth = layout.marginHeight = 0; >+ buttonComp.setLayout(layout); >+ buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); >+ >+ createButtons(toolkit, buttonComp); >+ >+ toolkit.paintBordersFor(container); >+ section.setClient(container); >+ GridData gd = new GridData(GridData.FILL_BOTH); >+ section.setLayoutData(gd); >+ updateButtons(); >+ } >+ >+ private void createTableViewer(FormToolkit toolkit, Composite parent) { >+ Table table = toolkit.createTable(parent, SWT.H_SCROLL | SWT.V_SCROLL); >+ table.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ fViewer = new TableViewer(table); >+ fViewer.setContentProvider(new DefaultTableProvider() { >+ public Object[] getElements(Object inputElement) { >+// return getTarget().getImplicitPlugins(); >+ return null; >+ } >+ }); >+ fViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); >+// fViewer.setComparator(new ViewerComparator() { >+ // TODO Compare bundle infos? >+// public int compare(Viewer viewer, Object e1, Object e2) { >+// p1 = (ITargetPlugin) e1; >+// ITargetPlugin p2 = (ITargetPlugin) e2; >+// return super.compare(viewer, p1.getId(), p2.getId()); >+// } >+// }); >+ // TODO Input might be the list of implicit dependencies >+// fViewer.setInput(getTarget()); >+ fViewer.addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) { >+ updateButtons(); >+ } >+ }); >+ fViewer.addDoubleClickListener(new IDoubleClickListener() { >+ public void doubleClick(DoubleClickEvent event) { >+ Object object = ((IStructuredSelection) event.getSelection()).getFirstElement(); >+ ManifestEditor.openPluginEditor(((ITargetPlugin) object).getId()); >+ } >+ }); >+ } >+ >+// public boolean doGlobalAction(String actionId) { >+// if (actionId.equals(ActionFactory.DELETE.getId())) { >+// handleRemove(); >+// return true; >+// } >+// if (actionId.equals(ActionFactory.CUT.getId())) { >+// // delete here and let the editor transfer >+// // the selection to the clipboard >+// handleRemove(); >+// return false; >+// } >+// if (actionId.equals(ActionFactory.PASTE.getId())) { >+// doPaste(); >+// return true; >+// } >+// return false; >+// } >+ >+ private void createButtons(FormToolkit toolkit, Composite parent) { >+ fAdd = toolkit.createButton(parent, PDEUIMessages.ImplicitDependenicesSection_Add, SWT.PUSH); >+ fAdd.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); >+ fAdd.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ handleAdd(); >+ } >+ }); >+ fRemove = toolkit.createButton(parent, PDEUIMessages.ImplicitDependenicesSection_Remove, SWT.PUSH); >+ fRemove.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); >+ fRemove.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ handleRemove(); >+ } >+ }); >+ fRemoveAll = toolkit.createButton(parent, PDEUIMessages.ImplicitDependenicesSection_RemoveAll, SWT.PUSH); >+ fRemoveAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); >+ fRemoveAll.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ handleRemoveAll(); >+ } >+ }); >+ Composite countComp = toolkit.createComposite(parent); >+ GridLayout layout = new GridLayout(); >+ layout.marginWidth = layout.marginHeight = 0; >+ countComp.setLayout(layout); >+ countComp.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_END | GridData.FILL_BOTH)); >+ fCount = toolkit.createLabel(parent, ""); //$NON-NLS-1$ >+ fCount.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); >+ fCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ fViewer.getTable().addPaintListener(new PaintListener() { >+ public void paintControl(PaintEvent e) { >+ updateLabel(); >+ } >+ }); >+ } >+ >+ private void updateButtons() { >+ fRemove.setEnabled(!fViewer.getSelection().isEmpty()); >+ fRemoveAll.setEnabled(fViewer.getTable().getItemCount() > 0); >+ } >+ >+ private void updateLabel() { >+ // TODO Finish >+ } >+ >+ protected void handleAdd() { >+// ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), PDEPlugin.getDefault().getLabelProvider()); >+// >+// dialog.setElements(getValidBundles()); >+// dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title); >+// dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message); >+// dialog.setMultipleSelection(true); >+// if (dialog.open() == Window.OK) { >+// Object[] models = dialog.getResult(); >+// ArrayList pluginsToAdd = new ArrayList(); >+// ITargetModel model = getModel(); >+// for (int i = 0; i < models.length; i++) { >+// BundleDescription desc = (BundleDescription) models[i]; >+// ITargetPlugin plugin = model.getFactory().createPlugin(); >+// plugin.setId(desc.getSymbolicName()); >+// plugin.setModel(model); >+// pluginsToAdd.add(plugin); >+// } >+// getImplicitPluginsInfo().addPlugins((ITargetPlugin[]) pluginsToAdd.toArray(new ITargetPlugin[pluginsToAdd.size()])); >+// updateButtons(); >+// } >+ } >+ >+// protected Object[] getValidBundles() { >+// ITargetPlugin[] plugins = getImplicitPluginsInfo().getPlugins(); >+// Set currentPlugins = new HashSet((4 / 3) * plugins.length + 1); >+// for (int i = 0; i < plugins.length; i++) { >+// currentPlugins.add(plugins[i].getId()); >+// } >+// >+// IPluginModelBase[] models = PluginRegistry.getActiveModels(false); >+// Set result = new HashSet((4 / 3) * models.length + 1); >+// for (int i = 0; i < models.length; i++) { >+// BundleDescription desc = models[i].getBundleDescription(); >+// if (desc != null) { >+// if (!currentPlugins.contains(desc.getSymbolicName())) >+// result.add(desc); >+// } >+// } >+// return result.toArray(); >+// } >+ >+ private void handleRemove() { >+// Object[] src = ((IStructuredSelection) fViewer.getSelection()).toArray(); >+// ITargetPlugin[] plugins = new ITargetPlugin[src.length]; >+// System.arraycopy(src, 0, plugins, 0, src.length); >+// getImplicitPluginsInfo().removePlugins(plugins); >+// updateButtons(); >+ } >+ >+ private void handleRemoveAll() { >+// IImplicitDependenciesInfo info = getImplicitPluginsInfo(); >+// info.removePlugins(info.getPlugins()); >+// updateButtons(); >+ } >+ >+// >+// if (e.getChangeType() == IModelChangedEvent.CHANGE && e.getChangedProperty().equals(IImplicitDependenciesInfo.P_IMPLICIT_PLUGINS)) { >+// ITargetPlugin[] plugins = (ITargetPlugin[]) e.getOldValue(); >+// for (int i = 0; i < plugins.length; i++) >+// fViewer.remove(plugins[i]); >+// plugins = (ITargetPlugin[]) e.getNewValue(); >+// for (int i = 0; i < plugins.length; i++) >+// fViewer.add(plugins[i]); >+// } >+// } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.AbstractFormPart#refresh() >+ */ >+ public void refresh() { >+ // TODO Input may not be the target >+// fViewer.setInput(getTarget()); >+ fViewer.refresh(); >+ updateButtons(); >+ super.refresh(); >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/target/LocationsSection.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/target/LocationsSection.java >diff -N src/org/eclipse/pde/internal/ui/editor/target/LocationsSection.java >--- src/org/eclipse/pde/internal/ui/editor/target/LocationsSection.java 16 Jan 2008 17:08:09 -0000 1.13 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,281 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import org.eclipse.core.runtime.Path; >-import org.eclipse.jface.action.*; >-import org.eclipse.jface.viewers.*; >-import org.eclipse.pde.core.IModelChangedEvent; >-import org.eclipse.pde.core.plugin.TargetPlatform; >-import org.eclipse.pde.internal.core.itarget.*; >-import org.eclipse.pde.internal.ui.PDEPlugin; >-import org.eclipse.pde.internal.ui.PDEUIMessages; >-import org.eclipse.pde.internal.ui.editor.*; >-import org.eclipse.pde.internal.ui.elements.DefaultTableProvider; >-import org.eclipse.pde.internal.ui.parts.TablePart; >-import org.eclipse.pde.internal.ui.util.SWTUtil; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.BusyIndicator; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.ui.actions.ActionFactory; >-import org.eclipse.ui.forms.widgets.FormToolkit; >-import org.eclipse.ui.forms.widgets.Section; >- >-public class LocationsSection extends TableSection { >- >- private TableViewer fContentViewer; >- >- class ContentProvider extends DefaultTableProvider { >- public Object[] getElements(Object parent) { >- ITarget target = getTarget(); >- return target.getAdditionalDirectories(); >- } >- } >- >- public LocationsSection(PDEFormPage page, Composite parent) { >- super(page, parent, Section.DESCRIPTION, new String[] {PDEUIMessages.LocationsSection_add, PDEUIMessages.LocationsSection_edit, PDEUIMessages.LocationsSection_remove}); >- } >- >- protected void createClient(Section section, FormToolkit toolkit) { >- section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1)); >- Composite client = toolkit.createComposite(section); >- client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2)); >- client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL)); >- >- createViewerPartControl(client, SWT.MULTI, 2, toolkit); >- >- TablePart tablePart = getTablePart(); >- GridData data = (GridData) tablePart.getControl().getLayoutData(); >- data.grabExcessVerticalSpace = true; >- data.grabExcessHorizontalSpace = true; >- fContentViewer = tablePart.getTableViewer(); >- fContentViewer.setContentProvider(new ContentProvider()); >- fContentViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); >- fContentViewer.setInput(getTarget()); >- fContentViewer.addSelectionChangedListener(new ISelectionChangedListener() { >- public void selectionChanged(SelectionChangedEvent event) { >- updateButtons(); >- } >- }); >- fContentViewer.setComparator(new ViewerComparator() { >- public int compare(Viewer viewer, Object e1, Object e2) { >- IAdditionalLocation loc1 = (IAdditionalLocation) e1; >- return loc1.getPath().compareToIgnoreCase(((IAdditionalLocation) e2).getPath()); >- } >- }); >- fContentViewer.addDoubleClickListener(new IDoubleClickListener() { >- public void doubleClick(DoubleClickEvent event) { >- // if user double clicked on one selected item >- if (((StructuredSelection) fContentViewer.getSelection()).toArray().length == 1) >- handleEdit(); >- } >- }); >- >- toolkit.paintBordersFor(client); >- section.setClient(client); >- section.setText(PDEUIMessages.LocationsSection_title); >- section.setDescription(PDEUIMessages.LocationsSection_description); >- GridData sectionData = new GridData(GridData.FILL_BOTH); >- sectionData.horizontalSpan = 2; >- section.setLayoutData(sectionData); >- updateButtons(); >- >- getModel().addModelChangedListener(this); >- } >- >- private ITarget getTarget() { >- return getModel().getTarget(); >- } >- >- private ITargetModel getModel() { >- return (ITargetModel) getPage().getPDEEditor().getAggregateModel(); >- } >- >- protected void updateButtons() { >- int selectionNum = ((StructuredSelection) fContentViewer.getSelection()).toArray().length; >- TablePart table = getTablePart(); >- table.setButtonEnabled(1, selectionNum == 1); >- table.setButtonEnabled(2, selectionNum > 0); >- } >- >- protected void buttonSelected(int index) { >- switch (index) { >- case 0 : >- handleAdd(); >- break; >- case 1 : >- handleEdit(); >- break; >- case 2 : >- handleDelete(); >- } >- } >- >- protected void handleAdd() { >- showDialog(null); >- } >- >- protected void handleEdit() { >- showDialog((IAdditionalLocation) ((StructuredSelection) fContentViewer.getSelection()).iterator().next()); >- } >- >- protected void handleDelete() { >- IStructuredSelection ssel = (IStructuredSelection) fContentViewer.getSelection(); >- if (ssel.size() > 0) { >- Object[] objects = ssel.toArray(); >- ITarget target = getTarget(); >- IAdditionalLocation[] dirs = new IAdditionalLocation[objects.length]; >- System.arraycopy(objects, 0, dirs, 0, objects.length); >- target.removeAdditionalDirectories(dirs); >- } >- } >- >- private void showDialog(final IAdditionalLocation location) { >- final ITarget model = getTarget(); >- BusyIndicator.showWhile(fContentViewer.getTable().getDisplay(), new Runnable() { >- public void run() { >- LocationDialog dialog = new LocationDialog(fContentViewer.getTable().getShell(), model, location); >- dialog.create(); >- SWTUtil.setDialogSize(dialog, 500, -1); >- dialog.open(); >- } >- }); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent) >- */ >- public void modelChanged(IModelChangedEvent e) { >- if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) { >- handleModelEventWorldChanged(e); >- return; >- } >- Object[] objects = e.getChangedObjects(); >- if (e.getChangeType() == IModelChangedEvent.INSERT) { >- for (int i = 0; i < objects.length; i++) { >- if (objects[i] instanceof IAdditionalLocation) { >- fContentViewer.add(objects[i]); >- } >- } >- } else if (e.getChangeType() == IModelChangedEvent.REMOVE) { >- for (int i = 0; i < objects.length; i++) { >- if (objects[i] instanceof IAdditionalLocation) { >- fContentViewer.remove(objects[i]); >- } >- } >- } >- if (e.getChangedProperty() == IAdditionalLocation.P_PATH) { >- fContentViewer.refresh(); >- } >- } >- >- /** >- * @param event >- */ >- private void handleModelEventWorldChanged(IModelChangedEvent event) { >- // Reload input >- fContentViewer.setInput(getTarget()); >- // Perform the refresh >- refresh(); >- } >- >- public boolean doGlobalAction(String actionId) { >- if (actionId.equals(ActionFactory.DELETE.getId())) { >- handleDelete(); >- return true; >- } >- if (actionId.equals(ActionFactory.CUT.getId())) { >- handleDelete(); >- return false; >- } >- if (actionId.equals(ActionFactory.PASTE.getId())) { >- doPaste(); >- return true; >- } >- return false; >- } >- >- protected boolean canPaste(Object target, Object[] objects) { >- for (int i = 0; i < objects.length; i++) { >- if (objects[i] instanceof IAdditionalLocation) >- return true; >- } >- return false; >- } >- >- protected void doPaste(Object target, Object[] objects) { >- for (int i = 0; i < objects.length; i++) { >- if (objects[i] instanceof IAdditionalLocation && !hasPath(((IAdditionalLocation) objects[i]).getPath())) { >- IAdditionalLocation loc = (IAdditionalLocation) objects[i]; >- loc.setModel(getModel()); >- getTarget().addAdditionalDirectories(new IAdditionalLocation[] {loc}); >- } >- } >- } >- >- protected boolean hasPath(String path) { >- Path checkPath = new Path(path); >- IAdditionalLocation[] locs = getModel().getTarget().getAdditionalDirectories(); >- for (int i = 0; i < locs.length; i++) { >- if (new Path(locs[i].getPath()).equals(checkPath)) >- return true; >- } >- return isTargetLocation(checkPath); >- } >- >- private boolean isTargetLocation(Path path) { >- ILocationInfo info = getModel().getTarget().getLocationInfo(); >- if (info.useDefault()) { >- Path home = new Path(TargetPlatform.getDefaultLocation()); >- return home.equals(path); >- } >- return new Path(info.getPath()).equals(path); >- } >- >- public void dispose() { >- ITargetModel model = getModel(); >- if (model != null) >- model.removeModelChangedListener(this); >- super.dispose(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.forms.AbstractFormPart#refresh() >- */ >- public void refresh() { >- fContentViewer.refresh(); >- updateButtons(); >- super.refresh(); >- } >- >- protected void fillContextMenu(IMenuManager manager) { >- IStructuredSelection ssel = (IStructuredSelection) fContentViewer.getSelection(); >- if (ssel == null) >- return; >- >- Action removeAction = new Action(PDEUIMessages.ContentSection_remove) { >- public void run() { >- handleDelete(); >- } >- }; >- removeAction.setEnabled(isEditable() && ssel.size() > 0); >- manager.add(removeAction); >- >- manager.add(new Separator()); >- >- getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager); >- } >- >- protected void selectionChanged(IStructuredSelection selection) { >- getPage().getPDEEditor().setSelection(selection); >- } >-} >Index: src/org/eclipse/pde/internal/ui/editor/target/TargetInputContext.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/target/TargetInputContext.java >diff -N src/org/eclipse/pde/internal/ui/editor/target/TargetInputContext.java >--- src/org/eclipse/pde/internal/ui/editor/target/TargetInputContext.java 16 Jan 2008 17:08:09 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,98 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import java.io.*; >-import java.util.ArrayList; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.jface.text.IDocument; >-import org.eclipse.pde.core.*; >-import org.eclipse.pde.internal.core.itarget.ITargetModel; >-import org.eclipse.pde.internal.core.target.TargetModel; >-import org.eclipse.pde.internal.core.target.WorkspaceTargetModel; >-import org.eclipse.pde.internal.ui.PDEPlugin; >-import org.eclipse.pde.internal.ui.editor.PDEFormEditor; >-import org.eclipse.pde.internal.ui.editor.context.UTF8InputContext; >-import org.eclipse.ui.*; >- >-public class TargetInputContext extends UTF8InputContext { >- >- public static final String CONTEXT_ID = "target-context"; //$NON-NLS-1$ >- >- public TargetInputContext(PDEFormEditor editor, IEditorInput input, boolean primary) { >- super(editor, input, primary); >- create(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.context.InputContext#getId() >- */ >- public String getId() { >- return CONTEXT_ID; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.context.InputContext#createModel(org.eclipse.ui.IEditorInput) >- */ >- protected IBaseModel createModel(IEditorInput input) throws CoreException { >- ITargetModel model = null; >- if (input instanceof IStorageEditorInput) { >- try { >- if (input instanceof IFileEditorInput) { >- IFile file = ((IFileEditorInput) input).getFile(); >- model = new WorkspaceTargetModel(file, true); >- model.load(); >- } else if (input instanceof IStorageEditorInput) { >- InputStream is = new BufferedInputStream(((IStorageEditorInput) input).getStorage().getContents()); >- model = new TargetModel(); >- model.load(is, false); >- } >- } catch (CoreException e) { >- PDEPlugin.logException(e); >- return null; >- } >- } >- return model; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.context.InputContext#addTextEditOperation(java.util.ArrayList, org.eclipse.pde.core.IModelChangedEvent) >- */ >- protected void addTextEditOperation(ArrayList ops, IModelChangedEvent event) { >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.context.InputContext#flushModel(org.eclipse.jface.text.IDocument) >- */ >- protected void flushModel(IDocument doc) { >- if (!(getModel() instanceof IEditable)) >- return; >- IEditable editableModel = (IEditable) getModel(); >- if (editableModel.isDirty() == false) >- return; >- try { >- StringWriter swriter = new StringWriter(); >- PrintWriter writer = new PrintWriter(swriter); >- editableModel.save(writer); >- writer.flush(); >- swriter.close(); >- doc.set(swriter.toString()); >- } catch (IOException e) { >- PDEPlugin.logException(e); >- } >- } >- >- protected String getPartitionName() { >- return "___target_partition"; //$NON-NLS-1$ >- } >- >-} >Index: src/org/eclipse/pde/internal/ui/editor/target/TargetOutlinePage.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/target/TargetOutlinePage.java >diff -N src/org/eclipse/pde/internal/ui/editor/target/TargetOutlinePage.java >--- src/org/eclipse/pde/internal/ui/editor/target/TargetOutlinePage.java 30 Nov 2008 21:18:58 -0000 1.12 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,109 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import org.eclipse.jface.viewers.ILabelProvider; >-import org.eclipse.pde.core.IModelChangedEvent; >-import org.eclipse.pde.internal.core.itarget.*; >-import org.eclipse.pde.internal.ui.*; >-import org.eclipse.pde.internal.ui.editor.FormOutlinePage; >-import org.eclipse.pde.internal.ui.editor.PDEFormEditor; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.ui.forms.editor.FormPage; >- >-public class TargetOutlinePage extends FormOutlinePage { >- >- public class TargetContentNode { >- >- private ITarget fTarget; >- private boolean fFeatureBased = false; >- >- public String toString() { >- return fFeatureBased ? PDEUIMessages.TargetOutlinePage_features : PDEUIMessages.TargetOutlinePage_plugins; >- } >- >- public TargetContentNode(ITarget target, boolean featureBased) { >- fTarget = target; >- fFeatureBased = featureBased; >- } >- >- public ITargetObject[] getModels() { >- if (fTarget.useAllPlugins()) >- return new ITargetObject[0]; >- if (fFeatureBased) >- return fTarget.getFeatures(); >- return fTarget.getPlugins(); >- } >- >- public boolean isFeatureBased() { >- return fFeatureBased; >- } >- >- } >- >- private TargetContentNode pNode; >- private TargetContentNode fNode; >- >- public TargetOutlinePage(PDEFormEditor editor) { >- super(editor); >- } >- >- public void modelChanged(IModelChangedEvent event) { >- if (ITarget.P_ALL_PLUGINS.equals(event.getChangedProperty()) || event.getChangeType() == IModelChangedEvent.WORLD_CHANGED) { >- super.modelChanged(event); >- return; >- } >- >- if (event.getChangeType() == IModelChangedEvent.INSERT || event.getChangeType() == IModelChangedEvent.REMOVE) { >- Object object = event.getChangedObjects()[0]; >- if (object instanceof ITargetPlugin) >- getTreeViewer().refresh(pNode); >- else >- getTreeViewer().refresh(fNode); >- return; >- } >- } >- >- protected Object[] getChildren(Object parent) { >- if (parent instanceof ContentPage) { >- ContentPage page = (ContentPage) parent; >- ITarget target = ((ITargetModel) page.getModel()).getTarget(); >- if (target.useAllPlugins()) >- return new Object[0]; >- >- if (pNode == null) >- pNode = new TargetContentNode(target, false); >- if (fNode == null) >- fNode = new TargetContentNode(target, true); >- return new Object[] {pNode, fNode}; >- } >- if (parent instanceof TargetContentNode) >- return ((TargetContentNode) parent).getModels(); >- return new Object[0]; >- } >- >- public ILabelProvider createLabelProvider() { >- return new BasicLabelProvider(PDEPlugin.getDefault().getLabelProvider()) { >- public Image getImage(Object element) { >- PDELabelProvider provider = PDEPlugin.getDefault().getLabelProvider(); >- if (element instanceof TargetContentNode) { >- if (((TargetContentNode) element).isFeatureBased()) >- return provider.get(PDEPluginImages.DESC_FEATURE_OBJ); >- return provider.get(PDEPluginImages.DESC_PLUGIN_OBJ); >- } >- if (element instanceof FormPage) >- return super.getImage(element); >- return provider.getImage(element); >- } >- }; >- } >- >-} >Index: src/org/eclipse/pde/internal/ui/editor/target/TargetEditor.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/target/TargetEditor.java,v >retrieving revision 1.15 >diff -u -r1.15 TargetEditor.java >--- src/org/eclipse/pde/internal/ui/editor/target/TargetEditor.java 15 Dec 2008 22:28:44 -0000 1.15 >+++ src/org/eclipse/pde/internal/ui/editor/target/TargetEditor.java 13 Jan 2009 16:34:30 -0000 >@@ -1,264 +1,93 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ > package org.eclipse.pde.internal.ui.editor.target; > >-import java.io.File; >-import java.lang.reflect.InvocationTargetException; >-import java.net.URL; >-import org.eclipse.core.filesystem.EFS; >-import org.eclipse.core.filesystem.IFileStore; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.*; >-import org.eclipse.jface.action.ControlContribution; >-import org.eclipse.jface.action.IToolBarManager; >-import org.eclipse.jface.dialogs.*; >-import org.eclipse.jface.operation.IRunnableWithProgress; >-import org.eclipse.osgi.service.datalocation.Location; >-import org.eclipse.pde.internal.core.LoadTargetOperation; >-import org.eclipse.pde.internal.core.itarget.ITarget; >-import org.eclipse.pde.internal.core.itarget.ITargetModel; >-import org.eclipse.pde.internal.ui.*; >-import org.eclipse.pde.internal.ui.editor.ISortableContentOutlinePage; >-import org.eclipse.pde.internal.ui.editor.PDEFormEditor; >-import org.eclipse.pde.internal.ui.editor.context.InputContext; >-import org.eclipse.pde.internal.ui.editor.context.InputContextManager; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.pde.internal.core.PDECore; >+import org.eclipse.pde.internal.core.target.provisional.*; >+import org.eclipse.pde.internal.ui.PDEPlugin; >+import org.eclipse.swt.widgets.Display; > import org.eclipse.ui.*; >-import org.eclipse.ui.forms.events.HyperlinkEvent; >-import org.eclipse.ui.forms.events.IHyperlinkListener; >-import org.eclipse.ui.forms.widgets.ImageHyperlink; >-import org.eclipse.ui.ide.FileStoreEditorInput; >-import org.eclipse.ui.progress.IProgressService; >- >-public class TargetEditor extends PDEFormEditor { >- >- protected static String LAST_PATH; >- >- static { >- Location installLoc = Platform.getInstallLocation(); >- if (installLoc == null) { >- LAST_PATH = ""; //$NON-NLS-1$ >- } >- URL url = installLoc.getURL(); >- LAST_PATH = new Path(url.getPath()).toOSString(); >- } >- >- public TargetEditor() { >- super(); >- } >+import org.eclipse.ui.forms.editor.FormEditor; >+import org.eclipse.ui.forms.widgets.FormToolkit; > >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getEditorID() >- */ >- protected String getEditorID() { >- return IPDEUIConstants.TARGET_EDITOR_ID; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#isSaveAsAllowed() >- */ >- public boolean isSaveAsAllowed() { >- return true; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getContextIDForSaveAs() >- */ >- public String getContextIDForSaveAs() { >- return TargetInputContext.CONTEXT_ID; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createInputContextManager() >- */ >- protected InputContextManager createInputContextManager() { >- return new TargetInputContextManager(this); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createResourceContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.ui.IFileEditorInput) >- */ >- protected void createResourceContexts(InputContextManager manager, IFileEditorInput input) { >- manager.putContext(input, new TargetInputContext(this, input, true)); >- manager.monitorFile(input.getFile()); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createSystemFileContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.pde.internal.ui.editor.SystemFileEditorInput) >- */ >- protected void createSystemFileContexts(InputContextManager manager, FileStoreEditorInput input) { >- File file = (File) input.getAdapter(File.class); >- if (file != null) { >- String name = file.getName(); >- if (name.endsWith(".target")) { //$NON-NLS-1$ >- IFileStore store; >- try { >- store = EFS.getStore(file.toURI()); >- IEditorInput in = new FileStoreEditorInput(store); >- manager.putContext(in, new TargetInputContext(this, in, true)); >- } catch (CoreException e) { >- PDEPlugin.logException(e); >- } >- } >- } >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createStorageContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.ui.IStorageEditorInput) >- */ >- protected void createStorageContexts(InputContextManager manager, IStorageEditorInput input) { >- if (input.getName().endsWith(".target")) { //$NON-NLS-1$ >- manager.putContext(input, new TargetInputContext(this, input, true)); >- } >- } >+public class TargetEditor extends FormEditor { > >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createContentOutline() >- */ >- protected ISortableContentOutlinePage createContentOutline() { >- return new TargetOutlinePage(this); >- } >+ private ITargetDefinition fInput; > >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getInputContext(java.lang.Object) >- */ >- protected InputContext getInputContext(Object object) { >- return fInputContextManager.findContext(TargetInputContext.CONTEXT_ID); >+ protected FormToolkit createToolkit(Display display) { >+ return new FormToolkit(PDEPlugin.getDefault().getFormColors(display)); > } > >- /* (non-Javadoc) >- * @see org.eclipse.ui.forms.editor.FormEditor#addPages() >- */ >- protected void addEditorPages() { >+ protected void addPages() { > try { > addPage(new OverviewPage(this)); >- addPage(new ContentPage(this)); > addPage(new EnvironmentPage(this)); >- addPageChangedListener(new IPageChangedListener() { >- >- public void pageChanged(PageChangedEvent event) { >- Object o = event.getSelectedPage(); >- if (o instanceof EnvironmentPage) >- ((EnvironmentPage) o).updateChoices(); >- } >- >- }); >+// addPageChangedListener(new IPageChangedListener() { >+// public void pageChanged(PageChangedEvent event) { >+// Object o = event.getSelectedPage(); >+// if (o instanceof EnvironmentPage) >+// ((EnvironmentPage) o).updateChoices(); >+// } >+// }); > } catch (PartInitException e) { > PDEPlugin.log(e); > } > } > >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#contextAdded(org.eclipse.pde.internal.ui.editor.context.InputContext) >- */ >- public void editorContextAdded(InputContext context) { >- } >+ public void doSave(IProgressMonitor monitor) { >+ // TODO Better error handling >+ commitPages(true); >+ ITargetDefinition target = getTarget(); >+ if (target != null) { >+ ITargetPlatformService service = (ITargetPlatformService) PDECore.getDefault().acquireService(ITargetPlatformService.class.getName()); >+ if (service != null) { >+ try { >+ service.saveTargetDefinition(target); >+ } catch (CoreException e) { >+ PDEPlugin.log(e); >+ } >+ } >+ } > >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#contextRemoved(org.eclipse.pde.internal.ui.editor.context.InputContext) >- */ >- public void contextRemoved(InputContext context) { >- close(false); >+ editorDirtyStateChanged(); > } > >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#monitoredFileAdded(org.eclipse.core.resources.IFile) >- */ >- public void monitoredFileAdded(IFile monitoredFile) { >+ public void doSaveAs() { >+ // TODO Auto-generated method stub > } > >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#monitoredFileRemoved(org.eclipse.core.resources.IFile) >- */ >- public boolean monitoredFileRemoved(IFile monitoredFile) { >+ public boolean isSaveAsAllowed() { > return true; > } > >- public void contributeToToolbar(IToolBarManager manager) { >- ControlContribution save = new ControlContribution("Set") { //$NON-NLS-1$ >- protected Control createControl(Composite parent) { >- final ImageHyperlink hyperlink = new ImageHyperlink(parent, SWT.NONE); >- hyperlink.setText(PDEUIMessages.AbstractTargetPage_setTarget); >- hyperlink.setUnderlined(true); >- hyperlink.setForeground(getToolkit().getHyperlinkGroup().getForeground()); >- hyperlink.addHyperlinkListener(new IHyperlinkListener() { >- public void linkActivated(HyperlinkEvent e) { >- doLoadTarget(); >- } >- >- public void linkEntered(HyperlinkEvent e) { >- hyperlink.setForeground(getToolkit().getHyperlinkGroup().getActiveForeground()); >+ public ITargetDefinition getTarget() { >+ // TODO Better error handling >+ if (fInput == null) { >+ ITargetPlatformService service = (ITargetPlatformService) PDECore.getDefault().acquireService(ITargetPlatformService.class.getName()); >+ if (service != null) { >+ IEditorInput input = getEditorInput(); >+ if (input instanceof IFileEditorInput) { >+ ITargetHandle fileHandle = service.getTarget(((IFileEditorInput) input).getFile()); >+ try { >+ fInput = fileHandle.getTargetDefinition(); >+ } catch (CoreException e) { >+ PDEPlugin.log(e); > } >- >- public void linkExited(HyperlinkEvent e) { >- hyperlink.setForeground(getToolkit().getHyperlinkGroup().getForeground()); >- } >- }); >- return hyperlink; >- } >- }; >- manager.add(save); >- } >- >- private void doLoadTarget() { >- IRunnableWithProgress run = new IRunnableWithProgress() { >- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >- try { >- ITargetModel model = getTargetModel(); >- if (!model.isLoaded()) { >- MessageDialog.openError(getActiveEditor().getSite().getShell(), PDEUIMessages.TargetPlatformPreferencePage_invalidTitle, PDEUIMessages.TargetPlatformPreferencePage_invalidDescription); >- monitor.done(); >- return; >- } >- LoadTargetOperation op = new LoadTargetOperation(getTarget(), getFilePath()); >- PDEPlugin.getWorkspace().run(op, monitor); >- Object[] features = op.getMissingFeatures(); >- Object[] plugins = op.getMissingPlugins(); >- if (plugins.length + features.length > 0) >- TargetErrorDialog.showDialog(getActiveEditor().getSite().getShell(), features, plugins); >- } catch (CoreException e) { >- throw new InvocationTargetException(e); >- } catch (OperationCanceledException e) { >- throw new InterruptedException(e.getMessage()); >- } finally { >- monitor.done(); > } >+ // TODO Support storage editor input? > } >- }; >- IProgressService service = PlatformUI.getWorkbench().getProgressService(); >- try { >- service.runInUI(service, run, PDEPlugin.getWorkspace().getRoot()); >- } catch (InvocationTargetException e) { >- } catch (InterruptedException e) { > } >+ return fInput; > } > >- private ITarget getTarget() { >- return getTargetModel().getTarget(); >+ public void init(IEditorSite site, IEditorInput input) throws PartInitException { >+ // TODO Auto-generated method stub >+ super.init(site, input); > } > >- private ITargetModel getTargetModel() { >- return ((ITargetModel) getAggregateModel()); >- } >- >- private IPath getFilePath() { >- IEditorInput input = getEditorInput(); >- if (input instanceof IFileEditorInput) { >- IFile file = ((IFileEditorInput) input).getFile(); >- if (file != null) >- return file.getFullPath(); >- } >- return null; >+ public boolean isDirty() { >+ // TODO Auto-generated method stub >+ return super.isDirty(); > } > >-} >\ No newline at end of file >+} >Index: src/org/eclipse/pde/internal/ui/editor/target/ArgumentsSection.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/target/ArgumentsSection.java,v >retrieving revision 1.8 >diff -u -r1.8 ArgumentsSection.java >--- src/org/eclipse/pde/internal/ui/editor/target/ArgumentsSection.java 16 Jan 2008 17:08:09 -0000 1.8 >+++ src/org/eclipse/pde/internal/ui/editor/target/ArgumentsSection.java 13 Jan 2009 16:34:29 -0000 >@@ -1,197 +1,159 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.target; >- >-import org.eclipse.debug.ui.StringVariableSelectionDialog; >-import org.eclipse.pde.core.IModelChangedEvent; >-import org.eclipse.pde.internal.core.itarget.*; >-import org.eclipse.pde.internal.ui.PDEPluginImages; >-import org.eclipse.pde.internal.ui.PDEUIMessages; >-import org.eclipse.pde.internal.ui.editor.*; >-import org.eclipse.pde.internal.ui.parts.FormEntry; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.CTabFolder; >-import org.eclipse.swt.custom.CTabItem; >-import org.eclipse.swt.dnd.Clipboard; >-import org.eclipse.swt.events.SelectionAdapter; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.widgets.*; >-import org.eclipse.ui.IActionBars; >-import org.eclipse.ui.forms.IFormColors; >-import org.eclipse.ui.forms.widgets.FormToolkit; >-import org.eclipse.ui.forms.widgets.Section; >- >-public class ArgumentsSection extends PDESection { >- >- private static final String[] TAB_LABELS = new String[2]; >- static { >- TAB_LABELS[0] = PDEUIMessages.ArgumentsSection_programTabLabel; >- TAB_LABELS[1] = PDEUIMessages.ArgumentsSection_vmTabLabel; >- } >- >- private CTabFolder fTabFolder; >- private FormEntry fArgument; >- private int fLastTab; >- private Image fImage; >- >- public ArgumentsSection(PDEFormPage page, Composite parent) { >- super(page, parent, Section.DESCRIPTION); >- fImage = PDEPluginImages.DESC_ARGUMENT_TAB.createImage(); >- createClient(getSection(), page.getEditor().getToolkit()); >- } >- >- protected void createClient(Section section, FormToolkit toolkit) { >- section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); >- section.setText(PDEUIMessages.ArgumentsSection_editorTitle); >- section.setDescription(PDEUIMessages.ArgumentsSection_description); >- GridData data = new GridData(GridData.FILL_BOTH); >- data.horizontalSpan = 1; >- section.setLayoutData(data); >- >- Composite client = toolkit.createComposite(section); >- client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1)); >- GridData gd = new GridData(GridData.FILL_BOTH); >- gd.widthHint = 100; >- client.setLayoutData(gd); >- >- fTabFolder = new CTabFolder(client, SWT.FLAT | SWT.TOP); >- toolkit.adapt(fTabFolder, true, true); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- fTabFolder.setLayoutData(gd); >- gd.heightHint = 2; >- toolkit.getColors().initializeSectionToolBarColors(); >- Color selectedColor = toolkit.getColors().getColor(IFormColors.TB_BG); >- fTabFolder.setSelectionBackground(new Color[] {selectedColor, toolkit.getColors().getBackground()}, new int[] {100}, true); >- fTabFolder.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (fArgument.isDirty()) >- fArgument.commit(); >- refresh(); >- } >- }); >- >- IActionBars actionBars = getPage().getPDEEditor().getEditorSite().getActionBars(); >- >- fArgument = new FormEntry(client, toolkit, PDEUIMessages.ArgumentsSection_argumentsTextLabel, SWT.MULTI | SWT.WRAP); >- fArgument.getText().setLayoutData(new GridData(GridData.FILL_BOTH)); >- fArgument.setFormEntryListener(new FormEntryAdapter(this, actionBars) { >- public void textValueChanged(FormEntry entry) { >- if (fLastTab == 0) >- getArgumentInfo().setProgramArguments(fArgument.getValue()); >- else >- getArgumentInfo().setVMArguments(fArgument.getValue()); >- } >- }); >- >- Button variables = toolkit.createButton(client, PDEUIMessages.ArgumentsSection_variableButtonTitle, SWT.NONE); >- variables.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); >- variables.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getSection().getShell()); >- dialog.open(); >- String variable = dialog.getVariableExpression(); >- if (variable != null) { >- fArgument.getText().insert(variable); >- } >- } >- }); >- >- createTabs(); >- toolkit.paintBordersFor(client); >- section.setClient(client); >- >- // Register to be notified when the model changes >- getModel().addModelChangedListener(this); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent) >- */ >- public void modelChanged(IModelChangedEvent e) { >- // No need to call super, handling world changed event here >- if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) { >- handleModelEventWorldChanged(e); >- } >- } >- >- /** >- * @param event >- */ >- private void handleModelEventWorldChanged(IModelChangedEvent event) { >- // Perform the refresh >- refresh(); >- } >- >- private void createTabs() { >- for (int i = 0; i < TAB_LABELS.length; i++) { >- CTabItem item = new CTabItem(fTabFolder, SWT.NULL); >- item.setText(TAB_LABELS[i]); >- item.setImage(fImage); >- } >- fLastTab = 0; >- fTabFolder.setSelection(fLastTab); >- } >- >- private IArgumentsInfo getArgumentInfo() { >- IArgumentsInfo info = getTarget().getArguments(); >- if (info == null) { >- info = getModel().getFactory().createArguments(); >- getTarget().setArguments(info); >- } >- return info; >- } >- >- private ITarget getTarget() { >- return getModel().getTarget(); >- } >- >- private ITargetModel getModel() { >- return (ITargetModel) getPage().getPDEEditor().getAggregateModel(); >- } >- >- public void refresh() { >- fLastTab = fTabFolder.getSelectionIndex(); >- if (fLastTab == 0) >- fArgument.setValue(getArgumentInfo().getProgramArguments(), true); >- else >- fArgument.setValue(getArgumentInfo().getVMArguments(), true); >- super.refresh(); >- } >- >- public void commit(boolean onSave) { >- fArgument.commit(); >- super.commit(onSave); >- } >- >- public void cancelEdit() { >- fArgument.cancelEdit(); >- super.cancelEdit(); >- } >- >- public boolean canPaste(Clipboard clipboard) { >- Display d = getSection().getDisplay(); >- return d.getFocusControl() instanceof Text; >- } >- >- public void dispose() { >- ITargetModel model = getModel(); >- if (model != null) { >- model.removeModelChangedListener(this); >- } >- if (fImage != null) >- fImage.dispose(); >- super.dispose(); >- } >- >-} >+/******************************************************************************* >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.target; >+ >+import org.eclipse.pde.internal.ui.editor.target.TargetEditor; >+import org.eclipse.pde.internal.ui.editor.target.TargetFormEntryAdapter; >+ >+import org.eclipse.debug.ui.StringVariableSelectionDialog; >+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+import org.eclipse.pde.internal.ui.PDEPluginImages; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+import org.eclipse.pde.internal.ui.parts.FormEntry; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.CTabFolder; >+import org.eclipse.swt.custom.CTabItem; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.forms.IFormColors; >+import org.eclipse.ui.forms.SectionPart; >+import org.eclipse.ui.forms.editor.FormPage; >+import org.eclipse.ui.forms.widgets.*; >+ >+public class ArgumentsSection extends SectionPart { >+ >+ private CTabFolder fTabFolder; >+ private FormEntry fProgramArguments; >+ private FormEntry fVMArguments; >+ private Image fImage; >+ private TargetEditor fEditor; >+ >+ public ArgumentsSection(FormPage page, Composite parent) { >+ super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR); >+ fEditor = (TargetEditor) page.getEditor(); >+ fImage = PDEPluginImages.DESC_ARGUMENT_TAB.createImage(); >+ createClient(getSection(), page.getEditor().getToolkit()); >+ } >+ >+ private ITargetDefinition getTarget() { >+ return fEditor.getTarget(); >+ } >+ >+ protected void createClient(Section section, FormToolkit toolkit) { >+ section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); >+ section.setText(PDEUIMessages.ArgumentsSection_editorTitle); >+ section.setDescription(PDEUIMessages.ArgumentsSection_description); >+ GridData data = new GridData(GridData.FILL_BOTH); >+ data.horizontalSpan = 1; >+ section.setLayoutData(data); >+ >+ Composite client = toolkit.createComposite(section); >+ client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1)); >+ GridData gd = new GridData(GridData.FILL_BOTH); >+ gd.widthHint = 100; >+ client.setLayoutData(gd); >+ >+ fTabFolder = new CTabFolder(client, SWT.FLAT | SWT.TOP); >+ toolkit.adapt(fTabFolder, true, true); >+ gd = new GridData(GridData.FILL_BOTH); >+ fTabFolder.setLayoutData(gd); >+ toolkit.getColors().initializeSectionToolBarColors(); >+ Color selectedColor = toolkit.getColors().getColor(IFormColors.TB_BG); >+ fTabFolder.setSelectionBackground(new Color[] {selectedColor, toolkit.getColors().getBackground()}, new int[] {100}, true); >+ >+ Composite programComp = toolkit.createComposite(fTabFolder); >+ programComp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1)); >+ programComp.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ fProgramArguments = new FormEntry(programComp, toolkit, "Program Arguments:", SWT.MULTI | SWT.WRAP); >+ fProgramArguments.getText().setLayoutData(new GridData(GridData.FILL_BOTH)); >+ fProgramArguments.setFormEntryListener(new TargetFormEntryAdapter(this) { >+ public void textValueChanged(FormEntry entry) { >+ getTarget().setProgramArguments(entry.getValue()); >+ } >+ }); >+ Button variables = toolkit.createButton(programComp, PDEUIMessages.ArgumentsSection_variableButtonTitle, SWT.NONE); >+ variables.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); >+ variables.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getSection().getShell()); >+ dialog.open(); >+ String variable = dialog.getVariableExpression(); >+ if (variable != null) { >+ fProgramArguments.getText().insert(variable); >+ } >+ } >+ }); >+ CTabItem programTab = new CTabItem(fTabFolder, SWT.NULL); >+ programTab.setText(PDEUIMessages.ArgumentsSection_programTabLabel); >+ programTab.setImage(fImage); >+ programTab.setControl(programComp); >+ toolkit.paintBordersFor(programComp); >+ >+ // TODO Could be done neatly in a method >+ Composite vmComp = toolkit.createComposite(fTabFolder); >+ vmComp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1)); >+ vmComp.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ fVMArguments = new FormEntry(vmComp, toolkit, "VM Arguments:", SWT.MULTI | SWT.WRAP); >+ fVMArguments.getText().setLayoutData(new GridData(GridData.FILL_BOTH)); >+ fVMArguments.setFormEntryListener(new TargetFormEntryAdapter(this) { >+ public void textValueChanged(FormEntry entry) { >+ getTarget().setProgramArguments(entry.getValue()); >+ } >+ }); >+ variables = toolkit.createButton(vmComp, PDEUIMessages.ArgumentsSection_variableButtonTitle, SWT.NONE); >+ variables.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); >+ variables.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getSection().getShell()); >+ dialog.open(); >+ String variable = dialog.getVariableExpression(); >+ if (variable != null) { >+ fVMArguments.getText().insert(variable); >+ } >+ } >+ }); >+ CTabItem vmTab = new CTabItem(fTabFolder, SWT.NULL); >+ vmTab.setText(PDEUIMessages.ArgumentsSection_vmTabLabel); >+ vmTab.setImage(fImage); >+ vmTab.setControl(vmComp); >+ toolkit.paintBordersFor(vmComp); >+ >+ fTabFolder.setSelection(programTab); >+ >+ toolkit.paintBordersFor(client); >+ section.setClient(client); >+ } >+ >+ public void refresh() { >+ fProgramArguments.setValue(getTarget().getProgramArguments(), true); >+ fVMArguments.setValue(getTarget().getVMArguments(), true); >+ super.refresh(); >+ } >+ >+ public void commit(boolean onSave) { >+ fProgramArguments.commit(); >+ fVMArguments.commit(); >+ super.commit(onSave); >+ } >+ >+ public void dispose() { >+ if (fImage != null) >+ fImage.dispose(); >+ super.dispose(); >+ } >+ >+} >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.69 >diff -u -r1.69 MANIFEST.MF >--- META-INF/MANIFEST.MF 15 Dec 2008 02:19:31 -0000 1.69 >+++ META-INF/MANIFEST.MF 13 Jan 2009 16:34:29 -0000 >@@ -98,7 +98,8 @@ > org.eclipse.equinox.p2.core;bundle-version="[1.0.0,2.0.0)", > org.eclipse.equinox.p2.director;bundle-version="[1.0.100,2.0.0)", > org.eclipse.equinox.p2.artifact.repository;bundle-version="[1.0.100,2.0.0)", >- org.eclipse.equinox.p2.metadata.repository;bundle-version="[1.0.100,2.0.0)" >+ org.eclipse.equinox.p2.metadata.repository;bundle-version="[1.0.100,2.0.0)", >+ org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)" > Eclipse-LazyStart: true > Import-Package: com.ibm.icu.text, > org.eclipse.jdt.debug.core >Index: src/org/eclipse/pde/internal/ui/editor/target/TargetContentTable.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/target/TargetContentTable.java >diff -N src/org/eclipse/pde/internal/ui/editor/target/TargetContentTable.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/target/TargetContentTable.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,132 @@ >+package org.eclipse.pde.internal.ui.editor.target; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.jface.viewers.*; >+import org.eclipse.pde.internal.core.target.provisional.IBundleContainer; >+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+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.Tree; >+import org.eclipse.ui.forms.widgets.FormToolkit; >+ >+public class TargetContentTable { >+ >+ private TreeViewer fTreeViewer; >+ >+// private Button fAddButton; >+ >+ public static TargetContentTable createTableInForm(Composite parent, FormToolkit toolkit) { >+ TargetContentTable contentTable = new TargetContentTable(); >+ contentTable.createFormContents(parent, toolkit); >+ return contentTable; >+ } >+ >+ public static TargetContentTable createTableInDialog(Composite parent) { >+ TargetContentTable contentTable = new TargetContentTable(); >+ contentTable.createDialogContents(parent); >+ return contentTable; >+ } >+ >+ private TargetContentTable() { >+ } >+ >+ private void createFormContents(Composite parent, FormToolkit toolkit) { >+ Composite comp = toolkit.createComposite(parent); >+ comp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2)); >+ comp.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL)); >+ >+ Tree atree = toolkit.createTree(comp, SWT.V_SCROLL | SWT.H_SCROLL); >+ atree.setLayout(new GridLayout()); >+ GridData gd = new GridData(GridData.FILL_BOTH); >+// gd.widthHint = 400; >+// gd.heightHint = 400; >+ atree.setLayoutData(gd); >+ initializeTreeViewer(atree); >+ >+ /*fAddButton = */toolkit.createButton(comp, "Add...", SWT.PUSH); >+ toolkit.paintBordersFor(comp); >+ >+// section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1)); >+// Composite client = toolkit.createComposite(section); >+// client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2)); >+// client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL)); >+// >+// createViewerPartControl(client, SWT.MULTI, 2, toolkit); >+// >+// TablePart tablePart = getTablePart(); >+// GridData data = (GridData) tablePart.getControl().getLayoutData(); >+// data.grabExcessVerticalSpace = true; >+// data.grabExcessHorizontalSpace = true; >+// fContentViewer = tablePart.getTableViewer(); >+// fContentViewer.setContentProvider(new ContentProvider()); >+// fContentViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); >+// fContentViewer.setInput(getTarget()); >+ >+ } >+ >+ private void createDialogContents(Composite parent) { >+ // TODO Auto-generated method stub >+ } >+ >+ private void initializeTreeViewer(Tree aTree) { >+ fTreeViewer = new TreeViewer(aTree); >+ fTreeViewer.setContentProvider(new TargetContentProvider()); >+ >+ } >+ >+ private class TargetContentProvider implements ITreeContentProvider { >+ >+ public Object[] getChildren(Object parentElement) { >+ if (parentElement instanceof IBundleContainer) { >+ try { >+ return ((IBundleContainer) parentElement).resolveBundles(new NullProgressMonitor()); >+ } catch (CoreException e) { >+ return new String[] {"Error getting bundle list!"}; >+ } >+ } >+ >+ if (parentElement instanceof String && "Test1".equals(parentElement)) { >+ return new String[] {"A", "B", "C"}; >+ } >+ return null; >+ } >+ >+ public Object getParent(Object element) { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public boolean hasChildren(Object element) { >+ if (element instanceof IBundleContainer) { >+ return true; >+ } >+ return element instanceof String && "Test1".equals(element); >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ return new String[] {"Test1", "Test2", "Test3"}; >+ } >+ >+ public void dispose() { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ } >+ >+ public void setInput(ITargetDefinition target) { >+ if (fTreeViewer != null) { >+ fTreeViewer.setInput(target.getBundleContainers()); >+ } >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/target/TargetFormEntryAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/target/TargetFormEntryAdapter.java >diff -N src/org/eclipse/pde/internal/ui/editor/target/TargetFormEntryAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/target/TargetFormEntryAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+package org.eclipse.pde.internal.ui.editor.target; >+ >+import org.eclipse.pde.internal.ui.parts.FormEntry; >+import org.eclipse.pde.internal.ui.parts.IFormEntryListener; >+import org.eclipse.ui.forms.AbstractFormPart; >+import org.eclipse.ui.forms.events.HyperlinkEvent; >+ >+public class TargetFormEntryAdapter implements IFormEntryListener { >+ >+ private AbstractFormPart fFormPart; >+ >+ public TargetFormEntryAdapter(AbstractFormPart formPart) { >+ fFormPart = formPart; >+ } >+ >+ public void browseButtonSelected(FormEntry entry) { >+ } >+ >+ public void focusGained(FormEntry entry) { >+ } >+ >+ public void selectionChanged(FormEntry entry) { >+ } >+ >+ public void textDirty(FormEntry entry) { >+ fFormPart.markDirty(); >+ } >+ >+ public void textValueChanged(FormEntry entry) { >+ } >+ >+ public void linkActivated(HyperlinkEvent e) { >+ } >+ >+ public void linkEntered(HyperlinkEvent e) { >+ } >+ >+ public void linkExited(HyperlinkEvent e) { >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 256910
:
119021
|
119023
|
119050
|
119547
|
120975
|
120980
|
121558
|
121570
|
122001
|
122175
| 122423 |
122424
|
122437
|
122498
|
122768
|
122847
|
122848
|
122849
|
122885
|
122887
|
123013
|
123025
|
123285
|
123446
|
123596
|
123639
|
123770
|
123771