X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TemplatePreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TemplatePreferencePage.java index 2fc70d4..f375353 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TemplatePreferencePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TemplatePreferencePage.java @@ -11,12 +11,13 @@ import net.sourceforge.phpdt.internal.corext.template.Template; import net.sourceforge.phpdt.internal.corext.template.TemplateMessages; import net.sourceforge.phpdt.internal.corext.template.TemplateSet; import net.sourceforge.phpdt.internal.corext.template.Templates; +import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions; import net.sourceforge.phpdt.internal.ui.text.template.TemplateContentProvider; import net.sourceforge.phpdt.internal.ui.text.template.TemplateLabelProvider; import net.sourceforge.phpdt.internal.ui.util.SWTUtil; +import net.sourceforge.phpdt.ui.text.JavaTextTools; +import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration; import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpeclipse.phpeditor.PHPEditorEnvironment; -import net.sourceforge.phpeclipse.phpeditor.PHPSourceViewerConfiguration; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.ErrorDialog; @@ -26,6 +27,7 @@ import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IDocumentPartitioner; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; @@ -59,7 +61,9 @@ import org.eclipse.swt.widgets.TableColumn; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; -public class TemplatePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { +public class TemplatePreferencePage + extends PreferencePage + implements IWorkbenchPreferencePage { // preference store keys private static final String PREF_FORMAT_TEMPLATES = PHPeclipsePlugin.PLUGIN_ID + ".template.format"; //$NON-NLS-1$ @@ -92,7 +96,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite ancestor) { - PHPEditorEnvironment.connect(this); + // PHPEditorEnvironment.connect(this); Composite parent = new Composite(ancestor, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; @@ -110,7 +114,10 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench gd.horizontalSpan = 2; innerParent.setLayoutData(gd); - Table table = new Table(innerParent, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); + Table table = + new Table( + innerParent, + SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = convertWidthInCharsToPixels(3); @@ -144,7 +151,8 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench int result = left.getName().compareToIgnoreCase(right.getName()); if (result != 0) return result; - return left.getDescription().compareToIgnoreCase(right.getDescription()); + return left.getDescription().compareToIgnoreCase( + right.getDescription()); } return super.compare(viewer, object1, object2); } @@ -255,7 +263,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench fPatternViewer = createViewer(parent); // fFormatButton= new Button(parent, SWT.CHECK); - // fFormatButton.setText(TemplateMessages.getString("TemplatePreferencePage.use.code.formatter")); //$NON-NLS-1$ + // fFormatButton.setText(ObfuscatorMessages.getString("TemplatePreferencePage.use.code.formatter")); //$NON-NLS-1$ // GridData gd1= new GridData(); // gd1.horizontalSpan= 2; // fFormatButton.setLayoutData(gd1); @@ -268,7 +276,13 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench // fFormatButton.setSelection(prefs.getBoolean(PREF_FORMAT_TEMPLATES)); updateButtons(); - configureTableResizing(innerParent, buttons, table, column1, column2, column3); + configureTableResizing( + innerParent, + buttons, + table, + column1, + column2, + column3); // WorkbenchHelp.setHelp(parent, IJavaHelpContextIds.TEMPLATE_PREFERENCE_PAGE); @@ -338,17 +352,20 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench data.horizontalSpan = 2; label.setLayoutData(data); - SourceViewer viewer = new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - // JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools(); + SourceViewer viewer = + new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); + JavaTextTools tools = PHPeclipsePlugin.getDefault().getJavaTextTools(); IDocument document = new Document(); - // IDocumentPartitioner partitioner= new PHPPartitionScanner(); //tools.createDocumentPartitioner(); - // document.setDocumentPartitioner(partitioner); - // partitioner.connect(document); + IDocumentPartitioner partitioner = tools.createDocumentPartitioner(); + document.setDocumentPartitioner(partitioner); + partitioner.connect(document); - viewer.configure(new PHPSourceViewerConfiguration(null)); // (tools, null)); + viewer.configure(new PHPSourceViewerConfiguration(tools, null, IPHPPartitions.PHP_PARTITIONING)); + // (tools, null)); viewer.setEditable(false); viewer.setDocument(document); - viewer.getTextWidget().setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); + viewer.getTextWidget().setBackground( + getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); Font font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); @@ -371,7 +388,8 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench } private void selectionChanged1() { - IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection(); + IStructuredSelection selection = + (IStructuredSelection) fTableViewer.getSelection(); if (selection.size() == 1) { Template template = (Template) selection.getFirstElement(); @@ -384,7 +402,8 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench } private void updateButtons() { - int selectionCount = ((IStructuredSelection) fTableViewer.getSelection()).size(); + int selectionCount = + ((IStructuredSelection) fTableViewer.getSelection()).size(); int itemCount = fTableViewer.getTable().getItemCount(); fEditButton.setEnabled(selectionCount == 1); @@ -410,7 +429,8 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench } template.setContext(contextTypeName); //$NON-NLS-1$ - EditTemplateDialog dialog = new EditTemplateDialog(getShell(), template, false); + EditTemplateDialog dialog = + new EditTemplateDialog(getShell(), template, false); if (dialog.open() == EditTemplateDialog.OK) { fTemplates.add(template); fTableViewer.refresh(); @@ -420,7 +440,8 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench } private void edit() { - IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection(); + IStructuredSelection selection = + (IStructuredSelection) fTableViewer.getSelection(); Object[] objects = selection.toArray(); if ((objects == null) || (objects.length != 1)) @@ -432,7 +453,8 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench private void edit(Template template) { Template newTemplate = new Template(template); - EditTemplateDialog dialog = new EditTemplateDialog(getShell(), newTemplate, true); + EditTemplateDialog dialog = + new EditTemplateDialog(getShell(), newTemplate, true); if (dialog.open() == EditTemplateDialog.OK) { if (!newTemplate.getName().equals(template.getName()) && MessageDialog.openQuestion(getShell(), TemplateMessages.getString("TemplatePreferencePage.question.create.new.title"), //$NON-NLS-1$ @@ -479,7 +501,8 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench } private void export() { - IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection(); + IStructuredSelection selection = + (IStructuredSelection) fTableViewer.getSelection(); Object[] templates = selection.toArray(); TemplateSet templateSet = new TemplateSet(); @@ -517,7 +540,8 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench } private void remove() { - IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection(); + IStructuredSelection selection = + (IStructuredSelection) fTableViewer.getSelection(); Iterator elements = selection.iterator(); while (elements.hasNext()) { @@ -586,7 +610,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench } PHPeclipsePlugin.getDefault().savePluginPreferences(); - PHPEditorEnvironment.disconnect(this); + // PHPEditorEnvironment.disconnect(this); return super.performOk(); } @@ -601,7 +625,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench openReadErrorDialog(e); } - PHPEditorEnvironment.disconnect(this); + // PHPEditorEnvironment.disconnect(this); return super.performCancel(); }