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;
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;
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$
* @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;
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);
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);
}
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);
// 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);
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()); // (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);
}
private void selectionChanged1() {
- IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
+ IStructuredSelection selection =
+ (IStructuredSelection) fTableViewer.getSelection();
if (selection.size() == 1) {
Template template = (Template) selection.getFirstElement();
}
private void updateButtons() {
- int selectionCount = ((IStructuredSelection) fTableViewer.getSelection()).size();
+ int selectionCount =
+ ((IStructuredSelection) fTableViewer.getSelection()).size();
int itemCount = fTableViewer.getTable().getItemCount();
fEditButton.setEnabled(selectionCount == 1);
}
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();
}
private void edit() {
- IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
+ IStructuredSelection selection =
+ (IStructuredSelection) fTableViewer.getSelection();
Object[] objects = selection.toArray();
if ((objects == null) || (objects.length != 1))
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$
}
private void export() {
- IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
+ IStructuredSelection selection =
+ (IStructuredSelection) fTableViewer.getSelection();
Object[] templates = selection.toArray();
TemplateSet templateSet = new TemplateSet();
}
private void remove() {
- IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
+ IStructuredSelection selection =
+ (IStructuredSelection) fTableViewer.getSelection();
Iterator elements = selection.iterator();
while (elements.hasNext()) {
}
PHPeclipsePlugin.getDefault().savePluginPreferences();
- PHPEditorEnvironment.disconnect(this);
+ // PHPEditorEnvironment.disconnect(this);
return super.performOk();
}
openReadErrorDialog(e);
}
- PHPEditorEnvironment.disconnect(this);
+ // PHPEditorEnvironment.disconnect(this);
return super.performCancel();
}