Author: rob.stryker(a)jboss.com
Date: 2008-10-30 22:23:28 -0400 (Thu, 30 Oct 2008)
New Revision: 11381
Removed:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/DescriptorXPathViewProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/EventLogViewProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/descriptors/
Modified:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java
Log:
Removing more outdated old-view stuff
Modified:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java 2008-10-31
02:11:39 UTC (rev 11380)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java 2008-10-31
02:23:28 UTC (rev 11381)
@@ -37,7 +37,9 @@
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
@@ -45,6 +47,7 @@
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
@@ -73,7 +76,6 @@
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.ui.Messages;
-import
org.jboss.ide.eclipse.as.ui.views.server.providers.descriptors.XPathPropertyLabelProvider;
/**
@@ -891,4 +893,49 @@
return server.getRuntime().getLocation().toOSString();
//return null;
}
+
+ public static class XPathPropertyLabelProvider extends LabelProvider implements
ITableLabelProvider {
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+ public String getColumnText(Object element, int columnIndex) {
+ if( element instanceof XPathQuery) {
+ if( columnIndex == 0 ) return ((XPathQuery)element).getName();
+ if( columnIndex == 1 ) {
+ XPathResultNode[] nodes = getResultNodes(((XPathQuery)element));
+ if( nodes.length == 1 )
+ return nodes[0].getText();
+ }
+ }
+
+ if( element instanceof XPathFileResult ) {
+ XPathFileResult result = (XPathFileResult)element;
+ if( columnIndex == 0 ) {
+ return result.getFileLocation().substring(result.getQuery().getBaseDir().length());
+ }
+ if( result.getChildren().length == 1 ) {
+ element = result.getChildren()[0];
+ }
+ }
+
+ if( element instanceof XPathResultNode ) {
+ XPathResultNode element2 = (XPathResultNode)element;
+ if( columnIndex == 0 ) return Messages.DescriptorXPathMatch + element2.getIndex();
+ if( columnIndex == 1 ) return element2.getText().trim();
+ }
+
+ return null;
+ }
+
+ public XPathResultNode[] getResultNodes(XPathQuery query) {
+ ArrayList<XPathResultNode> l = new ArrayList<XPathResultNode>();
+ XPathFileResult[] files = query.getResults();
+ for( int i = 0; i < files.length; i++ ) {
+ l.addAll(Arrays.asList(files[i].getChildren()));
+ }
+ return l.toArray(new XPathResultNode[l.size()]);
+ }
+
+ }
+
}
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/DescriptorXPathViewProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/DescriptorXPathViewProvider.java 2008-10-31
02:11:39 UTC (rev 11380)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/DescriptorXPathViewProvider.java 2008-10-31
02:23:28 UTC (rev 11381)
@@ -1,292 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.ui.views.server.providers;
-
-
-/**
- *
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public class DescriptorXPathViewProvider { /*
-extends JBossServerViewExtension {
-
- private XPathTreeContentProvider contentProvider;
- private XPathTreeLabelProvider labelProvider;
- private DescriptorXPathPropertySheetPage propertyPage;
-
- public Action newXPathCategoryAction, deleteXPathCategoryAction, newXPathAction,
- editXPathAction, deleteXPathAction, editFileAction;
-
- private IServer server;
- private XPathCategory activeCategory;
- private Object selectedPropertyObject;
-
-
- public DescriptorXPathViewProvider() {
- contentProvider = new XPathTreeContentProvider();
- labelProvider = new XPathTreeLabelProvider();
- createActions();
- }
-
- public void setActiveCategory(XPathCategory o) {
- if( o != null && o != activeCategory) {
- activeCategory = o;
- }
- }
-
- public XPathCategory getActiveCategory() {
- return activeCategory;
- }
-
- public void setPropertySelection(Object o) {
- selectedPropertyObject = o;
- }
-
- public Object getPropertySelection() {
- return selectedPropertyObject;
- }
-
- protected class XPathTreeContentProvider implements ITreeContentProvider {
-
- public Object[] getChildren(Object parentElement) {
- if( parentElement instanceof ServerViewProvider ) {
- if( server == null ) return new Object[]{};
- return XPathModel.getDefault().getCategories(server);
- }
- return new Object[0];
- }
- public Object getParent(Object element) {
- return null;
- }
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0 ? true : false;
- }
- public Object[] getElements(Object inputElement) {
- return new Object[0];
- }
- public void dispose() {
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if( oldInput != newInput ) {
- server = (IServer)newInput;
- }
- }
- }
-
- protected class XPathTreeLabelProvider extends LabelProvider {
-
- public Image getImage(Object element) {
- if( element instanceof XPathCategory) {
- return
PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
- }
- return null;
- }
-
- public String getText(Object element) {
- if( element instanceof XPathCategory) {
- return ((XPathCategory)element).getName();
- }
- return "";
- }
- }
-
-
- public ITreeContentProvider getContentProvider() {
- return contentProvider;
- }
-
- public LabelProvider getLabelProvider() {
- return labelProvider;
- }
-
- public void createActions() {
- newXPathCategoryAction = new Action() {
- public void run() {
- XPathCategoryDialog d = new XPathCategoryDialog(
- Display.getCurrent().getActiveShell(), server);
- if( d.open() == Window.OK ) {
- XPathModel.getDefault().addCategory(server, d.getText());
- XPathModel.getDefault().save(server);
- refreshViewer();
- }
- }
- };
- newXPathCategoryAction.setText("New Category");
-
- deleteXPathCategoryAction= new Action() {
- public void run() {
- int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
- MessageBox messageBox = new MessageBox (Display.getCurrent().getActiveShell(),
style);
- messageBox.setText (Messages.DescriptorXPathRemoveCategory + "?");
- messageBox.setMessage (Messages.DescriptorXPathRemoveCategoryDesc);
- if( messageBox.open () == SWT.YES ) {
- XPathModel.getDefault().removeCategory(server, getActiveCategory().getName());
- XPathModel.getDefault().save(server);
- setActiveCategory(null);
- refreshViewer();
- }
- }
- };
- deleteXPathCategoryAction.setText(Messages.DescriptorXPathRemoveCategory);
-
-
- newXPathAction = new Action() {
- public void run() {
- XPathCategory category = getActiveCategory();
- if( category != null ) {
- String categoryName = category.getName();
- XPathDialog d = new XPathDialog(Display.getCurrent().getActiveShell(), server,
categoryName);
- if( d.open() == Window.OK ) {
- XPathCategory[] categoryList = XPathModel.getDefault().getCategories(server);
- XPathCategory categoryItem = null;
- for( int i = 0; i < categoryList.length; i++ ) {
- if( categoryList[i].getName().equals(category.getName()))
- categoryItem = categoryList[i];
- }
- if( categoryItem != null ) {
- XPathQuery query = new XPathQuery(d.getName(),
XPathDialogs.getConfigFolder(server), null, d.getXpath(), d.getAttribute());
- categoryItem.addQuery(query);
- XPathModel.getDefault().save(server);
- refreshViewer();
- }
- }
- }
- }
- };
- newXPathAction.setText(Messages.DescriptorXPathNewXPath);
-
- editXPathAction = new Action() {
- public void run() {
- Object o = getPropertySelection();
- if( o != null && o instanceof XPathQuery) {
- XPathQuery original = (XPathQuery)o;
- XPathCategory category = original.getCategory();
-
- XPathDialog d = new XPathDialog(Display.getCurrent().getActiveShell(),
- server, category.getName(), original.getName());
- d.setAttribute(original.getAttribute());
- d.setXpath(original.getXpathPattern());
-
- if( d.open() == Window.OK ) {
- original.setAttribute(d.getAttribute());
- original.setXpathPattern(d.getXpath());
- original.setName(d.getName());
- category.save();
- refreshViewer();
- }
- }
- }
- };
- editXPathAction.setText(Messages.DescriptorXPathEditXPath);
-
- deleteXPathAction = new Action() {
- public void run() {
- Object o = getPropertySelection();
- if( o instanceof XPathQuery ) {
- XPathCategory cat = ((XPathQuery)o).getCategory();
- cat.removeQuery((XPathQuery)o);
- cat.save();
- refreshViewer();
- }
- }
- };
- deleteXPathAction.setText(Messages.DescriptorXPathDeleteXPath);
-
- editFileAction = new Action() {
- public void run() {
- try {
- Object o = getPropertySelection();
- Path p = null;
- if( o instanceof XPathQuery && ((XPathQuery)o).getResults().length == 1 ) {
- o = (XPathFileResult) ((XPathQuery)o).getResults()[0];
- }
- if( o instanceof XPathFileResult ) {
- p = new Path(((XPathFileResult)o).getFileLocation());
- } else if( o instanceof XPathResultNode ) {
- p = new Path(((XPathResultNode)o).getFileLocation());
- }
- if( p != null ) {
-
-
- IFileStore fileStore =
EFS.getLocalFileSystem().getStore(p.removeLastSegments(1));
- fileStore = fileStore.getChild(p.lastSegment());
- IWorkbench wb = PlatformUI.getWorkbench();
- IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
- IWorkbenchPage page = win.getActivePage();
-
- if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists())
{
- try {
- IDE.openEditorOnFileStore(page, fileStore);
- } catch (PartInitException e) {}
- }
- }
- } catch( Exception exc ) {
- JBossServerUIPlugin.log("Error running edit file action", exc);
- }
- }
- };
- editFileAction.setText("Edit File");
- }
-
- public void fillContextMenu(Shell shell, IMenuManager menu, Object[] selection) {
- if( selection[0] instanceof ServerViewProvider ) {
- menu.add(this.newXPathCategoryAction);
- menu.add(new Separator());
- return;
- }
-
- if( selection[0] instanceof XPathCategory ) {
- setActiveCategory((XPathCategory)selection[0]);
- menu.add(this.newXPathAction);
- menu.add(this.deleteXPathCategoryAction);
- menu.add(new Separator());
- }
- }
-
- protected boolean supports(IServer server) {
- return true;
- }
-
- // Property Sheet Page
- public IPropertySheetPage getPropertySheetPage() {
- if( propertyPage == null ) {
- propertyPage = new DescriptorXPathPropertySheetPage(this);
- }
- return propertyPage;
- }
-
- protected void refreshViewer() {
- if( isEnabled() ) {
- try {
- super.refreshViewer();
- if( propertyPage != null ) {
- propertyPage.getViewer().refresh();
- }
- } catch(Exception e) {
- JBossServerUIPlugin.log("Error refreshing view
(descriptorXPathViewProvider)", e);
- }
- }
- }
- */
-
-}
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/EventLogViewProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/EventLogViewProvider.java 2008-10-31
02:11:39 UTC (rev 11380)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/EventLogViewProvider.java 2008-10-31
02:23:28 UTC (rev 11381)
@@ -1,413 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.ui.views.server.providers;
-
-
-/**
- *
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public class EventLogViewProvider {
- /*
- extends JBossServerViewExtension implements IEventLogListener, ISimplePropertiesHolder
{
-
- public static final String SHOW_TIMESTAMP =
"org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.showTimestamp";
- public static final String GROUP_BY_CATEGORY =
"org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.groupByCategory";
- public static final String EVENT_ON_TOP =
"org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.eventOnTop";
- public static final int NEWEST_ON_TOP = 1;
- public static final int OLDEST_ON_TOP = 2;
- public static final int _TRUE_ = 1;
- public static final int _FALSE_ = 2;
-
- private ITreeContentProvider contentProvider;
- private LabelProvider labelProvider;
- private IEventLogLabelProvider[] labelProviderDelegates = null;
- private IPropertySheetPage propertyPage = null;
- private Object[] selection;
-
- private IServer input;
- private Action clearLogAction;
- private Action showStackTraceAction;
-
- private static HashMap<String, String> majorTypeToName = new HashMap<String,
String>();
- static {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf =
registry.getConfigurationElementsFor(JBossServerUIPlugin.PLUGIN_ID,
"EventLogMajorType");
- for( int i = 0; i < cf.length; i++ ) {
- String type = cf[i].getAttribute("typeId");
- String name = cf[i].getAttribute("name");
- majorTypeToName.put(type, name);
- }
- }
-
-
- public EventLogViewProvider() {
- contentProvider = new EventLogContentProvider();
- labelProvider = new EventLogLabelProvider();
- EventLogModel.getDefault().addListener(this);
- createActions();
- }
-
- protected void createActions() {
- clearLogAction = new Action() {
- public void run() {
- try {
- EventLogModel.getModel(input).clearEvents();
- refreshViewer();
- } catch( Exception e) {}
- }
- };
- clearLogAction.setText("Clear Event Log");
-
- showStackTraceAction = new Action() {
- public void run() {
- EventLogTreeItem item = (EventLogTreeItem)selection[0];
- ShowStackTraceDialog dialog = new ShowStackTraceDialog(new Shell(), item);
- dialog.open();
- }
- };
- showStackTraceAction.setText("See Exception Details");
- }
-
- public class EventLogContentProvider implements ITreeContentProvider {
- public Object[] getChildren(Object parentElement) {
- if( parentElement instanceof ServerViewProvider && input != null ) {
- boolean categorize = getCategorize();
- if( categorize )
- return getRootCategories();
- Object[] ret = EventLogModel.getModel(input).getRoot().getChildren();
- if( getSortOrder()) {
- List<Object> l = Arrays.asList(ret);
- Collections.reverse(l);
- return l.toArray();
- }
- return ret;
- }
-
- if( parentElement instanceof String ) {
- // get children only of this type
- SimpleTreeItem[] children = EventLogModel.getModel(input).getRoot().getChildren();
- ArrayList<SimpleTreeItem> items = new ArrayList<SimpleTreeItem>();
- for( int i = 0; i < children.length; i++ ) {
- if( children[i] instanceof EventLogTreeItem ) {
- String type = ((EventLogTreeItem)children[i]).getEventClass();
- if( type != null && type.equals(parentElement))
- items.add(children[i]);
- }
- }
-
- if( getSortOrder() ) Collections.reverse(items);
-
- return items.toArray(new Object[items.size()]);
- }
-
- // just return the object's kids
- if( parentElement instanceof EventLogTreeItem ) {
- return ((EventLogTreeItem)parentElement).getChildren();
- }
- return new Object[0];
- }
-
- protected Object[] getRootCategories() {
- EventLogRoot root = EventLogModel.getModel(input).getRoot();
- ArrayList<String> majorTypes = new ArrayList<String>();
- SimpleTreeItem[] children = root.getChildren();
- for( int i = 0; i < children.length; i++ ) {
- if( children[i] instanceof EventLogTreeItem ) {
- String type = ((EventLogTreeItem)children[i]).getEventClass();
- if( !majorTypes.contains(type))
- majorTypes.add(type);
- }
- }
- return majorTypes.toArray(new String[majorTypes.size()]);
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0 ? true : false;
- }
-
- public Object[] getElements(Object inputElement) {
- // Unused
- return null;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- input = (IServer)newInput;
- }
-
- }
-
- public class EventLogLabelProvider extends LabelProvider {
- public Image getImage(Object element) {
- if( labelProviderDelegates == null )
- loadLabelProviderDelegates();
-
- if( element instanceof ServerViewProvider ) {
- return ((ServerViewProvider)element).getImage();
- }
-
- if( !(element instanceof EventLogTreeItem)) return null;
- EventLogTreeItem item = (EventLogTreeItem)element;
-
- for( int i = 0; i < labelProviderDelegates.length; i++ ) {
- if( labelProviderDelegates[i] != null
- && labelProviderDelegates[i].supports(item.getSpecificType())) {
- Image image = labelProviderDelegates[i].getImage((EventLogTreeItem)element);
- if( image != null ) return image;
- }
- }
-
- return null;
- }
-
- public String getText(Object element) {
- if( element == null ) return "NULL, ERROR";
- String suffix = getShowTimestamp() ? createTimestamp(element) : "";
- if( labelProviderDelegates == null )
- loadLabelProviderDelegates();
-
- if( element instanceof ServerViewProvider ) {
- return ((ServerViewProvider)element).getName();
- }
-
- if( !(element instanceof EventLogTreeItem)) {
- if( element instanceof String ) {
- String val = majorTypeToName.get(element);
- if( val != null ) return val;
- }
- return element.toString();
- }
- EventLogTreeItem item = (EventLogTreeItem)element;
-
- for( int i = 0; i < labelProviderDelegates.length; i++ ) {
- if( labelProviderDelegates[i] != null
- && labelProviderDelegates[i].supports(item.getSpecificType())) {
- String text = labelProviderDelegates[i].getText((EventLogTreeItem)element);
- if( text != null ) return text + suffix;
- }
- }
-
- return element == null ? "" : element.toString() + suffix;
- }
-
- public void loadLabelProviderDelegates() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] elements =
registry.getConfigurationElementsFor(JBossServerUIPlugin.PLUGIN_ID,
"EventLogLabelProvider");
- labelProviderDelegates = new IEventLogLabelProvider[elements.length];
- for( int i = 0; i < elements.length; i++ ) {
- try {
- labelProviderDelegates[i] =
(IEventLogLabelProvider)elements[i].createExecutableExtension("class");
- } catch( CoreException ce ) {
- JBossServerUIPlugin.log("Error loading Event Log Label Provider Delegate",
ce);
- }
- }
- }
- }
-
- public void fillContextMenu(Shell shell, IMenuManager menu, Object selection[]) {
- this.selection = selection;
- if( selection.length == 1 && selection[0] == this.provider) {
- menu.add(clearLogAction);
- }
- if( selection.length == 1 && selection[0] instanceof EventLogTreeItem
&&
- (((EventLogTreeItem)selection[0]).getEventClass().equals(EventLogModel.EVENT_TYPE_EXCEPTION)
||
- ((EventLogTreeItem)selection[0]).getSpecificType().equals(EventLogModel.EVENT_TYPE_EXCEPTION)))
{
- menu.add(showStackTraceAction);
- }
- }
-
- public ITreeContentProvider getContentProvider() {
- return contentProvider;
- }
-
- public LabelProvider getLabelProvider() {
- return labelProvider;
- }
-
- public IPropertySheetPage getPropertySheetPage() {
- if( propertyPage == null )
- propertyPage = PropertySheetFactory.createSimplePropertiesSheet(this);
- return propertyPage;
- }
-
-
- public void eventModelChanged(String serverId, EventLogTreeItem changed) {
- if( input != null && serverId.equals(input.getId())) {
- if(changed.getSpecificType().equals(EventLogModel.JBOSS_EVENT_ROOT_TYPE))
- refreshViewer();
- else
- refreshViewer(changed);
- }
- }
-
- public Properties getProperties(Object selected) {
- if( !(selected instanceof EventLogTreeItem)) return new Properties();
- EventLogTreeItem item = (EventLogTreeItem)selected;
-
- for( int i = 0; i < labelProviderDelegates.length; i++ ) {
- if( labelProviderDelegates[i] != null
- && labelProviderDelegates[i].supports(item.getSpecificType())) {
- Properties props =
labelProviderDelegates[i].getProperties((EventLogTreeItem)selected);
- if( props != null ) return props;
- }
- }
- return new Properties();
- }
-
- public EventLogPreferenceComposite createPreferenceComposite(Composite parent) {
- return new EventLogPreferenceComposite(parent);
- }
-
- protected class EventLogPreferenceComposite extends Composite {
- private Button newestFirst, oldestFirst, showTime, sort;
- private Group firstGroup;
- public EventLogPreferenceComposite(Composite parent) {
- super(parent, SWT.NONE);
- setLayout(new FormLayout());
-
- createWidgets();
- fillWidgetsWithValues();
- }
- protected void fillWidgetsWithValues() {
- boolean showTimestamp = getShowTimestamp();
- boolean categorize = getCategorize();
- boolean onTop = getSortOrder();
-
- sort.setSelection(categorize);
- showTime.setSelection(showTimestamp);
- newestFirst.setSelection(onTop);
- oldestFirst.setSelection(!onTop);
- }
-
-
- protected void createWidgets() {
- firstGroup = new Group(this, SWT.NONE);
- firstGroup.setText("Which elements should be at the top?");
- firstGroup.setLayout(new GridLayout(2, false));
- newestFirst = new Button(firstGroup, SWT.RADIO);
- oldestFirst = new Button(firstGroup, SWT.RADIO);
-
- newestFirst.setText("Newest");
- oldestFirst.setText("Oldest");
-
- FormData firstGroupData = new FormData();
- firstGroupData.left = new FormAttachment(0,5);
- firstGroupData.top = new FormAttachment(0,5);
- firstGroup.setLayoutData(firstGroupData);
-
- showTime = new Button(this, SWT.CHECK);
- showTime.setText("Show timestamp? (ex: x minutes ago)");
-
- FormData d = new FormData();
- d.left = new FormAttachment(0, 5);
- d.top = new FormAttachment(firstGroup, 5);
- showTime.setLayoutData(d);
-
- sort = new Button(this, SWT.CHECK);
- sort.setText("Sort by event category?");
-
- d = new FormData();
- d.left = new FormAttachment(0, 5);
- d.top = new FormAttachment(showTime, 5);
- sort.setLayoutData(d);
- }
- public boolean isValid() {
- return true;
- }
- public boolean performCancel() {
- return true;
- }
- public boolean performOk() {
- Preferences store = JBossServerUIPlugin.getDefault().getPluginPreferences();
- store.setValue(SHOW_TIMESTAMP, showTime.getSelection() ? _TRUE_ : _FALSE_);
- store.setValue(GROUP_BY_CATEGORY, sort.getSelection() ? _TRUE_ : _FALSE_);
- store.setValue(EVENT_ON_TOP, newestFirst.getSelection() ? NEWEST_ON_TOP :
OLDEST_ON_TOP);
- return true;
- }
- public void performDefaults() {
- showTime.setSelection(false);
- newestFirst.setSelection(true);
- oldestFirst.setSelection(false);
- sort.setSelection(false);
- }
- }
-
-
-
-
- protected boolean getShowTimestamp() {
- Preferences store = JBossServerUIPlugin.getDefault().getPluginPreferences();
- int showTimestamp = store.getInt(SHOW_TIMESTAMP);
- if( showTimestamp == _TRUE_ ) return true;
- if( showTimestamp == _FALSE_) return false;
- return false; // default
- }
- protected boolean getSortOrder() {
- Preferences store = JBossServerUIPlugin.getDefault().getPluginPreferences();
- int showTimestamp = store.getInt(EVENT_ON_TOP);
- if( showTimestamp == OLDEST_ON_TOP) return false;
- return true;
- }
- protected boolean getCategorize() {
- Preferences store = JBossServerUIPlugin.getDefault().getPluginPreferences();
- int showTimestamp = store.getInt(GROUP_BY_CATEGORY);
- if( showTimestamp == _TRUE_ ) return true;
- if( showTimestamp == _FALSE_) return false;
- return false; // default
- }
-
- protected String createTimestamp(Object element) {
- if( element instanceof EventLogTreeItem ) {
- Long v = (Long) ((EventLogTreeItem)element).getProperty(EventLogTreeItem.DATE);
- if( v == null ) return "";
-
- double date = v.doubleValue();
- double now = new Date().getTime();
- int seconds = (int) (( now - date) / 1000);
- int minutes = seconds / 60;
- int hours = minutes / 60;
- minutes -= (hours * 60);
- String minString = minutes + "m ago";
- if( hours == 0 )
- return " (" + minString + ")";
- return " (" + hours + "h " + minString + ")";
- }
- return "";
- }
-
- public void enable() {
- EventLogModel.enableLogging();
- }
- public void disable() {
- EventLogModel.disableLogging();
- }
-
-*/
-}