* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
public class PHPDegugCorePluginImages {
private final static URL BASE_URL =
- PHPDebugCorePlugin.getDefault().getDescriptor().getInstallURL();
+ PHPDebugCorePlugin.getDefault().getBundle().getEntry("/");
+
private final static ImageRegistry PLUGIN_REGISTRY =
PHPDebugCorePlugin.getDefault().getImageRegistry();
create(PATH_LCL, "restore_log.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_READ_LOG_DISABLED =
create(PATH_LCL_DISABLED, "restore_log.gif"); //$NON-NLS-1$
-
+
public static final ImageDescriptor DESC_REMOVE_LOG =
create(PATH_LCL, "remove.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_REMOVE_LOG_DISABLED =
create(PATH_LCL_DISABLED, "remove.gif"); //$NON-NLS-1$
-
+
public static final ImageDescriptor DESC_FILTER =
create(PATH_LCL, "filter_ps.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_FILTER_DISABLED =
create(PATH_LCL, "export_log.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_EXPORT_DISABLED =
create(PATH_LCL_DISABLED, "export_log.gif"); //$NON-NLS-1$
-
+
public static final ImageDescriptor DESC_IMPORT =
create(PATH_LCL, "import_log.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_IMPORT_DISABLED =
create(PATH_LCL_DISABLED, "import_log.gif"); //$NON-NLS-1$
-
+
public static final ImageDescriptor DESC_COLLAPSE_ALL =
create(PATH_LCL, "collapseall.gif"); //$NON-NLS-1$
-
+
public static final ImageDescriptor DESC_HORIZONTAL_VIEW =
create(PATH_LCL, "th_horizontal.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_HORIZONTAL_VIEW_DISABLED =
+
+ public static final ImageDescriptor DESC_HORIZONTAL_VIEW_DISABLED =
create(PATH_LCL_DISABLED, "th_horizontal.gif"); //$NON-NLS-1$
-
+
public static final ImageDescriptor DESC_VERTICAL_VIEW =
create(PATH_LCL, "th_vertical.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_VERTICAL_VIEW_DISABLED =
+
+ public static final ImageDescriptor DESC_VERTICAL_VIEW_DISABLED =
create(PATH_LCL_DISABLED, "th_vertical.gif"); //$NON-NLS-1$
-
+
public static final ImageDescriptor DESC_HIDE_PANE =
create(PATH_EVENTS, "hide_pane.gif"); //$NON-NLS-1$
-
+
/*
* Event Details
*/
public static final ImageDescriptor DESC_PREV_EVENT =
create(PATH_EVENTS, "event_prev.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_NEXT_EVENT =
+ public static final ImageDescriptor DESC_NEXT_EVENT =
create(PATH_EVENTS, "event_next.gif"); //$NON-NLS-1$
/*
* Overlays
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import net.sourceforge.phpdt.debug.core.PHPDebugModel;
import net.sourceforge.phpdt.internal.debug.core.breakpoints.PHPLineBreakpoint;
import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiPlugin;
-import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
-
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.internal.ui.actions.ActionMessages;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
/**
* Toggles a line breakpoint in a Java editor.
- *
+ *
* @since 3.0
*/
public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
-
+
protected void report(String message, IWorkbenchPart part) {
IEditorStatusLine statusLine= (IEditorStatusLine) part.getAdapter(IEditorStatusLine.class);
if (statusLine != null) {
} else {
statusLine.setMessage(true, null, null);
}
- }
+ }
if (message != null && PHPDebugUiPlugin.getActiveWorkbenchShell() != null) {
PHPDebugUiPlugin.getActiveWorkbenchShell().getDisplay().beep();
}
}
-
+
// protected IType getType(ITextSelection selection) {
// IMember member= ActionDelegateHelper.getDefault().getCurrentMember(selection);
// IType type= null;
// PHPDebugUiPlugin.log(e);
// }
// return type;
-// }
-
+// }
+
/* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(IWorkbenchPart, ISelection)
*/
// }
// }
// }
-
+
// String typeName= null;
IResource resource;
PHPLineBreakpoint breakpoint= null;
}
// } else {
// typeName= type.getFullyQualifiedName();
-// PHPLineBreakpoint breakpoint=PHPDebugModel.lineBreakpointExists(lineNumber);
-// if (breakpoint==null)
+// PHPLineBreakpoint breakpoint=PHPDebugModel.lineBreakpointExists(lineNumber);
+// if (breakpoint==null)
// PHPDebugModel.createLineBreakpoint(getFile(), lineNumber, 0, true, null);
// else
-// DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
-//
+// DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
+//
PHPLineBreakpoint existingBreakpoint= PHPDebugModel.lineBreakpointExists(lineNumber); //typeName, lineNumber);
if (existingBreakpoint != null) {
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(existingBreakpoint, true);
// }
return false;
}
-
+
protected IMethod[] getMethods(IStructuredSelection selection) {
if (selection.isEmpty()) {
return new IMethod[0];
while (iterator.hasNext()) {
Object thing = iterator.next();
try {
- if (thing instanceof IMethod && !Flags.isAbstract(((IMethod)thing).getFlags())) {
+ if (thing instanceof IMethod && !Flags.isAbstract(((IMethod)thing).getFlags())) {
methods.add(thing);
}
} catch (JavaModelException e) {
return (IMethod[]) methods.toArray(new IMethod[methods.size()]);
}
}
-
+
// protected IField[] getFields(IStructuredSelection selection) {
// if (selection.isEmpty()) {
// return new IField[0];
// Iterator iterator = selection.iterator();
// while (iterator.hasNext()) {
// Object thing = iterator.next();
-// if (thing instanceof IField) {
+// if (thing instanceof IField) {
// fields.add(thing);
// } else if (thing instanceof IJavaFieldVariable) {
// IField field= getField((IJavaFieldVariable) thing);
// }
// return (IField[]) fields.toArray(new IField[fields.size()]);
// }
-// }
+// }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
// }
// }
}
-
+
public static String resolveMethodSignature(IType type, String methodSignature) throws JavaModelException {
String[] parameterTypes= Signature.getParameterTypes(methodSignature);
int length= length= parameterTypes.length;
String[] resolvedParameterTypes= new String[length];
-
+
for (int i = 0; i < length; i++) {
resolvedParameterTypes[i]= resolveType(type, parameterTypes[i]);
if (resolvedParameterTypes[i] == null) {
return null;
}
}
-
+
String resolvedReturnType= resolveType(type, Signature.getReturnType(methodSignature));
if (resolvedReturnType == null) {
return null;
}
-
+
return Signature.createMethodSignature(resolvedParameterTypes, resolvedReturnType);
}
-
+
private static String resolveType(IType type, String typeSignature) throws JavaModelException {
// int count= Signature.getArrayCount(typeSignature);
// String elementTypeSignature= Signature.getElementType(typeSignature);
// String resolvedElementTypeSignature= Signature.createTypeSignature(resolvedElementTypeName, true).replace('.', '/');
// return Signature.createArraySignature(resolvedElementTypeSignature, count);
return "";
- }
-
+ }
+
protected static IResource getResource(IEditorPart editor) {
IResource resource;
IEditorInput editorInput = editor.getEditorInput();
}
return resource;
}
-
+
/**
* Returns a handle to the specified method or <code>null</code> if none.
- *
+ *
* @param editorPart the editor containing the method
* @param typeName
* @param methodName
}
return null;
}
-
+
// protected IJavaBreakpoint getBreakpoint(IMember element) {
// IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
// IBreakpoint[] breakpoints= breakpointManager.getBreakpoints(JDIDebugModel.getPluginIdentifier());
// JDIDebugUIPlugin.log(e);
// }
// }
-// }
+// }
// }
// return null;
// }
// return (breakpointField.getElementName().equals(watchpoint.getFieldName()) &&
// breakpointField.getDeclaringType().getFullyQualifiedName().equals(watchpoint.getTypeName()));
// }
-//
+//
// protected CompilationUnit parseCompilationUnit(ITextEditor editor) {
// IEditorInput editorInput = editor.getEditorInput();
// IDocument document= editor.getDocumentProvider().getDocument(editorInput);
// parser.setSource(document.get().toCharArray());
// return (CompilationUnit) parser.createAST(null);
// }
-
+
/* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
// }
return false;
}
-
+
/**
* Returns a selection of the member in the given text selection,
* or the original selection if none.
- *
+ *
* @param part
* @param selection
* @return a structured selection of the member in the given text selection,
// }
/**
- * Returns a list of matching types (IType - Java model) that correspond to the
+ * Returns a list of matching types (IType - Java model) that correspond to the
* declaring type (ReferenceType - JDI model) of the given variable.
*/
// protected static List searchForDeclaringType(IJavaFieldVariable variable) {
// if (launch == null) {
// return types;
// }
-//
+//
// ILaunchConfiguration configuration= launch.getLaunchConfiguration();
// IJavaProject[] javaProjects = null;
// IWorkspace workspace= ResourcesPlugin.getWorkspace();
// ArrayList typeRefsFound= new ArrayList(3);
// ITypeNameRequestor requestor= new TypeInfoRequestor(typeRefsFound);
// try {
-// engine.searchAllTypeNames(
-// getPackage(declaringType),
-// getTypeName(declaringType),
-// SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
-// IJavaSearchConstants.CLASS,
-// scope,
-// requestor,
+// engine.searchAllTypeNames(
+// getPackage(declaringType),
+// getTypeName(declaringType),
+// SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
+// IJavaSearchConstants.CLASS,
+// scope,
+// requestor,
// IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
// null);
// } catch (JavaModelException x) {
// }
// return types;
// }
-
+
/**
* Returns the package name of the given fully qualified type name.
- * The package name is assumed to be the dot-separated prefix of the
+ * The package name is assumed to be the dot-separated prefix of the
* type name.
*/
// protected static char[] getPackage(String fullyQualifiedName) {
// }
// return fullyQualifiedName.substring(0, index).toCharArray();
// }
-//
+//
// /**
// * Returns a simple type name from the given fully qualified type name.
-// * The type name is assumed to be the last contiguous segment of the
+// * The type name is assumed to be the last contiguous segment of the
// * fullyQualifiedName not containing a '.' or '$'
// */
// protected static char[] getTypeName(String fullyQualifiedName) {
// }
// return typeName.toCharArray();
// }
-//
+//
// /**
// * Return the associated IField (Java model) for the given
// * IJavaFieldVariable (JDI model)
// }
// }
// return null;
-// }
+// }
}
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ListSelectionDialog;
-import org.eclipse.ui.help.WorkbenchHelp;
/**
* @author Christian
protected Button appendEnvironment;
protected Button replaceEnvironment;
protected Button envSelectButton;
-
+
/**
* Content provider for the environment table
*/
}
}
}
-
+
/**
* Label provider for the environment table
*/
// Create main composite
Composite mainComposite = new Composite(parent, SWT.NONE);
setControl(mainComposite);
- WorkbenchHelp.setHelp(getControl(), IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ENVIRONMENT_TAB);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ENVIRONMENT_TAB);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
mainComposite.setLayout(layout);
mainComposite.setLayoutData(gridData);
mainComposite.setFont(parent.getFont());
-
+
createEnvironmentTable(mainComposite);
createTableButtons(mainComposite);
createAppendReplace(mainComposite);
-
+
Dialog.applyDialogFont(mainComposite);
}
-
+
/**
* Creates and configures the widgets which allow the user to
* choose whether the specified environment should be appended
appendReplaceComposite.setLayoutData(gridData);
appendReplaceComposite.setLayout(layout);
appendReplaceComposite.setFont(parent.getFont());
-
+
appendEnvironment= createRadioButton(appendReplaceComposite, LaunchConfigurationsMessages.EnvironmentTab_16); //$NON-NLS-1$
appendEnvironment.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
});
replaceEnvironment= createRadioButton(appendReplaceComposite, LaunchConfigurationsMessages.EnvironmentTab_17); //$NON-NLS-1$
}
-
+
/**
* Updates the enablement of the append/replace widgets. The
* widgets should disable when there are no environment variables specified.
appendEnvironment.setEnabled(enable);
replaceEnvironment.setEnabled(enable);
}
-
+
/**
* Creates and configures the table that displayed the key/value
* pairs that comprise the environment.
tc.setText(envTableColumnHeaders[i]);
}
}
-
+
/**
* Responds to a selection changed event in the environment table
* @param event the selection change event
envEditButton.setEnabled(size == 1);
envRemoveButton.setEnabled(size > 0);
}
-
+
/**
* Creates the add/edit/remove buttons for the environment table
* @param parent the composite in which the buttons should be created
handleEnvAddCGIButtonSelected();
}
});
-
+
envSelectButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.EnvironmentTab_18, null); //$NON-NLS-1$
envSelectButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
});
envRemoveButton.setEnabled(false);
}
-
+
/**
* Adds a new environment variable to the table.
*/
MultipleInputDialog dialog = new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.EnvironmentTab_22); //$NON-NLS-1$
dialog.addTextField(NAME_LABEL, null, false);
dialog.addVariablesField(VALUE_LABEL, null, true);
-
+
if (dialog.open() != Window.OK) {
return;
}
-
+
String name = dialog.getStringValue(NAME_LABEL);
String value = dialog.getStringValue(VALUE_LABEL);
-
+
if (name != null && value != null && name.length() > 0 && value.length() >0) {
addVariable(new EnvironmentVariable(name.trim(), value.trim()));
updateAppendReplace();
}
}
-
+
/**
* Attempts to add the given variable. Returns whether the variable
* was added or not (as when the user answers not to overwrite an
updateLaunchConfigurationDialog();
return true;
}
-
+
/**
- * Displays a dialog that allows user to select native environment variables
+ * Displays a dialog that allows user to select native environment variables
* to add to the table.
*/
private void handleEnvSelectButtonSelected() {
EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
envVariables.remove(var.getName());
}
-
+
ListSelectionDialog dialog = new NativeEnvironmentDialog(getShell(), envVariables, createSelectionDialogContentProvider(), createSelectionDialogLabelProvider(), LaunchConfigurationsMessages.EnvironmentTab_19); //$NON-NLS-1$
dialog.setTitle(LaunchConfigurationsMessages.EnvironmentTab_20); //$NON-NLS-1$
-
+
int button = dialog.open();
if (button == Window.OK) {
- Object[] selected = dialog.getResult();
+ Object[] selected = dialog.getResult();
for (int i = 0; i < selected.length; i++) {
- environmentTable.add(selected[i]);
+ environmentTable.add(selected[i]);
}
}
-
+
updateAppendReplace();
updateLaunchConfigurationDialog();
}
-
+
/**
- * Displays a dialog that allows user to select native environment variables
+ * Displays a dialog that allows user to select native environment variables
* to add to the table.
*/
private void handleEnvAddCGIButtonSelected() {
Map envVariables = new HashMap();
-
+
envVariables.put("HTTP_COOKIE",new EnvironmentVariable("HTTP_COOKIE", "TestCookie=1"));
envVariables.put("REDIRECT_QUERY_STRING",new EnvironmentVariable("REDIRECT_QUERY_STRING", ""));
// envVariables.put("REQUEST_URI" + OSFilePath;
// envVariables.put("PATH_INFO=" + OSFilePath;
// envVariables.put("PATH_TRANSLATED=" + OSFilePath;
-
-
+
+
//get Environment Variables from the table
TableItem[] items = environmentTable.getTable().getItems();
for (int i = 0; i < items.length; i++) {
EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
envVariables.remove(var.getName());
}
-
+
ListSelectionDialog dialog = new NativeEnvironmentDialog(getShell(), envVariables, createSelectionDialogContentProvider(), createSelectionDialogLabelProvider(), LaunchConfigurationsMessages.EnvironmentTab_19); //$NON-NLS-1$
dialog.setTitle(LaunchConfigurationsMessages.EnvironmentTab_20); //$NON-NLS-1$
-
+
int button = dialog.open();
if (button == Window.OK) {
- Object[] selected = dialog.getResult();
+ Object[] selected = dialog.getResult();
for (int i = 0; i < selected.length; i++) {
- environmentTable.add(selected[i]);
+ environmentTable.add(selected[i]);
}
}
-
+
updateAppendReplace();
updateLaunchConfigurationDialog();
}
return false;
}
public void removeListener(ILabelProviderListener listener) {
- }
+ }
};
}
String s2 = (String)o2;
return s1.compareTo(s2);
}
-
+
};
TreeMap envVars = new TreeMap(comparator);
envVars.putAll((Map)inputElement);
}
return elements;
}
- public void dispose() {
+ public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
MultipleInputDialog dialog= new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.EnvironmentTab_11); //$NON-NLS-1$
dialog.addTextField(NAME_LABEL, originalName, false);
dialog.addVariablesField(VALUE_LABEL, value, true);
-
+
if (dialog.open() != Window.OK) {
return;
}
IStructuredSelection sel = (IStructuredSelection) environmentTable.getSelection();
environmentTable.getControl().setRedraw(false);
for (Iterator i = sel.iterator(); i.hasNext(); ) {
- EnvironmentVariable var = (EnvironmentVariable) i.next();
+ EnvironmentVariable var = (EnvironmentVariable) i.next();
environmentTable.remove(var);
}
environmentTable.getControl().setRedraw(true);
* Stores the environment in the given configuration
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
*/
- public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
// Convert the table's items into a Map so that this can be saved in the
// configuration's attributes.
TableItem[] items = environmentTable.getTable().getItems();
{
EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
map.put(var.getName(), var.getValue());
- }
+ }
if (map.size() == 0) {
configuration.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map) null);
} else {
public String getName() {
return LaunchConfigurationsMessages.EnvironmentTab_Environment_7; //$NON-NLS-1$
}
-
+
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
*/
public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {
// do nothing when deactivated
}
-
+
private class NativeEnvironmentDialog extends ListSelectionDialog {
public NativeEnvironmentDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider, ILabelProvider labelProvider, String message) {
super(parentShell, input, contentProvider, labelProvider, message);
setShellStyle(getShellStyle() | SWT.RESIZE);
}
-
+
protected IDialogSettings getDialogSettings() {
IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings();
IDialogSettings section = settings.getSection(getDialogSettingsSectionName());
if (section == null) {
section = settings.addNewSection(getDialogSettingsSectionName());
- }
+ }
return section;
}
-
+
/**
* Returns the name of the section that this dialog stores its settings in
- *
+ *
* @return String
*/
protected String getDialogSettingsSectionName() {
}
return super.getInitialLocation(initialSize);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#getInitialSize()
*/
Point size = super.getInitialSize();
return DialogSettingsHelper.getInitialSize(getDialogSettingsSectionName(), size);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#close()
*/
StringFieldEditor apacheRestartSFE;
StringFieldEditor mySQLCommandSFE;
-
+
StringFieldEditor externalParserSFE;
-
+
FileFieldEditor apacheRunFFE;
FileFieldEditor mysqlRunFFE;
FileFieldEditor phpRunFFE;
FileFieldEditor httpdConfFFE;
-
+
FileFieldEditor etcHostsFFE;
BooleanFieldEditor apacheStartBFE;
}
public boolean performOk() {
-// PHPFileUtil.setExtensions(null);
+// PHPFileUtil.setExtensions(null);
// phpParserExtensionsSFE.store();
xamppStartSFE.store();
xamppStopSFE.store();
apacheSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
apacheSettingsGroup.setLayout(new GridLayout());
-
+
xamppStartSFE = new StringFieldEditor(ExternalToolsPlugin.XAMPP_START_PREF, PHPPreferencesMessages
.getString("PHPBasePreferencePage.apacheGroup.xampp_start"), apacheSettingsGroup);
- xamppStartSFE.setPreferencePage(this);
+ xamppStartSFE.setPage(this);
xamppStartSFE.setPreferenceStore(getPreferenceStore());
xamppStartSFE.load();
new Label(apacheSettingsGroup, SWT.NONE);
-
+
xamppStopSFE = new StringFieldEditor(ExternalToolsPlugin.XAMPP_STOP_PREF, PHPPreferencesMessages
.getString("PHPBasePreferencePage.apacheGroup.xampp_stop"), apacheSettingsGroup);
- xamppStopSFE.setPreferencePage(this);
+ xamppStopSFE.setPage(this);
xamppStopSFE.setPreferenceStore(getPreferenceStore());
xamppStopSFE.load();
new Label(apacheSettingsGroup, SWT.NONE);
-
+
apacheStartBFE = new BooleanFieldEditor(ExternalToolsPlugin.APACHE_START_BACKGROUND, PHPPreferencesMessages
.getString("PHPBasePreferencePage.apacheGroup.start_background"), apacheSettingsGroup);
- apacheStartBFE.setPreferencePage(this);
+ apacheStartBFE.setPage(this);
apacheStartBFE.setPreferenceStore(getPreferenceStore());
apacheStartBFE.load();
new Label(apacheSettingsGroup, SWT.NONE);
apacheStartSFE = new StringFieldEditor(ExternalToolsPlugin.APACHE_START_PREF, PHPPreferencesMessages
.getString("PHPBasePreferencePage.apacheGroup.start"), apacheSettingsGroup);
- apacheStartSFE.setPreferencePage(this);
+ apacheStartSFE.setPage(this);
apacheStartSFE.setPreferenceStore(getPreferenceStore());
apacheStartSFE.load();
new Label(apacheSettingsGroup, SWT.NONE);
apacheStopBFE = new BooleanFieldEditor(ExternalToolsPlugin.APACHE_STOP_BACKGROUND, PHPPreferencesMessages
.getString("PHPBasePreferencePage.apacheGroup.stop_background"), apacheSettingsGroup);
- apacheStopBFE.setPreferencePage(this);
+ apacheStopBFE.setPage(this);
apacheStopBFE.setPreferenceStore(getPreferenceStore());
apacheStopBFE.load();
new Label(apacheSettingsGroup, SWT.NONE);
new Label(apacheSettingsGroup, SWT.NONE);
apacheStopSFE = new StringFieldEditor(ExternalToolsPlugin.APACHE_STOP_PREF, PHPPreferencesMessages
.getString("PHPBasePreferencePage.apacheGroup.stop"), apacheSettingsGroup);
- apacheStopSFE.setPreferencePage(this);
+ apacheStopSFE.setPage(this);
apacheStopSFE.setPreferenceStore(getPreferenceStore());
apacheStopSFE.load();
new Label(apacheSettingsGroup, SWT.NONE);
apacheRestartBFE = new BooleanFieldEditor(ExternalToolsPlugin.APACHE_RESTART_BACKGROUND, PHPPreferencesMessages
.getString("PHPBasePreferencePage.apacheGroup.restart_background"), apacheSettingsGroup);
- apacheRestartBFE.setPreferencePage(this);
+ apacheRestartBFE.setPage(this);
apacheRestartBFE.setPreferenceStore(getPreferenceStore());
apacheRestartBFE.load();
new Label(apacheSettingsGroup, SWT.NONE);
new Label(apacheSettingsGroup, SWT.NONE);
apacheRestartSFE = new StringFieldEditor(ExternalToolsPlugin.APACHE_RESTART_PREF, PHPPreferencesMessages
.getString("PHPBasePreferencePage.apacheGroup.restart"), apacheSettingsGroup);
- apacheRestartSFE.setPreferencePage(this);
+ apacheRestartSFE.setPage(this);
apacheRestartSFE.setPreferenceStore(getPreferenceStore());
apacheRestartSFE.load();
new Label(apacheSettingsGroup, SWT.NONE);
apacheRunFFE = new FileFieldEditor(ExternalToolsPlugin.APACHE_RUN_PREF, PHPPreferencesMessages
.getString("PHPBasePreferencePage.apacheGroup.run"), apacheSettingsGroup);
- apacheRunFFE.setPreferencePage(this);
+ apacheRunFFE.setPage(this);
apacheRunFFE.setPreferenceStore(getPreferenceStore());
apacheRunFFE.load();
- httpdConfFFE = new FileFieldEditor(ExternalToolsPlugin.HTTPD_CONF_PATH_PREF,
+ httpdConfFFE = new FileFieldEditor(ExternalToolsPlugin.HTTPD_CONF_PATH_PREF,
"Path to httpd.conf:", apacheSettingsGroup);
- httpdConfFFE.setPreferencePage(this);
+ httpdConfFFE.setPage(this);
httpdConfFFE.setPreferenceStore(getPreferenceStore());
httpdConfFFE.load();
- etcHostsFFE = new FileFieldEditor(ExternalToolsPlugin.ETC_HOSTS_PATH_PREF,
+ etcHostsFFE = new FileFieldEditor(ExternalToolsPlugin.ETC_HOSTS_PATH_PREF,
"Path to etc/hosts:", apacheSettingsGroup);
- etcHostsFFE.setPreferencePage(this);
+ etcHostsFFE.setPage(this);
etcHostsFFE.setPreferenceStore(getPreferenceStore());
etcHostsFFE.load();
phpRunFFE = new FileFieldEditor(ExternalToolsPlugin.PHP_RUN_PREF, PHPPreferencesMessages
.getString("PHPBasePreferencePage.console.php"), apacheSettingsGroup);
- phpRunFFE.setPreferencePage(this);
+ phpRunFFE.setPage(this);
phpRunFFE.setPreferenceStore(getPreferenceStore());
phpRunFFE.load();
mysqlStartBFE = new BooleanFieldEditor(ExternalToolsPlugin.MYSQL_START_BACKGROUND, PHPPreferencesMessages
.getString("PHPBasePreferencePage.mySQLGroup.start_background"), mySQLSettingsGroup);
- mysqlStartBFE.setPreferencePage(this);
+ mysqlStartBFE.setPage(this);
mysqlStartBFE.setPreferenceStore(getPreferenceStore());
mysqlStartBFE.load();
new Label(mySQLSettingsGroup, SWT.NONE);
mySQLCommandSFE = new StringFieldEditor(ExternalToolsPlugin.MYSQL_PREF, PHPPreferencesMessages
.getString("PHPBasePreferencePage.mySQLGroup.command"), mySQLSettingsGroup);
- mySQLCommandSFE.setPreferencePage(this);
+ mySQLCommandSFE.setPage(this);
mySQLCommandSFE.setPreferenceStore(getPreferenceStore());
mySQLCommandSFE.load();
new Label(mySQLSettingsGroup, SWT.NONE);
mysqlRunFFE = new FileFieldEditor(ExternalToolsPlugin.MYSQL_RUN_PREF, PHPPreferencesMessages
.getString("PHPBasePreferencePage.mySQLGroup.run"), mySQLSettingsGroup);
- mysqlRunFFE.setPreferencePage(this);
+ mysqlRunFFE.setPage(this);
mysqlRunFFE.setPreferenceStore(getPreferenceStore());
mysqlRunFFE.load();
-
+
Composite parserSettingsComposite = new Composite(composite, SWT.NULL);
parserSettingsComposite.setLayout(new GridLayout());
parserSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
Group parserSettingsGroup = new Group(parserSettingsComposite, SWT.NONE);
parserSettingsGroup.setText("External parser command");
parserSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
parserSettingsGroup.setLayout(new GridLayout());
-
+
externalParserSFE =
new StringFieldEditor(
ExternalToolsPlugin.EXTERNAL_PARSER_PREF,
PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.extcommand"),
parserSettingsGroup
);
- externalParserSFE.setPreferencePage(this);
+ externalParserSFE.setPage(this);
externalParserSFE.setPreferenceStore(getPreferenceStore());
externalParserSFE.load();
-
+
return composite;
}
}
\ No newline at end of file
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.Launch;
import org.eclipse.debug.core.model.IProcess;
public class InterpreterRunner {
public InterpreterRunner() {
}
- public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) {
- String commandLine = renderCommandLine(configuration);
+ public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) {
+ String commandLine = renderCommandLine(configuration);
File workingDirectory = configuration.getAbsoluteWorkingDirectory();
-
+
setEnvironmentVariables(configuration);
String[] env = configuration.getEnvironment();
Process nativePHPProcess = null;
IProcess process = DebugPlugin.newProcess(launch, nativePHPProcess, renderLabel(configuration));
process.setAttribute(PHPLaunchingPlugin.PLUGIN_ID + ".launcher.cmdline", commandLine);
process.setAttribute(IProcess.ATTR_PROCESS_TYPE, PHPLaunchConfigurationAttribute.PHP_LAUNCH_PROCESS_TYPE);
-
+
return process ;
}
return buffer.toString();
}
-
+
protected void setEnvironmentVariables(InterpreterRunnerConfiguration configuration) {
IPath FilePath= new Path(configuration.getAbsoluteFileName());
String OSFilePath= FilePath.toOSString();
configuration.addEnvironmentValue("GATEWAY_INTERFACE","CGI / 1.1",true);
configuration.addEnvironmentValue("REQUEST_METHOD","GET",true);
-
+
Map stringVars = DebugPlugin.getDefault().getLaunchManager().getNativeEnvironment();
if (stringVars.containsKey("SYSTEMROOT"))
configuration.addEnvironmentValue("SYSTEMROOT",(String) stringVars.get("SYSTEMROOT"),true);
-
+
}
protected String renderLoadPath(InterpreterRunnerConfiguration configuration) {
return aPath;
}
-
+
protected String getDebugCommandLineArgument() {
- return "" ;
- }
+ return "" ;
+ }
}
package net.sourceforge.phpdt.internal.launching;
import java.io.File;
-import java.io.FileWriter;
import java.io.IOException;
-import java.util.ArrayList;
-
-import net.sourceforge.phpdt.internal.ui.phpdocexport.JavadocExportMessages;
-import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.Launch;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.ui.IDebugUIConstants;
public class PHPInterpreter {
import javax.xml.parsers.SAXParserFactory;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
public class PHPRuntime {
protected static PHPRuntime runtime;
-
+
protected List installedInterpreters;
protected PHPInterpreter selectedInterpreter;
protected PHPRuntime() {
}
return runtime;
}
-
+
public PHPInterpreter getSelectedInterpreter() {
if (selectedInterpreter == null) {
loadRuntimeConfiguration();
if (each.getInstallLocation().toString().equals(installLocation))
return each;
}
-
+
return getSelectedInterpreter();
}
loadRuntimeConfiguration();
return installedInterpreters;
}
-
+
public void setInstalledInterpreters(List newInstalledInterpreters) {
installedInterpreters = newInstalledInterpreters;
if (installedInterpreters.size() > 0)
else
setSelectedInterpreter(null);
}
-
+
protected void saveRuntimeConfiguration() {
writeXML(getRuntimeConfigurationWriter());
}
return null;
}
-
+
protected void loadRuntimeConfiguration() {
installedInterpreters = new ArrayList();
try {
} catch(FileNotFoundException e) {}
return new StringReader("");
}
-
+
protected void writeXML(Writer writer) {
try {
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><runtimeconfig>");
Iterator interpretersIterator = installedInterpreters.iterator();
while (interpretersIterator.hasNext()) {
writer.write("<interpreter name=\"");
-
+
PHPInterpreter entry = (PHPInterpreter) interpretersIterator.next();
// writer.write(entry.getName());
writer.write("\" path=\"");
writer.write("\"");
if (entry.equals(selectedInterpreter))
writer.write(" selected=\"true\"");
-
+
writer.write("/>");
}
writer.write("</runtimeconfig>");
public void skippedEntity(String name) throws SAXException {}
};
}
-
+
protected File getRuntimeConfigurationFile() {
IPath stateLocation = PHPLaunchingPlugin.getDefault().getStateLocation();
IPath fileLocation = stateLocation.append("runtimeConfiguration.xml");
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer,
* int)
*/
String prefix = extractPrefix(viewer, offset);
prefix = prefix.toLowerCase();
- Region region = new Region(offset - prefix.length(), prefix.length());
+ IRegion region = new Region(offset - prefix.length(), prefix.length());
TemplateContext context = createContext(viewer, region);
if (context == null)
return new ICompletionProposal[0];
public char[] getCompletionProposalAutoActivationCharacters() {
return fProposalAutoActivationSet;
}
-
+
/**
* Sets this processor's set of characters triggering the activation of the
* completion proposal computation.
- *
+ *
* @param activationSet the activation set
*/
public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
fProposalAutoActivationSet= activationSet;
}
-
+
/**
* Order the given proposals.
*/
/**
* Tells this processor to order the proposals alphabetically.
- *
+ *
* @param order <code>true</code> if proposals should be ordered.
*/
// public void orderProposalsAlphabetically(boolean order) {
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/**
- *
+ *
*/
public class BrowserTableComposite extends Composite {
protected Table table;
protected Button remove;
protected Button search;
protected IWebBrowser selection;
-
+
protected Label location;
protected Label parameters;
-
+
public BrowserTableComposite(Composite parent, int style) {
super(parent, style);
createWidgets();
GridData data = new GridData(GridData.FILL_BOTH);
setLayoutData(data);
-
+
Label label = new Label(this, SWT.NONE);
label.setText(WebBrowserUIPlugin.getResource("%browserList"));
data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
data.horizontalSpan = 2;
label.setLayoutData(data);
-
+
table = new Table(this, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
data.widthHint = 300;
table.setLayoutData(data);
table.setHeaderVisible(false);
table.setLinesVisible(false);
-
+
TableLayout tableLayout = new TableLayout();
new TableColumn(table, SWT.NONE);
-
+
tableLayout.addColumnData(new ColumnWeightData(100));
table.setLayout(tableLayout);
-
+
tableViewer = new CheckboxTableViewer(table);
-
+
tableViewer.setContentProvider(new BrowserContentProvider());
tableViewer.setLabelProvider(new BrowserTableLabelProvider());
-
+
tableViewer.setInput("root");
// uncheck any other elements that might be checked and leave only the element checked to
checkNewDefaultBrowser(e.getElement());
IWebBrowser browser = (IWebBrowser) e.getElement();
BrowserManager.getInstance().setCurrentWebBrowser(browser);
-
+
// if no other browsers are checked, don't allow the single one currently
// checked to become unchecked, and lose a current browser. That is, don't
// permit unchecking if no other item is checked which is supposed to be the case.
tableViewer.setChecked(e.getElement(), true);
}
});
-
+
// set a default, checked browser based on the current browser. If there is not a
// current browser, but the first item exists, use that instead.
// This will work currently until workbench shutdown, because current browser is not yet persisted.
if (obj != null)
tableViewer.setChecked(obj, true);
}
-
+
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
Object obj = getSelection(event.getSelection());
-
+
if (obj instanceof IInternalWebBrowser) {
selection = (IInternalWebBrowser) obj;
remove.setEnabled(false);
edit.setEnabled(true);
} else
selection = null;
-
+
if (selection == null) {
edit.setEnabled(false);
remove.setEnabled(false);
}
}
});
-
+
Composite buttonComp = new Composite(this, SWT.NONE);
layout = new GridLayout();
layout.horizontalSpacing = 0;
buttonComp.setLayout(layout);
data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_FILL);
buttonComp.setLayoutData(data);
-
+
Button add = SWTUtil.createButton(buttonComp, WebBrowserUIPlugin.getResource("%add"));
add.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
tableViewer.refresh();
}
});
-
+
edit = SWTUtil.createButton(buttonComp, WebBrowserUIPlugin.getResource("%edit"));
edit.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
tableViewer.refresh(wc.save());
} catch (Exception ex) { }
}
- }
+ }
else if(browser2 instanceof IExternalWebBrowser) {
IExternalWebBrowserWorkingCopy wc = ((IExternalWebBrowser) browser2).getWorkingCopy();
ExternalBrowserDialog dialog = new ExternalBrowserDialog(getShell(), wc);
} catch (Exception ex) { }
}
}
- }
+ }
});
edit.setEnabled(false);
if (browser2 instanceof IInternalWebBrowser){
remove.setEnabled(false);
return; // nothing else possible to do
- }
+ }
else if(browser2 instanceof IExternalWebBrowser) {
remove.setEnabled(true);
((IExternalWebBrowser) browser2).delete();
-
+
tableViewer.remove(browser2);
-
+
// need here to ensure that if the item deleted was checked, ie, was
// the current browser, that the new current browser will be the first in the
// list, typically, the internal browser, which cannot be deleted, and be current.
}
});
remove.setEnabled(false);
-
+
search = SWTUtil.createButton(buttonComp, WebBrowserUIPlugin.getResource("%search"));
search.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
java.util.List browsersToCreate = BrowserSearcher.search(getShell());
-
+
if (browsersToCreate == null) // cancelled
return;
-
+
if (browsersToCreate.isEmpty()) { // no browsers found
WebBrowserUtil.openMessage(WebBrowserUIPlugin.getResource("%searchingNoneFound"));
return;
}
-
+
Iterator iterator = browsersToCreate.iterator();
while (iterator.hasNext()) {
IExternalWebBrowserWorkingCopy browser2 = (IExternalWebBrowserWorkingCopy) iterator.next();
tableViewer.refresh();
}
});
- WorkbenchHelp.setHelp(search, ContextIds.PREF_BROWSER_EXTERNAL_SEARCH);
-
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(search, ContextIds.PREF_BROWSER_EXTERNAL_SEARCH);
+
tableViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent e) {
checkNewDefaultBrowser(e.getElement());
});
search.setEnabled(true);
}
-
+
public IWebBrowser getSelectedWebBrowser() {
return selection;
}
-
+
protected Object getSelection(ISelection sel2) {
IStructuredSelection sel = (IStructuredSelection) sel2;
return sel.getFirstElement();
}
-
+
// Uncheck all the items except the current one that was just checked
protected void checkNewDefaultBrowser(Object browser) {
TableItem[] children = tableViewer.getTable().getItems();
for (int i = 0; i < children.length; i++) {
TableItem item = children[i];
-
- if (!(item.getData().equals(browser)))
+
+ if (!(item.getData().equals(browser)))
item.setChecked(false);
}
}
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/**
- *
+ *
*/
public class ExternalBrowserDialog extends Dialog {
protected IExternalWebBrowserWorkingCopy browser;
protected Text browserLocationTextfield;
protected Text browserParametersTextfield;
private Button okButton;
-
+
interface StringModifyListener {
public void valueChanged(String s);
}
-
+
/**
* @param parentShell
*/
protected void configureShell(Shell shell) {
super.configureShell(shell);
-
+
if (isEdit)
shell.setText(WebBrowserUIPlugin.getResource("%editExternalBrowser"));
else
text.setLayoutData(data);
if (listener != null)
text.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
+ public void modifyText(ModifyEvent e) {
listener.valueChanged(text.getText());
}
});
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
((GridLayout)composite.getLayout()).numColumns = 3;
-
+
if (isEdit)
- WorkbenchHelp.setHelp(composite, ContextIds.PREF_BROWSER_EXTERNAL_EDIT);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ContextIds.PREF_BROWSER_EXTERNAL_EDIT);
else
- WorkbenchHelp.setHelp(composite, ContextIds.PREF_BROWSER_EXTERNAL_ADD);
-
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ContextIds.PREF_BROWSER_EXTERNAL_ADD);
+
SWTUtil.createLabel(composite, WebBrowserUIPlugin.getResource("%name"));
browserNameTextfield = createText(composite, browser.getName(), new StringModifyListener() {
public void valueChanged(String s) {
validateFields();
}
});
-
+
new Label(composite, SWT.NONE);
-
+
SWTUtil.createLabel(composite, WebBrowserUIPlugin.getResource("%location"));
browserLocationTextfield = createText(composite, browser.getLocation(), new StringModifyListener() {
public void valueChanged(String s) {
browser.setLocation(s);
validateFields();
}
- });
-
+ });
+
browseButton = SWTUtil.createButton(composite, WebBrowserUIPlugin.getResource("%browse"));
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setText(WebBrowserUIPlugin.getResource("%browseMessage"));
-
+
String fname = browserLocationTextfield.getText();
-
+
dialog.setFileName(fname);
fname = dialog.open();
-
+
if (fname != null)
browserLocationTextfield.setText(fname);
}
});
-
+
SWTUtil.createLabel(composite, WebBrowserUIPlugin.getResource("%parameters"));
browserParametersTextfield = createText(composite, browser.getParameters(), new StringModifyListener() {
public void valueChanged(String s) {
});
new Label(composite, SWT.NONE);
-
+
new Label(composite, SWT.NONE);
Label urlLabel = new Label(composite, SWT.NONE);
urlLabel.setText(WebBrowserUIPlugin.getResource("%parametersMessage", WebBrowserPreference.URL_PARAMETER));
-
-
+
+
return composite;
}
WebBrowserUtil.openError(WebBrowserUIPlugin.getResource("%locationInvalid"));
return;
}
-
+
browser.save();
super.okPressed();
}
-
+
private void setOKButtonEnabled(boolean curIsEnabled) {
if (okButton == null)
okButton = getButton(IDialogConstants.OK_ID);
-
+
if (okButton != null)
okButton.setEnabled(curIsEnabled);
}
-
+
protected Control createButtonBar(Composite parent) {
Control buttonControl = super.createButtonBar(parent);
validateFields();
return buttonControl;
}
-
+
protected void validateFields() {
boolean valid = true;
-
+
String name = browserNameTextfield.getText();
if (name == null || name.trim().length() < 1)
valid = false;
-
+
String location = browserLocationTextfield.getText();
if (location == null || location.trim().length() < 1)
valid = false;
-
+
setOKButtonEnabled(valid);
}
}
\ No newline at end of file
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/**
- *
+ *
*/
public class InternalBrowserDialog extends Dialog {
protected IInternalWebBrowserWorkingCopy browser;
protected boolean isEdit;
protected Button newPageCheckbox;
protected Button clearURLHistoryCheckbox;
-
+
/**
* @param parentShell
*/
protected void configureShell(Shell shell) {
super.configureShell(shell);
-
+
if (isEdit)
shell.setText(WebBrowserUIPlugin.getResource("%editInternalBrowser"));
}
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
((GridLayout)composite.getLayout()).numColumns = 1;
-
+
Composite comp = new Composite(composite, SWT.NONE);
GridLayout layout = new GridLayout(1, true);
layout.marginHeight = 10;
layout.marginWidth = 10;
comp.setLayout(layout);
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
- WorkbenchHelp.setHelp(composite, ContextIds.PREF_BROWSER_INTERNAL);
-
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ContextIds.PREF_BROWSER_INTERNAL);
+
newPageCheckbox = SWTUtil.createCheckbox(comp, WebBrowserUIPlugin.getResource("%prefBrowserNewPage"), false);
clearURLHistoryCheckbox = SWTUtil.createCheckbox(comp, WebBrowserUIPlugin.getResource("%clearURLHistory"), true);
-
+
newPageCheckbox.setSelection(browser.getUseNewPage());
clearURLHistoryCheckbox.setSelection(browser.getClearHistoryOnExit());
-
+
return composite;
}
browser.setUseNewPage(newPageCheckbox.getSelection());
browser.setClearHistoryOnExit(clearURLHistoryCheckbox.getSelection());
browser.save();
-
+
super.okPressed();
}
}
\ No newline at end of file
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/**
* A preference page that holds internet preferences.
*/
*/
protected Control createContents(Composite parent) {
initializeDialogUnits(parent);
-
+
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
composite.setLayout(layout);
GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
composite.setLayoutData(data);
- WorkbenchHelp.setHelp(composite, ContextIds.PREF_BROWSER);
-
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ContextIds.PREF_BROWSER);
+
Label label = new Label(composite, SWT.WRAP);
label.setText(WebBrowserUIPlugin.getResource("%preferenceInternetDescription"));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
label.setLayoutData(data);
-
+
Dialog.applyDialogFont(composite);
-
+
return composite;
}
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
public class WebBrowser extends Composite {
protected Composite toolbarComp;
setLayout(layout);
setLayoutData(new GridData(GridData.FILL_BOTH));
clipboard = new Clipboard(parent.getDisplay());
- WorkbenchHelp.setHelp(this, ContextIds.WEB_BROWSER);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ContextIds.WEB_BROWSER);
if (showToolbar) {
toolbarComp = new Composite(this, SWT.NONE);
}
});
combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- WorkbenchHelp.setHelp(combo, ContextIds.WEB_BROWSER_URL);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(combo, ContextIds.WEB_BROWSER_URL);
ToolBar toolbar = new ToolBar(top, SWT.FLAT);
fillToolBar(toolbar);
forward.setEnabled(browser.isForwardEnabled());
}
- WorkbenchHelp.setHelp(browser, ContextIds.WEB_BROWSER_WEB);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(browser, ContextIds.WEB_BROWSER_WEB);
GridData data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.FILL;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/**
* The preference page that holds webbrowser preferences.
*/
*/
protected Control createContents(Composite parent) {
initializeDialogUnits(parent);
-
+
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
composite.setLayout(layout);
GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
composite.setLayoutData(data);
- WorkbenchHelp.setHelp(composite, ContextIds.PREF_BROWSER);
-
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ContextIds.PREF_BROWSER);
+
Label label = new Label(composite, SWT.WRAP);
label.setText(WebBrowserUIPlugin.getResource("%preferenceWebBrowserDescription"));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
label.setLayoutData(data);
-
+
BrowserTableComposite browserComposite = new BrowserTableComposite(composite, SWT.NONE);
-
+
data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
browserComposite.setLayoutData(data);
-
+
Dialog.applyDialogFont(composite);
-
+
return composite;
}
-
+
/**
* Initializes this preference page using the passed desktop.
*
* @param desktop the current desktop
*/
public void init(IWorkbench workbench) { }
-
+
/**
- *
+ *
*/
public void setVisible(boolean visible) {
super.setVisible(visible);
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
public final static int FIELD = 1;
public final static int CLASS_LITERAL = 2;
public final static int CHANGED_DECLARING_CLASS = 3;
-
+
Hashtable[] synthetics;
-
+
protected SourceTypeBinding() {
}
public SourceTypeBinding(char[][] compoundName, PackageBinding fPackage, ClassScope scope) {
if (synthetics[FIELD] == null) {
synthetics[FIELD] = new Hashtable(5);
}
-
+
FieldBinding synthField = (FieldBinding) synthetics[FIELD].get(actualOuterLocalVariable);
if (synthField == null) {
synthField = new SyntheticFieldBinding(
- CharOperation.concat(SyntheticArgumentBinding.OuterLocalPrefix, actualOuterLocalVariable.name),
- actualOuterLocalVariable.type,
- AccPrivate | AccFinal ,//| AccSynthetic,
- this,
+ CharOperation.concat(SyntheticArgumentBinding.OuterLocalPrefix, actualOuterLocalVariable.name),
+ actualOuterLocalVariable.type,
+ AccPrivate | AccFinal ,//| AccSynthetic,
+ this,
Constant.NotAConstant,
synthetics[FIELD].size());
synthetics[FIELD].put(actualOuterLocalVariable, synthField);
break;
}
}
- }
+ }
return synthField;
}
/* Add a new synthetic field for a class literal access.
break;
}
}
- }
+ }
return synthField;
}
if (accessors == null) {
accessMethod = new SyntheticAccessMethodBinding(targetField, isReadAccess, this);
synthetics[METHOD].put(targetField, accessors = new SyntheticAccessMethodBinding[2]);
- accessors[isReadAccess ? 0 : 1] = accessMethod;
+ accessors[isReadAccess ? 0 : 1] = accessMethod;
} else {
if ((accessMethod = accessors[isReadAccess ? 0 : 1]) == null) {
accessMethod = new SyntheticAccessMethodBinding(targetField, isReadAccess, this);
if (accessors == null) {
accessMethod = new SyntheticAccessMethodBinding(targetMethod, isSuperAccess, this);
synthetics[METHOD].put(targetMethod, accessors = new SyntheticAccessMethodBinding[2]);
- accessors[isSuperAccess ? 0 : 1] = accessMethod;
+ accessors[isSuperAccess ? 0 : 1] = accessMethod;
} else {
if ((accessMethod = accessors[isSuperAccess ? 0 : 1]) == null) {
accessMethod = new SyntheticAccessMethodBinding(targetMethod, isSuperAccess, this);
int newSize = fields.length - failed;
if (newSize == 0)
return fields = NoFields;
-
+
FieldBinding[] newFields = new FieldBinding[newSize];
for (int i = 0, n = 0, max = fields.length; i < max; i++)
if (fields[i] != null)
}
if (newFields != null){
System.arraycopy(newFields, 0, fields = new FieldBinding[count], 0, count);
- }
+ }
throw e;
}
return fields;
}
}
}
-
+
if (foundProblem || count > 1) {
for (int m = methods.length; --m >= 0;) {
MethodBinding method = methods[m];
}
}
}
-
+
if (failed > 0) {
int newSize = methods.length - failed;
if (newSize == 0)
return methods = NoMethods;
-
+
MethodBinding[] newMethods = new MethodBinding[newSize];
for (int i = 0, n = 0, max = methods.length; i < max; i++)
if (methods[i] != null)
}
if (newMethods != null){
System.arraycopy(newMethods, 0, methods = new MethodBinding[count], 0, count);
- }
+ }
modifiers ^= AccUnresolved;
throw e;
- }
+ }
return NoMethods;
}
/* Answer the synthetic field for <actualOuterLocalVariable>
*/
public FieldBinding getSyntheticField(LocalVariableBinding actualOuterLocalVariable) {
-
+
if (synthetics == null || synthetics[FIELD] == null) return null;
return (FieldBinding) synthetics[FIELD].get(actualOuterLocalVariable);
}
try {
if ((modifiers & AccUnresolved) == 0)
return methods;
-
+
int failed = 0;
for (int m = 0, max = methods.length; m < max; m++) {
if (resolveTypesFor(methods[m]) == null) {
failed++;
}
}
-
+
for (int m = methods.length; --m >= 0;) {
MethodBinding method = methods[m];
if (method != null) {
}
}
}
-
+
if (failed > 0) {
int newSize = methods.length - failed;
if (newSize == 0) {
methods = newMethods;
}
}
-
+
// handle forward references to potential default abstract methods
addDefaultAbstractMethods();
} catch(AbortCompilation e){
}
if (newMethods != null){
System.arraycopy(newMethods, 0, methods = new MethodBinding[count], 0, count);
- }
+ }
modifiers ^= AccUnresolved;
throw e;
- }
+ }
modifiers ^= AccUnresolved;
return methods;
}
return superInterfaces;
}
public SyntheticAccessMethodBinding[] syntheticAccessMethods() {
-
+
if (synthetics == null || synthetics[METHOD] == null || synthetics[METHOD].size() == 0) return null;
// difficult to compute size up front because of the embedded arrays so assume there is only 1
if (methodAccessors[1] != null) numberOfAccessors++;
if (index + numberOfAccessors > bindings.length)
System.arraycopy(bindings, 0, (bindings = new SyntheticAccessMethodBinding[index + numberOfAccessors]), 0, index);
- if (methodAccessors[0] != null)
- bindings[index++] = methodAccessors[0]; // super access
- if (methodAccessors[1] != null)
+ if (methodAccessors[0] != null)
+ bindings[index++] = methodAccessors[0]; // super access
+ if (methodAccessors[1] != null)
bindings[index++] = methodAccessors[1]; // normal access
} else {
if (fieldAccessors[1] != null) numberOfAccessors++;
if (index + numberOfAccessors > bindings.length)
System.arraycopy(bindings, 0, (bindings = new SyntheticAccessMethodBinding[index + numberOfAccessors]), 0, index);
- if (fieldAccessors[0] != null)
+ if (fieldAccessors[0] != null)
bindings[index++] = fieldAccessors[0]; // read access
- if (fieldAccessors[1] != null)
+ if (fieldAccessors[1] != null)
bindings[index++] = fieldAccessors[1]; // write access
}
}
* Answer the collection of synthetic fields to append into the classfile
*/
public FieldBinding[] syntheticFields() {
-
+
if (synthetics == null) return null;
int fieldSize = synthetics[FIELD] == null ? 0 : synthetics[FIELD].size();
// class T { class M{}}
// class S extends T { class N extends M {}} --> need to use S as a default enclosing instance for the super constructor call in N().
if (!onlyExactMatch){
- Enumeration enum = synthetics[FIELD].elements();
- while (enum.hasMoreElements()) {
- field = (FieldBinding) enum.nextElement();
+ Enumeration e = synthetics[FIELD].elements();
+ while (e.hasMoreElements()) {
+ field = (FieldBinding) e.nextElement();
if (CharOperation.prefixEquals(SyntheticArgumentBinding.EnclosingInstancePrefix, field.name)
&& targetEnclosingType.isSuperclassOf((ReferenceBinding) field.type))
return field;
FieldReference ref = (FieldReference) lhs;
if (!containsVariableSet(ref.token)) {
if (null==initHandler || initHandler.reportError()) {
- problemReporter.uninitializedLocalVariable(new String(ref.token), ref.sourceStart(), ref.sourceEnd(),
+ problemReporter.uninitializedLocalVariable(new String(ref.token), ref.sourceStart, ref.sourceEnd,
referenceContext, compilationUnit.compilationResult);
}
addVariableSet(ref.token);
// example:
// $var = & new Object();
if (fMethodVariables != null) {
- VariableInfo lhsInfo = new VariableInfo(((FieldReference) lhs).sourceStart());
+ VariableInfo lhsInfo = new VariableInfo(((FieldReference) lhs).sourceStart);
lhsInfo.reference = classRef;
lhsInfo.typeIdentifier = classRef.token;
fMethodVariables.put(new String(((FieldReference) lhs).token), lhsInfo);
if (fMethodVariables != null) {
VariableInfo rhsInfo = (VariableInfo) fMethodVariables.get(((FieldReference) rhs).token);
if (rhsInfo != null && rhsInfo.reference != null) {
- VariableInfo lhsInfo = new VariableInfo(((FieldReference) lhs).sourceStart());
+ VariableInfo lhsInfo = new VariableInfo(((FieldReference) lhs).sourceStart);
lhsInfo.reference = rhsInfo.reference;
lhsInfo.typeIdentifier = rhsInfo.typeIdentifier;
fMethodVariables.put(new String(((FieldReference) lhs).token), lhsInfo);
if (fMethodVariables != null) {
VariableInfo rhsInfo = (VariableInfo) fMethodVariables.get(((FieldReference) rhs).token);
if (rhsInfo != null && rhsInfo.reference != null) {
- VariableInfo lhsInfo = new VariableInfo(((FieldReference) lhs).sourceStart());
+ VariableInfo lhsInfo = new VariableInfo(((FieldReference) lhs).sourceStart);
lhsInfo.reference = rhsInfo.reference;
lhsInfo.typeIdentifier = rhsInfo.typeIdentifier;
fMethodVariables.put(new String(((FieldReference) lhs).token), lhsInfo);
// example:
// $var = new Object();
if (fMethodVariables != null) {
- VariableInfo lhsInfo = new VariableInfo(((FieldReference) lhs).sourceStart());
+ VariableInfo lhsInfo = new VariableInfo(((FieldReference) lhs).sourceStart);
lhsInfo.reference = (SingleTypeReference) rhs;
lhsInfo.typeIdentifier = ((SingleTypeReference) rhs).token;
fMethodVariables.put(new String(((FieldReference) lhs).token), lhsInfo);
}
if (rememberedVar == false && lhs != null && lhs instanceof FieldReference) {
if (fMethodVariables != null) {
- VariableInfo lhsInfo = new VariableInfo(((FieldReference) lhs).sourceStart());
+ VariableInfo lhsInfo = new VariableInfo(((FieldReference) lhs).sourceStart);
fMethodVariables.put(new String(((FieldReference) lhs).token), lhsInfo);
}
}
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
* same type of container.
*
* <li>This operation can be used to copy and rename elements within
- * the same container.
+ * the same container.
*
* <li>This operation only copies compilation units and package fragments.
* It does not copy package fragment roots - a platform operation must be used for that.
*/
protected ArrayList fRenamedCompilationUnits = null;
/**
- * Table specifying deltas for elements being
+ * Table specifying deltas for elements being
* copied/moved/renamed. Keyed by elements' project(s), and
* values are the corresponding deltas.
*/
// for (int i = 0, max = nonJavaResources.length, index = 0; i < max; i++){
// if (nonJavaResources[i] instanceof IResource) actualNonJavaResources[index++] = (IResource)nonJavaResources[i];
// }
-
+
// if (actualNonJavaResourceCount != 0) {
// int correctKindChildrenSize = correctKindChildren.size();
// IResource[] result = new IResource[correctKindChildrenSize + actualNonJavaResourceCount];
}
parentFolder = parentFolder.getFolder(new Path(subFolderName));
sourceFolder = sourceFolder.getFolder(new Path(subFolderName));
- if (sourceFolder.isReadOnly()) {
- parentFolder.setReadOnly(true);
+ if (sourceFolder.getResourceAttributes().isReadOnly()) {
+ parentFolder.getResourceAttributes().setReadOnly(true);
}
IPackageFragment sideEffectPackage = root.getPackageFragment(sideEffectPackageName.toString());
if (i < names.length - 1 // all but the last one are side effect packages
- && !net.sourceforge.phpdt.internal.core.util.Util.isExcluded(parentFolder, exclusionsPatterns)) {
+ && !net.sourceforge.phpdt.internal.core.util.Util.isExcluded(parentFolder, exclusionsPatterns)) {
if (projectDelta == null) {
projectDelta = getDeltaFor(root.getJavaProject());
}
* <li>one rooted in the source project
* <li>one rooted in the destination project</ul></ul>
* If the operation is rooted in a single project, the delta is rooted in that project
- *
+ *
*/
protected void prepareDeltas(IJavaElement sourceElement, IJavaElement destinationElement, boolean isMove) {
if (net.sourceforge.phpdt.internal.core.util.Util.isExcluded(sourceElement) || net.sourceforge.phpdt.internal.core.util.Util.isExcluded(destinationElement)) return;
String newCUName = getNewNameFor(source);
String destName = (newCUName != null) ? newCUName : source.getElementName();
String newContent = updatedContent(source, dest, newCUName); // null if unchanged
-
+
// copy resource
IFile sourceResource = (IFile)(source.isWorkingCopy() ? source.getOriginalElement() : source).getResource();
IContainer destFolder = (IContainer)dest.getResource(); // can be an IFolder or an IProject
} else {
// abort
throw new JavaModelException(new JavaModelStatus(
- IJavaModelStatusConstants.NAME_COLLISION,
+ IJavaModelStatusConstants.NAME_COLLISION,
Util.bind("status.nameCollision", destFile.getFullPath().toString()))); //$NON-NLS-1$
}
}
if (newContent != null) flags |= IResource.KEEP_HISTORY;
sourceResource.copy(destFile.getFullPath(), flags, getSubProgressMonitor(1));
}
- this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
} catch (JavaModelException e) {
throw e;
} catch (CoreException e) {
throw new JavaModelException(e);
}
-
+
// update new resource content
try {
if (newContent != null){
String encoding = source.getJavaProject().getOption(JavaCore.CORE_ENCODING, true);
destFile.setContents(
- new ByteArrayInputStream(encoding == null ? newContent.getBytes() : newContent.getBytes(encoding)),
+ new ByteArrayInputStream(encoding == null ? newContent.getBytes() : newContent.getBytes(encoding)),
force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
getSubProgressMonitor(1));
}
} catch (CoreException e) {
throw new JavaModelException(e);
}
-
+
// register the correct change deltas
ICompilationUnit destCU = dest.getCompilationUnit(destName);
prepareDeltas(source, destCU, isMove());
} else {
if (!force) {
throw new JavaModelException(new JavaModelStatus(
- IJavaModelStatusConstants.NAME_COLLISION,
+ IJavaModelStatusConstants.NAME_COLLISION,
Util.bind("status.nameCollision", destFile.getFullPath().toString()))); //$NON-NLS-1$
}
// update new resource content
if (newContent != null){
String encoding = source.getJavaProject().getOption(JavaCore.CORE_ENCODING, true);
destFile.setContents(
- new ByteArrayInputStream(encoding == null ? newContent.getBytes() : newContent.getBytes(encoding)),
- force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
+ new ByteArrayInputStream(encoding == null ? newContent.getBytes() : newContent.getBytes(encoding)),
+ force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
getSubProgressMonitor(1));
}
} catch(IOException e) {
processDeltas();
}
}
-
+
/**
* Copies/moves a package fragment with the name <code>newName</code>
* to the destination package.<br>
String newFragName = (newName == null) ? source.getElementName() : newName;
IPackageFragment newFrag = root.getPackageFragment(newFragName);
IResource[] resources = collectResourcesOfInterest(source);
-
+
// if isMove() can we move the folder itself ? (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=22458)
boolean shouldMoveFolder = isMove() && !newFrag.getResource().exists(); // if new pkg fragment exists, it is an override
IFolder srcFolder = (IFolder)source.getResource();
break;
}
}
- }
+ }
}
createNeededPackageFragments((IContainer) source.getParent().getResource(), root, newFragName, shouldMoveFolder);
-
+
// Process resources
if (shouldMoveFolder) {
// move underlying resource
srcFolder.move(destPath, force, true /* keep history */, getSubProgressMonitor(1));
- this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
} else {
// process the leaf resources
if (resources.length > 0) {
deleteResource(destinationResource, IResource.KEEP_HISTORY);
} else {
throw new JavaModelException(new JavaModelStatus(
- IJavaModelStatusConstants.NAME_COLLISION,
+ IJavaModelStatusConstants.NAME_COLLISION,
Util.bind("status.nameCollision", destinationResource.getFullPath().toString()))); //$NON-NLS-1$
}
}
deleteResource(destinationResource, IResource.KEEP_HISTORY);
} else {
throw new JavaModelException(new JavaModelStatus(
- IJavaModelStatusConstants.NAME_COLLISION,
+ IJavaModelStatusConstants.NAME_COLLISION,
Util.bind("status.nameCollision", destinationResource.getFullPath().toString()))); //$NON-NLS-1$
}
}
}
}
}
-
+
// Discard empty old package (if still empty after the rename)
boolean isEmpty = true;
if (isMove()) {
} else {
rootResource = source.getParent().getResource();
}
-
+
// delete recursively empty folders
deleteEmptyPackageFragment(source, false, rootResource);
}
}
-
+
// Update package statement in compilation unit if needed
if (!newFrag.getElementName().equals(source.getElementName())) { // if package has been renamed, update the compilation units
for (int i = 0; i < resources.length; i++) {
}
}
}
-
+
//register the correct change deltas
prepareDeltas(source, newFrag, isMove() && isEmpty);
} catch (DOMException dom) {
private void updatePackageStatement(IDOMCompilationUnit domCU, String pkgName) throws JavaModelException {
boolean defaultPackage = pkgName.equals(IPackageFragment.DEFAULT_PACKAGE_NAME);
boolean seenPackageNode = false;
- Enumeration enum = domCU.getChildren();
- while (enum.hasMoreElements()) {
- IDOMNode node = (IDOMNode) enum.nextElement();
+ Enumeration e = domCU.getChildren();
+ while (e.hasMoreElements()) {
+ IDOMNode node = (IDOMNode) e.nextElement();
if (node.getNodeType() == IDOMNode.PACKAGE) {
if (! defaultPackage) {
node.setName(pkgName);
if (!status.isOK()) {
return status;
}
-
+
if (fRenamingsList != null && fRenamingsList.length != fElementsToProcess.length) {
return new JavaModelStatus(IJavaModelStatusConstants.INDEX_OUT_OF_BOUNDS);
}
protected void verify(IJavaElement element) throws JavaModelException {
if (element == null || !element.exists())
error(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, element);
-
+
if (element.isReadOnly() && (isRename() || isMove()))
error(IJavaModelStatusConstants.READ_ONLY, element);
error(JavaModelStatus.INVALID_RESOURCE, element);
}
}
-
+
int elementType = element.getElementType();
-
+
if (elementType == IJavaElement.COMPILATION_UNIT) {
if (isMove() && ((ICompilationUnit) element).isWorkingCopy())
error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
} else if (elementType != IJavaElement.PACKAGE_FRAGMENT) {
error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
}
-
+
JavaElement dest = (JavaElement) getDestinationParent(element);
verifyDestination(element, dest);
if (fRenamings != null) {
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
} else {
JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().put(this, this);
}
- }
-
+ }
+
/**
* Builds this element's structure and properties in the given
* info object, based on this element's current contents (reuse buffer
//protected void buildStructure(OpenableElementInfo info, IProgressMonitor monitor) throws JavaModelException {
//
// if (monitor != null && monitor.isCanceled()) return;
-//
+//
// // remove existing (old) infos
// removeInfo();
// HashMap newElements = new HashMap(11);
// Object value = newElements.get(key);
// JavaModelManager.getJavaModelManager().putInfo(key, value);
// }
-//
+//
// // add the info for this at the end, to ensure that a getInfo cannot reply null in case the LRU cache needs
// // to be flushed. Might lead to performance issues.
// // see PR 1G2K5S7: ITPJCORE:ALL - NPE when accessing source for a binary type
-// JavaModelManager.getJavaModelManager().putInfo(this, info);
+// JavaModelManager.getJavaModelManager().putInfo(this, info);
//}
/*
* Returns whether this element can be removed from the Java model cache to make space.
// // fix for 1FVGGKF
// JavaProject project = (JavaProject)getJavaProject();
// ISearchableNameEnvironment environment = project.getSearchableNameEnvironment();
-//
+//
// // fix for 1FVXGDK
// SelectionEngine engine = new SelectionEngine(environment, requestor, project.getOptions(true));
// engine.select(cu, offset, offset + length - 1);
if (JavaModelManager.VERBOSE){
System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$
}
-
+
// open the parent if necessary
openParent(info, newElements, monitor);
if (monitor != null && monitor.isCanceled()) return;
newElements.remove(this);
throw e;
}
-
+
// remove out of sync buffer for this element
JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().remove(this);
* is the first time a request is being made for the buffer, an attempt is
* made to create and fill this element's buffer. If the buffer has been
* closed since it was first opened, the buffer is re-created.
- *
+ *
* @see IOpenable
*/
public IBuffer getBuffer() throws JavaModelException {
* @see IJavaElement
*/
public IOpenable getOpenable() {
- return this;
+ return this;
}
}
public boolean exists() {
-
+
IPackageFragmentRoot root = this.getPackageFragmentRoot();
if (root == null || root == this || !root.isArchive()) {
return parentExists() && resourceExists();
} else {
return super.exists();
}
-}
+}
/**
* Returns true if this element may have an associated source buffer,
return false;
}
/**
- * @see IParent
+ * @see IParent
*/
public boolean hasChildren() throws JavaModelException {
return getChildren().length > 0;
* @see IOpenable
*/
public boolean hasUnsavedChanges() throws JavaModelException{
-
+
if (isReadOnly() || !isOpen()) {
return false;
}
}
}
}
-
+
return false;
}
/**
return true;
}
/**
- *
+ *
* @see IOpenable
*/
public boolean isOpen() {
//}
/**
* @see IOpenable
- */
+ */
public void makeConsistent(IProgressMonitor monitor) throws JavaModelException {
if (isConsistent()) return;
-
+
// create a new info and make it the current info
// (this will remove the info and its children just before storing the new infos)
JavaModelManager manager = JavaModelManager.getJavaModelManager();
// */
//protected void openWhenClosed(IProgressMonitor pm) throws JavaModelException {
// try {
-//
+//
// if (JavaModelManager.VERBOSE){
// System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$
// }
-//
+//
// // 1) Parent must be open - open the parent if necessary
// openParent(pm);
//
// OpenableElementInfo info = createElementInfo();
// if (isSourceElement()) {
// this.openBuffer(pm);
-// }
+// }
//
// // 3) build the structure of the openable
// buildStructure(info, pm);
//
// // 4) anything special
// opening(info);
-//
+//
//// if (JavaModelManager.VERBOSE) {
//// System.out.println("-> Package cache size = " + JavaModelManager.getJavaModelManager().cache.pkgSize()); //$NON-NLS-1$
//// System.out.println("-> Openable cache filling ratio = " + JavaModelManager.getJavaModelManager().cache.openableFillingRatio() + "%"); //$NON-NLS-1$//$NON-NLS-2$
/**
* Answers true if the parent exists (null parent is answering true)
- *
+ *
*/
protected boolean parentExists(){
-
+
IJavaElement parent = this.getParent();
if (parent == null) return true;
return parent.exists();
protected boolean resourceExists() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (workspace == null) return false; // workaround for http://bugs.eclipse.org/bugs/show_bug.cgi?id=34069
- return
+ return
JavaModel.getTarget(
- workspace.getRoot(),
+ workspace.getRoot(),
this.getPath().makeRelative(), // ensure path is relative (see http://dev.eclipse.org/bugs/show_bug.cgi?id=22517)
true) != null;
}
* @see IOpenable
*/
public void save(IProgressMonitor pm, boolean force) throws JavaModelException {
- if (isReadOnly() || this.getResource().isReadOnly()) {
+ if (isReadOnly() || this.getResource().getResourceAttributes().isReadOnly()) {
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.READ_ONLY, this));
}
IBuffer buf = getBuffer();
//import net.sourceforge.phpdt.core.ICompilationUnit;
import net.sourceforge.phpdt.core.ICompilationUnit;
-import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType.File;
-
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.templates.GlobalTemplateVariables;
import org.eclipse.jface.text.templates.TemplateException;
/**
* A context type for javadoc.
- */
+ */
public class HTMLContextType extends CompilationUnitContextType {
/**
*/
public HTMLContextType() {
super("html"); //$NON-NLS-1$
-
+
// global
addResolver(new GlobalTemplateVariables.Cursor());
addResolver(new GlobalTemplateVariables.WordSelection());
addResolver(new GlobalTemplateVariables.Year());
addResolver(new GlobalTemplateVariables.Time());
addResolver(new GlobalTemplateVariables.User());
-
+
addResolver(new File());
}
-
+
/*
* @see ContextType#createContext()
- */
+ */
public CompilationUnitContext createContext(IDocument document, int offset, int length, ICompilationUnit compilationUnit) {
- return new HTMLUnitContext(this, document, offset, length, compilationUnit);
+ return new HTMLUnitContext(this, document, offset, length, compilationUnit);
}
/* (non-Javadoc)
* @see net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContextType#createContext(org.eclipse.jface.text.IDocument, int, int, net.sourceforge.phpdt.core.ICompilationUnit)
* @see net.sourceforge.phpdt.internal.corext.template.ContextType#validateVariables(net.sourceforge.phpdt.internal.corext.template.TemplateVariable[])
*/
protected void validateVariables(TemplateVariable[] variables) throws TemplateException {
- // check for multiple cursor variables
+ // check for multiple cursor variables
for (int i= 0; i < variables.length; i++) {
TemplateVariable var= variables[i];
if (var.getType().equals(GlobalTemplateVariables.Cursor.NAME)) {
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
* Utility methods for the Java Model.
*/
public class JavaModelUtil {
-
- /**
+
+ /**
* Finds a type by its qualified type name (dot separated).
* @param jproject The java project to search in
* @param str The fully qualified name (type name with enclosing type names and package (all separated by dots))
* @return The type found, or null if not existing
- */
+ */
// public static IType findType(IJavaProject jproject, String fullyQualifiedName) throws JavaModelException {
// //workaround for bug 22883
// IType type= jproject.findType(fullyQualifiedName);
// type= findType(root, fullyQualifiedName);
// if (type != null && type.exists())
// return type;
-// }
+// }
// return null;
// }
-
+
/**
* Returns <code>true</code> if the given package fragment root is
* referenced. This means it is own by a different project but is referenced
// }
return false;
}
-
+
// private static IType findType(IPackageFragmentRoot root, String fullyQualifiedName) throws JavaModelException{
// IJavaElement[] children= root.getChildren();
// for (int i= 0; i < children.length; i++) {
// if (type != null && type.exists())
// return type;
// }
-// }
+// }
// return null;
// }
-
+
// private static IType findType(IPackageFragment pack, String fullyQualifiedName) throws JavaModelException{
// ICompilationUnit[] cus= pack.getCompilationUnits();
// for (int i= 0; i < cus.length; i++) {
// }
// return null;
// }
-
+
// private static IType findType(ICompilationUnit cu, String fullyQualifiedName) throws JavaModelException{
// IType[] types= cu.getAllTypes();
// for (int i= 0; i < types.length; i++) {
// }
// return null;
// }
-
- /**
+
+ /**
* Finds a type by package and type name.
* @param jproject the java project to search in
* @param pack The package name
* @param typeQualifiedName the type qualified name (type name with enclosing type names (separated by dots))
* @return the type found, or null if not existing
* @deprecated Use IJavaProject.findType(String, String) instead
- */
+ */
// public static IType findType(IJavaProject jproject, String pack, String typeQualifiedName) throws JavaModelException {
// return jproject.findType(pack, typeQualifiedName);
// }
// if (!(result instanceof IPackageFragment)) {
// result= null;
// }
-//
+//
// }
// return result;
-// }
-
- /**
+// }
+
+ /**
* Finds a type in a compilation unit. Typical usage is to find the corresponding
* type in a working copy.
* @param cu the compilation unit to search in
* @param typeQualifiedName the type qualified name (type name with enclosing type names (separated by dots))
* @return the type found, or null if not existing
- */
+ */
public static IType findTypeInCompilationUnit(ICompilationUnit cu, String typeQualifiedName) throws JavaModelException {
IType[] types= cu.getAllTypes();
for (int i= 0; i < types.length; i++) {
}
return null;
}
-
- /**
+
+ /**
* Finds a a member in a compilation unit. Typical usage is to find the corresponding
* member in a working copy.
* @param cu the compilation unit (eg. working copy) to search in
* @param member the member (eg. from the original)
* @return the member found, or null if not existing
- */
+ */
public static IMember findMemberInCompilationUnit(ICompilationUnit cu, IMember member) throws JavaModelException {
IJavaElement[] elements= cu.findElements(member);
if (elements != null && elements.length > 0) {
}
return null;
}
-
-
- /**
+
+
+ /**
* Returns the element of the given compilation unit which is "equal" to the
* given element. Note that the given element usually has a parent different
* from the given compilation unit.
- *
+ *
* @param cu the cu to search in
* @param element the element to look for
* @return an element of the given cu "equal" to the given element
- */
+ */
public static IJavaElement findInCompilationUnit(ICompilationUnit cu, IJavaElement element) throws JavaModelException {
IJavaElement[] elements= cu.findElements(element);
if (elements != null && elements.length > 0) {
}
return null;
}
-
+
/**
* Returns the qualified type name of the given type using '.' as separators.
* This is a replace for IType.getTypeQualifiedName()
public static String getTypeQualifiedName(IType type) {
return type.getTypeQualifiedName('.');
}
-
+
private static void getTypeQualifiedName(IType type, StringBuffer buf) {
IType outerType= type.getDeclaringType();
if (outerType != null) {
buf.append('.');
}
buf.append(type.getElementName());
- }
+ }
/**
* Returns the fully qualified name of the given type using '.' as separators.
public static String getFullyQualifiedName(IType type) {
return type.getFullyQualifiedName('.');
}
-
+
/**
* Returns the fully qualified name of a type's container. (package name or enclosing type name)
*/
return type.getPackageFragment().getElementName();
}
}
-
-
+
+
/**
* Concatenates two names. Uses a dot for separation.
* Both strings can be empty or <code>null</code>.
buf.append('.');
}
buf.append(name2);
- }
+ }
return buf.toString();
}
-
+
/**
* Concatenates two names. Uses a dot for separation.
* Both strings can be empty or <code>null</code>.
buf.append('.');
}
buf.append(name2);
- }
+ }
return buf.toString();
- }
-
+ }
+
/**
* Evaluates if a member (possible from another package) is visible from
* elements in a package.
*/
public static boolean isVisible(IMember member, IPackageFragment pack) throws JavaModelException {
int otherflags= member.getFlags();
-
+
if (Flags.isPublic(otherflags)) {
return true;
} else if (Flags.isPrivate(otherflags)) {
return false;
- }
-
+ }
+
IPackageFragment otherpack= (IPackageFragment) findParentOfKind(member, IJavaElement.PACKAGE_FRAGMENT);
return (pack != null && pack.equals(otherpack));
}
-
+
/**
* Returns the package fragment root of <code>IJavaElement</code>. If the given
* element is already a package fragment root, the element itself is returned.
}
/**
- * Returns the parent of the supplied java element that conforms to the given
+ * Returns the parent of the supplied java element that conforms to the given
* parent type or <code>null</code>, if such a parent doesn't exit.
* @deprecated Use element.getParent().getAncestor(kind);
*/
}
return null;
}
-
+
/**
* Finds a method in a type.
* This searches for a method with the same name and signature. Parameter types are only
}
return null;
}
-
+
/**
* Finds a method declararion in a type's hierarchy. The search is top down, so this
// }
// return null;
// }
-
+
/**
* Finds a method implementation in a type's classhierarchy. The search is bottom-up, so this
* returns the nearest overridden method. Does not find methods in interfaces or abstract methods.
// }
// }
// return null;
-// }
-
+// }
+
/**
* Tests if a method equals to the given signature.
* Parameter types are only compared by the simple name, no resolving for
}
return false;
}
-
+
/**
* Checks whether the given type has a valid main method or not.
*/
}
return false;
}
-
+
/**
* Checks if the field is boolean.
*/
public static boolean isBoolean(IField field) throws JavaModelException{
return field.getTypeSignature().equals(Signature.SIG_BOOLEAN);
}
-
+
/**
* Returns true if the element is on the build path of the given project
* @deprecated Use jproject.isOnClasspath(element);
- */
+ */
// public static boolean isOnBuildPath(IJavaProject jproject, IJavaElement element) throws JavaModelException {
// return jproject.isOnClasspath(element);
// }
-
+
/**
* Tests if the given element is on the class path of its containing project. Handles the case
* that the containing project isn't a Java project.
* @param refTypeSig the type name in signature notation (for example 'QVector')
* this can also be an array type, but dimensions will be ignored.
* @param declaringType the context for resolving (type where the reference was made in)
- * @return returns the fully qualified type name or build-in-type name.
+ * @return returns the fully qualified type name or build-in-type name.
* if a unresoved type couldn't be resolved null is returned
*/
public static String getResolvedTypeName(String refTypeSig, IType declaringType) throws JavaModelException {
if (semi == -1) {
throw new IllegalArgumentException();
}
- String name= refTypeSig.substring(arrayCount + 1, semi);
-
+ String name= refTypeSig.substring(arrayCount + 1, semi);
+
// String[][] resolvedNames= declaringType.resolveType(name);
// if (resolvedNames != null && resolvedNames.length > 0) {
// return JavaModelUtil.concatenateName(resolvedNames[0][0], resolvedNames[0][1]);
return Signature.toString(refTypeSig.substring(arrayCount));
}
}
-
+
/**
* Returns if a CU can be edited.
*/
cu= (ICompilationUnit) cu.getOriginalElement();
}
IResource resource= cu.getResource();
- return (resource.exists() && !resource.isReadOnly());
+ return (resource.exists() && !resource.getResourceAttributes().isReadOnly());
}
/**
* Finds a qualified import for a type name.
- */
+ */
// public static IImportDeclaration findImport(ICompilationUnit cu, String simpleName) throws JavaModelException {
// IImportDeclaration[] existing= cu.getImports();
// for (int i= 0; i < existing.length; i++) {
// return existing[i];
// }
// }
-// }
+// }
// return null;
// }
-
+
/**
* Returns the original if the given member. If the member is already
* an original the input is returned. The returned member must not exist
return (IMember)cu.getOriginal(member);
return member;
}
-
+
/*
* XXX workaround for bug 18568
* http://bugs.eclipse.org/bugs/show_bug.cgi?id=18568
ICompilationUnit cu= method.getCompilationUnit();
if (cu == null || ! cu.isWorkingCopy())
return method;
- //use the workaround only if needed
+ //use the workaround only if needed
if (! method.getElementName().equals(method.getDeclaringType().getElementName()))
return (IMethod)cu.getOriginal(method);
-
+
IType originalType = (IType)toOriginal(method.getDeclaringType());
IMethod[] methods = originalType.findMethods(method);
boolean isConstructor = method.isConstructor();
for (int i=0; i < methods.length; i++) {
- if (methods[i].isConstructor() == isConstructor)
+ if (methods[i].isConstructor() == isConstructor)
return methods[i];
}
return null;
} catch(JavaModelException e){
return null;
- }
+ }
}
/**
if (cu != null && cu.isWorkingCopy())
return (ICompilationUnit) cu.getOriginal(cu);
return cu;
- }
-
+ }
+
/**
* Returns the working copy of the given member. If the member is already in a
* working copy or the member does not exist in the working copy the input is returned.
/**
* Returns the working copy CU of the given CU. If the CU is already a
* working copy or the CU has no working copy the input CU is returned.
- */
+ */
public static ICompilationUnit toWorkingCopy(ICompilationUnit cu) {
if (!cu.isWorkingCopy()) {
ICompilationUnit workingCopy= EditorUtility.getWorkingCopy(cu);
}
return cu;
}
-
+
/*
* http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- *
+ *
* Reconciling happens in a separate thread. This can cause a situation where the
* Java element gets disposed after an exists test has been done. So we should not
* log not present exceptions when they happen in working copies.
if (!unit.isWorkingCopy())
return true;
}
- return false;
+ return false;
}
// public static IType[] getAllSuperTypes(IType type, IProgressMonitor pm) throws JavaModelException {
// try{
// pm.beginTask("", 3); //$NON-NLS-1$
// ITypeHierarchy hierarchy= type.newSupertypeHierarchy(new SubProgressMonitor(pm, 1));
-//
+//
// IProgressMonitor subPm= new SubProgressMonitor(pm, 2);
// List typeList= Arrays.asList(hierarchy.getAllSupertypes(type));
// subPm.beginTask("", typeList.size()); //$NON-NLS-1$
// return (IType[]) types.toArray(new IType[types.size()]);
// } finally {
// pm.done();
-// }
+// }
// }
-
-
+
+
public static boolean isExcludedPath(IPath resourcePath, IPath[] exclusionPatterns) {
char[] path = resourcePath.toString().toCharArray();
for (int i = 0, length = exclusionPatterns.length; i < length; i++) {
return true;
}
}
- return false;
+ return false;
}
/*
* Returns whether the given resource path matches one of the exclusion
* patterns.
- *
+ *
* @see IClasspathEntry#getExclusionPatterns
*/
public final static boolean isExcluded(IPath resourcePath, char[][] exclusionPatterns) {
if (CharOperation.pathMatch(exclusionPatterns[i], path, true, '/'))
return true;
return false;
- }
-
+ }
+
private static final String ARGUMENTS_DELIMITER = "#"; //$NON-NLS-1$
private static final String EMPTY_ARGUMENT = " "; //$NON-NLS-1$
-
+
/**
* Copied from net.sourceforge.phpdt.internal.core.ProjectPrefUtil;
*/
int index = argumentsString.indexOf(':');
if(index == -1)
return null;
-
+
int length = argumentsString.length();
int numberOfArg;
try{
return null;
}
argumentsString = argumentsString.substring(index + 1, length);
-
+
String[] args = new String[length];
int count = 0;
-
+
StringTokenizer tokenizer = new StringTokenizer(argumentsString, ARGUMENTS_DELIMITER);
while(tokenizer.hasMoreTokens()) {
String argument = tokenizer.nextToken();
argument = ""; //$NON-NLS-1$
args[count++] = argument;
}
-
+
if(count != numberOfArg)
return null;
-
+
System.arraycopy(args, 0, args = new String[count], 0, count);
return args;
}
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/**
* Checks if the given resource is in sync with the underlying file system.
- *
+ *
* @param resource the resource to be checked
* @return IStatus status describing the check's result. If <code>status.
* isOK()</code> returns <code>true</code> then the resource is in sync
public static IStatus checkInSync(IResource resource) {
return checkInSync(new IResource[] {resource});
}
-
+
/**
* Checks if the given resources are in sync with the underlying file
* system.
- *
+ *
* @param resources the resources to be checked
* @return IStatus status describing the check's result. If <code>status.
* isOK() </code> returns <code>true</code> then the resources are in sync
IResource resource= resources[i];
if (!resource.isSynchronized(IResource.DEPTH_INFINITE)) {
result= addOutOfSync(result, resource);
- }
+ }
}
if (result != null)
return result;
- return new Status(IStatus.OK, PHPeclipsePlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
+ return new Status(IStatus.OK, PHPeclipsePlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
}
/**
* Makes the given resource committable. Committable means that it is
* writeable and that its content hasn't changed by calling
* <code>validateEdit</code> for the given resource on <tt>IWorkspace</tt>.
- *
+ *
* @param resource the resource to be checked
- * @param context the context passed to <code>validateEdit</code>
+ * @param context the context passed to <code>validateEdit</code>
* @return status describing the method's result. If <code>status.isOK()</code> returns <code>true</code> then the resources are committable.
- *
+ *
* @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
*/
public static IStatus makeCommittable(IResource resource, Object context) {
return makeCommittable(new IResource[] { resource }, context);
}
-
+
/**
* Makes the given resources committable. Committable means that all
* resources are writeable and that the content of the resources hasn't
* changed by calling <code>validateEdit</code> for a given file on
* <tt>IWorkspace</tt>.
- *
+ *
* @param resources the resources to be checked
- * @param context the context passed to <code>validateEdit</code>
+ * @param context the context passed to <code>validateEdit</code>
* @return IStatus status describing the method's result. If <code>status.
* isOK()</code> returns <code>true</code> then the add resources are
* committable
- *
+ *
* @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
*/
public static IStatus makeCommittable(IResource[] resources, Object context) {
List readOnlyFiles= new ArrayList();
for (int i= 0; i < resources.length; i++) {
IResource resource= resources[i];
- if (resource.getType() == IResource.FILE && resource.isReadOnly())
+ if (resource.getType() == IResource.FILE && resource.getResourceAttributes().isReadOnly())
readOnlyFiles.add(resource);
}
if (readOnlyFiles.size() == 0)
return new Status(IStatus.OK, PHPeclipsePlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
-
+
Map oldTimeStamps= createModificationStampMap(readOnlyFiles);
IStatus status= ResourcesPlugin.getWorkspace().validateEdit(
(IFile[]) readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), context);
if (!status.isOK())
return status;
-
+
IStatus modified= null;
Map newTimeStamps= createModificationStampMap(readOnlyFiles);
for (Iterator iter= oldTimeStamps.keySet().iterator(); iter.hasNext();) {
if (!oldTimeStamps.get(file).equals(newTimeStamps.get(file)))
modified= addModified(modified, file);
}
- if (modified != null)
+ if (modified != null)
return modified;
return new Status(IStatus.OK, PHPeclipsePlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
}
}
return map;
}
-
+
private static IStatus addModified(IStatus status, IFile file) {
IStatus entry= PHPUIStatus.createError(
- IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
- CorextMessages.getFormattedString("Resources.fileModified", file.getFullPath().toString()), //$NON-NLS-1$
+ IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
+ CorextMessages.getFormattedString("Resources.fileModified", file.getFullPath().toString()), //$NON-NLS-1$
null);
if (status == null) {
return entry;
} else {
MultiStatus result= new MultiStatus(PHPeclipsePlugin.getPluginId(),
IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
- CorextMessages.getString("Resources.modifiedResources"), null); //$NON-NLS-1$
+ CorextMessages.getString("Resources.modifiedResources"), null); //$NON-NLS-1$
result.add(status);
result.add(entry);
return result;
}
- }
+ }
private static IStatus addOutOfSync(IStatus status, IResource resource) {
IStatus entry= new Status(
IStatus.ERROR,
ResourcesPlugin.PI_RESOURCES,
IResourceStatus.OUT_OF_SYNC_LOCAL,
- CorextMessages.getFormattedString("Resources.outOfSync", resource.getFullPath().toString()), //$NON-NLS-1$
+ CorextMessages.getFormattedString("Resources.outOfSync", resource.getFullPath().toString()), //$NON-NLS-1$
null);
if (status == null) {
return entry;
MultiStatus result= new MultiStatus(
ResourcesPlugin.PI_RESOURCES,
IResourceStatus.OUT_OF_SYNC_LOCAL,
- CorextMessages.getString("Resources.outOfSyncResources"), null); //$NON-NLS-1$
+ CorextMessages.getString("Resources.outOfSyncResources"), null); //$NON-NLS-1$
result.add(status);
result.add(entry);
return result;
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import net.sourceforge.phpdt.internal.ui.PHPUiImages;
import org.eclipse.jface.action.Action;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/**
* This is an action template for actions that toggle whether
* it links its selection to the active editor.
- *
+ *
* @since 3.0
*/
public abstract class AbstractToggleLinkingAction extends Action {
-
+
/**
* Constructs a new action.
*/
super(ActionMessages.getString("ToggleLinkingAction.label")); //$NON-NLS-1$
setDescription(ActionMessages.getString("ToggleLinkingAction.description")); //$NON-NLS-1$
setToolTipText(ActionMessages.getString("ToggleLinkingAction.tooltip")); //$NON-NLS-1$
- PHPUiImages.setLocalImageDescriptors(this, "synced.gif"); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, IJavaHelpContextIds.LINK_EDITOR_ACTION);
+ PHPUiImages.setLocalImageDescriptors(this, "synced.gif"); //$NON-NLS-1$
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LINK_EDITOR_ACTION);
}
/**
}
/**
- * If set, the checked /gray state of containers (inner nodes) is derived from the checked state of its
+ * If set, the checked /gray state of containers (inner nodes) is derived from the checked state of its
* leaf nodes.
* @param containerMode The containerMode to set
*/
public void create() {
super.create();
- List initialSelections = getInitialSelections();
+ List initialSelections = getInitialElementSelections();
if (initialSelections != null) {
fViewer.setCheckedElements(initialSelections.toArray());
}
* A class to select elements out of a list of elements.
*/
public class ElementListSelectionDialog extends AbstractElementListSelectionDialog {
-
+
private Object[] fElements;
-
+
/**
* Creates a list selection dialog.
* @param parent the parent widget.
* @param renderer the label renderer.
- */
+ */
public ElementListSelectionDialog(Shell parent, ILabelProvider renderer) {
super(parent, renderer);
}
protected void computeResult() {
setResult(Arrays.asList(getSelectedElements()));
}
-
+
/*
* @see Dialog#createDialogArea(Composite)
*/
protected Control createDialogArea(Composite parent) {
Composite contents= (Composite) super.createDialogArea(parent);
-
+
createMessageArea(contents);
createFilterText(contents);
createFilteredList(contents);
setListElements(fElements);
- List initialSelections= getInitialSelections();
+ List initialSelections= getInitialElementSelections();
if (initialSelections != null)
setSelection(initialSelections.toArray());
-
+
return contents;
}
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.ui.help.WorkbenchHelp;
public class CustomFiltersDialog extends SelectionDialog {
private Stack fFilterDescriptorChangeHistory;
-
+
/**
* Creates a dialog to customize Java element filters.
- *
+ *
* @param shell the parent shell
* @param viewId the id of the view
* @param enablePatterns <code>true</code> if pattern filters are enabled
setTitle(FilterMessages.getString("CustomFiltersDialog.title")); //$NON-NLS-1$
setMessage(FilterMessages.getString("CustomFiltersDialog.filterList.label")); //$NON-NLS-1$
super.configureShell(shell);
- WorkbenchHelp.setHelp(shell, IJavaHelpContextIds.CUSTOM_FILTERS_DIALOG);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IJavaHelpContextIds.CUSTOM_FILTERS_DIALOG);
}
/**
* Overrides method in Dialog
- *
+ *
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
- */
+ */
protected Control createDialogArea(Composite parent) {
initializeDialogUnits(parent);
// create a composite with standard margins and spacing
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setFont(parent.getFont());
Composite group= composite;
-
+
// Checkbox
fEnableUserDefinedPatterns= new Button(group, SWT.CHECK);
fEnableUserDefinedPatterns.setFocus();
fEnableUserDefinedPatterns.setText(FilterMessages.getString("CustomFiltersDialog.enableUserDefinedPattern")); //$NON-NLS-1$
-
+
// Pattern field
fUserDefinedPatterns= new Text(group, SWT.SINGLE | SWT.BORDER);
GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
// Filters provided by extension point
if (fBuiltInFilters.length > 0)
createCheckBoxList(group);
-
- applyDialogFont(parent);
+
+ applyDialogFont(parent);
return parent;
}
private void createCheckBoxList(Composite parent) {
// Filler
new Label(parent, SWT.NONE);
-
+
Label info= new Label(parent, SWT.LEFT);
info.setText(FilterMessages.getString("CustomFiltersDialog.filterList.label")); //$NON-NLS-1$
-
+
fCheckBoxList= CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
GridData data= new GridData(GridData.FILL_BOTH);
data.heightHint= fCheckBoxList.getTable().getItemHeight() * 10;
fCheckBoxList.setInput(fBuiltInFilters);
setInitialSelections(getEnabledFilterDescriptors());
-
+
List initialSelection= getInitialElementSelections();
if (initialSelection != null && !initialSelection.isEmpty())
checkInitialSelections();
}
super.okPressed();
}
-
+
private ILabelProvider createLabelPrivder() {
- return
+ return
new LabelProvider() {
public Image getImage(Object element) {
return null;
}
// ---------- result handling ----------
-
+
protected void setResult(List newResult) {
super.setResult(newResult);
if (fUserDefinedPatterns.getText().length() > 0) {
} else {
fEnablePatterns= false;
fPatterns= new String[0];
- }
+ }
}
public boolean areUserDefinedPatternsEnabled() {
return fEnablePatterns;
}
-
+
/**
* @return a stack with the filter descriptor check history
* @since 3.0
}
return (String[])result.toArray(new String[result.size()]);
}
-
+
private static void addPattern(List list, String pattern) {
if (list.isEmpty())
list.add(pattern);
}
return strBuf.toString();
}
-
+
private static String escapeSeparator(String pattern, String separator) {
int length= pattern.length();
StringBuffer buf= new StringBuffer(length);
buf.append(ch);
}
return buf.toString();
-
+
}
}
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/**
* Abstract preference page which is used to wrap a
* {@link net.sourceforge.phpdt.internal.ui.preferences.IPreferenceConfigurationBlock}.
- *
+ *
* @since 3.0
*/
public abstract class AbstractConfigurationBlockPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
-
+
+
private IPreferenceConfigurationBlock fConfigurationBlock;
private OverlayPreferenceStore fOverlayStore;
-
+
/**
* Creates a new preference page.
fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {});
fConfigurationBlock= createConfigurationBlock(fOverlayStore);
}
-
+
protected abstract IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore);
protected abstract String getHelpId();
protected abstract void setDescription();
protected abstract void setPreferenceStore();
-
+
/*
* @see IWorkbenchPreferencePage#init()
- */
+ */
public void init(IWorkbench workbench) {
}
*/
public void createControl(Composite parent) {
super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), getHelpId());
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpId());
}
-
+
/*
* @see PreferencePage#createContents(Composite)
*/
protected Control createContents(Composite parent) {
-
+
fOverlayStore.load();
fOverlayStore.start();
-
+
fConfigurationBlock.createControl(parent);
-
+
initialize();
-
+
Dialog.applyDialogFont(parent);
return parent;
}
-
+
private void initialize() {
fConfigurationBlock.initialize();
}
-
+
/*
* @see PreferencePage#performOk()
*/
public boolean performOk() {
-
+
fConfigurationBlock.performOk();
fOverlayStore.propagate();
-
+
PHPeclipsePlugin.getDefault().savePluginPreferences();
-
+
return true;
}
-
+
/*
* @see PreferencePage#performDefaults()
*/
public void performDefaults() {
-
+
fOverlayStore.loadDefaults();
fConfigurationBlock.performDefaults();
super.performDefaults();
}
-
+
/*
* @see DialogPage#dispose()
*/
public void dispose() {
-
+
fConfigurationBlock.dispose();
-
+
if (fOverlayStore != null) {
fOverlayStore.stop();
fOverlayStore= null;
}
-
+
super.dispose();
}
}
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/*
* The page to configure the code formatter options.
public CodeTemplatePreferencePage() {
setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
//setDescription(PreferencesMessages.getString("CodeTemplatesPreferencePage.description")); //$NON-NLS-1$
-
+
// only used when page is shown programatically
setTitle(PreferencesMessages.getString("CodeTemplatesPreferencePage.title")); //$NON-NLS-1$
-
+
fCodeTemplateConfigurationBlock= new CodeTemplateBlock();
}
/*
* @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
+ */
public void init(IWorkbench workbench) {
}
*/
public void createControl(Composite parent) {
super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.CODE_MANIPULATION_PREFERENCE_PAGE);
- }
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.CODE_MANIPULATION_PREFERENCE_PAGE);
+ }
/*
* @see PreferencePage#createContents(Composite)
public boolean performOk() {
if (!fCodeTemplateConfigurationBlock.performOk(true)) {
return false;
- }
+ }
return super.performOk();
}
-
+
/*
* @see PreferencePage#performDefaults()
*/
fCodeTemplateConfigurationBlock.performDefaults();
super.performDefaults();
}
-
+
/* (non-Javadoc)
* @see net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
*/
public void statusChanged(IStatus status) {
setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
+ StatusUtil.applyToStatusLine(this, status);
}
/* (non-Javadoc)
*/
public boolean performCancel() {
fCodeTemplateConfigurationBlock.performCancel();
-
+
return super.performCancel();
}
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/*
* The page to configure the compiler options.
public CompilerPreferencePage() {
setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
setDescription(PreferencesMessages.getString("CompilerPreferencePage.description")); //$NON-NLS-1$
-
+
// only used when page is shown programatically
setTitle(PreferencesMessages.getString("CompilerPreferencePage.title")); //$NON-NLS-1$
-
+
fConfigurationBlock= new CompilerConfigurationBlock(this, null);
}
-
+
/*
* @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
+ */
public void init(IWorkbench workbench) {
}
*/
public void createControl(Composite parent) {
super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE);
- }
+ PlatformUI.getWorkbench().getHelpSystem().
+ setHelp(getControl(), IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE);
+ }
/*
* @see PreferencePage#createContents(Composite)
public boolean performOk() {
if (!fConfigurationBlock.performOk(true)) {
return false;
- }
+ }
return super.performOk();
}
-
+
/*
* @see PreferencePage#performDefaults()
*/
fConfigurationBlock.performDefaults();
super.performDefaults();
}
-
+
/* (non-Javadoc)
* @see net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
*/
public void statusChanged(IStatus status) {
setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
+ StatusUtil.applyToStatusLine(this, status);
}
}
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.ui.help.WorkbenchHelp;
/**
* Property page used to configure project specific compiler settings
private SelectionButtonDialogField fChangeWorkspaceSettings;
private SelectionButtonDialogField fUseProjectSettings;
private IStatus fBlockStatus;
-
+
public CompilerPropertyPage() {
fBlockStatus= new StatusInfo();
fBlockEnableState= null;
-
+
IDialogFieldListener listener= new IDialogFieldListener() {
public void dialogFieldChanged(DialogField field) {
doDialogFieldChanged(field);
}
};
-
+
fUseWorkspaceSettings= new SelectionButtonDialogField(SWT.RADIO);
fUseWorkspaceSettings.setDialogFieldListener(listener);
fUseWorkspaceSettings.setLabelText(PreferencesMessages.getString("CompilerPropertyPage.useworkspacesettings.label")); //$NON-NLS-1$
fChangeWorkspaceSettings= new SelectionButtonDialogField(SWT.PUSH);
fChangeWorkspaceSettings.setLabelText(PreferencesMessages.getString("CompilerPropertyPage.useworkspacesettings.change")); //$NON-NLS-1$
fChangeWorkspaceSettings.setDialogFieldListener(listener);
-
+
fUseWorkspaceSettings.attachDialogField(fChangeWorkspaceSettings);
fUseProjectSettings= new SelectionButtonDialogField(SWT.RADIO);
*/
public void createControl(Composite parent) {
super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.COMPILER_PROPERTY_PAGE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PROPERTY_PAGE);
}
/*
fBlockStatus= status;
doStatusChanged();
}
- };
+ };
fConfigurationBlock= new CompilerConfigurationBlock(listener, getProject());
-
+
Composite composite= new Composite(parent, SWT.NONE);
GridLayout layout= new GridLayout();
layout.marginHeight= 0;
layout.marginWidth= 0;
layout.numColumns= 2;
composite.setLayout(layout);
-
+
fUseWorkspaceSettings.doFillIntoGrid(composite, 1);
LayoutUtil.setHorizontalGrabbing(fUseWorkspaceSettings.getSelectionButton(null));
-
+
fChangeWorkspaceSettings.doFillIntoGrid(composite, 1);
-
+
fUseProjectSettings.doFillIntoGrid(composite, 2);
-
+
GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL );
data.horizontalSpan= 2;
-
+
fConfigurationBlockControl= fConfigurationBlock.createContents(composite);
fConfigurationBlockControl.setLayoutData(data);
-
+
boolean useProjectSettings= fConfigurationBlock.hasProjectSpecificOptions();
-
+
fUseProjectSettings.setSelection(useProjectSettings);
fUseWorkspaceSettings.setSelection(!useProjectSettings);
-
+
updateEnableState();
Dialog.applyDialogFont(composite);
return composite;
}
-
+
private boolean useProjectSettings() {
return fUseProjectSettings.isSelected();
}
-
+
private void doDialogFieldChanged(DialogField field) {
if (field == fChangeWorkspaceSettings) {
String id= "net.sourceforge.phpdt.ui.preferences.CompilerPreferencePage"; //$NON-NLS-1$
updateEnableState();
doStatusChanged();
}
- }
+ }
/**
* Method statusChanged.
*/
private void doStatusChanged() {
updateStatus(useProjectSettings() ? fBlockStatus : new StatusInfo());
}
-
+
/**
* Method getProject.
*/
private IJavaProject getProject() {
- return (IJavaProject) getElement().getAdapter(IJavaElement.class);
+ return (IJavaProject) getElement().getAdapter(IJavaElement.class);
}
-
+
private void updateEnableState() {
if (useProjectSettings()) {
if (fBlockEnableState != null) {
if (fBlockEnableState == null) {
fBlockEnableState= ControlEnableState.disable(fConfigurationBlockControl);
}
- }
+ }
}
-
+
/*
* @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
*/
public boolean performOk() {
return fConfigurationBlock.performOk(useProjectSettings());
}
-
+
private void updateStatus(IStatus status) {
setValid(!status.matches(IStatus.ERROR));
StatusUtil.applyToStatusLine(this, status);
}
-
+
private boolean showPreferencePage(String id, IPreferencePage page) {
final IPreferenceNode targetNode = new PreferenceNode(id, page);
-
+
PreferenceManager manager = new PreferenceManager();
manager.addToRoot(targetNode);
final PreferenceDialog dialog = new PreferenceDialog(getControl().getShell(), manager);
}
});
return result[0];
- }
+ }
}
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.IUpdate;
public class EditTemplateDialog extends StatusDialog {
private static class TextViewerAction extends Action implements IUpdate {
-
+
private int fOperationCode= -1;
private ITextOperationTarget fOperationTarget;
-
- /**
+
+ /**
* Creates a new action.
- *
+ *
* @param viewer the viewer
* @param operationCode the opcode
*/
fOperationTarget= viewer.getTextOperationTarget();
update();
}
-
+
/**
* Updates the enabled state of the action.
* Fires a property change if the enabled state changes.
- *
+ *
* @see Action#firePropertyChange(String, Object, Object)
*/
public void update() {
-
+
boolean wasEnabled= isEnabled();
boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
setEnabled(isEnabled);
-
+
if (wasEnabled != isEnabled) {
firePropertyChange(ENABLED, wasEnabled ? Boolean.TRUE : Boolean.FALSE, isEnabled ? Boolean.TRUE : Boolean.FALSE);
}
}
-
+
/**
* @see Action#run()
*/
fOperationTarget.doOperation(fOperationCode);
}
}
- }
+ }
private final Template fTemplate;
-
+
private Text fNameText;
private Text fDescriptionText;
private Combo fContextCombo;
- private SourceViewer fPatternEditor;
+ private SourceViewer fPatternEditor;
private Button fInsertVariableButton;
private boolean fIsNameModifiable;
private StatusInfo fValidationStatus;
- private boolean fSuppressError= true; // #4354
+ private boolean fSuppressError= true; // #4354
private Map fGlobalActions= new HashMap(10);
- private List fSelectionActions = new ArrayList(3);
+ private List fSelectionActions = new ArrayList(3);
private String[][] fContextTypes;
-
- private ContextTypeRegistry fContextTypeRegistry;
-
+
+ private ContextTypeRegistry fContextTypeRegistry;
+
private final TemplateVariableProcessor fTemplateProcessor= new TemplateVariableProcessor();
-
+
/**
* Creates a new dialog.
- *
+ *
* @param parent the shell parent of the dialog
* @param template the template to edit
* @param edit whether this is a new template or an existing being edited
*/
public EditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable, ContextTypeRegistry registry) {
super(parent);
-
+
setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE);
-
+
String title= edit
? PreferencesMessages.getString("EditTemplateDialog.title.edit") //$NON-NLS-1$
: PreferencesMessages.getString("EditTemplateDialog.title.new"); //$NON-NLS-1$
fTemplate= template;
fIsNameModifiable= isNameModifiable;
-
+
// XXX workaround for bug 63313 - disabling prefix until fixed.
// String delim= new Document().getLegalLineDelimiters()[0];
-
+
List contexts= new ArrayList();
for (Iterator it= registry.contextTypes(); it.hasNext();) {
TemplateContextType type= (TemplateContextType) it.next();
contexts.add(new String[] { type.getId(), type.getName(), "" }); //$NON-NLS-1$
}
fContextTypes= (String[][]) contexts.toArray(new String[contexts.size()][]);
-
+
fValidationStatus= new StatusInfo();
-
+
fContextTypeRegistry= registry;
-
+
TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId());
fTemplateProcessor.setContextType(type);
}
-
+
/*
* @see net.sourceforge.phpdt.internal.ui.dialogs.StatusDialog#create()
*/
public void create() {
super.create();
- // update initial ok button to be disabled for new templates
+ // update initial ok button to be disabled for new templates
boolean valid= fNameText == null || fNameText.getText().trim().length() != 0;
if (!valid) {
StatusInfo status = new StatusInfo();
updateButtonsEnableState(status);
}
}
-
+
/*
* @see Dialog#createDialogArea(Composite)
*/
layout.numColumns= 2;
parent.setLayout(layout);
parent.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
ModifyListener listener= new ModifyListener() {
public void modifyText(ModifyEvent e) {
doTextWidgetChanged(e.widget);
}
};
-
+
if (fIsNameModifiable) {
- createLabel(parent, PreferencesMessages.getString("EditTemplateDialog.name")); //$NON-NLS-1$
-
+ createLabel(parent, PreferencesMessages.getString("EditTemplateDialog.name")); //$NON-NLS-1$
+
Composite composite= new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- layout= new GridLayout();
+ layout= new GridLayout();
layout.numColumns= 3;
layout.marginWidth= 0;
layout.marginHeight= 0;
composite.setLayout(layout);
-
+
fNameText= createText(composite);
fNameText.addFocusListener(new FocusListener() {
-
+
public void focusGained(FocusEvent e) {
}
-
+
public void focusLost(FocusEvent e) {
if (fSuppressError) {
fSuppressError= false;
}
}
});
-
- createLabel(composite, PreferencesMessages.getString("EditTemplateDialog.context")); //$NON-NLS-1$
+
+ createLabel(composite, PreferencesMessages.getString("EditTemplateDialog.context")); //$NON-NLS-1$
fContextCombo= new Combo(composite, SWT.READ_ONLY);
-
+
for (int i= 0; i < fContextTypes.length; i++) {
fContextCombo.add(fContextTypes[i][1]);
}
-
+
fContextCombo.addModifyListener(listener);
}
-
- createLabel(parent, PreferencesMessages.getString("EditTemplateDialog.description")); //$NON-NLS-1$
-
+
+ createLabel(parent, PreferencesMessages.getString("EditTemplateDialog.description")); //$NON-NLS-1$
+
int descFlags= fIsNameModifiable ? SWT.BORDER : SWT.BORDER | SWT.READ_ONLY;
fDescriptionText= new Text(parent, descFlags );
- fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+ fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
fDescriptionText.addModifyListener(listener);
Label patternLabel= createLabel(parent, PreferencesMessages.getString("EditTemplateDialog.pattern")); //$NON-NLS-1$
patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
fPatternEditor= createEditor(parent);
-
- Label filler= new Label(parent, SWT.NONE);
+
+ Label filler= new Label(parent, SWT.NONE);
filler.setLayoutData(new GridData());
-
+
Composite composite= new Composite(parent, SWT.NONE);
- layout= new GridLayout();
+ layout= new GridLayout();
layout.marginWidth= 0;
layout.marginHeight= 0;
- composite.setLayout(layout);
+ composite.setLayout(layout);
composite.setLayoutData(new GridData());
-
+
fInsertVariableButton= new Button(composite, SWT.NONE);
fInsertVariableButton.setLayoutData(getButtonGridData(fInsertVariableButton));
fInsertVariableButton.setText(PreferencesMessages.getString("EditTemplateDialog.insert.variable")); //$NON-NLS-1$
fInsertVariableButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
fPatternEditor.getTextWidget().setFocus();
- fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
+ fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
}
public void widgetDefaultSelected(SelectionEvent e) {}
applyDialogFont(parent);
return composite;
}
-
+
protected void doTextWidgetChanged(Widget w) {
if (w == fNameText) {
fSuppressError= false;
String name= fNameText.getText();
fTemplate.setName(name);
- updateButtons();
+ updateButtons();
} else if (w == fContextCombo) {
String name= fContextCombo.getText();
String contextId= getContextId(name);
} else if (w == fDescriptionText) {
String desc= fDescriptionText.getText();
fTemplate.setDescription(desc);
- }
+ }
}
-
+
private String getContextId(String name) {
if (name == null)
return name;
-
+
for (int i= 0; i < fContextTypes.length; i++) {
if (name.equals(fContextTypes[i][1])) {
- return fContextTypes[i][0];
+ return fContextTypes[i][0];
}
}
return name;
updateUndoAction();
updateButtons();
- }
+ }
private static GridData getButtonGridData(Button button) {
GridData data= new GridData(GridData.FILL_HORIZONTAL);
data.heightHint= SWTUtil.getButtonHeightHint(button);
-
+
return data;
}
private static Text createText(Composite parent) {
Text text= new Text(parent, SWT.BORDER);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+ text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
return text;
}
// XXX workaround for bug 63313 - disabling prefix until fixed.
// viewer.setDocument(document, prefix.length(), document.getLength() - prefix.length());
viewer.setDocument(document);
-
+
Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
new JavaSourcePreviewerUpdater(viewer, configuration, store);
-
+
int nLines= document.getNumberOfLines();
if (nLines < 5) {
nLines= 5;
} else if (nLines > 12) {
- nLines= 12;
+ nLines= 12;
}
-
+
Control control= viewer.getControl();
GridData data= new GridData(GridData.FILL_BOTH);
data.widthHint= convertWidthInCharsToPixels(80);
data.heightHint= convertHeightInCharsToPixels(nLines);
control.setLayoutData(data);
-
+
viewer.addTextListener(new ITextListener() {
public void textChanged(TextEvent event) {
if (event .getDocumentEvent() != null)
}
});
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateSelectionDependentActions();
}
handleVerifyKeyPressed(event);
}
});
-
+
return viewer;
}
-
+
private String getPrefix() {
String prefix;
int idx= getIndex(fTemplate.getContextTypeId());
if (event.stateMask != SWT.MOD1)
return;
-
+
switch (event.character) {
case ' ':
fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
case 'z' - 'a' + 1:
fPatternEditor.doOperation(ITextOperationTarget.UNDO);
event.doit= false;
- break;
+ break;
}
}
fSelectionActions.add(ITextEditorActionConstants.CUT);
fSelectionActions.add(ITextEditorActionConstants.COPY);
fSelectionActions.add(ITextEditorActionConstants.PASTE);
-
+
// create context menu
MenuManager manager= new MenuManager(null, null);
manager.setRemoveAllWhenShown(true);
}
});
- StyledText text= fPatternEditor.getTextWidget();
+ StyledText text= fPatternEditor.getTextWidget();
Menu menu= manager.createContextMenu(text);
text.setMenu(menu);
}
private void fillContextMenu(IMenuManager menu) {
menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_UNDO));
menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, (IAction) fGlobalActions.get(ITextEditorActionConstants.UNDO));
-
- menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
+
+ menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.CUT));
menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.COPY));
menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.PASTE));
protected void updateSelectionDependentActions() {
Iterator iterator= fSelectionActions.iterator();
while (iterator.hasNext())
- updateAction((String)iterator.next());
+ updateAction((String)iterator.next());
}
protected void updateUndoAction() {
}
private int getIndex(String contextid) {
-
+
if (contextid == null)
return -1;
-
+
for (int i= 0; i < fContextTypes.length; i++) {
if (contextid.equals(fContextTypes[i][0])) {
- return i;
+ return i;
}
}
return -1;
}
-
+
protected void okPressed() {
super.okPressed();
}
-
- private void updateButtons() {
+
+ private void updateButtons() {
StatusInfo status;
boolean valid= fNameText == null || fNameText.getText().trim().length() != 0;
status.setError(PreferencesMessages.getString("EditTemplateDialog.error.noname")); //$NON-NLS-1$
}
} else {
- status= fValidationStatus;
+ status= fValidationStatus;
}
updateStatus(status);
}
*/
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
- WorkbenchHelp.setHelp(newShell, IJavaHelpContextIds.EDIT_TEMPLATE_DIALOG);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.EDIT_TEMPLATE_DIALOG);
}
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
PreferenceConstants.EDITOR_FORMAT_JAVADOCS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE));
-
+
overlayKeys
.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
*/
public void createControl(Composite parent) {
super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
}
private void handleSyntaxColorListSelection() {
label = PreferencesMessages.getString("JavaEditorPreferencePage.formatJavaDocs");
//$NON-NLS-1$
button = addCheckBox(group, label, PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
-
+
label = PreferencesMessages.getString("JavaEditorPreferencePage.p_rtrim_on_save");
addCheckBox(group, label, PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE, 1);
//
// insert);
// }
// };
- //
+ //
// fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO
// | SWT.LEFT);
// fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
// //$NON-NLS-1$
// fCompletionInsertsRadioButton.setLayoutData(new GridData());
// fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
- //
+ //
// fCompletionOverwritesRadioButton= new Button(completionComposite,
// SWT.RADIO | SWT.LEFT);
// fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
/**
* Computes the state mask for the given modifier string.
- *
+ *
* @param modifiers
* the string with the modifiers, separated by '+', '-', ';', ',' or '.'
* @return the state mask or -1 if the input is invalid
// fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
// fCompletionInsertsRadioButton.setSelection(completionInserts);
// fCompletionOverwritesRadioButton.setSelection(! completionInserts);
- //
+ //
fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
// boolean markOccurrences=
// fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/**
* Preference page for spell checking preferences.
- *
+ *
* @since 3.0
*/
public class SpellingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IStatusChangeListener {
*/
public void createControl(final Composite parent) {
super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
}
/*
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/**
* Dialog to enter a na new task tag
*/
public class TodoTaskInputDialog extends StatusDialog {
-
+
private class CompilerTodoTaskInputAdapter implements IDialogFieldListener {
public void dialogFieldChanged(DialogField field) {
doValidation();
- }
+ }
}
-
+
private StringDialogField fNameDialogField;
private ComboDialogField fPriorityDialogField;
-
+
private List fExistingNames;
-
+
public TodoTaskInputDialog(Shell parent, TodoTask task, List existingEntries) {
super(parent);
-
+
fExistingNames= new ArrayList(existingEntries.size());
for (int i= 0; i < existingEntries.size(); i++) {
TodoTask curr= (TodoTask) existingEntries.get(i);
fExistingNames.add(curr.name);
}
}
-
+
if (task == null) {
setTitle(PreferencesMessages.getString("TodoTaskInputDialog.new.title")); //$NON-NLS-1$
} else {
fNameDialogField= new StringDialogField();
fNameDialogField.setLabelText(PreferencesMessages.getString("TodoTaskInputDialog.name.label")); //$NON-NLS-1$
fNameDialogField.setDialogFieldListener(adapter);
-
+
fNameDialogField.setText((task != null) ? task.name : ""); //$NON-NLS-1$
-
+
String[] items= new String[] {
PreferencesMessages.getString("TodoTaskInputDialog.priority.high"), //$NON-NLS-1$
PreferencesMessages.getString("TodoTaskInputDialog.priority.normal"), //$NON-NLS-1$
PreferencesMessages.getString("TodoTaskInputDialog.priority.low") //$NON-NLS-1$
};
-
+
fPriorityDialogField= new ComboDialogField(SWT.READ_ONLY);
fPriorityDialogField.setLabelText(PreferencesMessages.getString("TodoTaskInputDialog.priority.label")); //$NON-NLS-1$
fPriorityDialogField.setItems(items);
fPriorityDialogField.selectItem(1);
}
}
-
+
public TodoTask getResult() {
TodoTask task= new TodoTask();
task.name= fNameDialogField.getText().trim();
break;
default :
task.priority= JavaCore.COMPILER_TASK_PRIORITY_LOW;
- break;
+ break;
}
return task;
}
-
+
protected Control createDialogArea(Composite parent) {
Composite composite= (Composite) super.createDialogArea(parent);
-
+
Composite inner= new Composite(composite, SWT.NONE);
GridLayout layout= new GridLayout();
layout.marginHeight= 0;
layout.marginWidth= 0;
layout.numColumns= 2;
inner.setLayout(layout);
-
+
fNameDialogField.doFillIntoGrid(inner, 2);
fPriorityDialogField.doFillIntoGrid(inner, 2);
-
+
LayoutUtil.setHorizontalGrabbing(fNameDialogField.getTextControl(null));
LayoutUtil.setWidthHint(fNameDialogField.getTextControl(null), convertWidthInCharsToPixels(45));
-
+
fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
-
- applyDialogFont(composite);
+
+ applyDialogFont(composite);
return composite;
}
-
+
private void doValidation() {
StatusInfo status= new StatusInfo();
String newText= fNameDialogField.getText();
*/
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
- WorkbenchHelp.setHelp(newShell, IJavaHelpContextIds.TODO_TASK_INPUT_DIALOG);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.TODO_TASK_INPUT_DIALOG);
}
}
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/*
* The page to configure the compiler options.
public TodoTaskPreferencePage() {
setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
//setDescription(PreferencesMessages.getString("TodoTaskPreferencePage.description")); //$NON-NLS-1$
-
+
// only used when page is shown programatically
setTitle(PreferencesMessages.getString("TodoTaskPreferencePage.title")); //$NON-NLS-1$
fConfigurationBlock= new TodoTaskConfigurationBlock(this, null);
}
-
+
/*
* @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
+ */
public void init(IWorkbench workbench) {
}
public void createControl(Composite parent) {
// added for 1GEUGE6: ITPJUI:WIN2000 - Help is the same on all preference pages
super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.TODOTASK_PREFERENCE_PAGE);
- }
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.TODOTASK_PREFERENCE_PAGE);
+ }
/*
* @see PreferencePage#createContents(Composite)
public boolean performOk() {
if (!fConfigurationBlock.performOk(true)) {
return false;
- }
+ }
return super.performOk();
}
-
+
/*
* @see PreferencePage#performDefaults()
*/
*/
public void statusChanged(IStatus status) {
setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
+ StatusUtil.applyToStatusLine(this, status);
}
}
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.ui.help.WorkbenchHelp;
/**
* Property page used to configure project specific task tags settings
private SelectionButtonDialogField fChangeWorkspaceSettings;
private SelectionButtonDialogField fUseProjectSettings;
private IStatus fBlockStatus;
-
+
public TodoTaskPropertyPage() {
fBlockStatus= new StatusInfo();
fBlockEnableState= null;
-
+
IDialogFieldListener listener= new IDialogFieldListener() {
public void dialogFieldChanged(DialogField field) {
doDialogFieldChanged(field);
}
};
-
+
fUseWorkspaceSettings= new SelectionButtonDialogField(SWT.RADIO);
fUseWorkspaceSettings.setDialogFieldListener(listener);
fUseWorkspaceSettings.setLabelText(PreferencesMessages.getString("TodoTaskPropertyPage.useworkspacesettings.label")); //$NON-NLS-1$
fChangeWorkspaceSettings= new SelectionButtonDialogField(SWT.PUSH);
fChangeWorkspaceSettings.setLabelText(PreferencesMessages.getString("TodoTaskPropertyPage.useworkspacesettings.change")); //$NON-NLS-1$
fChangeWorkspaceSettings.setDialogFieldListener(listener);
-
+
fUseWorkspaceSettings.attachDialogField(fChangeWorkspaceSettings);
fUseProjectSettings= new SelectionButtonDialogField(SWT.RADIO);
*/
public void createControl(Composite parent) {
super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.TODOTASK_PROPERTY_PAGE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.TODOTASK_PROPERTY_PAGE);
}
/*
fBlockStatus= status;
doStatusChanged();
}
- };
+ };
fConfigurationBlock= new TodoTaskConfigurationBlock(listener, getProject());
-
+
Composite composite= new Composite(parent, SWT.NONE);
GridLayout layout= new GridLayout();
layout.marginHeight= 0;
layout.marginWidth= 0;
layout.numColumns= 1;
composite.setLayout(layout);
-
+
fUseWorkspaceSettings.doFillIntoGrid(composite, 1);
LayoutUtil.setHorizontalGrabbing(fUseWorkspaceSettings.getSelectionButton(null));
-
+
fChangeWorkspaceSettings.doFillIntoGrid(composite, 1);
GridData data= (GridData) fChangeWorkspaceSettings.getSelectionButton(null).getLayoutData();
data.horizontalIndent= convertWidthInCharsToPixels(3);
data.horizontalAlignment= GridData.BEGINNING;
-
+
fUseProjectSettings.doFillIntoGrid(composite, 1);
-
+
data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL );
data.horizontalSpan= 1;
data.horizontalIndent= convertWidthInCharsToPixels(2);
-
+
fConfigurationBlockControl= fConfigurationBlock.createContents(composite);
fConfigurationBlockControl.setLayoutData(data);
-
+
boolean useProjectSettings= fConfigurationBlock.hasProjectSpecificOptions();
-
+
fUseProjectSettings.setSelection(useProjectSettings);
fUseWorkspaceSettings.setSelection(!useProjectSettings);
-
+
updateEnableState();
Dialog.applyDialogFont(composite);
return composite;
}
-
+
private boolean useProjectSettings() {
return fUseProjectSettings.isSelected();
}
-
+
private void doDialogFieldChanged(DialogField field) {
if (field == fChangeWorkspaceSettings) {
TodoTaskPreferencePage page= new TodoTaskPreferencePage();
updateEnableState();
doStatusChanged();
}
- }
+ }
/**
* Method statusChanged.
*/
private void doStatusChanged() {
updateStatus(useProjectSettings() ? fBlockStatus : new StatusInfo());
}
-
+
/**
* Method getProject.
*/
private IJavaProject getProject() {
- return (IJavaProject) getElement().getAdapter(IJavaElement.class);
+ return (IJavaProject) getElement().getAdapter(IJavaElement.class);
}
-
+
private void updateEnableState() {
if (useProjectSettings()) {
if (fBlockEnableState != null) {
if (fBlockEnableState == null) {
fBlockEnableState= ControlEnableState.disable(fConfigurationBlockControl);
}
- }
+ }
}
-
+
/*
* @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
*/
public boolean performOk() {
return fConfigurationBlock.performOk(useProjectSettings());
}
-
+
private void updateStatus(IStatus status) {
setValid(!status.matches(IStatus.ERROR));
StatusUtil.applyToStatusLine(this, status);
}
-
+
private boolean showPreferencePage(String id, IPreferencePage page) {
final IPreferenceNode targetNode = new PreferenceNode(id, page);
-
+
PreferenceManager manager = new PreferenceManager();
manager.addToRoot(targetNode);
final PreferenceDialog dialog = new PreferenceDialog(getShell(), manager);
}
});
return result[0];
- }
+ }
}
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultAutoIndentStrategy;
+import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
/**
* Auto indent strategy for java strings
*/
-public class JavaStringAutoIndentStrategyDQ extends DefaultAutoIndentStrategy {
-
+public class JavaStringAutoIndentStrategyDQ extends DefaultIndentLineAutoEditStrategy {
+
private String fPartitioning;
-
+
/**
* The input string doesn't contain any line delimiter.
- *
+ *
* @param inputString the given input string
* @return the displayable string.
*/
private String displayString(String inputString, String indentation, String delimiter) {
-
+
int length = inputString.length();
StringBuffer buffer = new StringBuffer(length);
java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(inputString, "\n\r", true); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()){
-
+
String token = tokenizer.nextToken();
if (token.equals("\r")) { //$NON-NLS-1$
buffer.append("\\r"); //$NON-NLS-1$
buffer.append(indentation);
buffer.append("\""); //$NON-NLS-1$
continue;
- }
-
+ }
+
StringBuffer tokenBuffer = new StringBuffer();
- for (int i = 0; i < token.length(); i++){
+ for (int i = 0; i < token.length(); i++){
char c = token.charAt(i);
switch (c) {
case '\r' :
/**
* Creates a new Java string auto indent strategy for the given document partitioning.
- *
+ *
* @param partitioning the document partitioning
*/
public JavaStringAutoIndentStrategyDQ(String partitioning) {
super();
fPartitioning= partitioning;
}
-
+
private boolean isLineDelimiter(IDocument document, String text) {
String[] delimiters= document.getLegalLineDelimiters();
if (delimiters != null)
return TextUtilities.equals(delimiters, text) > -1;
return false;
}
-
+
private String getLineIndentation(IDocument document, int offset) throws BadLocationException {
// find start of line
int adjustedOffset= (offset == document.getLength() ? offset - 1 : offset);
IRegion line= document.getLineInformationOfOffset(adjustedOffset);
int start= line.getOffset();
-
+
// find white spaces
int end= findEndOfWhiteSpace(document, start, offset);
-
+
return document.get(start, end - start);
}
- private String getModifiedText(String string, String indentation, String delimiter) throws BadLocationException {
+ private String getModifiedText(String string, String indentation, String delimiter) throws BadLocationException {
return displayString(string, indentation, delimiter);
}
// new JavaAutoIndentStrategy(fPartitioning).customizeDocumentCommand(document, command);
return;
}
-
+
if (command.offset == offset + length && document.getChar(offset + length - 1) == '\"')
return;
String string= document.get(line.getOffset(), offset - line.getOffset());
if (string.trim().length() != 0)
indentation += String.valueOf("\t\t"); //$NON-NLS-1$
-
+
IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
if (isLineDelimiter(document, command.text))
command.text= "\" ." + command.text + indentation + "\""; //$NON-NLS-1$//$NON-NLS-2$
else if (command.text.length() > 1 && preferenceStore.getBoolean(PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ))
- command.text= getModifiedText(command.text, indentation, delimiter);
+ command.text= getModifiedText(command.text, indentation, delimiter);
}
-
+
private boolean isSmartMode() {
IWorkbenchPage page= PHPeclipsePlugin.getActivePage();
if (page != null) {
- IEditorPart part= page.getActiveEditor();
+ IEditorPart part= page.getActiveEditor();
if (part instanceof ITextEditorExtension3) {
ITextEditorExtension3 extension= (ITextEditorExtension3) part;
return extension.getInsertMode() == ITextEditorExtension3.SMART_INSERT;
return;
IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
-
+
if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ) && isSmartMode())
javaStringIndentAfterNewLine(document, command);
-
+
} catch (BadLocationException e) {
}
}
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultAutoIndentStrategy;
+import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
/**
* Auto indent strategy for java strings
*/
-public class JavaStringAutoIndentStrategySQ extends DefaultAutoIndentStrategy {
-
+public class JavaStringAutoIndentStrategySQ extends DefaultIndentLineAutoEditStrategy {
+
private String fPartitioning;
-
+
/**
* The input string doesn't contain any line delimiter.
- *
+ *
* @param inputString the given input string
* @return the displayable string.
*/
private String displayString(String inputString, String indentation, String delimiter) {
-
+
int length = inputString.length();
StringBuffer buffer = new StringBuffer(length);
java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(inputString, "\n\r", true); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()){
-
+
String token = tokenizer.nextToken();
if (token.equals("\r")) { //$NON-NLS-1$
buffer.append("\\r"); //$NON-NLS-1$
buffer.append(indentation);
buffer.append("\'"); //$NON-NLS-1$
continue;
- }
-
+ }
+
StringBuffer tokenBuffer = new StringBuffer();
- for (int i = 0; i < token.length(); i++){
+ for (int i = 0; i < token.length(); i++){
char c = token.charAt(i);
switch (c) {
case '\r' :
/**
* Creates a new Java string auto indent strategy for the given document partitioning.
- *
+ *
* @param partitioning the document partitioning
*/
public JavaStringAutoIndentStrategySQ(String partitioning) {
super();
fPartitioning= partitioning;
}
-
+
private boolean isLineDelimiter(IDocument document, String text) {
String[] delimiters= document.getLegalLineDelimiters();
if (delimiters != null)
return TextUtilities.equals(delimiters, text) > -1;
return false;
}
-
+
private String getLineIndentation(IDocument document, int offset) throws BadLocationException {
// find start of line
int adjustedOffset= (offset == document.getLength() ? offset - 1 : offset);
IRegion line= document.getLineInformationOfOffset(adjustedOffset);
int start= line.getOffset();
-
+
// find white spaces
int end= findEndOfWhiteSpace(document, start, offset);
-
+
return document.get(start, end - start);
}
- private String getModifiedText(String string, String indentation, String delimiter) throws BadLocationException {
+ private String getModifiedText(String string, String indentation, String delimiter) throws BadLocationException {
return displayString(string, indentation, delimiter);
}
// new JavaAutoIndentStrategy(fPartitioning).customizeDocumentCommand(document, command);
return;
}
-
+
if (command.offset == offset + length && document.getChar(offset + length - 1) == '\'')
return;
String string= document.get(line.getOffset(), offset - line.getOffset());
if (string.trim().length() != 0)
indentation += String.valueOf("\t\t"); //$NON-NLS-1$
-
+
IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
if (isLineDelimiter(document, command.text))
command.text= "\' ." + command.text + indentation + "\'"; //$NON-NLS-1$//$NON-NLS-2$
else if (command.text.length() > 1 && preferenceStore.getBoolean(PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ))
- command.text= getModifiedText(command.text, indentation, delimiter);
+ command.text= getModifiedText(command.text, indentation, delimiter);
}
-
+
private boolean isSmartMode() {
IWorkbenchPage page= PHPeclipsePlugin.getActivePage();
if (page != null) {
- IEditorPart part= page.getActiveEditor();
+ IEditorPart part= page.getActiveEditor();
if (part instanceof ITextEditorExtension3) {
ITextEditorExtension3 extension= (ITextEditorExtension3) part;
return extension.getInsertMode() == ITextEditorExtension3.SMART_INSERT;
return;
IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
-
+
if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ) && isSmartMode())
javaStringIndentAfterNewLine(document, command);
-
+
} catch (BadLocationException e) {
}
}
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITextViewerExtension;
import org.eclipse.jface.text.ITextViewerExtension2;
-import org.eclipse.jface.text.ITextViewerExtension3;
+import org.eclipse.jface.text.ITextViewerExtension5;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextEvent;
public interface ExitListener {
void exit(boolean accept);
}
-
+
public static class ExitFlags {
- public int flags;
+ public int flags;
public boolean doit;
public ExitFlags(int flags, boolean doit) {
this.flags= flags;
this.doit= doit;
- }
+ }
}
-
+
public interface ExitPolicy {
ExitFlags doExit(LinkedPositionManager manager, VerifyEvent event, int offset, int length);
}
-
+
// leave flags
private static final int UNINSTALL= 1; // uninstall linked position manager
public static final int COMMIT= 2; // commit changes
private static final IPreferenceStore fgStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
private static final String CARET_POSITION_PREFIX= "LinkedPositionUI.caret.position"; //$NON-NLS-1$
private static int fgCounter= 0;
-
-
+
+
private final ITextViewer fViewer;
private final LinkedPositionManager fManager;
private final IPositionUpdater fUpdater;
private Position fFramePosition;
private int fInitialOffset= -1;
private int fCaretOffset;
-
+
private ExitPolicy fExitPolicy;
private ExitListener fExitListener;
-
+
private boolean fNeedRedraw;
-
+
private String fContentType;
private Position fPreviousPosition;
// private ContentAssistant2 fAssistant;
- /**
+ /**
* Flag that records the state of this ui object. As there are many different entities that may
* call leave or exit, these cannot always be sure whether the linked position infrastructure is
- * still active. This is especially true for multithreaded situations.
+ * still active. This is especially true for multithreaded situations.
*/
private boolean fIsActive= false;
/**
* Creates a user interface for <code>LinkedPositionManager</code>.
- *
+ *
* @param viewer the text viewer.
* @param manager the <code>LinkedPositionManager</code> managing a <code>IDocument</code> of the <code>ITextViewer</code>.
*/
public LinkedPositionUI(ITextViewer viewer, LinkedPositionManager manager) {
Assert.isNotNull(viewer);
Assert.isNotNull(manager);
-
+
fViewer= viewer;
fManager= manager;
-
+
fPositionCategoryName= CARET_POSITION_PREFIX + (fgCounter++);
fUpdater= new DefaultPositionUpdater(fPositionCategoryName);
-
+
fManager.setLinkedPositionListener(this);
initializeHighlightColor(viewer);
* Returns <code>null</code> if there is no such information available.
*/
private Color createColor(IPreferenceStore store, String key, Display display) {
-
- RGB rgb= null;
-
+
+ RGB rgb= null;
+
if (store.contains(key)) {
-
+
if (store.isDefault(key))
rgb= PreferenceConverter.getDefaultColor(store, key);
else
rgb= PreferenceConverter.getColor(store, key);
-
+
if (rgb != null)
return new Color(display, rgb);
}
-
+
return null;
}
* @param offset
*/
public void setInitialOffset(int offset) {
- fInitialOffset= offset;
+ fInitialOffset= offset;
}
-
+
/**
* Sets the final position of the caret when the linked mode is exited
* successfully by leaving the last linked position using TAB.
* <code>LinkedPositionManager</code>.
*/
public void setFinalCaretOffset(int offset) {
- fFinalCaretOffset= offset;
+ fFinalCaretOffset= offset;
}
/**
public void setCurrentPosition(Position position, int caretOffset) {
if (!fIsActive)
;//JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI is not active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
-
+
if (!fFramePosition.equals(position)) {
fNeedRedraw= true;
fFramePosition= position;
/**
* Enters the linked mode. The linked mode can be left by calling
* <code>exit</code>.
- *
+ *
* @see #exit(boolean)
*/
public void enter() {
fIsActive= true;
// JavaPlugin.log(new Status(IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI activated: "+fPositionCategoryName, new Exception())); //$NON-NLS-1$
}
-
+
// track final caret
IDocument document= fViewer.getDocument();
fViewer.addTextInputListener(this);
fViewer.addTextListener(this);
-
+
ITextViewerExtension extension= (ITextViewerExtension) fViewer;
extension.prependVerifyKeyListener(this);
- StyledText text= fViewer.getTextWidget();
+ StyledText text= fViewer.getTextWidget();
text.addVerifyListener(this);
text.addModifyListener(this);
text.addPaintListener(this);
Shell shell= text.getShell();
shell.addShellListener(this);
-
+
fFramePosition= (fInitialOffset == -1) ? fManager.getFirstPosition() : fManager.getPosition(fInitialOffset);
if (fFramePosition == null) {
leave(UNINSTALL | COMMIT | UPDATE_CARET);
public IRegion getSelectedRegion() {
if (!fIsActive)
;//JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI is not active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
-
+
if (fFramePosition == null)
return new Region(fFinalCaretOffset, 0);
else
return new Region(fFramePosition.getOffset(), fFramePosition.getLength());
}
-
+
private void leave(int flags) {
if (!fIsActive)
;//JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI is not active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
fIsActive= false;
//JavaPlugin.log(new Status(IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI deactivated: "+fPositionCategoryName, new Exception())); //$NON-NLS-1$
}
-
+
fInitialOffset= -1;
-
+
if ((flags & UNINSTALL) != 0)
fManager.uninstall((flags & COMMIT) != 0);
fgStore.removePropertyChangeListener(this);
-
+
if (fFrameColor != null) {
fFrameColor.dispose();
fFrameColor= null;
- }
-
+ }
+
StyledText text= fViewer.getTextWidget();
// bail out if the styled text is null, meaning the viewer has been disposed (-> document is null as well)
// see pr https://bugs.eclipse.org/bugs/show_bug.cgi?id=46821
if (text == null)
return;
-
+
text.removePaintListener(this);
text.removeModifyListener(this);
text.removeVerifyListener(this);
Shell shell= text.getShell();
shell.removeShellListener(this);
-
+
// if (fAssistant != null) {
// Display display= text.getDisplay();
// if (display != null && !display.isDisposed()) {
ITextViewerExtension extension= (ITextViewerExtension) fViewer;
extension.removeVerifyKeyListener(this);
-
+
IRewriteTarget target= extension.getRewriteTarget();
target.endCompoundChange();
fViewer.removeTextListener(this);
fViewer.removeTextInputListener(this);
-
+
try {
IDocument document= fViewer.getDocument();
{
Position[] positions= document.getPositions(fPositionCategoryName);
if ((positions != null) && (positions.length != 0)) {
-
- if (fViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension3= (ITextViewerExtension3) fViewer;
+
+ if (fViewer instanceof ITextViewerExtension5) {
+ ITextViewerExtension5 extension3= (ITextViewerExtension5) fViewer;
int widgetOffset= extension3.modelOffset2WidgetOffset(positions[0].getOffset());
if (widgetOffset >= 0)
text.setSelection(widgetOffset, widgetOffset);
-
+
} else {
IRegion region= fViewer.getVisibleRegion();
int offset= positions[0].getOffset() - region.getOffset();
document.removePositionUpdater(fUpdater);
document.removePositionCategory(fPositionCategoryName);
-
+
if (fExitListener != null)
fExitListener.exit(
((flags & COMMIT) != 0) ||
private void next() {
if (!fIsActive)
;//JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI is not active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
-
+
redrawRegion();
-
+
if (fFramePosition == fFinalCaretPosition)
fFramePosition= fManager.getFirstPosition();
else
redrawRegion();
}
}
-
+
private void previous() {
if (!fIsActive)
;//JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI is not active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
-
+
redrawRegion();
-
+
fFramePosition= fManager.getPreviousPosition(fFramePosition.getOffset());
if (fFramePosition == null) {
if (fFinalCaretPosition != null)
/** Trigger content assist on choice positions */
// private void triggerContentAssist() {
// if (fFramePosition instanceof ProposalPosition) {
-//
+//
// ProposalPosition pp= (ProposalPosition) fFramePosition;
// initializeContentAssistant();
// if (fAssistant == null)
// fAssistant.setCompletions(new ICompletionProposal[0]);
// }
// }
-
+
/** Lazy initialize content assistant for this linked ui */
// private void initializeContentAssistant() {
// if (fAssistant != null)
if (!event.doit || !fIsActive)
return;
-
+
Point selection= fViewer.getSelectedRange();
int offset= selection.x;
int length= selection.y;
-
+
ExitFlags exitFlags= fExitPolicy == null ? null : fExitPolicy.doExit(fManager, event, offset, length);
if (exitFlags != null) {
leave(UNINSTALL | exitFlags.flags);
event.doit= exitFlags.doit;
return;
}
-
+
switch (event.character) {
// [SHIFT-]TAB = hop between edit boxes
case 0x09:
return;
}
}
-
+
if (event.stateMask == SWT.SHIFT)
previous();
- else
- next();
-
+ else
+ next();
+
event.doit= false;
break;
// event.doit= false;
// break;
// }
-
+
// if enter was treated as a document change, would it exceed variable range?
if (!LinkedPositionManager.includes(fFramePosition, offset, length)
|| (fFramePosition == fFinalCaretPosition)) {
return;
}
}
-
+
leave(UNINSTALL | COMMIT | UPDATE_CARET);
event.doit= false;
break;
leave(UNINSTALL | COMMIT);
event.doit= false;
break;
-
+
case ';':
leave(UNINSTALL | COMMIT);
event.doit= true;
break;
-
+
default:
if (event.character != 0) {
if (!controlUndoBehavior(offset, length) || fFramePosition == fFinalCaretPosition) {
leave(UNINSTALL | COMMIT);
- break;
+ break;
}
}
}
}
-
+
private boolean controlUndoBehavior(int offset, int length) {
-
+
Position position= fManager.getEmbracingPosition(offset, length);
if (position != null) {
-
+
ITextViewerExtension extension= (ITextViewerExtension) fViewer;
IRewriteTarget target= extension.getRewriteTarget();
-
+
if (fPreviousPosition != null && !fPreviousPosition.equals(position))
target.endCompoundChange();
target.beginCompoundChange();
}
-
+
fPreviousPosition= position;
return fPreviousPosition != null;
}
-
+
/*
* @see VerifyListener#verifyText(VerifyEvent)
*/
public void verifyText(VerifyEvent event) {
if (!event.doit)
return;
-
-
+
+
int offset= 0;
int length= 0;
-
- if (fViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) fViewer;
+
+ if (fViewer instanceof ITextViewerExtension5) {
+ ITextViewerExtension5 extension= (ITextViewerExtension5) fViewer;
IRegion modelRange= extension.widgetRange2ModelRange(new Region(event.start, event.end - event.start));
if (modelRange == null)
return;
-
+
offset= modelRange.getOffset();
length= modelRange.getLength();
-
+
} else {
IRegion visibleRegion= fViewer.getVisibleRegion();
offset= event.start + visibleRegion.getOffset();
length= event.end - event.start;
}
-
+
// allow changes only within linked positions when coming through UI
if (!fManager.anyPositionIncludes(offset, length))
leave(UNINSTALL | COMMIT);
/*
* @see PaintListener#paintControl(PaintEvent)
*/
- public void paintControl(PaintEvent event) {
+ public void paintControl(PaintEvent event) {
if (fFramePosition == null)
return;
-
+
IRegion widgetRange= asWidgetRange(fFramePosition);
if (widgetRange == null) {
leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
int length= widgetRange.getLength();
StyledText text= fViewer.getTextWidget();
-
+
// support for bidi
Point minLocation= getMinimumLocation(text, offset, length);
Point maxLocation= getMaximumLocation(text, offset, length);
int x1= minLocation.x;
int x2= minLocation.x + maxLocation.x - minLocation.x - 1;
int y= minLocation.y + text.getLineHeight() - 1;
-
+
GC gc= event.gc;
gc.setForeground(fFrameColor);
gc.drawLine(x1, y, x2, y);
}
-
+
protected IRegion asWidgetRange(Position position) {
- if (fViewer instanceof ITextViewerExtension3) {
-
- ITextViewerExtension3 extension= (ITextViewerExtension3) fViewer;
+ if (fViewer instanceof ITextViewerExtension5) {
+
+ ITextViewerExtension5 extension= (ITextViewerExtension5) fViewer;
return extension.modelRange2WidgetRange(new Region(position.getOffset(), position.getLength()));
-
+
} else {
-
+
IRegion region= fViewer.getVisibleRegion();
if (includes(region, position))
return new Region(position.getOffset() - region.getOffset(), position.getLength());
}
-
+
return null;
}
for (int i= 0; i <= length; i++) {
Point location= text.getLocationAtOffset(offset + i);
-
+
if (location.x < minLocation.x)
- minLocation.x= location.x;
+ minLocation.x= location.x;
if (location.y < minLocation.y)
- minLocation.y= location.y;
- }
-
+ minLocation.y= location.y;
+ }
+
return minLocation;
}
for (int i= 0; i <= length; i++) {
Point location= text.getLocationAtOffset(offset + i);
-
+
if (location.x > maxLocation.x)
- maxLocation.x= location.x;
+ maxLocation.x= location.x;
if (location.y > maxLocation.y)
- maxLocation.y= location.y;
- }
-
+ maxLocation.y= location.y;
+ }
+
return maxLocation;
}
IRegion widgetRange= asWidgetRange(fFramePosition);
if (widgetRange == null) {
leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
- return;
+ return;
}
-
+
StyledText text= fViewer.getTextWidget();
- if (text != null && !text.isDisposed())
+ if (text != null && !text.isDisposed())
text.redrawRange(widgetRange.getOffset(), widgetRange.getLength(), true);
}
private void selectRegion() {
-
+
IRegion widgetRange= asWidgetRange(fFramePosition);
if (widgetRange == null) {
leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
- return;
+ return;
}
StyledText text= fViewer.getTextWidget();
text.setSelection(start, end);
}
}
-
+
private void updateCaret() {
-
+
IRegion widgetRange= asWidgetRange(fFramePosition);
if (widgetRange == null) {
leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
- return;
+ return;
}
-
+
int offset= widgetRange.getOffset() + fCaretOffset;
StyledText text= fViewer.getTextWidget();
if (text != null && !text.isDisposed())
/*
* @see ModifyListener#modifyText(ModifyEvent)
- */
+ */
public void modifyText(ModifyEvent e) {
// reposition caret after StyledText
redrawRegion();
public void textChanged(TextEvent event) {
if (!fNeedRedraw)
return;
-
+
redrawRegion();
fNeedRedraw= false;
}
// don't deactivate on focus lost, since the proposal popups may take focus
// plus: it doesn't hurt if you can check with another window without losing linked mode
// since there is no intrusive popup sticking out.
-
+
// need to check first what happens on reentering based on an open action
// Seems to be no problem
-
+
// TODO check whether we can leave it or uncomment it after debugging
// PS: why DOCUMENT_CHANGED? We want to trigger a redraw! (Shell deactivated does not mean
// it is not visible any longer.
// leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
-
+
// Better:
- // Check with content assistant and only leave if its not the proposal shell that took the
+ // Check with content assistant and only leave if its not the proposal shell that took the
// focus away.
-
+
StyledText text;
Display display;
-// if (fAssistant == null || fViewer == null || (text= fViewer.getTextWidget()) == null
+// if (fAssistant == null || fViewer == null || (text= fViewer.getTextWidget()) == null
// || (display= text.getDisplay()) == null || display.isDisposed()) {
- if ( fViewer == null || (text= fViewer.getTextWidget()) == null
+ if ( fViewer == null || (text= fViewer.getTextWidget()) == null
|| (display= text.getDisplay()) == null || display.isDisposed()) {
leave(UNINSTALL | COMMIT);
} else {
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package net.sourceforge.phpdt.internal.ui.text.phpdoc;
-
+
import java.text.BreakIterator;
import net.sourceforge.phpdt.core.ICompilationUnit;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultAutoIndentStrategy;
+import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
/**
* Auto indent strategy for java doc comments
*/
-public class JavaDocAutoIndentStrategy extends DefaultAutoIndentStrategy {
+public class JavaDocAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
private String fPartitioning;
/**
* Creates a new Javadoc auto indent strategy for the given document partitioning.
- *
+ *
* @param partitioning the document partitioning
*/
public JavaDocAutoIndentStrategy(String partitioning) {
fPartitioning= partitioning;
}
-
+
private static String getLineDelimiter(IDocument document) {
try {
if (document.getNumberOfLines() > 1)
return document.getLineDelimiter(0);
} catch (BadLocationException e) {
PHPeclipsePlugin.log(e);
- }
+ }
return System.getProperty("line.separator"); //$NON-NLS-1$
}
* @param c the command to deal with
*/
private void jdocIndentAfterNewLine(IDocument d, DocumentCommand c) {
-
+
if (c.offset == -1 || d.getLength() == 0)
return;
-
+
try {
// find start of line
int p= (c.offset == d.getLength() ? c.offset - 1 : c.offset);
IRegion info= d.getLineInformationOfOffset(p);
int start= info.getOffset();
-
+
// find white spaces
int end= findEndOfWhiteSpace(d, start, c.offset);
-
+
StringBuffer buf= new StringBuffer(c.text);
if (end >= start) { // 1GEYL1R: ITPJUI:ALL - java doc edit smartness not work for class comments
// append to input
if (PHPeclipsePlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS) && isNewComment(d, c.offset, fPartitioning)) {
String lineDelimiter= getLineDelimiter(d);
-
+
String endTag= lineDelimiter + indentation + " */"; //$NON-NLS-1$
d.replace(c.offset, 0, endTag); //$NON-NLS-1$
// evaluate method signature
// // ignore
// }
// }
- }
+ }
}
- }
+ }
}
-
+
c.text= buf.toString();
-
+
} catch (BadLocationException excp) {
// stop work
}
switch (element.getElementType()) {
case IJavaElement.TYPE:
- return createTypeTags(document, command, indentation, lineDelimiter, (IType) element);
+ return createTypeTags(document, command, indentation, lineDelimiter, (IType) element);
case IJavaElement.METHOD:
return createMethodTags(document, command, indentation, lineDelimiter, (IMethod) element);
default:
return null;
- }
+ }
}
-
+
/*
* Removes start and end of a comment and corrects indentation and line delimiters.
*/
// return Strings.changeIndent(comment, 0, CodeFormatterUtil.getTabWidth(), indentation, lineDelimiter);
return Strings.changeIndent(comment, 0, getTabWidth(), indentation, lineDelimiter);
}
-
+
public static int getTabWidth() {
Preferences preferences= PHPeclipsePlugin.getDefault().getPluginPreferences();
return preferences.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
}
-
+
private String createTypeTags(IDocument document, DocumentCommand command, String indentation, String lineDelimiter, IType type)
throws CoreException
{
}
return null;
}
-
+
private String createMethodTags(IDocument document, DocumentCommand command, String indentation, String lineDelimiter, IMethod method)
throws CoreException, BadLocationException
{
ISourceRange sourceRange= method.getSourceRange();
if (sourceRange == null || sourceRange.getOffset() != partition.getOffset())
return null;
-
+
// IMethod inheritedMethod= getInheritedMethod(method);
// String comment= CodeGeneration.getMethodComment(method, inheritedMethod, lineDelimiter);
// if (comment != null) {
// return JavaModelUtil.findMethodDeclarationInHierarchy(typeHierarchy, declaringType,
// method.getElementName(), method.getParameterTypes(), method.isConstructor());
// }
-
+
protected void jdocIndentForCommentEnd(IDocument d, DocumentCommand c) {
if (c.offset < 2 || d.getLength() == 0) {
return;
// modify document command
c.length++;
c.offset--;
- }
+ }
} catch (BadLocationException excp) {
// stop work
}
* If in doubt, it will assume that the javadoc is new.
*/
private static boolean isNewComment(IDocument document, int commandOffset, String partitioning) {
-
+
try {
int lineIndex= document.getLineOfOffset(commandOffset) + 1;
if (lineIndex >= document.getNumberOfLines())
return true;
-
+
IRegion line= document.getLineInformation(lineIndex);
ITypedRegion partition= TextUtilities.getPartition(document, partitioning, commandOffset, false);
int partitionEnd= partition.getOffset() + partition.getLength();
if (line.getOffset() >= partitionEnd)
return false;
-
+
if (document.getLength() == partitionEnd)
return true; // partition goes to end of document - probably a new comment
-
+
String comment= document.get(partition.getOffset(), partition.getLength());
if (comment.indexOf("/*", 2) != -1) //$NON-NLS-1$
return true; // enclosed another comment -> probably a new comment
-
+
return false;
-
+
} catch (BadLocationException e) {
return false;
- }
+ }
}
-
+
private boolean isSmartMode() {
IWorkbenchPage page= PHPeclipsePlugin.getActivePage();
if (page != null) {
- IEditorPart part= page.getActiveEditor();
+ IEditorPart part= page.getActiveEditor();
if (part instanceof ITextEditorExtension3) {
ITextEditorExtension3 extension= (ITextEditorExtension3) part;
return extension.getInsertMode() == ITextEditorExtension3.SMART_INSERT;
* @see IAutoIndentStrategy#customizeDocumentCommand
*/
public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
-
+
if (!isSmartMode())
return;
try {
-
+
if (command.text != null && command.length == 0) {
String[] lineDelimiters= document.getLegalLineDelimiters();
int index= TextUtilities.endsWith(lineDelimiters, command.text);
return;
}
}
-
+
if (command.text != null && command.text.equals("/")) { //$NON-NLS-1$
jdocIndentForCommentEnd(document, command);
return;
ITypedRegion partition= TextUtilities.getPartition(document, fPartitioning, command.offset, true);
int partitionStart= partition.getOffset();
- int partitionEnd= partition.getLength() + partitionStart;
-
+ int partitionEnd= partition.getLength() + partitionStart;
+
String text= command.text;
int offset= command.offset;
int length= command.length;
final int POSTFIX_LENGTH= "*/".length(); //$NON-NLS-1$
if ((offset < partitionStart + PREFIX_LENGTH || offset + length > partitionEnd - POSTFIX_LENGTH) ||
text != null && text.length() >= 2 && ((text.indexOf("*/") != -1) || (document.getChar(offset) == '*' && text.startsWith("/")))) //$NON-NLS-1$ //$NON-NLS-2$
- return;
+ return;
if (command.text == null || command.text.length() == 0)
jdocHandleBackspaceDelete(document, command);
-
+
else if (command.text != null && command.length == 0 && command.text.length() > 0)
jdocWrapParagraphOnInsert(document, command);
if (!command.doit)
return;
-
+
document.replace(command.offset, command.length, command.text);
command.doit= false;
if (command.text != null)
command.offset += command.text.length();
command.length= 0;
- command.text= null;
+ command.text= null;
}
protected void jdocWrapParagraphOnInsert(IDocument document, DocumentCommand command) throws BadLocationException {
// Assert.isTrue(command.length == 0);
// Assert.isTrue(command.text != null && command.text.length() == 1);
-
+
if (!getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_FORMAT_JAVADOCS))
return;
int lineOffset= region.getOffset();
int lineLength= region.getLength();
- String lineContents= document.get(lineOffset, lineLength);
+ String lineContents= document.get(lineOffset, lineLength);
StringBuffer buffer= new StringBuffer(lineContents);
int start= command.offset - lineOffset;
- int end= command.length + start;
+ int end= command.length + start;
buffer.replace(start, end, command.text);
-
- // handle whitespace
+
+ // handle whitespace
if (command.text != null && command.text.length() != 0 && command.text.trim().length() == 0) {
String endOfLine= document.get(command.offset, lineOffset + lineLength - command.offset);
// move caret to next line
flushCommand(document, command);
- if (isLineTooShort(document, line)) {
+ if (isLineTooShort(document, line)) {
int[] caretOffset= {command.offset};
jdocWrapParagraphFromLine(document, line, caretOffset, false);
command.offset= caretOffset[0];
String lineDelimiter= document.getLineDelimiter(line);
String nextLinePrefix= jdocExtractLinePrefix(document, line + 1);
command.offset += lineDelimiter.length() + nextLinePrefix.length();
- }
+ }
return;
// inside whitespace at end of line
} else if (endOfLine.trim().length() == 0) {
// simply insert space
- return;
+ return;
}
}
boolean wrapAlways= command.offset >= lineOffset && command.offset <= lineOffset + prefix.length();
// must insert the text now because it may include whitepace
- flushCommand(document, command);
+ flushCommand(document, command);
if (wrapAlways || calculateDisplayedWidth(buffer.toString()) > getMargin() || isLineTooShort(document, line)) {
- int[] caretOffset= {command.offset};
+ int[] caretOffset= {command.offset};
jdocWrapParagraphFromLine(document, line, caretOffset, wrapAlways);
- if (!wrapAlways)
+ if (!wrapAlways)
command.offset= caretOffset[0];
}
}
/**
* Method jdocWrapParagraphFromLine.
- *
+ *
* @param document
* @param line
* @param always
if (!isLineTooLong(document, line) && !isLineTooShort(document, line))
return;
}
-
+
boolean caretRelativeToParagraphOffset= false;
int caret= caretOffset[0];
StringBuffer buffer= new StringBuffer();
int currentLine= line;
while (line == currentLine || isJavaDocLine(document, currentLine)) {
-
+
if (buffer.length() != 0 && !Character.isWhitespace(buffer.charAt(buffer.length() - 1))) {
buffer.append(' ');
if (currentLine <= caretLine) {
}
}
- String string= getLineContents(document, currentLine);
+ String string= getLineContents(document, currentLine);
buffer.append(string);
currentLine++;
}
String paragraph= buffer.toString();
-
+
if (paragraph.trim().length() == 0)
return;
caretOffset[0]= caretRelativeToParagraphOffset ? caretOffset[0] + beginning : caret + beginning;
}
-
+
/**
- * Line break iterator to handle whitespaces as first class citizens.
+ * Line break iterator to handle whitespaces as first class citizens.
*/
private static class LineBreakIterator {
-
+
private final String fString;
private final BreakIterator fIterator= BreakIterator.getLineInstance();
-
+
private int fStart;
private int fEnd;
private int fBufferedEnd;
-
+
public LineBreakIterator(String string) {
fString= string;
fIterator.setText(string);
}
-
+
public int first() {
fBufferedEnd= -1;
fStart= fIterator.first();
- return fStart;
+ return fStart;
}
-
+
public int next() {
-
+
if (fBufferedEnd != -1) {
fStart= fEnd;
fEnd= fBufferedEnd;
final String word= string.trim();
if (word.length() == string.length())
return fEnd;
-
+
// suspected whitespace
fBufferedEnd= fEnd;
return fStart + word.length();
- }
+ }
}
-
+
/**
- * Formats a paragraph, using break iterator.
- *
+ * Formats a paragraph, using break iterator.
+ *
* @param offset an offset within the paragraph, which will be updated with respect to formatting.
*/
private static String formatParagraph(String paragraph, int[] offset, String prefix, String lineDelimiter, int margin) {
StringBuffer paragraphBuffer= new StringBuffer();
StringBuffer lineBuffer= new StringBuffer();
StringBuffer whiteSpaceBuffer= new StringBuffer();
-
+
int index= offset[0];
int indexBuffer= -1;
if (word.trim().length() == 0) {
whiteSpaceBuffer.append(word);
- // first word of line is always appended
+ // first word of line is always appended
} else if (lineBuffer.length() == 0) {
lineBuffer.append(prefix);
lineBuffer.append(whiteSpaceBuffer.toString());
} else {
String line= lineBuffer.toString() + whiteSpaceBuffer.toString() + word.toString();
-
- // margin exceeded
+
+ // margin exceeded
if (calculateDisplayedWidth(line) > margin) {
// flush line buffer and wrap paragraph
paragraphBuffer.append(lineBuffer.toString());
}
}
- // flush line buffer
+ // flush line buffer
paragraphBuffer.append(lineBuffer.toString());
paragraphBuffer.append(lineDelimiter);
// flush index buffer
- if (indexBuffer != -1)
+ if (indexBuffer != -1)
offset[0]= indexBuffer;
// last position is not returned by break iterator
else if (offset[0] == paragraph.length())
offset[0]= paragraphBuffer.length() - lineDelimiter.length();
-
+
return paragraphBuffer.toString();
}
private static IPreferenceStore getPreferenceStore() {
- return PHPeclipsePlugin.getDefault().getPreferenceStore();
+ return PHPeclipsePlugin.getDefault().getPreferenceStore();
}
/**
*/
private static int calculateDisplayedWidth(String string) {
- int tabWidth= getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
+ int tabWidth= getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
if (tabWidth<=0) {
tabWidth = 2;
}
column += tabWidth - (column % tabWidth);
else
column++;
-
+
return column;
}
int trim = jdocExtractLinePrefix(d, line).length();
return lineContents.substring(trim);
}
-
+
private static String getLine(IDocument document, int line) throws BadLocationException {
- IRegion region= document.getLineInformation(line);
- return document.get(region.getOffset(), region.getLength());
+ IRegion region= document.getLineInformation(line);
+ return document.get(region.getOffset(), region.getLength());
}
/**
private static final String[] fgInlineTags= {
"<b>", "<i>", "<em>", "<strong>", "<code>" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
};
-
+
private boolean isInlineTag(String string) {
for (int i= 0; i < fgInlineTags.length; i++)
if (string.startsWith(fgInlineTags[i]))
- return true;
+ return true;
return false;
}
-
+
/**
* returns true if the specified line is part of a paragraph and should be merged with
* the previous line.
length -= firstChar - offset;
String lineContents= document.get(firstChar, length);
- String prefix= lineContents.trim();
+ String prefix= lineContents.trim();
if (!prefix.startsWith("*") || prefix.startsWith("*/")) //$NON-NLS-1$ //$NON-NLS-2$
return false;
-
+
lineContents= lineContents.substring(1).trim().toLowerCase();
// preserve empty lines
}
protected void jdocHandleBackspaceDelete(IDocument document, DocumentCommand c) {
-
+
if (!getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_FORMAT_JAVADOCS))
return;
-
+
try {
String text= document.get(c.offset, c.length);
int line= document.getLineOfOffset(c.offset);
// erase line delimiter
String lineDelimiter= document.getLineDelimiter(line);
if (lineDelimiter != null && lineDelimiter.equals(text)) {
-
+
String prefix= jdocExtractLinePrefix(document, line + 1);
// strip prefix if any
} catch (BadLocationException e) {
PHPeclipsePlugin.log(e);
}
-
+
try {
int line= document.getLineOfOffset(c.offset);
int lineOffset= document.getLineOffset(line);
IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null)
return null;
-
+
IWorkbenchPage page= window.getActivePage();
- if (page == null)
+ if (page == null)
return null;
IEditorPart editor= page.getActiveEditor();
return unit;
}
-
+
}
package net.sourceforge.phpdt.internal.ui.util;
import java.io.File;
-import java.util.ArrayList;
import java.util.List;
-import java.util.StringTokenizer;
-
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.ui.overlaypages.ProjectPrefUtil;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IWorkbench;
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.ide.IDE.SharedImages;
import org.eclipse.ui.model.IWorkbenchAdapter;
/**
private static ImageDescriptor DESC_OBJ_FOLDER;
{
ISharedImages images = PHPeclipsePlugin.getDefault().getWorkbench().getSharedImages();
- DESC_OBJ_PROJECT_CLOSED = images.getImageDescriptor(ISharedImages.IMG_OBJ_PROJECT_CLOSED);
- DESC_OBJ_PROJECT = images.getImageDescriptor(ISharedImages.IMG_OBJ_PROJECT);
+ DESC_OBJ_PROJECT_CLOSED = images.getImageDescriptor(SharedImages.IMG_OBJ_PROJECT_CLOSED);
+ DESC_OBJ_PROJECT = images.getImageDescriptor(SharedImages.IMG_OBJ_PROJECT);
DESC_OBJ_FOLDER = images.getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
}
// } else {
// return PHPUiImages.DESC_OBJS_JAR_WSRC;
// }
- // }
+ // }
// } else {
return PHPUiImages.DESC_OBJS_PACKFRAG_ROOT;
// }
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import net.sourceforge.phpdt.ui.actions.MemberFilterActionGroup;
import org.eclipse.jface.action.Action;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
/**
* Action used to enable / disable method filter properties
private int fFilterProperty;
private MemberFilterActionGroup fFilterActionGroup;
-
+
public MemberFilterAction(MemberFilterActionGroup actionGroup, String title, int property, String contextHelpId, boolean initValue) {
super(title);
fFilterActionGroup= actionGroup;
fFilterProperty= property;
-
- WorkbenchHelp.setHelp(this, contextHelpId);
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, contextHelpId);
setChecked(initValue);
}
-
+
/**
* Returns this action's filter property.
*/
public int getFilterProperty() {
return fFilterProperty;
}
-
+
/*
* @see Action#actionPerformed
*/
- public void run() {
+ public void run() {
fFilterActionGroup.setMemberFilter(fFilterProperty, isChecked());
}
-
+
}
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
/*******************************************************************************
* Copyright (c) 2002 International Business Machines Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
******************************************************************************/
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.actions.AddBookmarkAction;
+import org.eclipse.ui.ide.IDEActionFactory;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.texteditor.ConvertLineDelimitersAction;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
/**
* Action group that adds the source and generate actions to a part's context
* menu and installs handlers for the corresponding global menu actions.
- *
+ *
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
- *
+ *
* @since 2.0
*/
public class GenerateActionGroup extends ActionGroup {
/**
* Pop-up menu: id of the source sub menu (value <code>net.sourceforge.phpdt.ui.source.menu</code>).
- *
+ *
* @since 3.0
*/
public static final String MENU_ID= "net.sourceforge.pheclipse.ui.source.menu"; //$NON-NLS-1$
-
+
private PHPEditor fEditor;
// private boolean fEditorIsOwner;
private IWorkbenchSite fSite;
private String fGroupName= IContextMenuConstants.GROUP_SOURCE;
private List fRegisteredSelectionListeners;
-
+
// private AddImportOnSelectionAction fAddImport;
// private OverrideMethodsAction fOverrideMethods;
// private AddGetterSetterAction fAddGetterSetter;
// private ExternalizeStringsAction fExternalizeStrings;
// private FindStringsToExternalizeAction fFindStringsToExternalize;
// private SurroundWithTryCatchAction fSurroundWithTryCatch;
-
+
// private OrganizeImportsAction fOrganizeImports;
private ConvertLineDelimitersAction fConvertToWindows;
private ConvertLineDelimitersAction fConvertToUNIX;
private ConvertLineDelimitersAction fConvertToMac;
-
+
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
*/
fSite= editor.getSite();
fEditor= editor;
fGroupName= groupName;
-
+
ISelectionProvider provider= fSite.getSelectionProvider();
ISelection selection= provider.getSelection();
// fAddImport.setActionDefinitionId(IJavaEditorActionDefinitionIds.ADD_IMPORT);
// fAddImport.update();
// editor.setAction("AddImport", fAddImport); //$NON-NLS-1$
-
+
// fOrganizeImports= new OrganizeImportsAction(editor);
// fOrganizeImports.setActionDefinitionId(IJavaEditorActionDefinitionIds.ORGANIZE_IMPORTS);
// fOrganizeImports.editorStateChanged();
// fOverrideMethods.setActionDefinitionId(IJavaEditorActionDefinitionIds.OVERRIDE_METHODS);
// fOverrideMethods.editorStateChanged();
// editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$
-
+
// fAddGetterSetter= new AddGetterSetterAction(editor);
// fAddGetterSetter.setActionDefinitionId(IJavaEditorActionDefinitionIds.CREATE_GETTER_SETTER);
// fAddGetterSetter.editorStateChanged();
// editor.setAction("AddGetterSetter", fAddGetterSetter); //$NON-NLS-1$
-
+
// fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(editor);
// fAddUnimplementedConstructors.setActionDefinitionId(IJavaEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONTRUCTORS);
// fAddUnimplementedConstructors.editorStateChanged();
-// editor.setAction("AddUnimplementedConstructors", fAddUnimplementedConstructors); //$NON-NLS-1$
-
+// editor.setAction("AddUnimplementedConstructors", fAddUnimplementedConstructors); //$NON-NLS-1$
+
// fAddJavaDocStub= new AddJavaDocStubAction(editor);
// fAddJavaDocStub.editorStateChanged();
-//
+//
// fSurroundWithTryCatch= new SurroundWithTryCatchAction(editor);
// fSurroundWithTryCatch.setActionDefinitionId(IJavaEditorActionDefinitionIds.SURROUND_WITH_TRY_CATCH);
// fSurroundWithTryCatch.update(selection);
// provider.addSelectionChangedListener(fSurroundWithTryCatch);
-// editor.setAction("SurroundWithTryCatch", fSurroundWithTryCatch); //$NON-NLS-1$
-//
+// editor.setAction("SurroundWithTryCatch", fSurroundWithTryCatch); //$NON-NLS-1$
+//
// fExternalizeStrings= new ExternalizeStringsAction(editor);
// fExternalizeStrings.setActionDefinitionId(IJavaEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
// fExternalizeStrings.editorStateChanged();
-// editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$
-
+// editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$
+
fConvertToWindows= new ConvertLineDelimitersAction(editor, "\r\n"); //$NON-NLS-1$
fConvertToWindows.setActionDefinitionId( ITextEditorActionDefinitionIds .CONVERT_LINE_DELIMITERS_TO_WINDOWS);
- editor.setAction("ConvertLineDelimitersToWindows", fConvertToWindows); //$NON-NLS-1$
-
+ editor.setAction("ConvertLineDelimitersToWindows", fConvertToWindows); //$NON-NLS-1$
+
fConvertToUNIX= new ConvertLineDelimitersAction(editor, "\n"); //$NON-NLS-1$
fConvertToUNIX.setActionDefinitionId( ITextEditorActionDefinitionIds .CONVERT_LINE_DELIMITERS_TO_UNIX);
- editor.setAction("ConvertLineDelimitersToUNIX", fConvertToUNIX); //$NON-NLS-1$
+ editor.setAction("ConvertLineDelimitersToUNIX", fConvertToUNIX); //$NON-NLS-1$
fConvertToMac= new ConvertLineDelimitersAction(editor, "\r"); //$NON-NLS-1$
fConvertToMac.setActionDefinitionId( ITextEditorActionDefinitionIds .CONVERT_LINE_DELIMITERS_TO_MAC);
- editor.setAction("ConvertLineDelimitersToMac", fConvertToMac); //$NON-NLS-1$
+ editor.setAction("ConvertLineDelimitersToMac", fConvertToMac); //$NON-NLS-1$
}
-
+
/**
- * Creates a new <code>GenerateActionGroup</code>. The group
- * requires that the selection provided by the page's selection provider
+ * Creates a new <code>GenerateActionGroup</code>. The group
+ * requires that the selection provided by the page's selection provider
* is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
+ *
* @param page the page that owns this action group
*/
public GenerateActionGroup(Page page) {
}
/**
- * Creates a new <code>GenerateActionGroup</code>. The group
- * requires that the selection provided by the part's selection provider
+ * Creates a new <code>GenerateActionGroup</code>. The group
+ * requires that the selection provided by the part's selection provider
* is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
+ *
* @param part the view part that owns this action group
*/
public GenerateActionGroup(IViewPart part) {
this(part.getSite());
}
-
+
private GenerateActionGroup(IWorkbenchSite site) {
fSite= site;
ISelectionProvider provider= fSite.getSelectionProvider();
ISelection selection= provider.getSelection();
-
+
// fOverrideMethods= new OverrideMethodsAction(site);
// fAddGetterSetter= new AddGetterSetterAction(site);
// fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(site);
// fExternalizeStrings= new ExternalizeStringsAction(site);
// fFindStringsToExternalize= new FindStringsToExternalizeAction(site);
// fOrganizeImports= new OrganizeImportsAction(site);
-//
+//
// fOverrideMethods.update(selection);
// fAddGetterSetter.update(selection);
-// fAddUnimplementedConstructors.update(selection);
+// fAddUnimplementedConstructors.update(selection);
// fAddJavaDocStub.update(selection);
// fExternalizeStrings.update(selection);
// fFindStringsToExternalize.update(selection);
} else {
fAddBookmark.setEnabled(false);
}
-
+
// registerSelectionListener(provider, fOverrideMethods);
// registerSelectionListener(provider, fAddGetterSetter);
// registerSelectionListener(provider, fAddUnimplementedConstructors);
// registerSelectionListener(provider, fOrganizeImports);
registerSelectionListener(provider, fAddTaskAction);
}
-
+
private void registerSelectionListener(ISelectionProvider provider, ISelectionChangedListener listener) {
if (fRegisteredSelectionListeners == null)
fRegisteredSelectionListeners= new ArrayList(12);
provider.addSelectionChangedListener(listener);
fRegisteredSelectionListeners.add(listener);
}
-
+
/*
- * The state of the editor owning this action group has changed.
+ * The state of the editor owning this action group has changed.
* This method does nothing if the group's owner isn't an
* editor.
*/
*/
public void editorStateChanged() {
Assert.isTrue(isEditorOwner());
-
+
// http://dev.eclipse.org/bugs/show_bug.cgi?id=17709
fConvertToMac.update();
fConvertToUNIX.update();
super.fillActionBars(actionBar);
setGlobalActionHandlers(actionBar);
}
-
+
/* (non-Javadoc)
* Method declared in ActionGroup
*/
String shortCut= null; //$NON-NLS-1$
// if (fQuickAccessAction != null) {
// shortCut= fQuickAccessAction.getShortCutString(); //$NON-NLS-1$
-// }
+// }
IMenuManager subMenu= new MenuManager(
ActionMessages.getString("SourceMenu.label") + (shortCut != null ? "\t" + shortCut : ""), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- MENU_ID);
+ MENU_ID);
int added= 0;
if (isEditorOwner()) {
added= fillEditorSubMenu(subMenu);
- }
+ }
// else {
// added= fillViewSubMenu(subMenu);
// }
// added+= addAction(result, fAddUnimplementedConstructors);
// added+= addAction(result, fAddJavaDocStub);
// added+= addAction(result, fAddBookmark);
-// result.add(new Separator());
+// result.add(new Separator());
// added+= addAction(result, fSurroundWithTryCatch);
// added+= addAction(result, fExternalizeStrings);
// if (added == 0)
fEditor= null;
super.dispose();
}
-
+
private void setGlobalActionHandlers(IActionBars actionBar) {
// actionBar.setGlobalActionHandler(JdtActionConstants.ADD_IMPORT, fAddImport);
// actionBar.setGlobalActionHandler(JdtActionConstants.SURROUND_WITH_TRY_CATCH, fSurroundWithTryCatch);
actionBar.setGlobalActionHandler(PHPdtActionConstants.CONVERT_LINE_DELIMITERS_TO_MAC, fConvertToMac);
if (!isEditorOwner()) {
// editor provides its own implementation of these actions.
- actionBar.setGlobalActionHandler(IWorkbenchActionConstants.BOOKMARK, fAddBookmark);
- actionBar.setGlobalActionHandler(IWorkbenchActionConstants.ADD_TASK, fAddTaskAction);
+ actionBar.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), fAddBookmark);
+ actionBar.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), fAddTaskAction);
}
}
-
+
private int appendToGroup(IMenuManager menu, IAction action) {
if (action != null && action.isEnabled()) {
menu.appendToGroup(fGroupName, action);
return 1;
}
return 0;
- }
+ }
private int addAction(IMenuManager menu, IAction action) {
if (action != null && action.isEnabled()) {
return 1;
}
return 0;
- }
-
+ }
+
private int addEditorAction(IMenuManager menu, String actionID) {
if (fEditor == null)
return 0;
}
return 0;
}
-
+
private boolean isEditorOwner() {
return fEditor != null;
- }
+ }
}
import net.sourceforge.phpeclipse.phpeditor.php.SmartyCodeScanner;
import net.sourceforge.phpeclipse.phpeditor.php.SmartyDocCodeScanner;
import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
-import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLPartitionScanner;
import net.sourceforge.phpeclipse.xml.ui.text.XMLTextTools;
import org.eclipse.core.runtime.Preferences;
import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
import net.sourceforge.phpdt.internal.ui.text.JavaPresentationReconciler;
import net.sourceforge.phpdt.internal.ui.text.JavaReconciler;
-import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategyDQ;
import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategySQ;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.DefaultAutoIndentStrategy;
+import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.IAutoIndentStrategy;
+import org.eclipse.jface.text.IAutoEditStrategy;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.util.Assert;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.texteditor.ChainedPreferenceStore;
import org.eclipse.ui.texteditor.ITextEditor;
/**
/*
* (non-Javadoc) Method declared on SourceViewerConfiguration
*/
- public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
+ public IAutoEditStrategy getAutoEditStrategy(ISourceViewer sourceViewer, String contentType) {
if (IPHPPartitions.PHP_PHPDOC_COMMENT.equals(contentType)
|| IPHPPartitions.PHP_MULTILINE_COMMENT.equals(contentType))
return new JavaDocAutoIndentStrategy(getConfiguredDocumentPartitioning(sourceViewer));
return (PHPDocumentPartitioner.PHP_TEMPLATE_DATA.equals(contentType)
|| PHPDocumentPartitioner.PHP_SCRIPT_CODE.equals(contentType) || IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)
|| IPHPPartitions.PHP_PARTITIONING.equals(contentType) || PHPPartitionScanner.PHP_SCRIPTING_AREA.equals(contentType) ? new PHPAutoIndentStrategy()
- : new DefaultAutoIndentStrategy());
+ : new DefaultIndentLineAutoEditStrategy());
}
/**
}
static IPath getInstallLocation() {
- return new Path(getDefault().getDescriptor().getInstallURL().getFile());
+ return new Path(getDefault().getBundle().getEntry("/").getFile());
}
// public static int getJVM() {
// }
public static String getPluginId() {
- return getDefault().getDescriptor().getUniqueIdentifier();
+ return getDefault().getBundle().getSymbolicName() ;
}
/**
InputStream is = getDefault().openStream(
new Path("prefs/default_" + operatingSystem + ".properties"));
PropertyResourceBundle resourceBundle = new PropertyResourceBundle(is);
- Enumeration enum = resourceBundle.getKeys();
+ Enumeration e = resourceBundle.getKeys();
String key;
- while (enum.hasMoreElements()) {
- key = (String)enum.nextElement();
+ while (e.hasMoreElements()) {
+ key = (String)e.nextElement();
store.setDefault(key, resourceBundle.getString( key ));
}
} catch (Exception e) {
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
* dialog.open();
* </pre>
* During the call to <code>open</code>, the wizard dialog is presented to the
- * user. When the user hits Finish, the user-selected workspace resources
+ * user. When the user hits Finish, the user-selected workspace resources
* are exported to the user-specified location in the local file system,
* the dialog closes, and the call to <code>open</code> returns.
* </p>
* Returns the image descriptor with the given relative path.
*/
private ImageDescriptor getImageDescriptor(String relativePath) {
- String iconPath = "icons/full/";//$NON-NLS-1$
+ String iconPath = "icons/full/";//$NON-NLS-1$
try {
AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
- URL installURL = plugin.getDescriptor().getInstallURL();
+ URL installURL = plugin.getBundle().getEntry("/");
URL url = new URL(installURL, iconPath + relativePath);
return ImageDescriptor.createFromURL(url);
}
*/
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
this.workbench = workbench;
-
-
+
+
//Make it the current selection by default but look it up otherwise
-
+
selection = currentSelection;
-
+
if(currentSelection.isEmpty() && workbench.getActiveWorkbenchWindow() != null){
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
if(page != null){
public boolean performFinish() {
return mainPage.finish();
}
-
+
}
import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewerExtension3;
+import org.eclipse.jface.text.ITextViewerExtension5;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.source.ISourceViewer;
public final class BracketPainter implements IPainter, PaintListener {
-
+
private PHPPairMatcher fMatcher= new PHPPairMatcher(new char[] { '{', '}', '(', ')', '[', ']' });
private Position fBracketPosition= new Position(0, 0);
private int fAnchor;
-
+
private boolean fIsActive= false;
private ISourceViewer fSourceViewer;
private StyledText fTextWidget;
private Color fColor;
-
+
private IPositionManager fPositionManager;
-
-
+
+
public BracketPainter(ISourceViewer sourceViewer) {
fSourceViewer= sourceViewer;
fTextWidget= sourceViewer.getTextWidget();
}
-
+
public void setHighlightColor(Color color) {
fColor= color;
}
-
+
public void dispose() {
if (fMatcher != null) {
fMatcher.dispose();
fMatcher= null;
}
-
+
fColor= null;
fTextWidget= null;
}
-
+
public void deactivate(boolean redraw) {
if (fIsActive) {
fIsActive= false;
handleDrawRequest(null);
}
}
-
+
public void paintControl(PaintEvent event) {
if (fTextWidget != null)
handleDrawRequest(event.gc);
}
-
+
private void handleDrawRequest(GC gc) {
-
+
if (fBracketPosition.isDeleted)
return;
-
+
int offset= fBracketPosition.getOffset();
int length= fBracketPosition.getLength();
if (length < 1)
return;
-
- if (fSourceViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension= (ITextViewerExtension3) fSourceViewer;
+
+ if (fSourceViewer instanceof ITextViewerExtension5) {
+ ITextViewerExtension5 extension= (ITextViewerExtension5) fSourceViewer;
IRegion widgetRange= extension.modelRange2WidgetRange(new Region(offset, length));
if (widgetRange == null)
return;
-
+
offset= widgetRange.getOffset();
length= widgetRange.getLength();
-
+
} else {
IRegion region= fSourceViewer.getVisibleRegion();
if (region.getOffset() > offset || region.getOffset() + region.getLength() < offset + length)
return;
offset -= region.getOffset();
}
-
+
if (PHPPairMatcher.RIGHT == fAnchor)
draw(gc, offset, 1);
- else
+ else
draw(gc, offset + length -1, 1);
}
-
+
private void draw(GC gc, int offset, int length) {
if (gc != null) {
Point left= fTextWidget.getLocationAtOffset(offset);
Point right= fTextWidget.getLocationAtOffset(offset + length);
-
+
gc.setForeground(fColor);
gc.drawRectangle(left.x, left.y, right.x - left.x - 1, gc.getFontMetrics().getHeight() - 1);
-
+
} else {
fTextWidget.redrawRange(offset, length, true);
}
}
-
+
/*
* @see IPainter#paint(int)
*/
deactivate(true);
return;
}
-
+
IRegion pair= fMatcher.match(fSourceViewer.getDocument(), selection.x);
if (pair == null) {
deactivate(true);
return;
}
-
+
if (fIsActive) {
// only if different
- if (pair.getOffset() != fBracketPosition.getOffset() ||
- pair.getLength() != fBracketPosition.getLength() ||
+ if (pair.getOffset() != fBracketPosition.getOffset() ||
+ pair.getLength() != fBracketPosition.getLength() ||
fMatcher.getAnchor() != fAnchor) {
-
+
// remove old highlighting
handleDrawRequest(null);
// update position
fAnchor= fMatcher.getAnchor();
// apply new highlighting
handleDrawRequest(null);
-
+
}
} else {
-
+
fIsActive= true;
-
+
fBracketPosition.isDeleted= false;
fBracketPosition.offset= pair.getOffset();
fBracketPosition.length= pair.getLength();
fAnchor= fMatcher.getAnchor();
-
+
fTextWidget.addPaintListener(this);
fPositionManager.addManagedPosition(fBracketPosition);
handleDrawRequest(null);
}
}
-
+
/*
* @see IPainter#setPositionManager(IPositionManager)
*/
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/**
* Adapts <code>IDocument</code> to <code>IBuffer</code>. Uses the
- * same algorithm as the text widget to determine the buffer's line delimiter.
+ * same algorithm as the text widget to determine the buffer's line delimiter.
* All text inserted into the buffer is converted to this line delimiter.
* This class is <code>public</code> for test purposes only.
*/
public class DocumentAdapter implements IBuffer, IDocumentListener {
-
+
/**
* Internal implementation of a NULL instanceof IBuffer.
*/
public void setContents(char[] contents) {}
public void setContents(String contents) {}
}
-
-
+
+
/** NULL implementing <code>IBuffer</code> */
public final static IBuffer NULL= new NullBuffer();
-
-
+
+
/**
* Executes a document set content call in the ui thread.
*/
protected class DocumentSetCommand implements Runnable {
-
+
private String fContents;
-
+
public void run() {
fDocument.set(fContents);
}
-
+
public void set(String contents) {
fContents= contents;
Display.getDefault().syncExec(this);
}
}
-
+
/**
* Executes a document replace call in the ui thread.
*/
protected class DocumentReplaceCommand implements Runnable {
-
+
private int fOffset;
private int fLength;
private String fText;
-
+
public void run() {
try {
fDocument.replace(fOffset, fLength, fText);
// ignore
}
}
-
+
public void replace(int offset, int length, String text) {
fOffset= offset;
fLength= length;
Display.getDefault().syncExec(this);
}
}
-
+
private static final boolean DEBUG_LINE_DELIMITERS= true;
-
+
private IOpenable fOwner;
private IFile fFile;
private ITextFileBuffer fTextFileBuffer;
private IDocument fDocument;
-
+
private DocumentSetCommand fSetCmd= new DocumentSetCommand();
private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand();
-
+
private Set fLegalLineDelimiters;
-
+
private List fBufferListeners= new ArrayList(3);
private IStatus fStatus;
-
-
+
+
/**
* This method is <code>public</code> for test purposes only.
*/
public DocumentAdapter(IOpenable owner, IFile file) {
-
+
fOwner= owner;
fFile= file;
-
+
initialize();
}
-
+
private void initialize() {
ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
IPath location= fFile.getFullPath();
}
fDocument.addPrenotifiedDocumentListener(this);
}
-
+
/**
* Returns the status of this document adapter.
*/
return fTextFileBuffer.getStatus();
return null;
}
-
+
/**
* Returns the adapted document.
- *
+ *
* @return the adapted document
*/
public IDocument getDocument() {
return fDocument;
}
-
+
/*
* @see IBuffer#addBufferChangedListener(IBufferChangedListener)
*/
if (!fBufferListeners.contains(listener))
fBufferListeners.add(listener);
}
-
+
/*
* @see IBuffer#removeBufferChangedListener(IBufferChangedListener)
*/
Assert.isNotNull(listener);
fBufferListeners.remove(listener);
}
-
+
/*
* @see IBuffer#append(char[])
*/
public void append(char[] text) {
append(new String(text));
}
-
+
/*
- * @see IBuffer#append(String)
+ * @see IBuffer#append(String)
*/
public void append(String text) {
if (DEBUG_LINE_DELIMITERS) {
}
fReplaceCmd.replace(fDocument.getLength(), 0, text);
}
-
+
/*
* @see IBuffer#close()
*/
public void close() {
-
+
if (isClosed())
return;
-
+
IDocument d= fDocument;
fDocument= null;
d.removePrenotifiedDocumentListener(this);
-
+
if (fTextFileBuffer != null) {
ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
try {
}
fTextFileBuffer= null;
}
-
+
fireBufferChanged(new BufferChangedEvent(this, 0, 0, null));
fBufferListeners.clear();
}
-
+
/*
* @see IBuffer#getChar(int)
*/
throw new ArrayIndexOutOfBoundsException();
}
}
-
+
/*
* @see IBuffer#getCharacters()
*/
String content= getContents();
return content == null ? null : content.toCharArray();
}
-
+
/*
* @see IBuffer#getContents()
*/
public String getContents() {
return fDocument.get();
}
-
+
/*
* @see IBuffer#getLength()
*/
public int getLength() {
return fDocument.getLength();
}
-
+
/*
* @see IBuffer#getOwner()
*/
public IOpenable getOwner() {
return fOwner;
}
-
+
/*
* @see IBuffer#getText(int, int)
*/
throw new ArrayIndexOutOfBoundsException();
}
}
-
+
/*
* @see IBuffer#getUnderlyingResource()
*/
public IResource getUnderlyingResource() {
return fFile;
}
-
+
/*
* @see IBuffer#hasUnsavedChanges()
*/
public boolean hasUnsavedChanges() {
return fTextFileBuffer != null ? fTextFileBuffer.isDirty() : false;
}
-
+
/*
* @see IBuffer#isClosed()
*/
public boolean isClosed() {
return fDocument == null;
}
-
+
/*
* @see IBuffer#isReadOnly()
*/
public boolean isReadOnly() {
IResource resource= getUnderlyingResource();
- return resource == null ? true : resource.isReadOnly();
+ return resource == null ? true : resource.getResourceAttributes().isReadOnly();
}
-
+
/*
* @see IBuffer#replace(int, int, char[])
*/
public void replace(int position, int length, char[] text) {
replace(position, length, new String(text));
}
-
+
/*
* @see IBuffer#replace(int, int, String)
*/
}
fReplaceCmd.replace(position, length, text);
}
-
+
/*
* @see IBuffer#save(IProgressMonitor, boolean)
*/
throw new JavaModelException(e);
}
}
-
+
/*
* @see IBuffer#setContents(char[])
*/
public void setContents(char[] contents) {
setContents(new String(contents));
}
-
+
/*
* @see IBuffer#setContents(String)
*/
public void setContents(String contents) {
int oldLength= fDocument.getLength();
-
+
if (contents == null) {
-
+
if (oldLength != 0)
fSetCmd.set(""); //$NON-NLS-1$
-
+
} else {
-
+
// set only if different
if (DEBUG_LINE_DELIMITERS) {
validateLineDelimiters(contents);
}
-
+
if (!contents.equals(fDocument.get()))
fSetCmd.set(contents);
}
}
-
-
+
+
private void validateLineDelimiters(String contents) {
if (fLegalLineDelimiters == null) {
return; // first insertion of a line delimiter: no test
}
fLegalLineDelimiters= existingDelimiters;
-
+
}
-
+
DefaultLineTracker tracker= new DefaultLineTracker();
tracker.set(contents);
-
+
int lines= tracker.getNumberOfLines();
if (lines <= 1)
return;
-
+
for (int i= 0; i < lines; i++) {
try {
String curr= tracker.getLineDelimiter(i);
public void documentChanged(DocumentEvent event) {
fireBufferChanged(new BufferChangedEvent(this, event.getOffset(), event.getLength(), event.getText()));
}
-
+
private void fireBufferChanged(BufferChangedEvent event) {
if (fBufferListeners != null && fBufferListeners.size() > 0) {
Iterator e= new ArrayList(fBufferListeners).iterator();
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
public class GotoAnnotationAction extends TextEditorAction {
-
+
private boolean fForward;
-
+
public GotoAnnotationAction(String prefix, boolean forward) {
super(PHPEditorMessages.getResourceBundle(), prefix, null);
fForward= forward;
if (forward)
- WorkbenchHelp.setHelp(this, IJavaHelpContextIds.GOTO_NEXT_ERROR_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_NEXT_ERROR_ACTION);
else
- WorkbenchHelp.setHelp(this, IJavaHelpContextIds.GOTO_PREVIOUS_ERROR_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_PREVIOUS_ERROR_ACTION);
}
-
+
public void run() {
PHPEditor e= (PHPEditor) getTextEditor();
e.gotoAnnotation(fForward);
}
-
+
public void setEditor(ITextEditor editor) {
- if (editor instanceof PHPEditor)
+ if (editor instanceof PHPEditor)
super.setEditor(editor);
update();
}
-
+
public void update() {
setEnabled(getTextEditor() instanceof PHPEditor);
}
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
public class GotoErrorAction extends TextEditorAction {
-
+
private boolean fForward;
-
+
public GotoErrorAction(String prefix, boolean forward) {
super(PHPEditorMessages.getResourceBundle(), prefix, null);
fForward= forward;
if (forward)
- WorkbenchHelp.setHelp(this, IJavaHelpContextIds.GOTO_NEXT_ERROR_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_NEXT_ERROR_ACTION);
else
- WorkbenchHelp.setHelp(this, IJavaHelpContextIds.GOTO_PREVIOUS_ERROR_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_PREVIOUS_ERROR_ACTION);
}
-
+
public void run() {
PHPEditor e= (PHPEditor) getTextEditor();
e.gotoError(fForward);
}
-
+
public void setEditor(ITextEditor editor) {
- if (editor instanceof PHPEditor)
+ if (editor instanceof PHPEditor)
super.setEditor(editor);
update();
}
-
+
public void update() {
setEnabled(getTextEditor() instanceof PHPEditor);
}
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.model.WorkbenchAdapter;
import org.eclipse.ui.part.IPageSite;
public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdaptable , IPostSelectionProvider {
static Object[] NO_CHILDREN= new Object[0];
-
+
/**
* The element change listener of the java outline viewer.
* @see IElementChangedListener
*/
class ElementChangedListener implements IElementChangedListener {
-
+
public void elementChanged(final ElementChangedEvent e) {
-
+
if (getControl() == null)
return;
-
+
Display d= getControl().getDisplay();
if (d != null) {
d.asyncExec(new Runnable() {
});
}
}
-
+
private boolean isPossibleStructuralChange(IJavaElementDelta cuDelta) {
if (cuDelta.getKind() != IJavaElementDelta.CHANGED) {
return true; // add or remove
}
return (flags & (IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_FINE_GRAINED)) == IJavaElementDelta.F_CONTENT;
}
-
+
protected IJavaElementDelta findElement(IJavaElement unit, IJavaElementDelta delta) {
-
+
if (delta == null || unit == null)
return null;
-
+
IJavaElement element= delta.getElement();
-
+
if (unit.equals(element)) {
if (isPossibleStructuralChange(delta)) {
return delta;
}
return null;
}
-
-
+
+
if (element.getElementType() > IJavaElement.CLASS_FILE)
return null;
-
+
IJavaElementDelta[] children= delta.getAffectedChildren();
if (children == null || children.length == 0)
return null;
-
+
for (int i= 0; i < children.length; i++) {
IJavaElementDelta d= findElement(unit, children[i]);
if (d != null)
return d;
}
-
+
return null;
}
}
-
+
static class NoClassElement extends WorkbenchAdapter implements IAdaptable {
/*
* @see java.lang.Object#toString()
public String toString() {
return PHPEditorMessages.getString("JavaOutlinePage.error.NoTopLevelType"); //$NON-NLS-1$
}
-
+
/*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
*/
return null;
}
}
-
+
/**
* Content provider for the children of an ICompilationUnit or
* an IClassFile
* @see ITreeContentProvider
*/
class ChildrenProvider implements ITreeContentProvider {
-
+
private Object[] NO_CLASS= new Object[] {new NoClassElement()};
private ElementChangedListener fListener;
-
+
protected boolean matches(IJavaElement element) {
if (element.getElementType() == IJavaElement.METHOD) {
String name= element.getElementName();
}
return false;
}
-
+
protected IJavaElement[] filter(IJavaElement[] children) {
boolean initializers= false;
for (int i= 0; i < children.length; i++) {
break;
}
}
-
+
if (!initializers)
return children;
-
+
Vector v= new Vector();
for (int i= 0; i < children.length; i++) {
if (matches(children[i]))
continue;
v.addElement(children[i]);
}
-
+
IJavaElement[] result= new IJavaElement[v.size()];
v.copyInto(result);
return result;
}
-
+
public Object[] getChildren(Object parent) {
if (parent instanceof IParent) {
IParent c= (IParent) parent;
}
return NO_CHILDREN;
}
-
+
public Object[] getElements(Object parent) {
if (fTopLevelTypeOnly) {
if (parent instanceof ICompilationUnit) {
} catch (JavaModelException e) {
PHPeclipsePlugin.log(e);
}
- }
+ }
// else if (parent instanceof IClassFile) {
// try {
// IType type= getMainType((IClassFile) parent);
// return type != null ? type.getChildren() : NO_CLASS;
// } catch (JavaModelException e) {
// PHPeclipsePlugin.log(e);
-// }
+// }
// }
}
return getChildren(parent);
}
-
+
public Object getParent(Object child) {
if (child instanceof IJavaElement) {
IJavaElement e= (IJavaElement) child;
}
return null;
}
-
+
public boolean hasChildren(Object parent) {
if (parent instanceof IParent) {
IParent c= (IParent) parent;
}
return false;
}
-
+
public boolean isDeleted(Object o) {
return false;
}
-
+
public void dispose() {
if (fListener != null) {
JavaCore.removeElementChangedListener(fListener);
fListener= null;
- }
+ }
}
-
+
/*
* @see IContentProvider#inputChanged(Viewer, Object, Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
boolean isCU= (newInput instanceof ICompilationUnit);
-
+
if (isCU && fListener == null) {
fListener= new ElementChangedListener();
JavaCore.addElementChangedListener(fListener);
}
}
}
-
-
+
+
class JavaOutlineViewer extends TreeViewer {
-
+
/**
* Indicates an item which has been reused. At the point of
* its reuse it has been expanded. This field is used to
private Item fReusedExpandedItem;
private boolean fReorderedMembers;
private boolean fForceFireSelectionChanged;
-
+
public JavaOutlineViewer(Tree tree) {
super(tree);
setAutoExpandLevel(ALL_LEVELS);
setUseHashlookup(true);
}
-
+
/**
* Investigates the given element change event and if affected
* incrementally updates the Java outline.
- *
+ *
* @param delta the Java element delta used to reconcile the Java outline
*/
public void reconcile(IJavaElementDelta delta) {
refresh(true);
}
}
-
+
/*
* @see TreeViewer#internalExpandToLevel
*/
}
super.internalExpandToLevel(node, level);
}
-
+
protected void reuseTreeItem(Item item, Object element) {
-
+
// remove children
Item[] c= getChildren(item);
if (c != null && c.length > 0) {
-
+
if (getExpanded(item))
fReusedExpandedItem= item;
-
+
for (int k= 0; k < c.length; k++) {
if (c[k].getData() != null)
disassociate(c[k]);
c[k].dispose();
}
}
-
+
updateItem(item, element);
updatePlus(item, element);
internalExpandToLevel(item, ALL_LEVELS);
-
+
fReusedExpandedItem= null;
fForceFireSelectionChanged= true;
}
-
+
protected boolean mustUpdateParent(IJavaElementDelta delta, IJavaElement element) {
if (element instanceof IMethod) {
if ((delta.getKind() & IJavaElementDelta.ADDED) != 0) {
}
return false;
}
-
+
/*
* @see org.eclipse.jface.viewers.AbstractTreeViewer#isExpandable(java.lang.Object)
*/
}
return super.isExpandable(element);
}
-
+
protected ISourceRange getSourceRange(IJavaElement element) throws JavaModelException {
if (element instanceof ISourceReference)
return ((ISourceReference) element).getSourceRange();
return ((IMember) element).getNameRange();
return null;
}
-
+
protected boolean overlaps(ISourceRange range, int start, int end) {
return start <= (range.getOffset() + range.getLength() - 1) && range.getOffset() <= end;
}
-
+
protected boolean filtered(IJavaElement parent, IJavaElement child) {
-
+
Object[] result= new Object[] { child };
ViewerFilter[] filters= getFilters();
for (int i= 0; i < filters.length; i++) {
if (result.length == 0)
return true;
}
-
+
return false;
}
-
+
protected void update(Widget w, IJavaElementDelta delta) {
-
+
Item item;
-
+
IJavaElement parent= delta.getElement();
IJavaElementDelta[] affected= delta.getAffectedChildren();
Item[] children= getChildren(w);
boolean doUpdateParent= false;
boolean doUpdateParentsPlus= false;
-
+
Vector deletions= new Vector();
- Vector additions= new Vector();
+ Vector additions= new Vector();
for (int i= 0; i < affected.length; i++) {
IJavaElementDelta affectedDelta= affected[i];
for (j= 0; j < children.length; j++)
if (affectedElement.equals(children[j].getData()))
break;
-
+
if (j == children.length) {
// remove from collapsed parent
if ((status & IJavaElementDelta.REMOVED) != 0) {
doUpdateParentsPlus= true;
continue;
- }
+ }
// addition
- if ((status & IJavaElementDelta.CHANGED) != 0 &&
+ if ((status & IJavaElementDelta.CHANGED) != 0 &&
(affectedDelta.getFlags() & IJavaElementDelta.F_MODIFIERS) != 0 &&
!filtered(parent, affectedElement))
{
item= children[j];
- // removed
+ // removed
if ((status & IJavaElementDelta.REMOVED) != 0) {
deletions.addElement(item);
doUpdateParent= doUpdateParent || mustUpdateParent(affectedDelta, affectedElement);
- // changed
+ // changed
} else if ((status & IJavaElementDelta.CHANGED) != 0) {
int change= affectedDelta.getFlags();
doUpdateParent= doUpdateParent || mustUpdateParent(affectedDelta, affectedElement);
-
+
if ((change & IJavaElementDelta.F_MODIFIERS) != 0) {
if (filtered(parent, affectedElement))
deletions.addElement(item);
else
updateItem(item, affectedElement);
}
-
+
if ((change & IJavaElementDelta.F_CONTENT) != 0)
updateItem(item, affectedElement);
-
+
if ((change & IJavaElementDelta.F_CHILDREN) != 0)
- update(item, affectedDelta);
-
+ update(item, affectedDelta);
+
if ((change & IJavaElementDelta.F_REORDER) != 0)
fReorderedMembers= true;
}
}
-
+
// find all elements to add
IJavaElementDelta[] add= delta.getAddedChildren();
if (additions.size() > 0) {
tmp[i + add.length]= (IJavaElementDelta) additions.elementAt(i);
add= tmp;
}
-
+
// add at the right position
go2: for (int i= 0; i < add.length; i++) {
-
+
try {
-
+
IJavaElement e= add[i].getElement();
if (filtered(parent, e))
continue go2;
-
+
doUpdateParent= doUpdateParent || mustUpdateParent(add[i], e);
ISourceRange rng= getSourceRange(e);
int start= rng.getOffset();
if (nameRange != null)
nameOffset= nameRange.getOffset();
}
-
+
Item last= null;
item= null;
children= getChildren(w);
-
+
for (int j= 0; j < children.length; j++) {
item= children[j];
IJavaElement r= (IJavaElement) item.getData();
-
+
if (r == null) {
// parent node collapsed and not be opened before -> do nothing
continue go2;
}
-
-
+
+
try {
rng= getSourceRange(r);
- // multi-field declarations always start at
+ // multi-field declarations always start at
// the same offset. They also have the same
// end offset if the field sequence is terminated
// with a semicolon. If not, the source range
// ends behind the identifier / initializer
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=51851
- boolean multiFieldDeclaration=
- r.getElementType() == IJavaElement.FIELD
+ boolean multiFieldDeclaration=
+ r.getElementType() == IJavaElement.FIELD
&& e.getElementType() == IJavaElement.FIELD
&& rng.getOffset() == start;
}
}
}
-
+
if (!multiFieldDeclaration && overlaps(rng, start, end)) {
-
- // be tolerant if the delta is not correct, or if
+
+ // be tolerant if the delta is not correct, or if
// the tree has been updated other than by a delta
reuseTreeItem(item, e);
continue go2;
-
+
} else if (multiFieldOrderBefore || rng.getOffset() > start) {
-
+
if (last != null && deletions.contains(last)) {
// reuse item
deletions.removeElement(last);
}
continue go2;
}
-
+
} catch (JavaModelException x) {
// stumbled over deleted element
}
-
+
last= item;
}
-
+
// add at the end of the list
if (last != null && deletions.contains(last)) {
// reuse item
// nothing to reuse
createTreeItem(w, e, -1);
}
-
+
} catch (JavaModelException x) {
// the element to be added is not present -> don't add it
}
}
-
-
+
+
// remove items which haven't been reused
Enumeration e= deletions.elements();
while (e.hasMoreElements()) {
disassociate(item);
item.dispose();
}
-
+
if (doUpdateParent)
updateItem(w, delta.getElement());
if (!doUpdateParent && doUpdateParentsPlus && w instanceof Item)
updatePlus((Item)w, delta.getElement());
}
-
-
+
+
/*
* @see ContentViewer#handleLabelProviderChanged(LabelProviderChangedEvent)
*/
}
super.handleLabelProviderChanged(event);
}
-
+
private IResource getUnderlyingResource() {
Object input= getInput();
if (input instanceof ICompilationUnit) {
ICompilationUnit cu= (ICompilationUnit) input;
cu= JavaModelUtil.toOriginal(cu);
- return cu.getResource();
- }
+ return cu.getResource();
+ }
// else if (input instanceof IClassFile) {
// return ((IClassFile) input).getResource();
// }
return null;
- }
-
+ }
+
}
-
+
class LexicalSortingAction extends Action {
-
- private JavaElementSorter fSorter= new JavaElementSorter();
+
+ private JavaElementSorter fSorter= new JavaElementSorter();
public LexicalSortingAction() {
super();
- WorkbenchHelp.setHelp(this, IJavaHelpContextIds.LEXICAL_SORTING_OUTLINE_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LEXICAL_SORTING_OUTLINE_ACTION);
setText(PHPEditorMessages.getString("JavaOutlinePage.Sort.label")); //$NON-NLS-1$
PHPUiImages.setLocalImageDescriptors(this, "alphab_sort_co.gif"); //$NON-NLS-1$
setToolTipText(PHPEditorMessages.getString("JavaOutlinePage.Sort.tooltip")); //$NON-NLS-1$
setDescription(PHPEditorMessages.getString("JavaOutlinePage.Sort.description")); //$NON-NLS-1$
-
+
boolean checked= PHPeclipsePlugin.getDefault().getPreferenceStore().getBoolean("LexicalSortingAction.isChecked"); //$NON-NLS-1$
valueChanged(checked, false);
}
-
+
public void run() {
valueChanged(isChecked(), true);
}
-
+
private void valueChanged(final boolean on, boolean store) {
setChecked(on);
BusyIndicator.showWhile(fOutlineViewer.getControl().getDisplay(), new Runnable() {
public ClassOnlyAction() {
super();
- WorkbenchHelp.setHelp(this, IJavaHelpContextIds.GO_INTO_TOP_LEVEL_TYPE_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GO_INTO_TOP_LEVEL_TYPE_ACTION);
setText(PHPEditorMessages.getString("JavaOutlinePage.GoIntoTopLevelType.label")); //$NON-NLS-1$
setToolTipText(PHPEditorMessages.getString("JavaOutlinePage.GoIntoTopLevelType.tooltip")); //$NON-NLS-1$
setDescription(PHPEditorMessages.getString("JavaOutlinePage.GoIntoTopLevelType.description")); //$NON-NLS-1$
fTopLevelTypeOnly= show;
setChecked(show);
fOutlineViewer.refresh(false);
-
- IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
+
+ IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
preferenceStore.setValue("GoIntoTopLevelTypeAction.isChecked", show); //$NON-NLS-1$
}
}
/**
* This action toggles whether this Java Outline page links
* its selection to the active editor.
- *
+ *
* @since 3.0
*/
public class ToggleLinkingAction extends AbstractToggleLinkingAction {
-
+
JavaOutlinePage fJavaOutlinePage;
-
+
/**
* Constructs a new action.
- *
+ *
* @param outlinePage the Java outline page
*/
public ToggleLinkingAction(JavaOutlinePage outlinePage) {
setChecked(isLinkingEnabled);
fJavaOutlinePage= outlinePage;
}
-
+
/**
* Runs the action.
*/
if (isChecked() && fEditor != null)
fEditor.synchronizeOutlinePage(fEditor.computeHighlightRangeSourceReference(), false);
}
-
+
}
/** A flag to show contents of top level type only */
private boolean fTopLevelTypeOnly;
-
+
private IJavaElement fInput;
private String fContextMenuID;
private Menu fMenu;
private JavaOutlineViewer fOutlineViewer;
private PHPEditor fEditor;
-
+
private MemberFilterActionGroup fMemberFilterActionGroup;
-
+
private ListenerList fSelectionChangedListeners= new ListenerList();
private ListenerList fPostSelectionChangedListeners= new ListenerList();
private Hashtable fActions= new Hashtable();
-
+
private TogglePresentationAction fTogglePresentation;
private GotoAnnotationAction fPreviousAnnotation;
private GotoAnnotationAction fNextAnnotation;
private TextEditorAction fShowJavadoc;
private IAction fUndo;
private IAction fRedo;
-
+
private ToggleLinkingAction fToggleLinkingAction;
-
+
private CompositeActionGroup fActionGroups;
private IPropertyChangeListener fPropertyChangeListener;
* @since 3.0
*/
private CustomFiltersActionGroup fCustomFiltersActionGroup;
-
+
public JavaOutlinePage(String contextMenuID, PHPEditor editor) {
super();
-
+
Assert.isNotNull(editor);
-
+
fContextMenuID= contextMenuID;
fEditor= editor;
fTogglePresentation= new TogglePresentationAction();
fShowJavadoc= (TextEditorAction) fEditor.getAction("ShowJavaDoc"); //$NON-NLS-1$
fUndo= fEditor.getAction(ITextEditorActionConstants.UNDO);
fRedo= fEditor.getAction(ITextEditorActionConstants.REDO);
-
+
fTogglePresentation.setEditor(editor);
fPreviousAnnotation.setEditor(editor);
- fNextAnnotation.setEditor(editor);
-
+ fNextAnnotation.setEditor(editor);
+
fPropertyChangeListener= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
doPropertyChange(event);
};
PHPeclipsePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
}
-
+
/**
* Returns the primary type of a compilation unit (has the same
* name as the compilation unit).
- *
+ *
* @param compilationUnit the compilation unit
* @return returns the primary type of the compilation unit, or
* <code>null</code> if is does not have one
*/
protected IType getMainType(ICompilationUnit compilationUnit) {
-
+
if (compilationUnit == null)
return null;
-
+
String name= compilationUnit.getElementName();
int index= name.indexOf('.');
if (index != -1)
/**
* Returns the primary type of a class file.
- *
+ *
* @param classFile the class file
* @return returns the primary type of the class file, or <code>null</code>
* if is does not have one
// IType type= classFile.getType();
// return type != null && type.exists() ? type : null;
// } catch (JavaModelException e) {
-// return null;
+// return null;
// }
// }
-
+
/* (non-Javadoc)
* Method declared on Page
*/
public void init(IPageSite pageSite) {
super.init(pageSite);
}
-
+
private void doPropertyChange(PropertyChangeEvent event) {
if (fOutlineViewer != null) {
if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) {
fOutlineViewer.refresh(false);
}
}
- }
-
+ }
+
/*
* @see ISelectionProvider#addSelectionChangedListener(ISelectionChangedListener)
*/
else
fSelectionChangedListeners.add(listener);
}
-
+
/*
* @see ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener)
*/
else
fSelectionChangedListeners.remove(listener);
}
-
+
/*
* @see ISelectionProvider#setSelection(ISelection)
*/
public void setSelection(ISelection selection) {
if (fOutlineViewer != null)
- fOutlineViewer.setSelection(selection);
- }
-
+ fOutlineViewer.setSelection(selection);
+ }
+
/*
* @see ISelectionProvider#getSelection()
*/
return StructuredSelection.EMPTY;
return fOutlineViewer.getSelection();
}
-
+
/*
* @see org.eclipse.jface.text.IPostSelectionProvider#addPostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
*/
else
fPostSelectionChangedListeners.add(listener);
}
-
+
/*
* @see org.eclipse.jface.text.IPostSelectionProvider#removePostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
*/
if (fOutlineViewer != null)
fOutlineViewer.removePostSelectionChangedListener(listener);
else
- fPostSelectionChangedListeners.remove(listener);
+ fPostSelectionChangedListeners.remove(listener);
}
-
+
private void registerToolbarActions(IActionBars actionBars) {
-
+
IToolBarManager toolBarManager= actionBars.getToolBarManager();
- if (toolBarManager != null) {
+ if (toolBarManager != null) {
toolBarManager.add(new LexicalSortingAction());
-
+
fMemberFilterActionGroup= new MemberFilterActionGroup(fOutlineViewer, "net.sourceforge.phpeclipse.JavaOutlinePage"); //$NON-NLS-1$
fMemberFilterActionGroup.contributeToToolBar(toolBarManager);
fCustomFiltersActionGroup.fillActionBars(actionBars);
-
+
IMenuManager menu= actionBars.getMenuManager();
menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$
-
+
fToggleLinkingAction= new ToggleLinkingAction(this);
- menu.add(new ClassOnlyAction());
+ menu.add(new ClassOnlyAction());
menu.add(fToggleLinkingAction);
}
}
-
+
/*
* @see IPage#createControl
*/
public void createControl(Composite parent) {
-
+
Tree tree= new Tree(parent, SWT.MULTI);
AppearanceAwareLabelProvider lprovider= new AppearanceAwareLabelProvider(
AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
);
- fOutlineViewer= new JavaOutlineViewer(tree);
+ fOutlineViewer= new JavaOutlineViewer(tree);
initDragAndDrop();
fOutlineViewer.setContentProvider(new ChildrenProvider());
fOutlineViewer.setLabelProvider(new DecoratingJavaLabelProvider(lprovider));
-
+
Object[] listeners= fSelectionChangedListeners.getListeners();
for (int i= 0; i < listeners.length; i++) {
fSelectionChangedListeners.remove(listeners[i]);
fOutlineViewer.addSelectionChangedListener((ISelectionChangedListener) listeners[i]);
}
-
+
listeners= fPostSelectionChangedListeners.getListeners();
for (int i= 0; i < listeners.length; i++) {
fPostSelectionChangedListeners.remove(listeners[i]);
fOutlineViewer.addPostSelectionChangedListener((ISelectionChangedListener) listeners[i]);
}
-
+
MenuManager manager= new MenuManager(fContextMenuID, fContextMenuID);
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
});
fMenu= manager.createContextMenu(tree);
tree.setMenu(fMenu);
-
+
IPageSite site= getSite();
site.registerContextMenu(PHPeclipsePlugin.getPluginId() + ".outline", manager, fOutlineViewer); //$NON-NLS-1$
site.setSelectionProvider(fOutlineViewer);
// we must create the groups after we have set the selection provider to the site
fActionGroups= new CompositeActionGroup(new ActionGroup[] {
-// new OpenViewActionGroup(this),
+// new OpenViewActionGroup(this),
// new CCPActionGroup(this),
new GenerateActionGroup(this)});
-// new RefactorActionGroup(this),
+// new RefactorActionGroup(this),
// new JavaSearchActionGroup(this)});
-
+
// register global actions
IActionBars bars= site.getActionBars();
-
+
bars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, fUndo);
bars.setGlobalActionHandler(ITextEditorActionConstants.REDO, fRedo);
- bars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, fPreviousAnnotation);
- bars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, fNextAnnotation);
+ bars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAnnotation);
+ bars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAnnotation);
bars.setGlobalActionHandler(PHPdtActionConstants.SHOW_JAVA_DOC, fShowJavadoc);
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNextAnnotation);
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPreviousAnnotation);
-
-
+
+
fActionGroups.fillActionBars(bars);
IStatusLineManager statusLineManager= bars.getStatusLineManager();
fCustomFiltersActionGroup= new CustomFiltersActionGroup("net.sourceforge.phpdt.ui.JavaOutlinePage", fOutlineViewer); //$NON-NLS-1$
registerToolbarActions(bars);
-
- fOutlineViewer.setInput(fInput);
+
+ fOutlineViewer.setInput(fInput);
}
public void dispose() {
-
+
if (fEditor == null)
return;
-
+
if (fMemberFilterActionGroup != null) {
fMemberFilterActionGroup.dispose();
fMemberFilterActionGroup= null;
}
-
+
if (fCustomFiltersActionGroup != null) {
fCustomFiltersActionGroup.dispose();
fCustomFiltersActionGroup= null;
}
-
-
+
+
fEditor.outlinePageClosed();
fEditor= null;
fSelectionChangedListeners.clear();
fSelectionChangedListeners= null;
-
+
fPostSelectionChangedListeners.clear();
fPostSelectionChangedListeners= null;
PHPeclipsePlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
fPropertyChangeListener= null;
}
-
+
if (fMenu != null && !fMenu.isDisposed()) {
fMenu.dispose();
fMenu= null;
}
-
+
if (fActionGroups != null)
fActionGroups.dispose();
-
+
fTogglePresentation.setEditor(null);
fPreviousAnnotation.setEditor(null);
- fNextAnnotation.setEditor(null);
-
+ fNextAnnotation.setEditor(null);
+
fOutlineViewer= null;
-
+
super.dispose();
}
-
+
public Control getControl() {
if (fOutlineViewer != null)
return fOutlineViewer.getControl();
return null;
}
-
+
public void setInput(IJavaElement inputElement) {
- fInput= inputElement;
+ fInput= inputElement;
if (fOutlineViewer != null)
fOutlineViewer.setInput(fInput);
}
-
+
public void select(ISourceReference reference) {
if (fOutlineViewer != null) {
-
+
ISelection s= fOutlineViewer.getSelection();
if (s instanceof IStructuredSelection) {
IStructuredSelection ss= (IStructuredSelection) s;
}
}
}
-
+
public void setAction(String actionID, IAction action) {
Assert.isNotNull(actionID);
if (action == null)
else
fActions.put(actionID, action);
}
-
+
public IAction getAction(String actionID) {
Assert.isNotNull(actionID);
return (IAction) fActions.get(actionID);
/**
* Convenience method to add the action installed under the given actionID to the
* specified group of the menu.
- *
+ *
* @param menu the menu manager
* @param group the group to which to add the action
* @param actionID the ID of the new action
if (action != null) {
if (action instanceof IUpdate)
((IUpdate) action).update();
-
+
if (action.isEnabled()) {
IMenuManager subMenu= menu.findMenuUsingPath(group);
if (subMenu != null)
}
}
}
-
+
protected void contextMenuAboutToShow(IMenuManager menu) {
-
+
PHPeclipsePlugin.createStandardGroups(menu);
-
+
IStructuredSelection selection= (IStructuredSelection)getSelection();
fActionGroups.setContext(new ActionContext(selection));
fActionGroups.fillContextMenu(menu);
}
-
+
/*
* @see Page#setFocus()
*/
if (fOutlineViewer != null)
fOutlineViewer.getControl().setFocus();
}
-
+
/**
* Checks whether a given Java element is an inner type.
- *
+ *
* @param element the java element
* @return <code>true</code> iff the given element is an inner type
*/
private boolean isInnerType(IJavaElement element) {
-
+
if (element != null && element.getElementType() == IJavaElement.TYPE) {
IType type= (IType)element;
try {
}
}
}
-
- return false;
+
+ return false;
}
-
+
/**
* Returns the <code>IShowInSource</code> for this view.
- *
+ *
* @return the {@link IShowInSource}
*/
protected IShowInSource getShowInSource() {
/**
* Returns the <code>IShowInTarget</code> for this view.
- *
+ *
* @return the {@link IShowInTarget}
*/
protected IShowInTarget getShowInTarget() {
}
};
}
-
+
private void initDragAndDrop() {
int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
Transfer[] transfers= new Transfer[] {
LocalSelectionTransfer.getInstance()
};
-
+
// Drop Adapter
// TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
// new SelectionTransferDropAdapter(fOutlineViewer)
// };
// fOutlineViewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, new DelegatingDropAdapter(dropListeners));
-
+
// Drag Adapter
// TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
// new SelectionTransferDragAdapter(fOutlineViewer)
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorExtension;
public JavaSelectMarkerRulerAction(ResourceBundle bundle, String prefix, ITextEditor editor, IVerticalRulerInfo ruler) {
super(bundle, prefix, editor, ruler);
fTextEditor= editor;
- WorkbenchHelp.setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
}
-
+
public void run() {
// if (PHPeclipsePlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER))
// return;
}
super.run();
}
-
+
public void update() {
// Begin Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20114
if (!(fTextEditor instanceof ITextEditorExtension) || ((ITextEditorExtension) fTextEditor).isEditorInputReadOnly()) {
else
super.update();
}
-
+
private Position getJavaAnnotationPosition() {
AbstractMarkerAnnotationModel model= getAnnotationModel();
IDocument document= getDocument();
if (cu == null) {
return null;
}
-
+
// boolean hasAssistLightbulb= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.APPEARANCE_QUICKASSIST_LIGHTBULB);
Annotation assistAnnotation= null;
-
+
Iterator iter= model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation= (Annotation) iter.next();
// if (includesRulerLine(position, document) && JavaCorrectionProcessor.hasCorrections(javaAnnotation))
// return position;
}
- }
+ }
// else if (hasAssistLightbulb && annotation instanceof AssistAnnotation) {
// // there is only one AssistAnnotation at a time
-// assistAnnotation= annotation;
+// assistAnnotation= annotation;
// }
}
if (assistAnnotation != null) {
}
return null;
}
-
+
private ICompilationUnit getCompilationUnit() {
IEditorInput input= fTextEditor.getEditorInput();
if (input instanceof IFileEditorInput) {
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.VerticalRulerEvent;
import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.IUpdate;
public JavaSelectMarkerRulerAction2(ResourceBundle bundle, String prefix, ITextEditor editor) {
super(bundle, prefix, editor);
- WorkbenchHelp.setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
}
-
+
/*
* @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationDefaultSelected(org.eclipse.ui.texteditor.VerticalRulerEvent)
*/
public void annotationDefaultSelected(VerticalRulerEvent event) {
Annotation annotation= event.getSelectedAnnotation();
IAnnotationModel model= getAnnotationModel();
-
+
// if (isOverrideIndicator(annotation)) {
// ((OverrideIndicatorManager.OverrideIndicator)annotation).open();
// return;
// }
-
+
if (isBreakpoint(annotation))
triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK);
-
+
Position position= model.getPosition(annotation);
if (position == null)
return;
-
+
// if (isQuickFixTarget(annotation)) {
// ITextOperationTarget operation= (ITextOperationTarget) getTextEditor().getAdapter(ITextOperationTarget.class);
// final int opCode= PHPUnitEditor.CORRECTIONASSIST_PROPOSALS;
// return;
// }
// }
-
+
// default:
super.annotationDefaultSelected(event);
}
* @return
*/
private boolean isBreakpoint(Annotation annotation) {
- return annotation.getType().equals("org.eclipse.debug.core.breakpoint");
+ return annotation.getType().equals("org.eclipse.debug.core.breakpoint");
//|| annotation.getType().equals(JavaExpandHover.NO_BREAKPOINT_ANNOTATION); //$NON-NLS-1$
-
+
}
private boolean isQuickFixTarget(Annotation a) {
import net.sourceforge.phpdt.core.compiler.InvalidInputException;
import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
import net.sourceforge.phpdt.internal.compiler.parser.SyntaxError;
-import net.sourceforge.phpdt.internal.core.CompilationUnit;
import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
import net.sourceforge.phpdt.internal.ui.actions.FoldingActionGroup;
import net.sourceforge.phpdt.internal.ui.actions.SelectionConverter;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITextViewerExtension2;
-import org.eclipse.jface.text.ITextViewerExtension3;
import org.eclipse.jface.text.ITextViewerExtension4;
import org.eclipse.jface.text.ITextViewerExtension5;
import org.eclipse.jface.text.ITypedRegion;
try {
int widgetLocation = styledText.getOffsetAtLocation(new Point(x, y));
- if (textViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension = (ITextViewerExtension3) textViewer;
+ if (textViewer instanceof ITextViewerExtension5) {
+ ITextViewerExtension5 extension = (ITextViewerExtension5) textViewer;
return extension.widgetOffset2ModelOffset(widgetLocation);
} else {
IRegion visibleRegion = textViewer.getVisibleRegion();
int targetOffset = (PHPPairMatcher.RIGHT == anchor) ? offset : offset + length - 1;
boolean visible = false;
- if (sourceViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension = (ITextViewerExtension3) sourceViewer;
+ if (sourceViewer instanceof ITextViewerExtension5) {
+ ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
visible = (extension.modelOffset2WidgetOffset(targetOffset) > -1);
} else {
IRegion visibleRegion = sourceViewer.getVisibleRegion();
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.dialogs.SaveAsDialog;
import org.eclipse.ui.editors.text.IStorageDocumentProvider;
-import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.ContentAssistAction;
}
/*
- * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
- */
- public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
- if (WorkbenchHelp.isContextHelpDisplayed())
- return false;
- return super.requestWidgetToken(requester);
- }
+ * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
+ */
+ public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
+ if (PlatformUI.getWorkbench().getHelpSystem()
+ .isContextHelpDisplayed())
+ return false;
+ return super.requestWidgetToken(requester);
+ }
/*
- * @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper, int)
- * @since 3.0
- */
- public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) {
- if (WorkbenchHelp.isContextHelpDisplayed())
- return false;
- return super.requestWidgetToken(requester, priority);
- }
+ * @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper,
+ * int)
+ * @since 3.0
+ */
+ public boolean requestWidgetToken(IWidgetTokenKeeper requester,
+ int priority) {
+ if (PlatformUI.getWorkbench().getHelpSystem()
+ .isContextHelpDisplayed())
+ return false;
+ return super.requestWidgetToken(requester, priority);
+ }
/*
* @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewerExtension3;
+import org.eclipse.jface.text.ITextViewerExtension5;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.source.Annotation;
/**
* Highlights the temporary problems.
*/
-public class ProblemPainter implements IPainter, PaintListener, IAnnotationModelListener {
-
+public class ProblemPainter implements IPainter, PaintListener, IAnnotationModelListener {
+
private static class ProblemPosition {
Position fPosition;
Color fColor;
boolean fMultiLine;
};
-
+
private boolean fIsActive= false;
private boolean fIsPainting= false;
private boolean fIsSettingModel= false;
-
+
private ITextEditor fTextEditor;
private ISourceViewer fSourceViewer;
private StyledText fTextWidget;
private IAnnotationModel fModel;
private List fProblemPositions= new ArrayList();
-
+
private Map fColorTable= new HashMap();
private Set fAnnotationSet= new HashSet();
-
-
+
+
public ProblemPainter(ITextEditor textEditor, ISourceViewer sourceViewer) {
fTextEditor= textEditor;
fSourceViewer= sourceViewer;
fTextWidget= sourceViewer.getTextWidget();
}
-
+
private boolean hasProblems() {
return !fProblemPositions.isEmpty();
- }
-
+ }
+
private void enablePainting() {
if (!fIsPainting && hasProblems()) {
fIsPainting= true;
handleDrawRequest(null);
}
}
-
+
private void disablePainting(boolean redraw) {
if (fIsPainting) {
fIsPainting= false;
handleDrawRequest(null);
}
}
-
+
private void setModel(IAnnotationModel model) {
if (fModel != model) {
if (fModel != null)
}
}
}
-
- private void catchupWithModel() {
+
+ private void catchupWithModel() {
if (fProblemPositions != null) {
fProblemPositions.clear();
if (fModel != null) {
-
+
Iterator e= new ProblemAnnotationIterator(fModel, true);
while (e.hasNext()) {
IProblemAnnotation pa= (IProblemAnnotation) e.next();
Annotation a= (Annotation) pa;
-
+
Color color= null;
AnnotationType type= pa.getAnnotationType();
if (fAnnotationSet.contains(type))
color= (Color) fColorTable.get(type);
-
+
if (color != null) {
ProblemPosition pp= new ProblemPosition();
pp.fPosition= fModel.getPosition(a);
}
}
}
-
+
private void updatePainting() {
disablePainting(true);
- catchupWithModel();
+ catchupWithModel();
enablePainting();
}
-
+
/*
* @see IAnnotationModelListener#modelChanged(IAnnotationModel)
*/
}
}
}
-
+
public void setColor(AnnotationType annotationType, Color color) {
if (color != null)
fColorTable.put(annotationType, color);
else
fColorTable.remove(annotationType);
}
-
+
public void paintAnnotations(AnnotationType annotationType, boolean paint) {
if (paint)
fAnnotationSet.add(annotationType);
else
fAnnotationSet.remove(annotationType);
}
-
+
public boolean isPaintingAnnotations() {
return !fAnnotationSet.isEmpty();
}
-
+
/*
* @see IPainter#dispose()
*/
public void dispose() {
-
- if (fColorTable != null)
+
+ if (fColorTable != null)
fColorTable.clear();
fColorTable= null;
-
+
if (fAnnotationSet != null)
fAnnotationSet.clear();
fAnnotationSet= null;
-
+
fTextWidget= null;
fModel= null;
fProblemPositions= null;
* possibly including partially visible lines.
*/
private int getInclusiveTopIndexStartOffset() {
-
- if (fTextWidget != null && !fTextWidget.isDisposed()) {
+
+ if (fTextWidget != null && !fTextWidget.isDisposed()) {
int top= fSourceViewer.getTopIndex();
if ((fTextWidget.getTopPixel() % fTextWidget.getLineHeight()) != 0)
top--;
} catch (BadLocationException ex) {
}
}
-
+
return -1;
}
-
+
/*
* @see PaintListener#paintControl(PaintEvent)
*/
if (fTextWidget != null)
handleDrawRequest(event.gc);
}
-
+
private void handleDrawRequest(GC gc) {
int vOffset= getInclusiveTopIndexStartOffset();
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=17147
- int vLength= fSourceViewer.getBottomIndexEndOffset() + 1;
-
+ int vLength= fSourceViewer.getBottomIndexEndOffset() + 1;
+
for (Iterator e = fProblemPositions.iterator(); e.hasNext();) {
ProblemPosition pp = (ProblemPosition) e.next();
Position p= pp.fPosition;
if (p.overlapsWith(vOffset, vLength)) {
-
+
if (!pp.fMultiLine) {
-
+
IRegion widgetRange= getWidgetRange(p);
if (widgetRange != null)
draw(gc, widgetRange.getOffset(), widgetRange.getLength(), pp.fColor);
-
+
} else {
-
+
IDocument document= fSourceViewer.getDocument();
try {
-
- int startLine= document.getLineOfOffset(p.getOffset());
+
+ int startLine= document.getLineOfOffset(p.getOffset());
int lastInclusive= Math.max(p.getOffset(), p.getOffset() + p.getLength() - 1);
int endLine= document.getLineOfOffset(lastInclusive);
-
+
for (int i= startLine; i <= endLine; i++) {
IRegion line= document.getLineInformation(i);
int paintStart= Math.max(line.getOffset(), p.getOffset());
draw(gc, widgetRange.getOffset(), widgetRange.getLength(), pp.fColor);
}
}
-
+
} catch (BadLocationException x) {
}
}
}
}
}
-
+
private IRegion getWidgetRange(Position p) {
- if (fSourceViewer instanceof ITextViewerExtension3) {
-
- ITextViewerExtension3 extension= (ITextViewerExtension3) fSourceViewer;
+ if (fSourceViewer instanceof ITextViewerExtension5) {
+ ITextViewerExtension5 extension= (ITextViewerExtension5) fSourceViewer;
return extension.modelRange2WidgetRange(new Region(p.getOffset(), p.getLength()));
-
+
} else {
-
+
IRegion region= fSourceViewer.getVisibleRegion();
int offset= region.getOffset();
int length= region.getLength();
-
+
if (p.overlapsWith(offset , length)) {
int p1= Math.max(offset, p.getOffset());
int p2= Math.min(offset + length, p.getOffset() + p.getLength());
return new Region(p1 - offset, p2 - p1);
}
}
-
+
return null;
}
-
+
private int[] computePolyline(Point left, Point right, int height) {
-
+
final int WIDTH= 4; // must be even
final int HEIGHT= 2; // can be any number
// final int MINPEEKS= 2; // minimal number of peeks
-
+
int peeks= (right.x - left.x) / WIDTH;
// if (peeks < MINPEEKS) {
// int missing= (MINPEEKS - peeks) * WIDTH;
// left.x= Math.max(0, left.x - missing/2);
// peeks= MINPEEKS;
// }
-
+
int leftX= left.x;
-
+
// compute (number of point) * 2
int length= ((2 * peeks) + 1) * 2;
if (length < 0)
return new int[0];
-
+
int[] coordinates= new int[length];
-
+
// cache peeks' y-coordinates
int bottom= left.y + height - 1;
int top= bottom - HEIGHT;
-
+
// populate array with peek coordinates
for (int i= 0; i < peeks; i++) {
int index= 4 * i;
coordinates[index+2]= coordinates[index] + WIDTH/2;
coordinates[index+3]= top;
}
-
+
// the last down flank is missing
coordinates[length-2]= left.x + (WIDTH * peeks);
coordinates[length-1]= bottom;
-
+
return coordinates;
}
-
+
private void draw(GC gc, int offset, int length, Color color) {
if (gc != null) {
-
+
Point left= fTextWidget.getLocationAtOffset(offset);
Point right= fTextWidget.getLocationAtOffset(offset + length);
-
+
gc.setForeground(color);
int[] polyline= computePolyline(left, right, gc.getFontMetrics().getHeight());
gc.drawPolyline(polyline);
-
+
} else {
fTextWidget.redrawRange(offset, length, true);
}
}
-
+
/*
* @see IPainter#deactivate(boolean)
*/
catchupWithModel();
}
}
-
+
/*
* @see IPainter#paint(int)
*/
package net.sourceforge.phpeclipse.phpeditor.php;
import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultAutoIndentStrategy;
+import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.IDocument;
/**
* Auto indent strategy sensitive to brackets.
*/
-public class PHPAutoIndentStrategy extends DefaultAutoIndentStrategy {
+public class PHPAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
public PHPAutoIndentStrategy() {
}
-
+
/* (non-Javadoc)
* Method declared on IAutoIndentStrategy
*/
public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
if (c.length == 0 && c.text != null && endsWithDelimiter(d, c.text))
smartIndentAfterNewLine(d, c);
- else if ("}".equals(c.text)) {
+ else if ("}".equals(c.text)) {
smartInsertAfterBracket(d, c);
}
}
-
+
/**
* Returns whether or not the text ends with one of the given search strings.
*/
return false;
}
-
+
/**
* Returns the line number of the next bracket after end.
* @returns the line number of the next matching bracket after end
int start= document.getLineOffset(line);
int brackcount= getBracketCount(document, start, end, false) - closingBracketIncrease;
- // sum up the brackets counts of each line (closing brackets count negative,
+ // sum up the brackets counts of each line (closing brackets count negative,
// opening positive) until we find a line the brings the count to zero
while (brackcount < 0) {
line--;
}
return line;
}
-
+
/**
- * Returns the bracket value of a section of text. Closing brackets have a value of -1 and
+ * Returns the bracket value of a section of text. Closing brackets have a value of -1 and
* open brackets have a value of 1.
* @returns the line number of the next matching bracket after end
* @param document - the document being parsed
// a comment starts, advance to the comment end
begin= getCommentEnd(document, begin + 1, end);
} else if (next == '/') {
- // '//'-comment: nothing to do anymore on this line
+ // '//'-comment: nothing to do anymore on this line
begin= end;
}
}
}
return bracketcount;
}
-
+
/**
* Returns the end position a comment starting at pos.
* @returns the end position a comment starting at pos
}
return end;
}
-
+
/**
* Returns the String at line with the leading whitespace removed.
* @returns the String at line with the leading whitespace removed.
return ""; //$NON-NLS-1$
}
}
-
+
/**
* Returns the position of the character in the document after position.
* @returns the next location of character.
}
return end;
}
-
+
/**
* Set the indent of a new line based on the command provided in the supplied document.
* @param document - the document being parsed
System.out.println(PHPEditorMessages.getString("AutoIndent.error.bad_location_1")); //$NON-NLS-1$
}
}
-
+
/**
* Set the indent of a bracket based on the command provided in the supplied document.
* @param document - the document being parsed
import java.util.List;
import java.util.Map;
-import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
import net.sourceforge.phpdt.internal.ui.text.AbstractJavaScanner;
import net.sourceforge.phpdt.ui.text.IColorManager;
import net.sourceforge.phpeclipse.IPreferenceConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import net.sourceforge.phpdt.internal.compiler.parser.VariableInfo;
import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory;
import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
-import net.sourceforge.phpdt.internal.core.CompilationUnit;
-import net.sourceforge.phpdt.internal.core.SourceType;
import net.sourceforge.phpdt.internal.corext.template.php.JavaContext;
import net.sourceforge.phpdt.internal.corext.template.php.JavaContextType;
import net.sourceforge.phpdt.internal.ui.text.PHPCodeReader;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.ide.IDE.SharedImages;
public class PHPProjectLibraryPage {
protected JavaProject workingProject;
ITableLabelProvider labelProvider = new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
IWorkbench workbench = PHPeclipsePlugin.getDefault().getWorkbench();
- return workbench.getSharedImages().getImage(ISharedImages.IMG_OBJ_PROJECT);
+ return workbench.getSharedImages().getImage(SharedImages.IMG_OBJ_PROJECT);
}
public String getColumnText(Object element, int columnIndex) {