JBoss Tools SVN: r3701 - in trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server: providers and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-09-18 22:32:12 -0400 (Tue, 18 Sep 2007)
New Revision: 3701
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/AttributeGroup.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXLabelProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXPropertySheetPage.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXTreeContentProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXViewProvider.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/JMXViewProvider.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/ExtensionTableViewer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/JBossServerView.java
Log:
Separated out JMX addition into several classes
Finished implementing attribute editor
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/ExtensionTableViewer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/ExtensionTableViewer.java 2007-09-18 20:22:36 UTC (rev 3700)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/ExtensionTableViewer.java 2007-09-19 02:32:12 UTC (rev 3701)
@@ -339,9 +339,9 @@
IPropertySheetPage page = null;
if( selected instanceof ContentWrapper ) {
page = getDelegatePage(((ContentWrapper)selected).getProvider());
- } else if( selected instanceof ServerViewProvider ) {
+ } else /*if( selected instanceof ServerViewProvider ) {
page = getDelegatePage((ServerViewProvider)selected);
- } else if( page == null ) {
+ } else if( page == null ) */ {
page = topLevelPropertiesPage;
}
page.selectionChanged(part, sel);
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/JBossServerView.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/JBossServerView.java 2007-09-18 20:22:36 UTC (rev 3700)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/JBossServerView.java 2007-09-19 02:32:12 UTC (rev 3701)
@@ -43,7 +43,20 @@
if( getDefault() != null )
getDefault().getExtensionFrame().getViewer().addSelectionChangedListener(listener);
}
-
+
+ public static void removeServerFrameListener(ISelectionChangedListener listener) {
+ if( serverFrameListeners.contains(listener))
+ serverFrameListeners.remove(listener);
+ if( getDefault() != null )
+ getDefault().getServerFrame().getViewer().removeSelectionChangedListener(listener);
+ }
+ public static void removeExtensionFrameListener(ISelectionChangedListener listener) {
+ if( extensionFrameListeners.contains(listener))
+ extensionFrameListeners.remove(listener);
+ if( getDefault() != null )
+ getDefault().getExtensionFrame().getViewer().removeSelectionChangedListener(listener);
+ }
+
public static interface IServerViewFrame {
public IAction[] getActionBarActions();
public int getDefaultSize();
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/JMXViewProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/JMXViewProvider.java 2007-09-18 20:22:36 UTC (rev 3700)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/JMXViewProvider.java 2007-09-19 02:32:12 UTC (rev 3701)
@@ -1,537 +0,0 @@
-package org.jboss.ide.eclipse.as.ui.views.server.providers;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.jdt.internal.ui.JavaPluginImages;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerLifecycleListener;
-import org.eclipse.wst.server.core.IServerListener;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.ServerEvent;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXClassLoaderRepository;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXAttributesWrapper;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXBean;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXDomain;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXException;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.WrappedMBeanOperationInfo;
-import org.jboss.ide.eclipse.as.ui.views.server.JBossServerView;
-import org.jboss.ide.eclipse.as.ui.views.server.ExtensionTableViewer.ContentWrapper;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.JBossServerViewExtension;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerViewProvider;
-import org.jboss.ide.eclipse.as.ui.views.server.util.ViewUtilityMethods;
-
-public class JMXViewProvider extends JBossServerViewExtension {
- protected static final Object LOADING = new Object();
- protected static final String[] LOADING_STRING_ARRAY = new String[] { "Loading..." };
- protected static final String ATTRIBUTES_STRING = "Attributes...";
-
- protected JMXPropertySheetPage propertyPage;
- protected JMXServerLifecycleListener lcListener;
- protected JMXServerListener serverListener;
- protected JMXTreeContentProvider contentProvider;
- protected JMXLabelProvider labelProvider;
- protected IServer server;
- protected JMXModel model;
-
- public JMXViewProvider() {
- model = new JMXModel();
- addListeners();
- }
-
- protected void addListeners() {
- JBossServerView.addExtensionFrameListener(
- new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- Object o = JBossServerView.getDefault()
- .getExtensionFrame().getViewer()
- .getSelectedElement();
- if (o instanceof JMXBean) {
- ViewUtilityMethods.activatePropertiesView(null);
- }
- }
- });
-
- // make sure we know about server events
- serverListener = new JMXServerListener();
- lcListener = new JMXServerLifecycleListener();
- ServerCore.addServerLifecycleListener(lcListener);
- IServer[] servers = ServerCore.getServers();
- for (int i = 0; i < servers.length; i++) {
- servers[i].addServerListener(serverListener);
- }
-
- }
-
- protected class JMXServerLifecycleListener implements
- IServerLifecycleListener {
- public void serverAdded(IServer server) {
- server.addServerListener(serverListener);
- }
-
- public void serverChanged(IServer server) {
- }
-
- public void serverRemoved(IServer server) {
- server.removeServerListener(serverListener);
- JMXClassLoaderRepository.getDefault()
- .removeConcerned(server, model);
- }
- }
-
- protected class JMXServerListener implements IServerListener {
- public void serverChanged(ServerEvent event) {
- if ((event.getKind() & ServerEvent.SERVER_CHANGE) != 0) {
- if ((event.getKind() & ServerEvent.STATE_CHANGE) != 0) {
- if (event.getState() == IServer.STATE_STARTED) {
- JMXClassLoaderRepository.getDefault().addConcerned(
- event.getServer(), model);
- } else {
- JMXClassLoaderRepository.getDefault().removeConcerned(
- event.getServer(), model);
- }
- }
- }
- }
- }
-
- public IPropertySheetPage getPropertySheetPage() {
- if (propertyPage == null) {
- propertyPage = new JMXPropertySheetPage(this);
- }
- return propertyPage;
- }
-
- public ITreeContentProvider getContentProvider() {
- if (contentProvider == null)
- contentProvider = new JMXTreeContentProvider();
- return contentProvider;
- }
-
- public LabelProvider getLabelProvider() {
- if (labelProvider == null)
- labelProvider = new JMXLabelProvider();
- return labelProvider;
- }
-
- class JMXLabelProvider extends LabelProvider {
- public String getText(Object obj) {
- if (obj instanceof JMXDomain)
- return ((JMXDomain) obj).getName();
- if (obj instanceof JMXBean) {
- return ((JMXBean) obj).getName().substring(
- ((JMXBean) obj).getDomain().length() + 1);
- }
- if (obj instanceof WrappedMBeanOperationInfo) {
- return ((WrappedMBeanOperationInfo) obj).getInfo().getName();
- }
-
- if (obj instanceof JMXException) {
- String message = "";
- message += ((JMXException) obj).getException().getClass()
- .getName()
- + ": ";
- message += ((JMXException) obj).getException().getMessage();
- return message;
- }
- if (obj instanceof JMXAttributesWrapper) {
- return "Attributes";
- }
- if (obj == LOADING)
- return "loading...";
- return "not sure yet: " + obj.getClass().getName();
- }
-
- public Image getImage(Object obj) {
- if (obj instanceof JMXException) {
- return PlatformUI.getWorkbench().getSharedImages().getImage(
- ISharedImages.IMG_OBJS_ERROR_TSK);
- }
- if (obj instanceof WrappedMBeanOperationInfo)
- return JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC);
- if (obj instanceof JMXAttributesWrapper) {
- return JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
- }
-
- return null;
- }
-
- }
-
- public class JMXTreeContentProvider implements ITreeContentProvider {
-
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof ServerViewProvider) {
- if (server == null)
- return new Object[] {};
- if (server.getServerState() != IServer.STATE_STARTED) {
- model.clearModel(server);
- return new Object[] {};
- }
- JMXDomain[] domains = model.getModel(server).getDomains();
- if (domains == null
- && model.getModel(server).getException() == null) {
- loadChildrenRefreshViewer(parentElement);
- return new Object[] { LOADING };
- } else if (domains == null
- && model.getModel(server).getException() != null) {
- return new Object[] { model.getModel(server).getException() };
- }
- return domains;
- }
- if (parentElement instanceof JMXDomain) {
- JMXBean[] beans = ((JMXDomain) parentElement).getBeans();
- if (beans == null
- && ((JMXDomain) parentElement).getException() == null) {
- loadChildrenRefreshViewer(parentElement);
- return new Object[] { LOADING };
- } else if (beans == null
- && ((JMXDomain) parentElement).getException() != null) {
- return new Object[] { ((JMXDomain) parentElement)
- .getException() };
- }
- return beans;
- }
- if (parentElement instanceof JMXBean) {
- WrappedMBeanOperationInfo[] operations = ((JMXBean) parentElement)
- .getOperations();
- if (operations == null
- && ((JMXBean) parentElement).getException() == null) {
- loadChildrenRefreshViewer(parentElement);
- return new Object[] { LOADING };
- } else if (operations == null
- && ((JMXBean) parentElement).getException() != null) {
- return new Object[] { ((JMXBean) parentElement)
- .getException() };
- }
- // add the Attributes element
- ArrayList<Object> list = new ArrayList<Object>();
- list.add(new JMXAttributesWrapper((JMXBean) parentElement));
- list.addAll(Arrays.asList(operations));
- return (Object[]) list.toArray(new Object[list.size()]);
- }
- return new Object[0];
- }
-
- public Object getParent(Object element) {
- return null; // unused
- }
-
- public boolean hasChildren(Object element) {
- if (element instanceof ServerViewProvider) {
- if (server == null
- || server.getServerState() != IServer.STATE_STARTED) {
- return false;
- }
- return true;
- }
- if (element instanceof JMXException)
- return false;
- if (element instanceof WrappedMBeanOperationInfo)
- return false;
- if (element instanceof JMXAttributesWrapper)
- return false;
- return true; // always true?
- }
-
- public Object[] getElements(Object inputElement) {
- return null; // unused here
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (oldInput != newInput) {
- server = (IServer) newInput;
- }
- }
- }
-
- protected void loadChildrenRefreshViewer(final Object parent) {
- new Thread() {
- public void run() {
- loadChildren(parent);
- refreshViewerAsync(parent);
- }
- }.start();
- }
-
- protected void loadChildren(Object parent) {
- if (parent instanceof ServerViewProvider)
- model.getModel(server).loadDomains();
- else if (parent instanceof JMXDomain)
- ((JMXDomain) parent).loadBeans();
- else if (parent instanceof JMXBean)
- ((JMXBean) parent).loadInfo();
- }
-
- protected void refreshViewerAsync(final Object parent) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- refreshViewer(parent);
- }
- });
- }
-
- public void refreshModel(Object object) {
- if( object instanceof ContentWrapper )
- object = ((ContentWrapper)object).getElement();
- if (object instanceof ServerViewProvider) {
- model.clearModel(server);
- } else if (object instanceof JMXDomain) {
- ((JMXDomain) object).resetChildren();
- } else if (object instanceof JMXBean) {
- ((JMXBean) object).resetChildren();
- }
- }
-
- public class JMXPropertySheetPage implements IPropertySheetPage {
-
- // data
- protected JMXViewProvider provider;
- protected JMXBean bean;
- protected WrappedMBeanOperationInfo[] operations;
-
- // ui pieces
- protected Composite main;
- protected Combo pulldown;
- protected PageBook book;
- protected ErrorGroup errorGroup;
- protected OperationGroup operationGroup;
- protected AttributeGroup attributeGroup;
-
- public JMXPropertySheetPage(JMXViewProvider provider) {
- this.provider = provider;
- }
-
- public void createControl(Composite parent) {
- main = new Composite(parent, SWT.NONE);
- main.setLayout(new FormLayout());
-
- pulldown = new Combo(main, SWT.READ_ONLY);
- FormData pulldownData = new FormData();
- pulldownData.left = new FormAttachment(0, 10);
- // pulldownData.right = new FormAttachment(0,300);
- pulldownData.top = new FormAttachment(0, 10);
- pulldown.setLayoutData(pulldownData);
-
-
- Listener listener = new Listener() {
- public void handleEvent(Event event) {
- switch(event.type) {
- case SWT.Selection:
- case SWT.Modify:
- pulldownSelectionChanged();
- break;
- }
- }
- };
- pulldown.addListener(SWT.Selection, listener);
- pulldown.addListener(SWT.Modify, listener);
-
- book = new PageBook(main, SWT.NONE);
- FormData bookData = new FormData();
- bookData.top = new FormAttachment(pulldown, 10);
- bookData.left = new FormAttachment(0,5);
- bookData.right = new FormAttachment(100,-5);
- bookData.bottom = new FormAttachment(100, -5);
- book.setLayoutData(bookData);
-
- errorGroup = new ErrorGroup(book, SWT.NONE);
- operationGroup = new OperationGroup(book, SWT.NONE);
- attributeGroup = new AttributeGroup(book, SWT.NONE);
- }
-
- public void dispose() {
- }
-
- public Control getControl() {
- return main;
- }
-
- public void setActionBars(IActionBars actionBars) {
- }
-
- public void setFocus() {
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- Object obj = ((IStructuredSelection) selection)
- .getFirstElement();
- if (obj instanceof ContentWrapper)
- obj = ((ContentWrapper) obj).getElement();
-
- if (obj == null)
- return;
- setInputObject(obj);
- }
- }
-
- protected void setInputObject(Object obj) {
- if (obj instanceof JMXDomain) {
- showDomainComposite((JMXDomain) obj);
- } else if (obj instanceof JMXBean) {
- setBean((JMXBean) obj);
- } else if (obj instanceof JMXAttributesWrapper
- || obj instanceof WrappedMBeanOperationInfo) {
- setBean(getBeanFromInput(obj));
- setComboSelectionFromInput(obj);
- }
- }
-
- protected void setBean(JMXBean bean) {
- if (bean != null ) {
- boolean requiresLoading = bean.getOperations() == null && bean.getException() == null;
- boolean hasError = bean.getOperations() == null && bean.getException() != null;
- boolean currentBeanLoading = bean == this.bean && pulldown.getItems().length == 1 && pulldown.getItems()[0].equals(LOADING_STRING_ARRAY[0]);
- boolean finishedLoading = bean.getOperations() != null;
-
- this.bean = bean;
- if( requiresLoading ) {
- pulldown.setItems(LOADING_STRING_ARRAY);
- pulldown.select(0); // select Loading...
- loadChildrenRefreshProperties(bean);
- } else if( hasError ) {
- // some error
- showErrorComposite();
- } else if( finishedLoading ) {
- // finished loading
- operations = bean.getOperations();
- pulldown.setItems(pulldownItems());
- pulldown.select(0); // select Loading...
- }
- main.layout();
- }
- }
-
- protected JMXBean getBeanFromInput(Object obj) {
- return obj instanceof JMXAttributesWrapper ?
- ((JMXAttributesWrapper) obj).getBean() :
- ((WrappedMBeanOperationInfo) obj).getBean();
- }
-
- protected void setComboSelectionFromInput(Object obj) {
- int index = -1;
- if (obj instanceof WrappedMBeanOperationInfo)
- index = pulldown
- .indexOf(getStringForOperation(((WrappedMBeanOperationInfo) obj)));
- if (index == -1)
- index = 0;
- pulldown.select(index);
- }
-
- // get the list of combo items based on the bean
- // The list should be Two larger than the number of operations
- // ex: {Attributes..., ------, op1, op2, op3... etc}
- protected String[] pulldownItems() {
- WrappedMBeanOperationInfo[] ops = bean.getOperations();
- String[] vals = null;
- if (ops != null) {
- if( ops.length == 0 ) return new String[]{ATTRIBUTES_STRING};
- vals = new String[ops.length + 2];
- vals[0] = ATTRIBUTES_STRING;
- vals[1] = "---------------";
- for (int i = 0; i < ops.length; i++) {
- vals[i + 2] = getStringForOperation(ops[i]);
- }
- }
- return vals;
- }
-
- protected String getStringForOperation(WrappedMBeanOperationInfo op) {
- return op.getInfo().getReturnType() + " " + op.getInfo().getName();
- }
-
- protected void loadChildrenRefreshProperties(final Object bean) {
- new Thread() {
- public void run() {
- loadChildren(bean);
- Display.getDefault().asyncExec(new Runnable() { public void run() {
- setInputObject(bean);
- }});
- }
- }.start();
- }
-
- protected void showDomainComposite(JMXDomain domain) {
- // nothing
- }
- protected void showErrorComposite() {
- book.showPage(errorGroup);
- }
-
- protected void pulldownSelectionChanged() {
- if( pulldown.getSelectionIndex() != -1 ) {
- int index = pulldown.getSelectionIndex();
- if( index == 0 && pulldown.getItem(0).equals(ATTRIBUTES_STRING)) {
- book.showPage(attributeGroup);
- } else if( index != 1 && index <= operations.length) {
- book.showPage(operationGroup);
- }
- String selected = pulldown.getItem(pulldown.getSelectionIndex());
- System.out.println(selected);
- }
- }
-
- }
-
- protected static class ErrorGroup extends Composite {
- protected Group group;
- public ErrorGroup(Composite parent, int style) {
- super(parent, style);
- setLayout(new FillLayout());
- group = new Group(this, SWT.NONE);
- group.setText("Error");
- }
- }
-
- protected static class OperationGroup extends Composite {
- protected Group group;
- public OperationGroup(Composite parent, int style) {
- super(parent, style);
- setLayout(new FillLayout());
- group = new Group(this, SWT.NONE);
- group.setText("Operation");
- }
- }
-
- protected static class AttributeGroup extends Composite {
- protected Group group;
- public AttributeGroup(Composite parent, int style) {
- super(parent, style);
- setLayout(new FillLayout());
- group = new Group(this, SWT.NONE);
- group.setText("Attributes");
- }
- }
-
-}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/AttributeGroup.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/AttributeGroup.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/AttributeGroup.java 2007-09-19 02:32:12 UTC (rev 3701)
@@ -0,0 +1,300 @@
+package org.jboss.ide.eclipse.as.ui.views.server.providers.jmx;
+
+import javax.management.Attribute;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+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;
+import org.eclipse.swt.custom.TreeEditor;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXBean;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXRunnable;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXSafeRunner;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.WrappedMBeanAttributeInfo;
+import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
+
+public class AttributeGroup extends Composite {
+
+ protected Group group;
+ protected Tree tree;
+ protected TreeColumn nameColumn, typeColumn, accessColumn, valueColumn,
+ descriptionColumn;
+ protected TreeViewer treeViewer;
+ protected JMXPropertySheetPage page;
+
+ public AttributeGroup(Composite parent, int style, JMXPropertySheetPage page) {
+ super(parent, style);
+ this.page = page;
+ setLayout(new FillLayout());
+// group = new Group(this, SWT.NONE);
+// group.setText("Attributes");
+// group.setLayout(new FillLayout());
+
+ tree = new Tree(this, SWT.BORDER | SWT.FULL_SELECTION);
+
+ nameColumn = new TreeColumn(tree, SWT.NONE);
+ typeColumn = new TreeColumn(tree, SWT.NONE);
+ accessColumn = new TreeColumn(tree, SWT.NONE);
+ valueColumn = new TreeColumn(tree, SWT.NONE);
+ descriptionColumn = new TreeColumn(tree, SWT.NONE);
+
+ nameColumn.setWidth(100);
+ typeColumn.setWidth(150);
+ accessColumn.setWidth(50);
+ valueColumn.setWidth(200);
+ descriptionColumn.setWidth(300);
+
+ nameColumn.setText("Name");
+ typeColumn.setText("Type");
+ accessColumn.setText("Access");
+ valueColumn.setText("Value");
+ descriptionColumn.setText("Description");
+
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+
+ treeViewer = new TreeViewer(tree);
+ treeViewer.setContentProvider(new AttributeViewerContentProvider());
+ treeViewer.setLabelProvider(new AttributeViewerLabelProvider());
+
+ JMXAttributePropertySelListener selListener = new JMXAttributePropertySelListener();
+ tree.addListener(SWT.MouseDoubleClick, selListener);
+ }
+
+ public void setBean(JMXBean bean) {
+ treeViewer.setInput(bean);
+ }
+
+ protected class JMXAttributePropertySelListener implements Listener {
+ private final Color black;
+ private final TreeEditor editor;
+
+ public JMXAttributePropertySelListener() {
+ black = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
+ editor = new TreeEditor(tree);
+ }
+
+ public void handleEvent(Event event) {
+ TreeItem[] selectedItems = tree.getSelection();
+ if (selectedItems.length != 1)
+ return;
+ final TreeItem item = selectedItems[0];
+
+ if (!(item.getData() instanceof WrappedMBeanAttributeInfo))
+ return;
+ if (!((WrappedMBeanAttributeInfo) item.getData()).getInfo()
+ .isWritable())
+ return;
+
+ final WrappedMBeanAttributeInfo attInfo = (WrappedMBeanAttributeInfo) item
+ .getData();
+
+ final int column = 3;
+ boolean isCarbon = SWT.getPlatform().equals("carbon");
+ final Composite composite = new Composite(tree, SWT.NONE);
+ if (!isCarbon)
+ composite.setBackground(black);
+ final Text text = new Text(composite, SWT.NONE);
+ final int inset = isCarbon ? 0 : 1;
+ composite.addListener(SWT.Resize, new Listener() {
+ public void handleEvent(Event e) {
+ Rectangle rect = composite.getClientArea();
+ text.setBounds(rect.x + inset, rect.y + inset, rect.width
+ - inset * 2, rect.height - inset * 2);
+ }
+ });
+ Listener textListener = new Listener() {
+ public void handleEvent(final Event e) {
+ switch (e.type) {
+ case SWT.FocusOut:
+ composite.dispose();
+ break;
+ case SWT.Verify:
+ String newText = text.getText();
+ String leftText = newText.substring(0, e.start);
+ String rightText = newText.substring(e.end, newText
+ .length());
+ GC gc = new GC(text);
+ Point size = gc.textExtent(leftText + e.text
+ + rightText);
+ gc.dispose();
+ size = text.computeSize(size.x, SWT.DEFAULT);
+ editor.horizontalAlignment = SWT.LEFT;
+ Rectangle itemRect = item.getBounds(),
+ rect = tree.getClientArea();
+ editor.minimumWidth = Math.max(size.x, itemRect.width)
+ + inset * 2;
+ int left = itemRect.x,
+ right = rect.x + rect.width;
+ editor.minimumWidth = Math.min(editor.minimumWidth,
+ right - left);
+ editor.minimumHeight = size.y + inset * 2;
+ editor.setColumn(column);
+ editor.layout();
+ break;
+ case SWT.Traverse:
+ switch (e.detail) {
+ case SWT.TRAVERSE_RETURN:
+ saveAttributeChange(attInfo, text);
+ // FALL THROUGH
+ case SWT.TRAVERSE_ESCAPE:
+ composite.dispose();
+ e.doit = false;
+ }
+ break;
+ }
+ }
+ };
+ text.addListener(SWT.FocusOut, textListener);
+ text.addListener(SWT.Traverse, textListener);
+ text.addListener(SWT.Verify, textListener);
+ editor.setEditor(composite, item);
+ text.setText(item.getText(column));
+ text.selectAll();
+ text.setFocus();
+
+ }
+ }
+
+ protected void saveAttributeChange(final WrappedMBeanAttributeInfo attInfo, Text text) {
+ if (text.isDisposed())
+ return;
+ final String text2 = text.getText();
+ final Attribute att = createAttribute(attInfo, text2);
+ final Boolean[] errorBool = new Boolean[1];
+ if( att == null ) {
+ // throw up a message box and say no can do, for now
+ MessageBox messageBox = new MessageBox (new Shell(), SWT.OK);
+ messageBox.setText ("Cannot update bean");
+ messageBox.setMessage ("Bean update cannot proceed. Plug-in cannot convert " + text2 + " into " + attInfo.getInfo().getType());
+ messageBox.open();
+ return;
+ }
+
+ final JMXRunnable run = new JMXRunnable() {
+ public void run(MBeanServerConnection connection) {
+ try {
+ connection.setAttribute(new ObjectName(
+ attInfo.getBean().getName()), att);
+ } catch (final Exception e) {
+ Display.getDefault().asyncExec(new Runnable() { public void run() {
+ IStatus status = new Status(IStatus.ERROR, JBossServerUIPlugin.PLUGIN_ID, e.getMessage(), e);
+ JBossServerUIPlugin.getDefault().getLog().log(status);
+ errorBool[0] = new Boolean(true);
+ }});
+ }
+ }
+ };
+
+ new Thread() { public void run() {
+ JMXSafeRunner.run(attInfo.getBean().getServer(), run);
+ if( errorBool[0] == null ) {
+ page.provider.loadChildren(attInfo.getBean());
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ page.setInputObject(attInfo.getBean());
+ }
+ });
+ }
+ }}.start();
+ }
+
+ protected Attribute createAttribute(WrappedMBeanAttributeInfo attInfo, String text) {
+ String type = attInfo.getInfo().getType();
+ Object val = null;
+
+ try {
+ if( type.equals("java.lang.String")) val = text;
+ else if( type.equals("boolean")) val = new Boolean(text);
+ else if( type.equals("int")) val = new Integer(text);
+ else if( type.equals("long")) val = new Long(text);
+ } catch( Exception e ) {}
+
+ return val == null ? null :
+ new Attribute(attInfo.getInfo().getName(), val);
+ }
+
+ protected class AttributeViewerContentProvider implements
+ ITreeContentProvider {
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof JMXBean)
+ return ((JMXBean) parentElement).getAttributes();
+ return new Object[] {};
+ }
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof JMXBean)
+ return ((JMXBean) inputElement).getAttributes();
+ return new Object[] {};
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ protected class AttributeViewerLabelProvider extends LabelProvider
+ implements ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof WrappedMBeanAttributeInfo) {
+ WrappedMBeanAttributeInfo element2 = (WrappedMBeanAttributeInfo) element;
+ if (columnIndex == 0)
+ return element2.getInfo().getName();
+ if (columnIndex == 1)
+ return element2.getInfo().getType();
+ if (columnIndex == 3)
+ return (element2.getValue() != null ? element2.getValue()
+ .toString() : "");
+ if (columnIndex == 4)
+ return element2.getInfo().getDescription();
+ if (columnIndex == 2) {
+ String ret = element2.getInfo().isReadable() ? "R" : "";
+ ret += element2.getInfo().isWritable() ? "W" : "";
+ return ret;
+ }
+
+ }
+ return null;
+ }
+
+ }
+
+}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXLabelProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXLabelProvider.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXLabelProvider.java 2007-09-19 02:32:12 UTC (rev 3701)
@@ -0,0 +1,56 @@
+package org.jboss.ide.eclipse.as.ui.views.server.providers.jmx;
+
+import org.eclipse.jdt.internal.ui.JavaPluginImages;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXAttributesWrapper;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXBean;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXDomain;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXException;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.WrappedMBeanOperationInfo;
+
+class JMXLabelProvider extends LabelProvider {
+ public String getText(Object obj) {
+ if (obj instanceof JMXDomain)
+ return ((JMXDomain) obj).getName();
+ if (obj instanceof JMXBean) {
+ return ((JMXBean) obj).getName().substring(
+ ((JMXBean) obj).getDomain().length() + 1);
+ }
+ if (obj instanceof WrappedMBeanOperationInfo) {
+ return ((WrappedMBeanOperationInfo) obj).getInfo().getName();
+ }
+
+ if (obj instanceof JMXException) {
+ String message = "";
+ message += ((JMXException) obj).getException().getClass()
+ .getName()
+ + ": ";
+ message += ((JMXException) obj).getException().getMessage();
+ return message;
+ }
+ if (obj instanceof JMXAttributesWrapper) {
+ return "Attributes";
+ }
+ if (obj == JMXViewProvider.LOADING)
+ return "loading...";
+ return "not sure yet: " + obj.getClass().getName();
+ }
+
+ public Image getImage(Object obj) {
+ if (obj instanceof JMXException) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(
+ ISharedImages.IMG_OBJS_ERROR_TSK);
+ }
+ if (obj instanceof WrappedMBeanOperationInfo)
+ return JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC);
+ if (obj instanceof JMXAttributesWrapper) {
+ return JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
+ }
+
+ return null;
+ }
+
+}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXPropertySheetPage.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXPropertySheetPage.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXPropertySheetPage.java 2007-09-19 02:32:12 UTC (rev 3701)
@@ -0,0 +1,247 @@
+package org.jboss.ide.eclipse.as.ui.views.server.providers.jmx;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXAttributesWrapper;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXBean;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXDomain;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.WrappedMBeanOperationInfo;
+import org.jboss.ide.eclipse.as.ui.views.server.ExtensionTableViewer.ContentWrapper;
+import org.jboss.ide.eclipse.as.ui.views.server.providers.jmx.JMXViewProvider.ErrorGroup;
+import org.jboss.ide.eclipse.as.ui.views.server.providers.jmx.JMXViewProvider.OperationGroup;
+
+public class JMXPropertySheetPage implements IPropertySheetPage {
+
+ // data
+ protected JMXViewProvider provider;
+ protected JMXBean bean;
+ protected WrappedMBeanOperationInfo[] operations;
+
+ // ui pieces
+ protected Composite main;
+ protected Combo pulldown;
+ protected Label beanLabel;
+ protected PageBook book;
+ protected ErrorGroup errorGroup;
+ protected OperationGroup operationGroup;
+ protected AttributeGroup attributeGroup;
+
+ public JMXPropertySheetPage(JMXViewProvider provider) {
+ this.provider = provider;
+ }
+
+ public void createControl(Composite parent) {
+ main = new Composite(parent, SWT.NONE);
+ main.setLayout(new FormLayout());
+
+ pulldown = new Combo(main, SWT.READ_ONLY);
+ FormData pulldownData = new FormData();
+ pulldownData.left = new FormAttachment(0, 10);
+ pulldownData.right = new FormAttachment(0,400);
+ pulldownData.top = new FormAttachment(0, 10);
+ pulldown.setLayoutData(pulldownData);
+
+ beanLabel = new Label(main, SWT.NONE);
+ FormData beanLabelData = new FormData();
+ beanLabelData.left = new FormAttachment(0, 10);
+ beanLabelData.top = new FormAttachment(pulldown, 3);
+ beanLabel.setLayoutData(beanLabelData);
+
+ // small font size
+ Font initialFont = beanLabel.getFont();
+ FontData[] fontData = initialFont.getFontData();
+ for (int i = 0; i < fontData.length; i++) {
+ fontData[i].setHeight(7);
+ }
+ Font newFont = new Font(Display.getDefault(), fontData);
+ beanLabel.setFont(newFont);
+
+ Listener listener = new Listener() {
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.Selection:
+ case SWT.Modify:
+ pulldownSelectionChanged();
+ break;
+ }
+ }
+ };
+ pulldown.addListener(SWT.Selection, listener);
+ pulldown.addListener(SWT.Modify, listener);
+
+ book = new PageBook(main, SWT.NONE);
+ FormData bookData = new FormData();
+ bookData.top = new FormAttachment(beanLabel, 5);
+ bookData.left = new FormAttachment(0, 5);
+ bookData.right = new FormAttachment(100, -5);
+ bookData.bottom = new FormAttachment(100, -5);
+ book.setLayoutData(bookData);
+
+ errorGroup = new ErrorGroup(book, SWT.NONE);
+ operationGroup = new OperationGroup(book, SWT.NONE);
+ attributeGroup = new AttributeGroup(book, SWT.NONE, this);
+ }
+
+ public void dispose() {
+ }
+
+ public Control getControl() {
+ return main;
+ }
+
+ public void setActionBars(IActionBars actionBars) {
+ }
+
+ public void setFocus() {
+ }
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ Object obj = ((IStructuredSelection) selection).getFirstElement();
+ if (obj instanceof ContentWrapper)
+ obj = ((ContentWrapper) obj).getElement();
+
+ if (obj == null)
+ return;
+ setInputObject(obj);
+ }
+ }
+
+ protected void setInputObject(Object obj) {
+ if (obj instanceof JMXDomain) {
+ showDomainComposite((JMXDomain) obj);
+ } else if (obj instanceof JMXBean) {
+ setBean((JMXBean) obj);
+ } else if (obj instanceof JMXAttributesWrapper
+ || obj instanceof WrappedMBeanOperationInfo) {
+ setBean(getBeanFromInput(obj));
+ setComboSelectionFromInput(obj);
+ }
+ }
+
+ protected void setBean(JMXBean bean) {
+ if (bean != null) {
+ boolean requiresLoading = bean.getOperations() == null
+ && bean.getException() == null;
+ boolean hasError = bean.getOperations() == null
+ && bean.getException() != null;
+ boolean currentBeanLoading = bean == this.bean
+ && pulldown.getItems().length == 1
+ && pulldown.getItems()[0].equals(JMXViewProvider.LOADING_STRING_ARRAY[0]);
+ boolean finishedLoading = bean.getOperations() != null;
+
+ this.bean = bean;
+ beanLabel.setText("for MBean " + bean.getName());
+ if (requiresLoading) {
+ pulldown.setItems(JMXViewProvider.LOADING_STRING_ARRAY);
+ pulldown.select(0); // select Loading...
+ loadChildrenRefreshProperties(bean);
+ return; // do not re-layout during loading
+ } else if (hasError) {
+ // some error
+ showErrorComposite();
+ } else if (finishedLoading) {
+ // finished loading
+ operations = bean.getOperations();
+ pulldown.setItems(pulldownItems());
+ pulldown.select(0); // select Loading...
+ beanLabel.setText("for MBean " + bean.getName() + " ("
+ + operations.length + " operations, "
+ + bean.getAttributes().length + " attributes)");
+ }
+ main.layout();
+ }
+ }
+
+ protected JMXBean getBeanFromInput(Object obj) {
+ return obj instanceof JMXAttributesWrapper ? ((JMXAttributesWrapper) obj)
+ .getBean() : ((WrappedMBeanOperationInfo) obj).getBean();
+ }
+
+ protected void setComboSelectionFromInput(Object obj) {
+ int index = -1;
+ if (obj instanceof WrappedMBeanOperationInfo)
+ index = pulldown
+ .indexOf(getStringForOperation(((WrappedMBeanOperationInfo) obj)));
+ if (index == -1)
+ index = 0;
+ pulldown.select(index);
+ }
+
+ // get the list of combo items based on the bean
+ // The list should be Two larger than the number of operations
+ // ex: {Attributes..., ------, op1, op2, op3... etc}
+ protected String[] pulldownItems() {
+ WrappedMBeanOperationInfo[] ops = bean.getOperations();
+ String[] vals = null;
+ if (ops != null) {
+ if (ops.length == 0)
+ return new String[] { JMXViewProvider.ATTRIBUTES_STRING };
+ vals = new String[ops.length + 2];
+ vals[0] = JMXViewProvider.ATTRIBUTES_STRING;
+ vals[1] = "---------------";
+ for (int i = 0; i < ops.length; i++) {
+ vals[i + 2] = getStringForOperation(ops[i]);
+ }
+ }
+ return vals;
+ }
+
+ protected String getStringForOperation(WrappedMBeanOperationInfo op) {
+ return op.getInfo().getReturnType() + " " + op.getInfo().getName();
+ }
+
+ public void loadChildrenRefreshProperties(final Object bean) {
+ new Thread() {
+ public void run() {
+ provider.loadChildren(bean);
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ setInputObject(bean);
+ }
+ });
+ }
+ }.start();
+ }
+
+ protected void showDomainComposite(JMXDomain domain) {
+ // nothing
+ }
+
+ protected void showErrorComposite() {
+ book.showPage(errorGroup);
+ }
+
+ protected void pulldownSelectionChanged() {
+ if (pulldown.getSelectionIndex() != -1) {
+ int index = pulldown.getSelectionIndex();
+ if (index == 0 && pulldown.getItem(0).equals(JMXViewProvider.ATTRIBUTES_STRING)) {
+ attributeGroup.setBean(bean);
+ book.showPage(attributeGroup);
+ } else if (index >= 2 && operations != null
+ && index <= operations.length + 1) {
+ String selected = pulldown
+ .getItem(pulldown.getSelectionIndex());
+ book.showPage(operationGroup);
+ }
+ }
+ }
+
+}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXTreeContentProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXTreeContentProvider.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXTreeContentProvider.java 2007-09-19 02:32:12 UTC (rev 3701)
@@ -0,0 +1,121 @@
+package org.jboss.ide.eclipse.as.ui.views.server.providers.jmx;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXAttributesWrapper;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXBean;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXDomain;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXException;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.WrappedMBeanOperationInfo;
+import org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerViewProvider;
+
+public class JMXTreeContentProvider implements ITreeContentProvider {
+
+ protected JMXViewProvider provider;
+ public JMXTreeContentProvider(JMXViewProvider provider) {
+ this.provider = provider;
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof ServerViewProvider) {
+ if (provider.getServer() == null)
+ return new Object[] {};
+ if (provider.getServer().getServerState() != IServer.STATE_STARTED) {
+ JMXModel.getDefault().clearModel(provider.getServer());
+ return new Object[] {};
+ }
+ JMXDomain[] domains = JMXModel.getDefault().getModel(provider.getServer()).getDomains();
+ if (domains == null
+ && JMXModel.getDefault().getModel(provider.getServer()).getException() == null) {
+ loadChildrenRefreshViewer(parentElement);
+ return new Object[] { JMXViewProvider.LOADING };
+ } else if (domains == null
+ && JMXModel.getDefault().getModel(provider.getServer()).getException() != null) {
+ return new Object[] { JMXModel.getDefault().getModel(provider.getServer()).getException() };
+ }
+ return domains;
+ }
+ if (parentElement instanceof JMXDomain) {
+ JMXBean[] beans = ((JMXDomain) parentElement).getBeans();
+ if (beans == null
+ && ((JMXDomain) parentElement).getException() == null) {
+ loadChildrenRefreshViewer(parentElement);
+ return new Object[] { JMXViewProvider.LOADING };
+ } else if (beans == null
+ && ((JMXDomain) parentElement).getException() != null) {
+ return new Object[] { ((JMXDomain) parentElement)
+ .getException() };
+ }
+ return beans;
+ }
+ if (parentElement instanceof JMXBean) {
+ WrappedMBeanOperationInfo[] operations = ((JMXBean) parentElement)
+ .getOperations();
+ if (operations == null
+ && ((JMXBean) parentElement).getException() == null) {
+ loadChildrenRefreshViewer(parentElement);
+ return new Object[] { JMXViewProvider.LOADING };
+ } else if (operations == null
+ && ((JMXBean) parentElement).getException() != null) {
+ return new Object[] { ((JMXBean) parentElement)
+ .getException() };
+ }
+ // add the Attributes element
+ ArrayList<Object> list = new ArrayList<Object>();
+ list.add(new JMXAttributesWrapper((JMXBean) parentElement));
+ list.addAll(Arrays.asList(operations));
+ return (Object[]) list.toArray(new Object[list.size()]);
+ }
+ return new Object[0];
+ }
+
+ public Object getParent(Object element) {
+ return null; // unused
+ }
+
+ public boolean hasChildren(Object element) {
+ if (element instanceof ServerViewProvider) {
+ if (provider.getServer() == null ||
+ provider.getServer().getServerState() != IServer.STATE_STARTED) {
+ return false;
+ }
+ return true;
+ }
+ if (element instanceof JMXException)
+ return false;
+ if (element instanceof WrappedMBeanOperationInfo)
+ return false;
+ if (element instanceof JMXAttributesWrapper)
+ return false;
+ return true; // always true?
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return null; // unused here
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if (oldInput != newInput) {
+ provider.setServer((IServer) newInput);
+ }
+ }
+
+ protected void loadChildrenRefreshViewer(final Object parent) {
+ new Thread() {
+ public void run() {
+ provider.loadChildren(parent);
+ provider.refreshViewerAsync(parent);
+ }
+ }.start();
+ }
+
+
+}
Copied: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXViewProvider.java (from rev 3672, trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/JMXViewProvider.java)
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXViewProvider.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXViewProvider.java 2007-09-19 02:32:12 UTC (rev 3701)
@@ -0,0 +1,205 @@
+package org.jboss.ide.eclipse.as.ui.views.server.providers.jmx;
+
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerLifecycleListener;
+import org.eclipse.wst.server.core.IServerListener;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerEvent;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXClassLoaderRepository;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXBean;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXDomain;
+import org.jboss.ide.eclipse.as.ui.views.server.JBossServerView;
+import org.jboss.ide.eclipse.as.ui.views.server.ExtensionTableViewer.ContentWrapper;
+import org.jboss.ide.eclipse.as.ui.views.server.extensions.JBossServerViewExtension;
+import org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerViewProvider;
+import org.jboss.ide.eclipse.as.ui.views.server.util.ViewUtilityMethods;
+
+public class JMXViewProvider extends JBossServerViewExtension {
+ public static final Object LOADING = new Object();
+ public static final String[] LOADING_STRING_ARRAY = new String[] { "Loading..." };
+ public static final String ATTRIBUTES_STRING = "Attributes...";
+
+ public static final Object CLASSLOADING_TOKEN = new Object();
+
+ protected JMXPropertySheetPage propertyPage;
+ protected JMXServerLifecycleListener lcListener;
+ protected JMXServerListener serverListener;
+ protected ISelectionChangedListener jbossServerViewSelectionListener;
+ protected JMXTreeContentProvider contentProvider;
+ protected JMXLabelProvider labelProvider;
+ protected IServer server;
+
+ public JMXViewProvider() {
+ }
+
+ public void setServer(IServer server) {
+ this.server = server;
+ }
+
+ public IServer getServer() {
+ return this.server;
+ }
+
+ public void enable() {
+ addListeners();
+ }
+ public void disable() {
+ removeListeners();
+ }
+
+
+ protected void addListeners() {
+ jbossServerViewSelectionListener = new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ Object o = JBossServerView.getDefault()
+ .getExtensionFrame().getViewer()
+ .getSelectedElement();
+ if (o instanceof JMXBean) {
+ Display.getDefault().asyncExec(new Runnable() { public void run() {
+ ViewUtilityMethods.activatePropertiesView(null);
+ }});
+ }
+ }
+ };
+
+ JBossServerView.addExtensionFrameListener(jbossServerViewSelectionListener);
+
+ // make sure we know about server events
+ serverListener = new JMXServerListener();
+ lcListener = new JMXServerLifecycleListener();
+ ServerCore.addServerLifecycleListener(lcListener);
+ IServer[] servers = ServerCore.getServers();
+ for (int i = 0; i < servers.length; i++) {
+ servers[i].addServerListener(serverListener);
+ if( servers[i].getServerState() == IServer.STATE_STARTED )
+ JMXClassLoaderRepository.getDefault().addConcerned(
+ servers[i], CLASSLOADING_TOKEN);
+ }
+ }
+
+ protected void removeListeners() {
+ ServerCore.removeServerLifecycleListener(lcListener);
+ IServer[] servers = ServerCore.getServers();
+ for (int i = 0; i < servers.length; i++) {
+ servers[i].removeServerListener(serverListener);
+ JMXClassLoaderRepository.getDefault().removeConcerned(
+ servers[i], CLASSLOADING_TOKEN);
+ }
+ JBossServerView.removeExtensionFrameListener(jbossServerViewSelectionListener);
+ }
+
+ protected class JMXServerLifecycleListener implements
+ IServerLifecycleListener {
+ public void serverAdded(IServer server) {
+ server.addServerListener(serverListener);
+ }
+
+ public void serverChanged(IServer server) {
+ }
+
+ public void serverRemoved(IServer server) {
+ server.removeServerListener(serverListener);
+ JMXClassLoaderRepository.getDefault()
+ .removeConcerned(server, JMXModel.getDefault());
+ }
+ }
+
+ protected class JMXServerListener implements IServerListener {
+ public void serverChanged(ServerEvent event) {
+ if ((event.getKind() & ServerEvent.SERVER_CHANGE) != 0) {
+ if ((event.getKind() & ServerEvent.STATE_CHANGE) != 0) {
+ if (event.getState() == IServer.STATE_STARTED) {
+ JMXClassLoaderRepository.getDefault().addConcerned(
+ event.getServer(), CLASSLOADING_TOKEN);
+ } else {
+ JMXClassLoaderRepository.getDefault().removeConcerned(
+ event.getServer(), CLASSLOADING_TOKEN);
+ }
+ }
+ }
+ }
+ }
+
+ public IPropertySheetPage getPropertySheetPage() {
+ if (propertyPage == null) {
+ propertyPage = new JMXPropertySheetPage(this);
+ }
+ return propertyPage;
+ }
+
+ public ITreeContentProvider getContentProvider() {
+ if (contentProvider == null)
+ contentProvider = new JMXTreeContentProvider(this);
+ return contentProvider;
+ }
+
+ public LabelProvider getLabelProvider() {
+ if (labelProvider == null)
+ labelProvider = new JMXLabelProvider();
+ return labelProvider;
+ }
+
+
+ protected void loadChildren(Object parent) {
+ if (parent instanceof ServerViewProvider)
+ JMXModel.getDefault().getModel(server).loadDomains();
+ else if (parent instanceof JMXDomain)
+ ((JMXDomain) parent).loadBeans();
+ else if (parent instanceof JMXBean)
+ ((JMXBean) parent).loadInfo();
+ }
+
+ public void refreshViewerAsync(final Object parent) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ refreshViewer(parent);
+ }
+ });
+ }
+
+ public void refreshModel(Object object) {
+ if( object instanceof ContentWrapper )
+ object = ((ContentWrapper)object).getElement();
+ if (object instanceof ServerViewProvider) {
+ JMXModel.getDefault().clearModel(server);
+ } else if (object instanceof JMXDomain) {
+ ((JMXDomain) object).resetChildren();
+ } else if (object instanceof JMXBean) {
+ ((JMXBean) object).resetChildren();
+ }
+ }
+
+ protected static class ErrorGroup extends Composite {
+ protected Group group;
+ public ErrorGroup(Composite parent, int style) {
+ super(parent, style);
+ setLayout(new FillLayout());
+ group = new Group(this, SWT.NONE);
+ group.setText("Error");
+ }
+ }
+
+ protected static class OperationGroup extends Composite {
+ protected Group group;
+ public OperationGroup(Composite parent, int style) {
+ super(parent, style);
+ setLayout(new FillLayout());
+ group = new Group(this, SWT.NONE);
+ group.setText("Operation");
+ }
+ }
+
+
+}
17 years, 3 months
JBoss Tools SVN: r3700 - trunk/common/plugins/org.jboss.tools.common/META-INF.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-09-18 16:22:36 -0400 (Tue, 18 Sep 2007)
New Revision: 3700
Modified:
trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF
Log:
http://jira.jboss.org/jira/browse/JBIDE-848
Modified: trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF 2007-09-18 19:44:57 UTC (rev 3699)
+++ trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF 2007-09-18 20:22:36 UTC (rev 3700)
@@ -134,6 +134,7 @@
org.eclipse.jface,
org.eclipse.core.resources,
org.eclipse.ui,
+ org.eclipse.ui.ide,
org.eclipse.wst.common.uriresolver;visibility:=reexport,
org.eclipse.core.net
Bundle-Version: 2.0.0
17 years, 3 months
JBoss Tools SVN: r3699 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-09-18 15:44:57 -0400 (Tue, 18 Sep 2007)
New Revision: 3699
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-848
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-09-18 19:44:52 UTC (rev 3698)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-09-18 19:44:57 UTC (rev 3699)
@@ -12,6 +12,7 @@
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import org.apache.tools.ant.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection;
@@ -47,6 +48,7 @@
import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.util.ResourcesUtils;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
@@ -286,9 +288,7 @@
hibernateDialectFilterSet.addFilterSet(projectFilterSet);
hibernateDialectFilterSet.addFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
- final CreateTestProject createTest = new CreateTestProject(model,project,selectedRuntime);
- createTest.setUser(true);
- createTest.setRule(ResourcesPlugin.getWorkspace().getRoot());
+ createTestProject(model,project,selectedRuntime);
// ********************************************************************************************
// Handle WAR/EAR configurations
@@ -403,8 +403,6 @@
create.setRule(ResourcesPlugin.getWorkspace().getRoot());
create.schedule();
- createTest.schedule();
-
} else {
model.setProperty(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT, project.getName()+"-ejb");
model.setProperty(ISeamFacetDataModelProperties.SEAM_EAR_PROJECT, project.getName()+"-ear");
@@ -418,12 +416,17 @@
} catch (IOException e) {
SeamCorePlugin.getPluginLog().logError(e);
}
- Job create = new Job("Creating EAR and EJB modules") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
-
- IProject ear = WtpUtils.createEclipseProject(model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME)+"-ear", monitor);
- IProject ejb = WtpUtils.createEclipseProject(model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME)+"-ejb", monitor);
+// Job create = new Job("Creating EAR and EJB modules") {
+// @Override
+// protected IStatus run(IProgressMonitor monitor) {
+//
+// IProject ear = WtpUtils.createEclipseProject(model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME)+"-ear", monitor);
+// IProject ejb = WtpUtils.createEclipseProject(model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME)+"-ejb", monitor);
+
+ File ear = new File(project.getLocation().removeLastSegments(1).toFile(),model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME)+"-ear");
+ File ejb = new File(project.getLocation().removeLastSegments(1).toFile(),model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME)+"-ejb");
+ ear.mkdir();
+ ejb.mkdir();
try {
FilterSet filterSet = new FilterSet();
filterSet.addFilter("projectName", project.getName());
@@ -438,7 +441,7 @@
AntCopyUtils.copyFilesAndFolders(
new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"ejb"),
- ejb.getLocation().toFile(), new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
+ ejb, new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
new FilterSetCollection(filterSet), true);
// *******************************************************************************************
@@ -446,30 +449,30 @@
// *******************************************************************************************
AntCopyUtils.copyFileToFile(
new File(seamGenHomeFolder,"src/Authenticator.java"),
- new File(ejb.getLocation().toFile(),"ejbModule/" + model.getProperty(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME).toString().replace('.', '/')+"/"+"Authenticator.java"),
+ new File(ejb,"ejbModule/" + model.getProperty(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME).toString().replace('.', '/')+"/"+"Authenticator.java"),
new FilterSetCollection(filtersFilterSet), true);
AntCopyUtils.copyFileToFile(
persistenceFile,
- new File(ejb.getLocation().toFile(),"ejbModule/META-INF/persistence.xml"),
+ new File(ejb,"ejbModule/META-INF/persistence.xml"),
viewFilterSetCollection, true);
// ********************************************************************************************
// Copy seam project indicator
// ********************************************************************************************
- AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,"seam.properties"), new File(ejb.getLocation().toFile(),"ejbModule/"), true);
+ AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,"seam.properties"), new File(ejb,"ejbModule/"), true);
AntCopyUtils.copyFileToFile(
dataSourceDsFile,
- new File(ejb.getLocation().toFile(),"ejbModule/"+project.getName()+"-ds.xml"),
+ new File(ejb,"ejbModule/"+project.getName()+"-ds.xml"),
viewFilterSetCollection, true);
AntCopyUtils.copyFileToFolder(
new File(seamGenResFolder,"META-INF/ejb-jar.xml"),
- new File(ejb.getLocation().toFile(),"ejbModule/META-INF/"),
+ new File(ejb,"ejbModule/META-INF/"),
viewFilterSetCollection, true);
AntCopyUtils.copyFileToFolder(
hibernateConsolePref,
- new File(ejb.getLocation().toFile(),".settings"),
+ new File(ejb,".settings"),
new FilterSetCollection(projectFilterSet), true);
FilterSet ejbFilterSet = new FilterSet();
@@ -477,15 +480,15 @@
AntCopyUtils.copyFileToFile(
hibernateConsoleLaunchFile,
- new File(ejb.getLocation().toFile(),ejb.getName()+".launch"),
+ new File(ejb,ejb.getName()+".launch"),
new FilterSetCollection(ejbFilterSet), true);
AntCopyUtils.copyFileToFolder(
hibernateConsolePropsFile,
- ejb.getLocation().toFile(),
+ ejb,
hibernateDialectFilterSet, true);
- File earContentsFolder = new File(ear.getLocation().toFile(),"EarContent");
+ File earContentsFolder = new File(ear,"EarContent");
File earContentsMetaInfFolder = new File(earContentsFolder,"META-INF");
AntCopyUtils.copyFilesAndFolders(
@@ -497,7 +500,7 @@
// Copy configuration files from template
AntCopyUtils.copyFilesAndFolders(
new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"ear"),
- ear.getLocation().toFile(), new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
+ ear, new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
new FilterSetCollection(filterSet), true);
// Fill ear contents
@@ -512,22 +515,7 @@
AntCopyUtils.copyFiles((String[])model.getProperty(ISeamFacetDataModelProperties.JDBC_DRIVER_JAR_PATH), earContentsFolder);
} catch (IOException e) {
SeamCorePlugin.getPluginLog().logError(e);
- } finally {
- try {
- ejb.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- ear.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- // EclipseResourceUtil.addNatureToProject(ejb, ISeamProject.NATURE_ID);
- } catch(CoreException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- }
}
- createTest.run(monitor);
- return Status.OK_STATUS;
- }
- };
- create.setUser(true);
- create.setRule(ResourcesPlugin.getWorkspace().getRoot());
- create.schedule();
}
ClasspathHelper.addClasspathEntries(project, fv);
@@ -568,41 +556,33 @@
} catch (BackingStoreException e) {
SeamCorePlugin.getPluginLog().logError(e);
}
-
- EclipseResourceUtil.addNatureToProject(project, ISeamProject.NATURE_ID);
- project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ try {
+ EclipseResourceUtil.addNatureToProject(project, ISeamProject.NATURE_ID);
+ project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ if(!isWarConfiguration(model)) {
+ ResourcesUtils.importProject(project.getLocation().removeLastSegments(1).toFile().getAbsoluteFile()+"/"+project.getName()+"-ejb", monitor);
+ ResourcesUtils.importProject(project.getLocation().removeLastSegments(1).toFile().getAbsoluteFile()+"/"+project.getName()+"-ear", monitor);
+ }
+ ResourcesUtils.importProject(project.getLocation().removeLastSegments(1).toFile().getAbsoluteFile()+"/"+project.getName()+"-test", monitor);
+
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ } catch (InvocationTargetException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ } catch (InterruptedException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+
}
public static boolean isWarConfiguration(IDataModel model) {
return "war".equals(model.getProperty(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS));
}
- public class CreateTestProject extends Job {
-
- IDataModel model = null;
-
- IProject seamWebProject = null;
-
- SeamRuntime seamRuntime = null;
-
- /**
- * @param name
- */
- public CreateTestProject(IDataModel model, IProject seamWebProject, SeamRuntime seamRuntime) {
- super("Create Test project");
- this.model = model;
- this.seamWebProject = seamWebProject;
- this.seamRuntime = seamRuntime;
- }
-
- /**
- * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public IStatus run(IProgressMonitor monitor) {
+ void createTestProject(IDataModel model, IProject seamWebProject, SeamRuntime seamRuntime) {
String projectName = model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME).toString();
- IProject test = WtpUtils.createEclipseProject(projectName+"-test", monitor);
- File testProjectDir = test.getLocation().toFile();
+ File testProjectDir = new File(seamWebProject.getLocation().removeLastSegments(1).toFile(),projectName+"-test");
+ testProjectDir.mkdir();
File seamProjectDir = seamWebProject.getLocation().toFile();
File testLibDir = new File(testProjectDir,"lib");
File embededEjbDir = new File(testProjectDir,"embedded-ejb");
@@ -627,7 +607,7 @@
testTemplateDir = new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"test");
} catch (IOException e) {
SeamCorePlugin.getPluginLog().logError(e);
- return new Status(IStatus.ERROR,SeamCorePlugin.PLUGIN_ID,e.getMessage()+"");
+ return;
}
AntCopyUtils.FileSet excludeCvsSvn
= new AntCopyUtils.FileSet(CVS_SVN).dir(testTemplateDir);
@@ -649,14 +629,7 @@
new File(seamRuntime.getHomeDir(),"lib"),
testLibDir,
new AntCopyUtils.FileSetFileFilter(includeLibs));
- try {
- test.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- } catch (CoreException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- }
- return Status.OK_STATUS;
}
- }
/* (non-Javadoc)
* @see org.eclipse.wst.common.project.facet.core.IActionConfigFactory#create()
17 years, 3 months
JBoss Tools SVN: r3698 - trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-09-18 15:44:52 -0400 (Tue, 18 Sep 2007)
New Revision: 3698
Added:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/ResourcesUtils.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/WorkbenchUtils.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-848
Copied: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/ResourcesUtils.java (from rev 3673, trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ResourcesUtils.java)
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/ResourcesUtils.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/ResourcesUtils.java 2007-09-18 19:44:52 UTC (rev 3698)
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author eskimo
+ *
+ */
+public class ResourcesUtils {
+
+ public static IProject importProject(Bundle bundle, String templLocation,
+ IProgressMonitor monitor) throws IOException, CoreException,
+ InvocationTargetException, InterruptedException {
+
+ String tplPrjLcStr;
+ tplPrjLcStr = FileLocator.resolve(bundle.getEntry(templLocation))
+ .getFile();
+
+ return importProject(tplPrjLcStr, monitor);
+ }
+
+ public static IProject importProject(String location,
+ IProgressMonitor monitor) throws CoreException, IOException,
+ InvocationTargetException, InterruptedException {
+ IProject importedPrj = createEclipseProjectDromDescriptor(location,
+ monitor);
+ ImportOperation op = new ImportOperation(importedPrj.getFullPath(),
+ new File(location), FileSystemStructureProvider.INSTANCE,
+ new IOverwriteQuery() {
+ public String queryOverwrite(String pathString) {
+ return IOverwriteQuery.ALL;
+ }
+ }, Arrays.asList(new File(location).listFiles()));
+
+ op.setCreateContainerStructure(false);
+ op.run(monitor);
+ return importedPrj;
+ }
+
+ public static IProject createEclipseProject(String projectName,
+ IProgressMonitor monitor) throws CoreException {
+
+ IProject newProjectHandle = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(projectName);
+
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ final IProjectDescription description = workspace
+ .newProjectDescription(projectName);
+ newProjectHandle.create(description, new NullProgressMonitor());
+ newProjectHandle.open(monitor);
+ return newProjectHandle;
+ }
+
+ public static IProject createEclipseProjectDromDescriptor(
+ String templateLocation, IProgressMonitor monitor)
+ throws CoreException, IOException {
+
+ IPath tplPrjDescr = new Path(templateLocation)
+ .append(IProjectDescription.DESCRIPTION_FILE_NAME);
+ IProjectDescription descr = ResourcesPlugin.getWorkspace()
+ .loadProjectDescription(tplPrjDescr);
+ descr.setLocation(null);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ descr.getName());
+ project.create(descr, monitor);
+ project.open(IResource.BACKGROUND_REFRESH, monitor);
+
+ return project;
+ }
+}
Copied: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/WorkbenchUtils.java (from rev 3673, trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java)
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/WorkbenchUtils.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/WorkbenchUtils.java 2007-09-18 19:44:52 UTC (rev 3698)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.common.util;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.wizards.IWizardDescriptor;
+import org.jboss.tools.common.CommonPlugin;
+
+/**
+ * @author eskimo
+ *
+ */
+public class WorkbenchUtils {
+
+ static public IWizard findWizardByDefId(String definitionId) {
+ IWizardDescriptor aWizardDescr =
+ getWorkbench().getNewWizardRegistry()
+ .findWizard(definitionId);
+ IWorkbenchWizard aWizard=null;
+ try {
+ aWizard = aWizardDescr.createWizard();
+ } catch (CoreException e) {
+ CommonPlugin.getPluginLog().logError("Cannot create IWorkbenchWizard instance",e);
+ }
+ return aWizard;
+ }
+
+ public static IWorkbench getWorkbench() {
+ return PlatformUI.getWorkbench();
+ }
+
+ /**
+ * @return
+ */
+ public static IWorkbenchPage getWorkbenchActivePage() {
+ // TODO Auto-generated method stub
+ return getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ }
+}
17 years, 3 months
JBoss Tools SVN: r3697 - in branches/jbosstools_xulrunner/vpe/plugins: org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2007-09-18 14:03:58 -0400 (Tue, 18 Sep 2007)
New Revision: 3697
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
Log:
code adjustment,eclipse global commands(CTRL+N for example) was notified about changes
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-09-18 17:53:00 UTC (rev 3696)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-09-18 18:03:58 UTC (rev 3697)
@@ -827,31 +827,7 @@
}
switcher.stopActiveEditor();
}
-
- public void _keyPress(nsIDOMKeyEvent keyEvent) {
- if (VpeDebug.printVisualKeyEvent) {
- System.out.println("<<< keyPress type: " + keyEvent.getType() + " Ctrl: " + keyEvent.getCtrlKey() + " Shift: " + keyEvent.getShiftKey() + " CharCode: " + keyEvent.getCharCode() + " KeyCode: " + keyEvent.getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- }
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- visualEditor.hideResizer();
- switcher.stopActiveEditor();
-
- try {
- if (visualKeyHandler.keyPressHandler(keyEvent)) {
- switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
- sourceSelectionChanged1();
- // TODO Max Areshkau figure out with Selection Controller
- visualSelectionController.setCaretEnabled(true);
- switcher.stopActiveEditor();
- }
- } catch (Exception e) {
- VpePlugin.getPluginLog().logError(e);
- visualRefresh();
- }
- }
-
+
public void keyPress(nsIDOMKeyEvent keyEvent) {
if (VpeDebug.printVisualKeyEvent) {
System.out.println("<<< keyPress type: " + keyEvent.getType() + " Ctrl: " + keyEvent.getCtrlKey() + " Shift: " + keyEvent.getShiftKey() + " CharCode: " + keyEvent.getCharCode() + " KeyCode: " + keyEvent.getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
@@ -870,8 +846,7 @@
if (visualKeyHandler.keyPressHandler(keyEvent)) {
switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
// Edward
- sourceSelectionChanged(true);
- // TODO Max Areshkau figure out with Selection
+ sourceSelectionChanged(true);
visualSelectionController.setCaretEnabled(true);
switcher.stopActiveEditor();
} else {
@@ -893,13 +868,13 @@
keyboardEvent.keyCode=(int)keyEvent.getKeyCode();
}
//for maximaze/minimaze command(CTRL+M), we shouldn't call event listeners
- List possibleKeyStrokes = WorkbenchKeyboard.generatePossibleKeyStrokes(keyboardEvent);
+ List<?> possibleKeyStrokes = WorkbenchKeyboard.generatePossibleKeyStrokes(keyboardEvent);
IWorkbench iWorkbench = VpePlugin.getDefault().getWorkbench();
if(iWorkbench.hasService(IBindingService.class)){
IBindingService iBindingService = (IBindingService) iWorkbench.getService(IBindingService.class);
KeySequence sequenceBeforeKeyStroke = KeySequence.getInstance();
- for (Iterator iterator = possibleKeyStrokes.iterator(); iterator
+ for (Iterator<?> iterator = possibleKeyStrokes.iterator(); iterator
.hasNext();){
KeySequence sequenceAfterKeyStroke = KeySequence.getInstance(
sequenceBeforeKeyStroke, (KeyStroke) iterator.next());
@@ -916,8 +891,8 @@
}
}
}
- // TODO Sergey Vasilyev figure out with key handlers
-// xulRunnerEditor.notifyListeners(keyboardEvent.type, keyboardEvent);
+ //sends xulrunner event to eclipse environment
+ getXulRunnerEditor().getBrowser().notifyListeners(keyboardEvent.type, keyboardEvent);
}
} catch (Exception e) {
@@ -1307,8 +1282,6 @@
}
private boolean startActiveEditor(int newType) {
- //TODO Max Areshkau( add in test purposes, remove after all)
-// System.out.print("start");
if (type == ACTIVE_EDITOR_NONE) {
if( newType == ACTIVE_EDITOR_SOURCE &&
editPart.getVisualMode() == VpeEditorPart.SOURCE_MODE) {
@@ -1322,8 +1295,6 @@
}
private void stopActiveEditor() {
- //TODO Max Areshkau( add in test purposes, remove after all)
-// System.out.println("stop");
onRefresh();
type = ACTIVE_EDITOR_NONE;
}
@@ -1799,30 +1770,9 @@
}
public void dragOver(nsIDOMEvent event) {
-// nsIDragSession dragSession = xulRunnerEditor.getCurrentDragSession();
-//
-// boolean isFlavor = dragSession.isDataFlavorSupported(ModelTransfer.MODEL);
-// if (VpeDebug.printVisualDragDropEvent) {
-// System.out.println("<<< outerDragOver isFlavor: " + isFlavor); //$NON-NLS-1$
-// }
visualBuilder.getDnd().dragOver(event, this);
-// nsITransferable transferable = xulRunnerEditor.createTransferable();
-//
-// transferable.addDataFlavor(XulRunnerEditor.TRANS_FLAVOR_kURLDataMime);
-// transferable.addDataFlavor(XulRunnerEditor.TRANS_FLAVOR_kFileMime);
-// transferable.addDataFlavor(XulRunnerEditor.TRANS_FLAVOR_kURLMime);
-//
-// dragSession.getData(transferable, 0);
-//
-// String[] flavors = new String[] {null};
-// nsISupports[] data = new nsISupports[] {null};
-// long[] length = new long[] {0};
-// transferable.getAnyTransferData(flavors, data, length);
-//
-//
-// dragSession.setCanDrop(true);
-// event.preventDefault();
+
}
public void _dragOver(nsIDOMEvent event) {
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-09-18 17:53:00 UTC (rev 3696)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-09-18 18:03:58 UTC (rev 3697)
@@ -1457,11 +1457,7 @@
}
nsIDOMElement getDragElement(nsIDOMMouseEvent mouseEvent) {
- // TODO Max Areshkau figure out with selected element
- /*We use element on which was click
- *
- */
-
+
nsIDOMElement selectedElement = xulRunnerEditor.getLastSelectedElement();
if (selectedElement != null && canInnerDrag(selectedElement)) {
if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil.getMousePoint(mouseEvent))) {
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-09-18 17:53:00 UTC (rev 3696)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-09-18 18:03:58 UTC (rev 3697)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.mozilla;
+import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.VpeController;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
import org.mozilla.interfaces.nsIDOMDocument;
@@ -31,8 +32,7 @@
// private XPCOMObject dropListener;
private XulRunnerEditor visualEditor;
- // TODO Max Areshkau add DnD
-// private VpeDnD dnd;
+
private EditorDomEventListener editorDomEventListener;
//possible events
@@ -123,7 +123,10 @@
/* (non-Javadoc)
* @see org.mozilla.interfaces.nsIDOMEventListener#handleEvent(org.mozilla.interfaces.nsIDOMEvent)
*/
- public void handleEvent(nsIDOMEvent domEvent) {
+ public void handleEvent(nsIDOMEvent domEvent) {
+ //TODO To many information in LOG
+ //VpePlugin.getDefault().logInfo("VPE was handled+EventType is["+domEvent.getType()+"]");
+
try{
if(getEditorDomEventListener()==null){
@@ -186,10 +189,11 @@
}
getEditorDomEventListener().onRefresh();
- //not using default mozilla event handlers
+
}catch(Throwable th) {
- //TODO Max Areshkau remove when all will be adjusted
- th.printStackTrace();
+
+ VpePlugin.getPluginLog().logError("Event Handling Error", th);
+ throw new RuntimeException(th);
}
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2007-09-18 17:53:00 UTC (rev 3696)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2007-09-18 18:03:58 UTC (rev 3697)
@@ -526,7 +526,6 @@
public void setSelectionRectangle(nsIDOMElement element, int resizerConstrains, boolean scroll) {
if (contentAreaEventListener != null) {
- // TODO Max Areshkau add selection support
xulRunnerEditor.setSelectionRectangle((nsIDOMElement)element, resizerConstrains, scroll);
}
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2007-09-18 17:53:00 UTC (rev 3696)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2007-09-18 18:03:58 UTC (rev 3697)
@@ -211,7 +211,7 @@
}
private void initDndHandler(Element templateSection) {
- // TODO Max Areshkau add DnD support
+
if (getDragger() == null) {
setDragger(new VpeDnd());
getDragger().setDndData(templateSection);
@@ -680,7 +680,7 @@
* @return <code>true</code> The node can be dropped
*/
public boolean canInnerDrop(VpePageContext pageContext, Node container, Node sourceDragNode) {
- // TODO Max Areshkau add DnD support
+
if (dragger != null) {
return dragger.isDropEnabled(pageContext, container, sourceDragNode);
} else {
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2007-09-18 17:53:00 UTC (rev 3696)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2007-09-18 18:03:58 UTC (rev 3697)
@@ -13,11 +13,13 @@
import java.util.regex.Pattern;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
+import org.jboss.tools.vpe.xulrunner.BrowserPlugin;
import org.jboss.tools.vpe.xulrunner.XPCOM;
import org.jboss.tools.vpe.xulrunner.XulRunnerException;
import org.jboss.tools.vpe.xulrunner.browser.XulRunnerBrowser;
@@ -240,15 +242,9 @@
*/
public nsISelection getSelection() {
-// try{
-// nsIServiceManager serviceManager = Mozilla.getInstance().getServiceManager();
nsIDOMWindow domWindow = getWebBrowser().getContentDOMWindow();
nsISelection selection = domWindow.getSelection();
return selection;
-// } catch(XPCOMException exception) {
-// exception.printStackTrace();
-// }
-// return null;
}
/**
@@ -266,10 +262,8 @@
private void setLastSelectedElement(nsIDOMElement lastSelectedElement) {
this.lastSelectedElement = lastSelectedElement;
}
+
/**
- *
- */
- /**
* Draws rectangle around the element.
* @param element
* @param resizerConstrains
@@ -295,14 +289,14 @@
}
getIFlasher().repaintElement(getLastSelectedElement());
-// getIFlasher().drawElementOutline(getLastSelectedElement());
+
}else {
getIFlasher().setColor(flasherHiddentElementColor);
nsIDOMElement domElement = findVisbleParentElement(getLastSelectedElement());
if(domElement!=null) {
-// getIFlasher().drawElementOutline(getLastSelectedElement());
+
getIFlasher().repaintElement(domElement);
}
@@ -495,13 +489,14 @@
getIFlasher().drawElementOutline(domElement);
}
}
- } else if(getIFlasher()!=null){
+ } else if(getIFlasher()!=null&&Platform.getOSArch().equals(Platform.OS_MACOSX)){
//Max Areshkau (bug on Mac OS X, when we switch to preview from other view, selection rectangle doesn't disappear
//TODO Max Areshkau (may be exist passability not draw selection on resize event when we switches to other view)
try {
((nsIBaseWindow)getWebBrowser().queryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(true);
} catch(XPCOMException ex) {
//just ignore its
+ BrowserPlugin.getDefault().logInfo("repaint failed", ex);
}
}
}
17 years, 3 months
JBoss Tools SVN: r3696 - trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-09-18 13:53:00 -0400 (Tue, 18 Sep 2007)
New Revision: 3696
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/AbstractSeamContentProvider.java
Log:
System.out was removed
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/AbstractSeamContentProvider.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/AbstractSeamContentProvider.java 2007-09-18 17:20:34 UTC (rev 3695)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/AbstractSeamContentProvider.java 2007-09-18 17:53:00 UTC (rev 3696)
@@ -45,6 +45,7 @@
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.event.ISeamProjectChangeListener;
import org.jboss.tools.seam.core.event.SeamProjectChangeEvent;
+import org.jboss.tools.seam.ui.SeamGuiPlugin;
import org.jboss.tools.seam.ui.views.actions.ScopePresentationActionProvider;
/**
@@ -208,7 +209,7 @@
if(o instanceof ISeamElement) {
refresh(o);
} else {
- System.out.println("event without source");
+ SeamGuiPlugin.getPluginLog().logError("Seam Project change event occurs, but no soyrce of project provided");
}
}
17 years, 3 months
JBoss Tools SVN: r3694 - in branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe: src/org/jboss/tools/vpe/editor/template and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-09-18 13:18:10 -0400 (Tue, 18 Sep 2007)
New Revision: 3694
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/plugin.xml
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java
Log:
JBIDE-901 and remove org.jboss.tools.vpe.ui plugin
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/plugin.xml
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2007-09-18 17:18:05 UTC (rev 3693)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2007-09-18 17:18:10 UTC (rev 3694)
@@ -44,4 +44,7 @@
<xclass id="org.jboss.tools.vpe.editor.css.VpeAddReferenceSupport"
class="org.jboss.tools.vpe.editor.css.VpeAddReferenceSupport"/>
</extension>
+ <extension point="org.eclipse.ui.preferencePages">
+ <page category="org.jboss.tools.common.xstudio.editors" class="org.jboss.tools.vpe.editor.preferences.VpeEditorPreferencesPage" id="org.jboss.tools.vpe.editor" name="Visual Page Editor"></page>
+ </extension>
</plugin>
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java 2007-09-18 17:18:05 UTC (rev 3693)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java 2007-09-18 17:18:10 UTC (rev 3694)
@@ -567,6 +567,11 @@
}
public Node getNodeForUptate(VpePageContext pageContext, Node sourceNode, nsIDOMNode visualNode, Object data) {
+ // TODO Sergey Vasilyev redevelop JSF's facet template
+ if (sourceNode.getNodeName().endsWith(":facet")) {
+ return sourceNode.getParentNode();
+ }
+
if (creator != null) {
return creator.getNodeForUptate(pageContext, sourceNode, visualNode, (Map)data);
}
17 years, 3 months
JBoss Tools SVN: r3693 - branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-09-18 13:18:05 -0400 (Tue, 18 Sep 2007)
New Revision: 3693
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java
Log:
JBIDE-901 and remove org.jboss.tools.vpe.ui plugin
Modified: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java
===================================================================
--- branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java 2007-09-18 16:58:04 UTC (rev 3692)
+++ branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java 2007-09-18 17:18:05 UTC (rev 3693)
@@ -37,11 +37,9 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) {
-
-
VpeCreationData creatorInfo = null;
- try {
- Element sourceElement = (Element)sourceNode;
+
+ Element sourceElement = (Element)sourceNode;
nsIDOMElement visualMenu = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
ComponentUtil.setCSSLink(pageContext, "dropDownMenu/dropDownMenu.css", "richFacesDropDownMenu");
@@ -55,8 +53,6 @@
STYLE_ATTR_NAME,
HtmlComponentUtil.HTML_STYLE_ATTR, null, null);
- Attr ddmLabelFromAttribute = sourceElement.getAttributeNode("value");
-
nsIDOMElement visualMenuLabel = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
visualMenuLabel.setAttribute("class", "dr-label-text-decor rich-label-text-decor");
correctAttribute(sourceElement, visualMenuLabel,
@@ -71,61 +67,52 @@
visualMenu.appendChild(visualMenuLabel);
- String ddmLabelFromFacet = getLabelFacet(sourceElement);
- Map visualNodeMap = pageContext.getDomMapping().getVisualMap();
creatorInfo = new VpeCreationData(visualMenu);
VpeChildrenInfo childrenInfo = new VpeChildrenInfo(visualMenuLabel);
- nsIDOMNode textLabel = null;
- if (ddmLabelFromFacet != null) {
- textLabel = visualDocument.createTextNode(ddmLabelFromFacet);
+ Element facetElement = getLabelFacet(sourceElement);
+
+ if (facetElement != null) {
+ childrenInfo.addSourceChild(facetElement);
} else {
- String valueForLabel = ddmLabelFromAttribute == null
- ? ""
- : ddmLabelFromAttribute.getValue();
- textLabel = visualDocument.createTextNode(valueForLabel);
- }
- if (textLabel != null) {
+ Attr ddmLabelFromAttribute = sourceElement.getAttributeNode("value");
+ String valueForLabel = ddmLabelFromAttribute != null && ddmLabelFromAttribute.getValue() != null
+ ? ddmLabelFromAttribute.getValue()
+ : "";
+ nsIDOMNode textLabel = visualDocument.createTextNode(valueForLabel);
visualMenuLabel.appendChild(textLabel);
- creatorInfo.addChildrenInfo(childrenInfo);
}
+
+ creatorInfo.addChildrenInfo(childrenInfo);
visualMenu.appendChild(visualMenuLabel);
- }catch(Throwable t) {
- t.printStackTrace();
- }
return creatorInfo;
}
- private String getLabelFacet(Element sourceElement) {
- String labelFacet = null;
- NodeList children = sourceElement.getChildNodes();
- int cnt = children != null ? children.getLength() : 0;
- if (cnt > 0) {
- for (int i = 0; i < cnt; i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE &&
- child.getNodeName().endsWith(":facet")) {
- Element facetElement = (Element)child;
- String facetName = facetElement.getAttribute("name");
- if (LABEL_FACET_NAME.equals(facetName)) {
- NodeList facetChildren = facetElement.getChildNodes();
- int facetCnt = facetChildren != null ? facetChildren.getLength() : 0;
- if (facetCnt > 0) {
- for (int j = 0; j < facetCnt; j++) {
- Node facetChild = facetChildren.item(i);
- if (facetChild.getNodeType() == Node.ELEMENT_NODE &&
- facetChild.getNodeName().endsWith(":verbatim")) {
- labelFacet = getElementTextContent((Element)facetChild);
- break;
- }
- }
+
+ private Element getLabelFacet(Element sourceElement) {
+ if (sourceElement == null) {
+ return null;
+ }
+
+ NodeList children = sourceElement.getChildNodes();
+ if (children != null) {
+ int size = children.getLength();
+ if (size > 0) {
+ for (int i=0; i<size; i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE
+ && child.getNodeName().endsWith(":facet")) {
+ Element facetElement = (Element)child;
+ if (LABEL_FACET_NAME.equals(facetElement.getAttribute("name"))) {
+ return facetElement;
}
}
}
}
}
- return labelFacet;
+
+ return null;
}
private String getElementTextContent(Element element) {
17 years, 3 months
JBoss Tools SVN: r3692 - trunk/vpe/plugins.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-09-18 12:58:04 -0400 (Tue, 18 Sep 2007)
New Revision: 3692
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe.ui/
Log:
The only extension point="org.eclipse.ui.preferencePages" of this plugin was replaced to org.jboss.tools.vpe plugin.
17 years, 3 months