Author: rob.stryker(a)jboss.com
Date: 2008-10-29 22:21:00 -0400 (Wed, 29 Oct 2008)
New Revision: 11315
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/AbstractServerActionDelegate.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ChangeTimeStampActionDelegate.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/DebugServerActionDelegate.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/RunServerActionDelegate.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/SelectServerActionDelegate.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ServerActionMessages.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ServerManager.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ServerManagerListener.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/StopServerActionDelegate.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/messages.properties
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogActionProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogContentProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogLabelProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathActionProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathChangeValueAction.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathDecorator.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathTreeContentProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathTreeLabelProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerContentProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerDecorator.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerLabelProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersView.java
Removed:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/JBossServerViewExtension.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerViewProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/InactiveExtensionViewProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ExtensionManager.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ToolsServerUICore.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/action/
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ExtensionTableViewer.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/JBossServerView.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ServerExtensionFrame.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ServerFrame.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ServerTableViewer.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/preferencepages/
Modified:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/PropertySheetFactory.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/SimplePropertiesViewExtension.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/DescriptorXPathViewProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/EventLogViewProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/descriptors/DescriptorXPathPropertySheetPage.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/descriptors/XPathPropertyContentProvider.java
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
incremental update of moving stuff around, and renaming packages. This was necessary
because the last release had package names in the org.eclipse namespace, which was clearly
wrong. Also, deleted JBoss Servers View to replace it with the new beta view and made
sure the extensions worked with it.
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/AbstractServerActionDelegate.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/AbstractServerActionDelegate.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/AbstractServerActionDelegate.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.actions;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+public abstract class AbstractServerActionDelegate implements
IWorkbenchWindowActionDelegate, ServerManagerListener {
+
+ static Map<String, AbstractServerActionDelegate> delegates = new
HashMap<String,AbstractServerActionDelegate>();
+
+ protected IWorkbenchWindow window;
+ protected IAction action;
+ protected boolean isInitialised = false;
+
+ public AbstractServerActionDelegate() {
+ delegates.put(getClass().getName(), this);
+ }
+
+ public static void updateAll() {
+ AbstractServerActionDelegate[] ds = delegates.values().toArray(new
AbstractServerActionDelegate[0]);
+ for (int i = 0; i < ds.length; i++) {
+ try {
+ ds[i].update();
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ public void init(IWorkbenchWindow window) {
+ this.window = window;
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ initModel();
+ }
+ });
+ }
+
+ private void initModel() {
+ ServerManager.getInstance().addListener(this);
+ update();
+ isInitialised = true;
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ if(this.action == action) return;
+ this.action = action;
+ serverManagerChanged();
+ }
+
+ public void run(IAction action) {
+ if(!isInitialised) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if(isActionEnabled()) {
+ _run();
+ }
+ }
+ });
+ } else {
+ _run();
+ }
+ }
+
+ private void _run() {
+ try {
+ doRun();
+ } catch (Exception e) {
+ }
+ }
+
+ public void dispose() {}
+ protected void doRun() {}
+
+ protected boolean isActionEnabled() {
+ return true;
+ }
+
+ protected void update() {
+ if(action != null) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ action.setEnabled(isActionEnabled());
+ setToolTip();
+ }
+ });
+ }
+ }
+
+ public void serverManagerChanged() {
+ update();
+ }
+
+ protected void setToolTip() {
+ if(action != null) {
+ String tooltip = computeToolTip();
+ if(tooltip != null) action.setToolTipText(tooltip);
+ }
+ }
+
+ protected String computeToolTip() {
+ return null;
+ }
+
+
+ // a stub that can be used by subclasses
+ protected static ISelectionProvider getSelectionProvider() {
+ return new ISelectionProvider() {
+ public void addSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+ public ISelection getSelection() {
+ return null;
+ }
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+ public void setSelection(ISelection selection) {
+ }
+ };
+ }
+
+}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ChangeTimeStampActionDelegate.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ChangeTimeStampActionDelegate.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ChangeTimeStampActionDelegate.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+
+public class ChangeTimeStampActionDelegate implements IWorkbenchWindowActionDelegate {
+
+ protected IWorkbenchWindow window;
+ String tooltip = null;
+ IProject project = null;
+ public void init(IWorkbenchWindow window) {
+ this.window = window;
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ if(project == null && action.isEnabled()) action.setEnabled(false);
+ if(tooltip != null && (selection instanceof IStructuredSelection)) {
+ Object o = ((IStructuredSelection)selection).getFirstElement();
+ IProject p = getProject(o);
+ if(p != null) {
+ project = p;
+ action.setEnabled(computeEnabled());
+ action.setToolTipText(NLS.bind(ServerActionMessages.CHANGE_TIME_STAMP,project.getName()));
+ return;
+ }
+ }
+ tooltip = ServerActionMessages.CHANGE_TIME_STAMP_DEFAULT;
+ action.setToolTipText(tooltip);
+ }
+
+ IProject getProject(Object selection) {
+ if(selection instanceof IResource) {
+ return ((IResource)selection).getProject();
+ } else if(selection instanceof IAdaptable) {
+ Object r = ((IAdaptable)selection).getAdapter(IResource.class);
+ return r instanceof IResource ? ((IResource)r).getProject() : null;
+ }
+ return null;
+ }
+
+ protected boolean computeEnabled() {
+ if(project == null || !project.isAccessible()) return false;
+ boolean isWar = J2EEProjectUtilities.isDynamicWebProject(project);
+ boolean isEar = J2EEProjectUtilities.isEARProject(project);
+ boolean isEJB = J2EEProjectUtilities.isEJBProject(project);
+ return isEar || isEJB || isWar;
+ }
+
+ public void run(IAction action) {
+ try {
+ changeTimeStamp(project);
+ } catch (Exception e) {
+
+ }
+ }
+
+ public void dispose() {
+ window = null;
+ }
+
+ public static void changeTimeStamp(IProject project) throws CoreException {
+ if(project == null || !project.isAccessible()) return;
+ List<IFile> fs = getFilesToTouch(project);
+ for (int i = 0; i < fs.size(); i++) {
+ IFile f = (IFile)fs.get(i);
+ f.setLocalTimeStamp(System.currentTimeMillis());
+ f.touch(new NullProgressMonitor()); // done so deployers/listeners can detect the
actual change.
+ }
+ }
+
+ private static List<IFile> getFilesToTouch(IProject project) {
+ List<IFile> fs = new ArrayList<IFile>();
+ if(project == null || !project.isAccessible()) return fs;
+ boolean isWar = J2EEProjectUtilities.isDynamicWebProject(project);
+ boolean isEar = J2EEProjectUtilities.isEARProject(project);
+
+ boolean isReferencedByEar = false;
+ if(!isEar) {
+ IProject[] ps = J2EEProjectUtilities.getReferencingEARProjects(project);
+ for (int i = 0; i < ps.length; i++) {
+ fs.addAll(getFilesToTouch(ps[i]));
+ isReferencedByEar = true;
+ }
+ }
+ if(isEar) {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ IPath path = component.getRootFolder().getProjectRelativePath();
+ IFile f =
project.getFile(path.append("META-INF").append("application.xml"));
+ if(f != null && f.exists()) {
+ fs.add(f);
+ }
+ }
+ if(isWar && !isReferencedByEar) {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ IPath path = component.getRootFolder().getProjectRelativePath();
+ IFile f =
project.getFile(path.append("WEB-INF").append("web.xml"));
+ if(f != null && f.exists()) {
+ fs.add(f);
+ }
+ }
+ return fs;
+ }
+}
\ No newline at end of file
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/DebugServerActionDelegate.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/DebugServerActionDelegate.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/DebugServerActionDelegate.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.actions;
+
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.server.core.IServer;
+
+public class DebugServerActionDelegate extends RunServerActionDelegate {
+
+ protected String getLaunchMode() {
+ return ILaunchManager.DEBUG_MODE;
+ }
+
+
+ protected String computeToolTip() {
+ IServer selected = ServerManager.getInstance().getSelectedServer();
+ String name = selected == null ? "" : selected.getName(); //$NON-NLS-1$
+ if( selected != null && selected.getServerState() == IServer.STATE_STARTED)
+ return NLS.bind(ServerActionMessages.RESTART_IN_DEBUG_MODE, name);
+ return NLS.bind(ServerActionMessages.START_IN_DEBUG_MODE, name); //$NON-NLS-2$
+ }
+
+}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/RunServerActionDelegate.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/RunServerActionDelegate.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/RunServerActionDelegate.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.actions;
+
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.internal.view.servers.StartAction;
+
+public class RunServerActionDelegate extends AbstractServerActionDelegate {
+
+ private StartAction delegate;
+ public void init(IWorkbenchWindow window) {
+ super.init(window);
+ update();
+ }
+
+ protected void doRun() {
+ IServer server = ServerManager.getInstance().getSelectedServer();
+ if(server == null)
+ return;
+ delegate = new StartAction(window.getShell(), getSelectionProvider(),
getLaunchMode());
+ if( delegate.accept(server))
+ delegate.perform(server);
+ updateAll();
+ }
+
+ protected String getLaunchMode() {
+ return ILaunchManager.RUN_MODE;
+ }
+
+ protected boolean isActionEnabled() {
+ IServer selected = ServerManager.getInstance().getSelectedServer();
+ return (selected != null
+ && selected.getServerState() != IServer.STATE_STARTING);
+ }
+
+ protected String computeToolTip() {
+ IServer selected = ServerManager.getInstance().getSelectedServer();
+ String name = selected == null ? "" : selected.getName(); //$NON-NLS-1$
+ if( selected != null && selected.getServerState() == IServer.STATE_STARTED)
+ return NLS.bind(ServerActionMessages.RESTART_IN_RUN_MODE, name);
+ return NLS.bind(ServerActionMessages.START_IN_RUN_MODE, name);
+ }
+}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/SelectServerActionDelegate.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/SelectServerActionDelegate.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/SelectServerActionDelegate.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.TaskModel;
+import org.eclipse.wst.server.ui.internal.ImageResource;
+import org.eclipse.wst.server.ui.internal.wizard.NewServerWizard;
+import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
+
+
+public class SelectServerActionDelegate extends AbstractServerActionDelegate
+ implements IWorkbenchWindowPulldownDelegate {
+
+ private ArrayList images = new ArrayList();
+
+ protected void safeSelectionChanged(IAction action, ISelection selection) {
+ this.action = action;
+ update();
+ }
+
+ protected void update() {
+ if (action == null) return;
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ update0();
+ }
+ });
+ }
+
+ private void update0() {
+ if(action == null) return;
+ IServer server = ServerManager.getInstance().getSelectedServer();
+ if( server != null ) {
+ ImageDescriptor id =
ImageResource.getImageDescriptor(server.getServerType().getId());
+ action.setImageDescriptor(id);
+ }
+ action.setText(null);
+ action.setToolTipText(ServerActionMessages.SELECT_A_SERVER);
+ }
+
+ protected void doRun() {
+ getMenu(window.getShell()).setVisible(true);
+ }
+
+ public void dispose() {
+ action = null;
+ }
+
+ public Menu getMenu(Control parent) {
+ cleanImages();
+
+ Menu menu = new Menu(parent);
+ IServer[] servers = ServerManager.getInstance().getServers();
+ for (int i = 0; i < servers.length; i++) {
+ createServerItem(menu, servers[i]);
+ }
+ new MenuItem(menu, SWT.SEPARATOR);
+ createNewServerItem(menu);
+ return menu;
+ }
+
+ // prevent memory leaks
+ protected void cleanImages() {
+ Iterator<Image> i = images.iterator();
+ while(i.hasNext())
+ ((Image)i.next()).dispose();
+ images.clear();
+ }
+
+ private void createServerItem(Menu menu, final IServer server) {
+ MenuItem item = new MenuItem(menu, SWT.RADIO);
+ if(server == ServerManager.getInstance().getSelectedServer()) {
+ item.setSelection(true);
+ }
+
+ item.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ ServerManager.getInstance().setSelectedServer(server.getId());
+ update();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+ item.setText(server.getName());
+ ImageDescriptor id = ImageResource.getImageDescriptor(server.getServerType().getId());
+ Image i = id.createImage();
+ images.add(i);
+ item.setImage(i);
+ }
+
+ private void createNewServerItem(Menu menu) {
+ MenuItem item = new MenuItem(menu, SWT.PUSH);
+ item.setText("New server...");
+ item.setImage(JBossServerUISharedImages.getImage(JBossServerUISharedImages.GENERIC_SERVER_IMAGE));
+ item.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ newServer();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ newServer();
+ widgetSelected(e);
+ }
+ });
+ }
+
+ private void newServer() {
+ NewServerWizard wizard = new NewServerWizard();
+ WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
+ if (dialog.open() != Window.CANCEL) {
+ IServer server =
(IServer)wizard.getRootFragment().getTaskModel().getObject(TaskModel.TASK_SERVER);
+ if(server != null) {
+ ServerManager.getInstance().setSelectedServer(server.getId());
+ update();
+ }
+ }
+ }
+}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ServerActionMessages.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ServerActionMessages.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ServerActionMessages.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,20 @@
+package org.jboss.ide.eclipse.as.ui.actions;
+
+import org.eclipse.osgi.util.NLS;
+
+public class ServerActionMessages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.as.wst.server.ui.action.messages";
+
+ static {
+ // load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, ServerActionMessages.class);
+ }
+ public static String START_IN_DEBUG_MODE;
+ public static String RESTART_IN_DEBUG_MODE;
+ public static String START_IN_RUN_MODE;
+ public static String RESTART_IN_RUN_MODE;
+ public static String SELECT_A_SERVER;
+ public static String STOP_SERVER;
+ public static String CHANGE_TIME_STAMP;
+ public static String CHANGE_TIME_STAMP_DEFAULT;
+}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ServerManager.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ServerManager.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ServerManager.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeLifecycleListener;
+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.ui.JBossServerUIPlugin;
+
+public class ServerManager {
+ private static ServerManager instance;
+
+ public static synchronized ServerManager getInstance() {
+ if(instance == null) {
+ instance = new ServerManager();
+ }
+ return instance;
+ }
+
+ private List<ServerManagerListener> listeners = new
ArrayList<ServerManagerListener>();
+ private IServerListener serverListener;
+ protected IServer[] servers = new IServer[0];
+
+ IServer selected = null;
+
+ public ServerManager() {
+ serverListener = new ServerListenerImpl();
+ load();
+ }
+
+ void load() {
+ servers = (IServer[])ServerCore.getServers().clone();
+ loadSelectedServer();
+ ServerResourceListenerImpl listener = new ServerResourceListenerImpl();
+ ServerCore.addRuntimeLifecycleListener(listener);
+ ServerCore.addServerLifecycleListener(listener);
+ }
+
+ private void loadSelectedServer() {
+ if(servers == null || servers.length == 0) return;
+ String ds = getDefaultWebServer();
+ IServer s = getServer(ds);
+ if(s == null && servers.length > 0) {
+ s = servers[0];
+ setDefaultWebServer(servers[0].getId());
+ }
+ setSelectedServerInternal(s);
+ }
+
+ public IServer[] getServers() {
+ return servers;
+ }
+
+ public IServer getServer(String serverId) {
+ for (int i = 0; i < servers.length; i++) {
+ if(servers[i].getId().equals(serverId)) {
+ return servers[i];
+ }
+ }
+ return null;
+ }
+
+ public void addListener(ServerManagerListener listener) {
+ if(!listeners.contains(listener)) listeners.add(listener);
+ }
+
+ public void removeListener(ServerManagerListener listener) {
+ listeners.remove(listener);
+ }
+
+ void fire() {
+ ServerManagerListener[] ls = (ServerManagerListener[])listeners.toArray(new
ServerManagerListener[0]);
+ for (int i = 0; i < ls.length; i++) {
+ ls[i].serverManagerChanged();
+ }
+ }
+
+ public void setSelectedServer(String id) {
+ IServer server = getServer(id);
+ if(server == selected) return;
+ setSelectedServerInternal(server);
+ setDefaultWebServer(id);
+ fire();
+ }
+
+ private void setSelectedServerInternal(IServer server) {
+ if(selected == server) return;
+ if(selected != null) selected.removeServerListener(serverListener);
+ selected = server;
+ if(selected != null) selected.addServerListener(serverListener);
+ }
+
+ public String getSelectedServerId() {
+ String result = getDefaultWebServer();
+ return result == null ? "" : result;
+ }
+
+ public IServer getSelectedServer() {
+ return selected;
+ }
+
+ class ServerResourceListenerImpl implements IRuntimeLifecycleListener,
IServerLifecycleListener {
+ public void serverAdded(IServer server) {
+ IServer[] ss = new IServer[servers.length + 1];
+ System.arraycopy(servers, 0, ss, 0, servers.length);
+ ss[servers.length] = server;
+ servers = ss;
+ loadSelectedServer();
+ fire();
+ }
+ public void serverChanged(IServer server) {
+ fire();
+ }
+ public void serverRemoved(IServer server) {
+ List<IServer> l = new ArrayList<IServer>();
+ for (int i = 0; i < servers.length; i++) {
+ if(servers[i] != server) l.add(servers[i]);
+ }
+ if(l.size() == servers.length) return;
+ servers = l.toArray(new IServer[0]);
+ loadSelectedServer();
+ fire();
+ }
+ public void runtimeAdded(IRuntime runtime) {
+ fire();
+ }
+ public void runtimeChanged(IRuntime runtime) {
+ fire();
+ }
+ public void runtimeRemoved(IRuntime runtime) {
+ fire();
+ }
+ }
+
+ class ServerListenerImpl implements IServerListener {
+ public void serverChanged(ServerEvent arg0) {
+ fire();
+ }
+ }
+
+ static String DEFAULT_WEB_SERVER = JBossServerUIPlugin.PLUGIN_ID +
".defaultWebServer";
+
+ static String getDefaultWebServer() {
+ String result = getInstancePreference(DEFAULT_WEB_SERVER);
+ return result;
+ }
+
+ static void setDefaultWebServer(String value) {
+ getInstancePreferences().put(DEFAULT_WEB_SERVER, value);
+ }
+
+ static IEclipsePreferences getInstancePreferences() {
+ return new InstanceScope().getNode(JBossServerUIPlugin.PLUGIN_ID);
+ }
+
+ static IEclipsePreferences getDefaultPreferences() {
+ return new DefaultScope().getNode(JBossServerUIPlugin.PLUGIN_ID);
+ }
+
+ static String getInstancePreference(String key) {
+ IEclipsePreferences p = getInstancePreferences();
+ String value = p == null ? null : p.get(key, null);
+ return value != null ? value : getDefaultPreference(key);
+ }
+
+ static String getDefaultPreference(String key) {
+ IEclipsePreferences p = getDefaultPreferences();
+ return p == null ? null : p.get(key, null);
+ }
+
+}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ServerManagerListener.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ServerManagerListener.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ServerManagerListener.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.actions;
+
+public interface ServerManagerListener {
+ public void serverManagerChanged();
+
+}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/StopServerActionDelegate.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/StopServerActionDelegate.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/StopServerActionDelegate.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.actions;
+
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.internal.view.servers.StopAction;
+
+public class StopServerActionDelegate extends AbstractServerActionDelegate {
+ protected StopAction delegate;
+
+ public void init(IWorkbenchWindow window) {
+ super.init(window);
+ update();
+ delegate = new StopAction(window.getShell(), getSelectionProvider());
+ }
+
+ protected void doRun() {
+ IServer server = ServerManager.getInstance().getSelectedServer();
+ if(server == null) return;
+ if( delegate.accept(server))
+ delegate.perform(server);
+ }
+
+ protected boolean isActionEnabled() {
+ IServer selected = ServerManager.getInstance().getSelectedServer();
+ return (selected != null &&
+ (selected.getServerState() == IServer.STATE_STARTED
+ || selected.getServerState() == IServer.STATE_STARTING));
+ }
+
+ protected String computeToolTip() {
+ IServer selected = ServerManager.getInstance().getSelectedServer();
+ String name = selected == null ? "" : selected.getName(); //$NON-NLS-1$
+ return NLS.bind(ServerActionMessages.STOP_SERVER, name);
+ }
+
+}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/messages.properties
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/messages.properties
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/messages.properties 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,8 @@
+START_IN_DEBUG_MODE=Start {0} in debug mode
+RESTART_IN_DEBUG_MODE=Restart {0} in debug mode
+START_IN_RUN_MODE=Start {0}
+RESTART_IN_RUN_MODE=Restart {0}
+SELECT_A_SERVER=Select a default server
+STOP_SERVER=Shutdown {0}
+CHANGE_TIME_STAMP=Change Timestamp of {0}
+CHANGE_TIME_STAMP_DEFAULT=Touch descriptors
\ No newline at end of file
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogActionProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogActionProvider.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogActionProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,72 @@
+package org.jboss.ide.eclipse.as.ui.views.server.extensions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.ServerEventModel;
+import org.jboss.ide.eclipse.as.ui.dialogs.ShowStackTraceDialog;
+
+public class EventLogActionProvider extends CommonActionProvider {
+ private Action clearLogAction;
+ private Action showStackTraceAction;
+ private ICommonActionExtensionSite actionSite;
+ public EventLogActionProvider() {
+ super();
+ }
+
+ public void init(ICommonActionExtensionSite aSite) {
+ super.init(aSite);
+ this.actionSite = aSite;
+ createActions();
+ }
+ public void fillContextMenu(IMenuManager menu) {
+ ICommonViewerSite site = actionSite.getViewSite();
+ IStructuredSelection selection = null;
+ if( site instanceof ICommonViewerWorkbenchSite ) {
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
+ selection = (IStructuredSelection) wsSite.getSelectionProvider().getSelection();
+ Object first = selection.getFirstElement();
+ if( first != null && first instanceof ServerEventModel) {
+ menu.add(clearLogAction);
+ }
+ if( first != null && first instanceof EventLogTreeItem &&
+ (((EventLogTreeItem)first).getEventClass().equals(EventLogModel.EVENT_TYPE_EXCEPTION)
||
+ ((EventLogTreeItem)first).getSpecificType().equals(EventLogModel.EVENT_TYPE_EXCEPTION)))
{
+ menu.add(showStackTraceAction);
+ }
+ }
+ }
+
+
+ protected void createActions() {
+ clearLogAction = new Action() {
+ public void run() {
+ IStructuredSelection selection =
(IStructuredSelection)actionSite.getStructuredViewer().getSelection();
+ if(selection.getFirstElement() != null && selection.getFirstElement()
instanceof ServerEventModel) {
+ ((ServerEventModel)selection.getFirstElement()).clearEvents();
+ actionSite.getStructuredViewer().refresh(((ServerEventModel)selection.getFirstElement()));
+ }
+ }
+ };
+ clearLogAction.setText("Clear Event Log");
+
+ showStackTraceAction = new Action() {
+ public void run() {
+ IStructuredSelection selection =
(IStructuredSelection)actionSite.getStructuredViewer().getSelection();
+ if( selection.getFirstElement() != null && selection.getFirstElement()
instanceof EventLogTreeItem ) {
+ EventLogTreeItem item = (EventLogTreeItem)selection.getFirstElement();
+ ShowStackTraceDialog dialog = new ShowStackTraceDialog(new Shell(), item);
+ dialog.open();
+ }
+ }
+ };
+ showStackTraceAction.setText("See Exception Details");
+ }
+}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogContentProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogContentProvider.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogContentProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,165 @@
+package org.jboss.ide.eclipse.as.ui.views.server.extensions;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogRoot;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.IEventLogListener;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.ServerEventModel;
+import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
+import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
+
+public class EventLogContentProvider implements ITreeContentProvider {
+ public static final String SHOW_TIMESTAMP =
"org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.showTimestamp";
+ public static final String GROUP_BY_CATEGORY =
"org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.groupByCategory";
+ public static final String EVENT_ON_TOP =
"org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.eventOnTop";
+ public static final int NEWEST_ON_TOP = 1;
+ public static final int OLDEST_ON_TOP = 2;
+ public static final int _TRUE_ = 1;
+ public static final int _FALSE_ = 2;
+
+ private Viewer viewer;
+
+ public EventLogContentProvider() {
+ EventLogModel.enableLogging();
+ EventLogModel.getDefault().addListener(new IEventLogListener() {
+ public void eventModelChanged(String serverId,
+ EventLogTreeItem changed) {
+ if( viewer instanceof StructuredViewer ) {
+ final Object o = changed.getEventRoot();
+ if( o instanceof EventLogRoot) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ ((StructuredViewer)viewer).refresh(((EventLogRoot)o).getModel());
+ }
+ });
+ }
+ }
+ }
+ });
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if( parentElement instanceof IServer && parentElement != null ) {
+ return new Object[] { EventLogModel.getModel((IServer)parentElement)};
+ }
+ if( parentElement instanceof ServerEventModel) {
+ ServerEventModel s = ((ServerEventModel)parentElement);
+ boolean categorize = getCategorize();
+ if( categorize )
+ return getRootCategories(s);
+ Object[] ret = s.getRoot().getChildren();
+ if( getSortOrder()) {
+ List<Object> l = Arrays.asList(ret);
+ Collections.reverse(l);
+ return l.toArray();
+ }
+ return ret;
+ }
+
+ if( parentElement instanceof MajorEventType ) {
+ // get children only of this type
+ String serverId = ((MajorEventType)parentElement).getServer();
+ SimpleTreeItem[] children = EventLogModel.getModel(serverId).getRoot().getChildren();
+ ArrayList<SimpleTreeItem> items = new ArrayList<SimpleTreeItem>();
+ for( int i = 0; i < children.length; i++ ) {
+ if( children[i] instanceof EventLogTreeItem ) {
+ String type = ((EventLogTreeItem)children[i]).getEventClass();
+ if( type != null && type.equals(((MajorEventType)parentElement).getId()))
+ items.add(children[i]);
+ }
+ }
+
+ if( getSortOrder() ) Collections.reverse(items);
+
+ return items.toArray(new Object[items.size()]);
+ }
+
+ // just return the object's kids
+ if( parentElement instanceof EventLogTreeItem ) {
+ return ((EventLogTreeItem)parentElement).getChildren();
+ }
+ return new Object[0];
+ }
+
+ public static class MajorEventType {
+ private String id;
+ private String serverId;
+ public MajorEventType(String serverId, String id) {
+ this.id = id;
+ this.serverId = serverId;
+ }
+ public String getId() {
+ return id;
+ }
+ public String getServer() { return serverId; }
+ public String toString() { return id; }
+ public boolean equals(Object o) {
+ return o instanceof MajorEventType &&
+ ((MajorEventType)o).getId().equals(id) &&
+ ((MajorEventType)o).getServer().equals(serverId);
+ }
+ }
+
+ protected Object[] getRootCategories(ServerEventModel model) {
+ EventLogRoot root = model.getRoot();
+ ArrayList<String> list = new ArrayList<String>();
+ ArrayList<MajorEventType> majorTypes = new ArrayList<MajorEventType>();
+ SimpleTreeItem[] children = root.getChildren();
+ for( int i = 0; i < children.length; i++ ) {
+ if( children[i] instanceof EventLogTreeItem ) {
+ String type = ((EventLogTreeItem)children[i]).getEventClass();
+ if( !list.contains(type)) {
+ list.add(type);
+ majorTypes.add(new MajorEventType(model.getId(), type));
+ }
+ }
+ }
+ return majorTypes.toArray(new MajorEventType[majorTypes.size()]);
+ }
+
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length > 0 ? true : false;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return null;
+ }
+
+ public void dispose() {
+ EventLogModel.disableLogging();
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ this.viewer = viewer;
+ }
+
+ protected boolean getSortOrder() {
+ Preferences store = JBossServerUIPlugin.getDefault().getPluginPreferences();
+ int showTimestamp = store.getInt(EVENT_ON_TOP);
+ if( showTimestamp == OLDEST_ON_TOP) return false;
+ return true;
+ }
+ protected boolean getCategorize() {
+ Preferences store = JBossServerUIPlugin.getDefault().getPluginPreferences();
+ int showTimestamp = store.getInt(GROUP_BY_CATEGORY);
+ if( showTimestamp == _TRUE_ ) return true;
+ if( showTimestamp == _FALSE_) return false;
+ return false; // default
+ }
+}
\ No newline at end of file
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogLabelProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogLabelProvider.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogLabelProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,142 @@
+package org.jboss.ide.eclipse.as.ui.views.server.extensions;
+
+import java.util.Date;
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.ServerEventModel;
+import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
+import
org.jboss.ide.eclipse.as.ui.views.server.extensions.EventLogContentProvider.MajorEventType;
+
+public class EventLogLabelProvider extends LabelProvider {
+
+ public static final String SHOW_TIMESTAMP =
"org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.showTimestamp";
+ public static final int _TRUE_ = 1;
+ public static final int _FALSE_ = 2;
+ private static HashMap<String, String> majorTypeToName = new HashMap<String,
String>();
+
+ static {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf =
registry.getConfigurationElementsFor(JBossServerUIPlugin.PLUGIN_ID,
"EventLogMajorType");
+ for( int i = 0; i < cf.length; i++ ) {
+ String type = cf[i].getAttribute("typeId");
+ String name = cf[i].getAttribute("name");
+ majorTypeToName.put(type, name);
+ }
+ }
+
+ private Image rootImage;
+ public EventLogLabelProvider() {
+ super();
+ ImageDescriptor des =
ImageDescriptor.createFromURL(JBossServerUIPlugin.getDefault().getBundle().getEntry("icons/info_obj.gif"));
+ rootImage = des.createImage();
+ }
+ public void dispose() {
+ super.dispose();
+ rootImage.dispose();
+ }
+
+ private IEventLogLabelProvider[] labelProviderDelegates = null;
+ public Image getImage(Object element) {
+ if( labelProviderDelegates == null )
+ loadLabelProviderDelegates();
+
+ if( element instanceof ServerEventModel ) {
+ return rootImage;
+ }
+
+ if( !(element instanceof EventLogTreeItem))
+ return null;
+
+ EventLogTreeItem item = (EventLogTreeItem)element;
+ for( int i = 0; i < labelProviderDelegates.length; i++ ) {
+ if( labelProviderDelegates[i] != null
+ && labelProviderDelegates[i].supports(item.getSpecificType())) {
+ Image image = labelProviderDelegates[i].getImage((EventLogTreeItem)element);
+ if( image != null ) return image;
+ }
+ }
+
+ return null;
+ }
+
+ public String getText(Object element) {
+ if( element == null ) return "ERROR: Unknown String type";
+
+ if( element instanceof ServerEventModel ) {
+ return "Event Log";
+ }
+
+
+ String suffix = getShowTimestamp() ? createTimestamp(element) : "";
+ if( labelProviderDelegates == null )
+ loadLabelProviderDelegates();
+
+
+ if( !(element instanceof EventLogTreeItem)) {
+ if( element instanceof MajorEventType ) {
+ String val = majorTypeToName.get(((MajorEventType)element).getId());
+ if( val != null ) return val;
+ }
+ return element.toString();
+ }
+ EventLogTreeItem item = (EventLogTreeItem)element;
+
+ for( int i = 0; i < labelProviderDelegates.length; i++ ) {
+ if( labelProviderDelegates[i] != null
+ && labelProviderDelegates[i].supports(item.getSpecificType())) {
+ String text = labelProviderDelegates[i].getText((EventLogTreeItem)element);
+ if( text != null ) return text + suffix;
+ }
+ }
+
+ return element == null ? "" : element.toString() + suffix;
+ }
+
+ public void loadLabelProviderDelegates() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] elements =
registry.getConfigurationElementsFor(JBossServerUIPlugin.PLUGIN_ID,
"EventLogLabelProvider");
+ labelProviderDelegates = new IEventLogLabelProvider[elements.length];
+ for( int i = 0; i < elements.length; i++ ) {
+ try {
+ labelProviderDelegates[i] =
(IEventLogLabelProvider)elements[i].createExecutableExtension("class");
+ } catch( CoreException ce ) {
+ JBossServerUIPlugin.log("Error loading Event Log Label Provider Delegate",
ce);
+ }
+ }
+ }
+ protected boolean getShowTimestamp() {
+ Preferences store = JBossServerUIPlugin.getDefault().getPluginPreferences();
+ int showTimestamp = store.getInt(SHOW_TIMESTAMP);
+ if( showTimestamp == _TRUE_ ) return true;
+ if( showTimestamp == _FALSE_) return false;
+ return false; // default
+ }
+
+ protected String createTimestamp(Object element) {
+ if( element instanceof EventLogTreeItem ) {
+ Long v = (Long) ((EventLogTreeItem)element).getProperty(EventLogTreeItem.DATE);
+ if( v == null ) return "";
+
+ double date = v.doubleValue();
+ double now = new Date().getTime();
+ int seconds = (int) (( now - date) / 1000);
+ int minutes = seconds / 60;
+ int hours = minutes / 60;
+ minutes -= (hours * 60);
+ String minString = minutes + "m ago";
+ if( hours == 0 )
+ return " (" + minString + ")";
+ return " (" + hours + "h " + minString + ")";
+ }
+ return "";
+ }
+}
\ No newline at end of file
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/JBossServerViewExtension.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/JBossServerViewExtension.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/JBossServerViewExtension.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -1,167 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.ui.views.server.extensions;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
-import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
-import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
-import org.jboss.tools.as.wst.server.ui.views.server.ExtensionTableViewer;
-import org.jboss.tools.as.wst.server.ui.views.server.JBossServerView;
-import
org.jboss.tools.as.wst.server.ui.views.server.ExtensionTableViewer.ContentWrapper;
-import
org.jboss.tools.as.wst.server.ui.views.server.preferencepages.ViewProviderPreferenceComposite;
-
-/**
- *
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public abstract class JBossServerViewExtension {
- protected ServerViewProvider provider;
-
- /**
- * Which extension point is mine.
- * @param provider
- */
- public void setViewProvider(ServerViewProvider provider) {
- this.provider = provider;
- }
-
- /**
- * Should query preferencestore to see if I'm enabled or not
- * @return
- */
- public boolean isEnabled() {
- return provider.isEnabled();
- }
-
-
- public void init() {
- }
- public void enable() {
- }
- public void disable() {
- }
- public void dispose() {
- if( getPropertySheetPage() != null )
- getPropertySheetPage().dispose();
- }
-
-
- public void fillContextMenu(Shell shell, IMenuManager menu, Object[] selected) {
- }
-
- public ITreeContentProvider getContentProvider() {
- return null;
- }
- public LabelProvider getLabelProvider() {
- return null;
- }
-
- public IPropertySheetPage getPropertySheetPage() {
- return null;
- }
-
- public ViewProviderPreferenceComposite createPreferenceComposite(Composite parent) {
- return null;
- }
-
- public Image createIcon() {
- return null;
- }
-
- public void refreshModel(Object object) {
- // override me
- }
-
- protected void suppressingRefresh(Runnable runnable) {
- JBossServerView.getDefault().getExtensionFrame().getViewer().suppressingRefresh(runnable);
- }
-
- protected void refreshViewer() {
- refreshViewer(null);
- }
- protected void refreshViewer(final Object o) {
- Runnable r = new Runnable() {
- public void run() {
- if( isEnabled() ) {
- if( o == null || o == provider ) {
- JBossServerView.getDefault().getExtensionFrame().getViewer().refresh(provider);
- } else {
- ExtensionTableViewer viewer =
JBossServerView.getDefault().getExtensionFrame().getViewer();
- ContentWrapper wrapped = new ContentWrapper(o, provider);
- if( viewer.elementInTree(wrapped))
- viewer.refresh(new ContentWrapper(o, provider));
- else
- viewer.refresh(provider);
- }
- }
- }
- };
-
- if( JBossServerView.getDefault() == null )
- return;
-
- if( Display.getCurrent() == null )
- Display.getDefault().asyncExec(r);
- else
- r.run();
- }
- protected void removeElement(Object o) {
- JBossServerView.getDefault().getServerFrame().getViewer().remove(new ContentWrapper(o,
provider));
- }
- protected void addElement(Object parent, Object child) {
- JBossServerView.getDefault().getServerFrame().getViewer().add(new
ContentWrapper(parent, provider), new ContentWrapper(child, provider));
- }
-
- // what servers should i show for?
- protected boolean supports(IServer server) {
- if( server == null ) return false;
- return isJBossDeployable(server);
- }
-
- // show for anything that's jboss deployable
- protected boolean isJBossDeployable(IServer server) {
- return (IDeployableServer)server.loadAdapter(IDeployableServer.class, new
NullProgressMonitor()) != null;
- }
-
- // show only for full jboss servers
- protected boolean isJBossServer(IServer server) {
- return (JBossServer)server.loadAdapter(JBossServer.class, new NullProgressMonitor()) !=
null;
- }
-
- protected boolean allAre(Object[] list, Class clazz) {
- for( int i = 0; i < list.length; i++ )
- if( list[i].getClass() != clazz )
- return false;
- return true;
- }
-}
Modified:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/PropertySheetFactory.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/PropertySheetFactory.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/PropertySheetFactory.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -45,7 +45,6 @@
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.jboss.ide.eclipse.as.ui.Messages;
-import
org.jboss.tools.as.wst.server.ui.views.server.ExtensionTableViewer.ContentWrapper;
/**
*
@@ -161,9 +160,6 @@
}
public Object[] getElements(Object inputElement) {
- if( inputElement instanceof ContentWrapper ) {
- inputElement = ((ContentWrapper)inputElement).getElement();
- }
if( properties != null )
return properties.keySet().toArray();
@@ -174,9 +170,6 @@
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if( newInput instanceof ContentWrapper )
- newInput = ((ContentWrapper)newInput).getElement();
-
input = newInput;
properties = holder.getProperties(newInput);
}
@@ -198,9 +191,6 @@
}
public String getColumnText(Object element, int columnIndex) {
- if( element instanceof ContentWrapper )
- element = ((ContentWrapper)element).getElement();
-
if( columnIndex == 0 ) return element.toString();
if( columnIndex == 1 && element instanceof String && properties !=
null ) {
return properties.getProperty((String)element);
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerViewProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerViewProvider.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerViewProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -1,141 +0,0 @@
-package org.jboss.ide.eclipse.as.ui.views.server.extensions;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
-import org.osgi.framework.Bundle;
-
-/**
- *
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public class ServerViewProvider {
- public static final String EXTENSION_ENABLED = "EXTENSION_ENABLED_";
- public static final String EXTENSION_WEIGHT = "EXTENSION_WEIGHT_";
-
- public static final String ID_LABEL = "id";
- public static final String NAME_LABEL = "name";
- public static final String DESCRIPTION_LABEL = "description";
- public static final String PROVIDER_LABEL = "providerClass";
- public static final String ICON_LABEL = "icon";
-
-
- private IConfigurationElement element;
- private JBossServerViewExtension extension;
-
- private ImageDescriptor iconDescriptor;
- private Image icon;
-
- private boolean enabled;
- private int weight;
- private boolean loadFailed = false;
-
- public ServerViewProvider(IConfigurationElement element) {
- this.element = element;
-
- // Am I enabled?
- Preferences prefs = JBossServerUIPlugin.getDefault().getPluginPreferences();
-
-
- String enabledKey = EXTENSION_ENABLED + getId();
- setEnabled( prefs.contains(enabledKey) ? prefs.getBoolean(enabledKey) : true );
-
- String weightKey = EXTENSION_WEIGHT + getId();
- setWeight( prefs.contains(weightKey) ? prefs.getInt(weightKey) : 0 );
-
- Bundle pluginBundle = JBossServerUIPlugin.getDefault().getBundle();
- String iconLoc = getIconLocation();
- if( iconLoc != null ) {
- iconDescriptor =
- ImageDescriptor.createFromURL(pluginBundle.getEntry(iconLoc));
- }
- }
-
- public String getId() {
- return element.getAttribute(ID_LABEL);
- }
-
- public String getName() {
- return element.getAttribute(NAME_LABEL);
- }
-
- public String getDescription() {
- return element.getAttribute(DESCRIPTION_LABEL);
- }
-
- public String getIconLocation() {
- return element.getAttribute(ICON_LABEL);
- }
-
- public Image getImage() {
- if( icon == null && iconDescriptor != null ) {
- icon = iconDescriptor.createImage();
- } else if( icon == null && iconDescriptor == null ){
- icon = getDelegate().createIcon();
- } else if( icon != null && icon.isDisposed()) {
- icon = iconDescriptor == null ? getDelegate().createIcon() :
iconDescriptor.createImage();
- }
- return icon;
- }
-
- public JBossServerViewExtension getDelegate() {
- try {
- if( extension == null && !loadFailed) {
- extension =
(JBossServerViewExtension)element.createExecutableExtension(PROVIDER_LABEL);
- extension.setViewProvider(this);
- }
- } catch( CoreException ce ) {
- loadFailed = true;
- ce.printStackTrace();
- }
- return extension;
- }
-
- public String getDelegateName() {
- return element.getAttribute(PROVIDER_LABEL);
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public void setEnabled(boolean enable) {
- if( enable && !enabled ) {
- enabled = true;
- if(getDelegate() != null ) getDelegate().enable();
- } else if( !enable && enabled ) {
- enabled = false;
- if(getDelegate() != null ) getDelegate().disable();
- }
- }
-
- public boolean supports(IServer server) {
- return getDelegate() == null ? false : getDelegate().supports(server);
- }
-
- public int getWeight() {
- return weight;
- }
-
- public void setWeight(int weight) {
- this.weight = weight;
- }
-
- public void dispose() {
- if( getDelegate() != null )
- getDelegate().dispose();
- if( icon != null && iconDescriptor != null )
- icon.dispose();
-
- Preferences prefs = JBossServerUIPlugin.getDefault().getPluginPreferences();
-
- prefs.setValue(EXTENSION_ENABLED + getId(), enabled);
- prefs.setValue(EXTENSION_WEIGHT + getId(), weight);
- JBossServerUIPlugin.getDefault().savePluginPreferences();
- }
-}
Modified:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/SimplePropertiesViewExtension.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/SimplePropertiesViewExtension.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/SimplePropertiesViewExtension.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -36,7 +36,7 @@
* @author Rob Stryker <rob.stryker(a)redhat.com>
*
*/
-public abstract class SimplePropertiesViewExtension
+public abstract class SimplePropertiesViewExtension { /*
extends JBossServerViewExtension implements ISimplePropertiesHolder {
private SimplePropertiesPropertySheetPage propertiesSheet;
@@ -60,5 +60,5 @@
public abstract String[] getPropertyKeys(Object selected);
public abstract Properties getProperties(Object selected);
-
+*/
}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathActionProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathActionProvider.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathActionProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,271 @@
+package org.jboss.ide.eclipse.as.ui.views.server.extensions;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import
org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
+import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
+import org.jboss.ide.eclipse.as.ui.Messages;
+import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs;
+import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs.XPathCategoryDialog;
+import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs.XPathDialog;
+import
org.jboss.ide.eclipse.as.ui.views.server.extensions.XPathTreeContentProvider.ServerWrapper;
+
+public class XPathActionProvider extends CommonActionProvider {
+
+ private ICommonActionExtensionSite actionSite;
+ public Action newXPathCategoryAction, deleteXPathCategoryAction,
+ newXPathAction, editXPathAction, deleteXPathAction, editFileAction;
+ private XPathChangeValueAction xpathChangeValueAction;
+ private Object selectedNode;
+
+ public void init(ICommonActionExtensionSite aSite) {
+ super.init(aSite);
+ this.actionSite = aSite;
+ ICommonViewerSite site = aSite.getViewSite();
+ if( site instanceof ICommonViewerWorkbenchSite ) {
+ StructuredViewer v = aSite.getStructuredViewer();
+ if( v instanceof CommonViewer ) {
+ CommonViewer cv = (CommonViewer)v;
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
+ createActions(cv, wsSite.getSelectionProvider());
+ }
+ }
+ }
+
+ public void createActions(CommonViewer tableViewer, ISelectionProvider provider) {
+ Shell shell = tableViewer.getTree().getShell();
+ newXPathCategoryAction = new Action() {
+ public void run() {
+ XPathCategoryDialog d = new XPathCategoryDialog(Display
+ .getCurrent().getActiveShell(), getServer());
+ if (d.open() == Window.OK) {
+ XPathModel.getDefault().addCategory(getServer(),
+ d.getText());
+ XPathModel.getDefault().save(getServer());
+ refreshViewer();
+ }
+ }
+ };
+ newXPathCategoryAction.setText("New Category");
+
+ deleteXPathCategoryAction = new Action() {
+ public void run() {
+ int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
+ MessageBox messageBox = new MessageBox(Display.getCurrent()
+ .getActiveShell(), style);
+ messageBox
+ .setText(Messages.DescriptorXPathRemoveCategory + "?");
+ messageBox
+ .setMessage(Messages.DescriptorXPathRemoveCategoryDesc);
+ if (messageBox.open() == SWT.YES) {
+ XPathModel.getDefault().removeCategory(getServer(),
+ ((XPathCategory) selectedNode).getName());
+ XPathModel.getDefault().save(getServer());
+ refreshViewer();
+ }
+ }
+ };
+ deleteXPathCategoryAction
+ .setText(Messages.DescriptorXPathRemoveCategory);
+
+ newXPathAction = new Action() {
+ public void run() {
+ XPathCategory category = (XPathCategory) selectedNode;
+ if (category != null) {
+ String categoryName = category.getName();
+ XPathDialog d = new XPathDialog(Display.getCurrent()
+ .getActiveShell(), getServer(), categoryName);
+ if (d.open() == Window.OK) {
+ XPathCategory[] categoryList = XPathModel.getDefault()
+ .getCategories(getServer());
+ XPathCategory categoryItem = null;
+ for (int i = 0; i < categoryList.length; i++) {
+ if (categoryList[i].getName().equals(
+ category.getName()))
+ categoryItem = categoryList[i];
+ }
+ if (categoryItem != null) {
+ XPathQuery query = new XPathQuery(d.getName(),
+ XPathDialogs.getConfigFolder(getServer()),
+ null, d.getXpath(), d.getAttribute());
+ categoryItem.addQuery(query);
+ XPathModel.getDefault().save(getServer());
+ refreshViewer();
+ }
+ }
+ }
+ }
+ };
+ newXPathAction.setText(Messages.DescriptorXPathNewXPath);
+
+ editXPathAction = new Action() {
+ public void run() {
+ Object o = selectedNode;
+ if (o != null && o instanceof XPathQuery) {
+ XPathQuery original = (XPathQuery) o;
+ XPathCategory category = original.getCategory();
+
+ XPathDialog d = new XPathDialog(Display.getCurrent()
+ .getActiveShell(), getServer(), category.getName(),
+ original.getName());
+ d.setAttribute(original.getAttribute());
+ d.setXpath(original.getXpathPattern());
+
+ if (d.open() == Window.OK) {
+ original.setAttribute(d.getAttribute());
+ original.setXpathPattern(d.getXpath());
+ original.setName(d.getName());
+ category.save();
+ refreshViewer();
+ }
+ }
+ }
+ };
+ editXPathAction.setText(Messages.DescriptorXPathEditXPath);
+
+ deleteXPathAction = new Action() {
+ public void run() {
+ Object o = selectedNode;
+ if (o instanceof XPathQuery) {
+ XPathCategory cat = ((XPathQuery) o).getCategory();
+ cat.removeQuery((XPathQuery) o);
+ cat.save();
+ refreshViewer();
+ }
+ }
+ };
+ deleteXPathAction.setText(Messages.DescriptorXPathDeleteXPath);
+
+ editFileAction = new Action() {
+ public void run() {
+ try {
+ Object o = selectedNode;
+ Path p = null;
+ if (o instanceof XPathQuery
+ && ((XPathQuery) o).getResults().length == 1) {
+ o = (XPathFileResult) ((XPathQuery) o).getResults()[0];
+ }
+ if (o instanceof XPathFileResult) {
+ p = new Path(((XPathFileResult) o).getFileLocation());
+ } else if (o instanceof XPathResultNode) {
+ p = new Path(((XPathResultNode) o).getFileLocation());
+ }
+ if (p != null) {
+
+ IFileStore fileStore = EFS.getLocalFileSystem()
+ .getStore(p.removeLastSegments(1));
+ fileStore = fileStore.getChild(p.lastSegment());
+ IWorkbench wb = PlatformUI.getWorkbench();
+ IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
+ IWorkbenchPage page = win.getActivePage();
+
+ if (!fileStore.fetchInfo().isDirectory()
+ && fileStore.fetchInfo().exists()) {
+ try {
+ IDE.openEditorOnFileStore(page, fileStore);
+ } catch (PartInitException e) {
+ }
+ }
+ }
+ } catch (Exception exc) {
+ JBossServerUIPlugin.log("Error running edit file action",
+ exc);
+ }
+ }
+ };
+ editFileAction.setText("Edit File");
+
+ xpathChangeValueAction = new XPathChangeValueAction(shell, tableViewer, provider);
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ ICommonViewerSite site = actionSite.getViewSite();
+ IStructuredSelection selection = null;
+ if (site instanceof ICommonViewerWorkbenchSite) {
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite) site;
+ selection = (IStructuredSelection) wsSite.getSelectionProvider()
+ .getSelection();
+ Object first = selection.getFirstElement();
+ if (first == null)
+ return;
+
+ if (first instanceof ServerWrapper) {
+ menu.add(newXPathCategoryAction);
+ menu.add(new Separator());
+ return;
+ }
+
+ if (first instanceof XPathCategory) {
+ menu.add(newXPathAction);
+ menu.add(deleteXPathCategoryAction);
+ menu.add(new Separator());
+ return;
+ }
+
+ if (first instanceof XPathQuery) {
+ selectedNode = first;
+ menu.add(newXPathAction);
+ menu.add(editXPathAction);
+ menu.add(deleteXPathAction);
+ }
+
+ if( xpathChangeValueAction.shouldRun())
+ menu.add(xpathChangeValueAction);
+
+ if ((first instanceof XPathResultNode || first instanceof XPathFileResult)
+ || (first instanceof XPathQuery && ((XPathQuery) first)
+ .getResults().length == 1)) {
+ menu.add(editFileAction);
+ }
+ }
+ }
+
+ protected void refreshViewer() {
+ actionSite.getStructuredViewer().refresh();
+ }
+
+ protected IServer getServer() {
+ Object o = selectedNode;
+ if (o instanceof ServerWrapper)
+ return ((ServerWrapper) o).server;
+ if (o instanceof XPathCategory)
+ return ((XPathCategory) o).getServer();
+ if (o instanceof XPathQuery)
+ return ((XPathQuery) o).getCategory().getServer();
+ if (o instanceof XPathFileResult)
+ return ((XPathFileResult) o).getQuery().getCategory().getServer();
+ if (o instanceof XPathResultNode)
+ return ((XPathResultNode) o).getFile().getQuery().getCategory()
+ .getServer();
+ return null;
+ }
+
+}
\ No newline at end of file
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathChangeValueAction.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathChangeValueAction.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathChangeValueAction.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,364 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.views.server.extensions;
+
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TreeEditor;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.actions.SelectionProviderAction;
+import org.eclipse.ui.actions.TextActionHandler;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import
org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
+/**
+ * Action to rename a server.
+ */
+public class XPathChangeValueAction extends SelectionProviderAction {
+ protected CustomTreeEditor treeEditor;
+ protected Tree tree;
+ protected TreeViewer viewer;
+ protected Text textEditor;
+ protected Composite textEditorParent;
+ private TextActionHandler textActionHandler;
+ protected Shell shell;
+ protected int width = -1;
+ protected Rectangle newParentBounds;
+
+ protected boolean saving = false;
+
+ public XPathChangeValueAction(Shell shell, TreeViewer viewer, ISelectionProvider
selectionProvider) {
+ super(selectionProvider, "Change Value");
+ this.shell = shell;
+ this.viewer = viewer;
+ this.tree = viewer.getTree();
+ this.treeEditor = new CustomTreeEditor(tree);
+ }
+
+ public boolean shouldRun() {
+ if( getStructuredSelection().toArray().length > 1)
+ return false;
+
+ Object o = getStructuredSelection().getFirstElement();
+ if( XPathDecorator.getDecoration(o) != null )
+ return true;
+ return false;
+ }
+
+ public void run() {
+ queryNewValueInline(getStructuredSelection().getFirstElement());
+ }
+
+ /**
+ * On Mac the text widget already provides a border when it has focus, so
+ * there is no need to draw another one. The value of returned by this
+ * method is usd to control the inset we apply to the text field bound's in
+ * order to get space for drawing a border. A value of 1 means a one-pixel
+ * wide border around the text field. A negative value supresses the border.
+ * However, in M9 the system property
+ * "org.eclipse.swt.internal.carbon.noFocusRing" has been introduced as a
+ * temporary workaround for bug #28842. The existence of the property turns
+ * the native focus ring off if the widget is contained in a main window
+ * (not dialog). The check for the property should be removed after a final
+ * fix for #28842 has been provided.
+ */
+ private static int getCellEditorInset(Control c) {
+ // special case for MacOS X
+ if ("carbon".equals(SWT.getPlatform())) { //$NON-NLS-1$
+ if (System
+ .getProperty("org.eclipse.swt.internal.carbon.noFocusRing") == null ||
c.getShell().getParent() != null) { //$NON-NLS-1$
+ return -2; // native border
+ }
+ }
+ return 1; // one pixel wide black border
+ }
+
+ /**
+ * Get the Tree being edited.
+ *
+ * @returnTree
+ */
+ private Tree getTree() {
+ return tree;
+ }
+
+ private Composite createParent() {
+ Tree tree2 = getTree();
+ Composite result = new Composite(tree2, SWT.NONE);
+ TreeItem[] selectedItems = tree2.getSelection();
+ treeEditor.horizontalAlignment = SWT.LEFT;
+ treeEditor.grabHorizontal = true;
+ treeEditor.setEditor(result, selectedItems[0]);
+ return result;
+ }
+
+ /**
+ * Return the new name to be given to the target resource or
+ * <code>null<code>
+ * if the query was canceled. Rename the currently selected server using the table
editor.
+ * Continue the action when the user is done.
+ *
+ * @param server the server to rename
+ */
+ private void queryNewValueInline(final Object node) {
+
+ // Make sure text editor is created only once. Simply reset text
+ // editor when action is executed more than once. Fixes bug 22269
+ if (textEditorParent == null) {
+ createTextEditor(node);
+ }
+ textEditor.setText(XPathModel.getResultNode(node).getText());
+ // Open text editor with initial size
+ Point textSize = textEditor.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ textSize.x += textSize.y; // Add extra space for new characters
+ Point parentSize = textEditorParent.getSize();
+ int inset = getCellEditorInset(textEditorParent);
+ textEditor.setBounds(2, inset, Math.min(textSize.x, parentSize.x - 4),
+ parentSize.y - 2 * inset);
+ textEditor.setText(new XPathTreeLabelProvider().getText(node));
+ width = textEditor.getSize().x - 10;
+ textEditor.setText(XPathModel.getResultNode(node).getText());
+ treeEditor.layout();
+ textEditorParent.setVisible(true);
+ textEditor.setVisible(true);
+ textEditorParent.redraw();
+ textEditor.selectAll();
+ textEditor.setFocus();
+ }
+
+ /**
+ * Create the text editor widget.
+ *
+ * @param server the server to rename
+ */
+ private void createTextEditor(final Object node) {
+ // Create text editor parent. This draws a nice bounding rect
+ textEditorParent = createParent();
+ textEditorParent.setVisible(false);
+ final int inset = getCellEditorInset(textEditorParent);
+ if (inset > 0) {
+ textEditorParent.addListener(SWT.Paint, new Listener() {
+ public void handleEvent(Event e) {
+ Point textSize = textEditor.getSize();
+ Point parentSize = textEditorParent.getSize();
+ e.gc.drawRectangle(0, 0, Math.min(textSize.x + 4,
+ parentSize.x - 1), parentSize.y - 1);
+ }
+ });
+ }
+ // Create inner text editor
+ textEditor = new Text(textEditorParent, SWT.NONE);
+ textEditor.setFont(tree.getFont());
+ textEditorParent.setBackground(textEditor.getBackground());
+ textEditor.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event e) {
+ Point textSize = textEditor.computeSize(SWT.DEFAULT,
+ SWT.DEFAULT);
+ textSize.x += textSize.y; // Add extra space for new
+ // characters.
+ Point parentSize = textEditorParent.getSize();
+
+ textEditor.setBounds(2, inset, Math.min(textSize.x,
+ parentSize.x - 4), parentSize.y - 2 * inset);
+ textEditorParent.redraw();
+ }
+ });
+ textEditor.addListener(SWT.Traverse, new Listener() {
+ public void handleEvent(Event event) {
+
+ // Workaround for Bug 20214 due to extra
+ // traverse events
+ switch (event.detail) {
+ case SWT.TRAVERSE_ESCAPE:
+ // Do nothing in this case
+ disposeTextWidget();
+ event.doit = true;
+ event.detail = SWT.TRAVERSE_NONE;
+ break;
+ case SWT.TRAVERSE_RETURN:
+ saveChangesAndDispose(node);
+ event.doit = true;
+ event.detail = SWT.TRAVERSE_NONE;
+ break;
+ }
+ }
+ });
+ textEditor.addFocusListener(new FocusAdapter() {
+ public void focusLost(FocusEvent fe) {
+ saveChangesAndDispose(node);
+ }
+ });
+
+ if (textActionHandler != null) {
+ textActionHandler.addText(textEditor);
+ }
+ textEditor.setVisible(false);
+ }
+
+ /**
+ * Close the text widget and reset the editorText field.
+ */
+ protected void disposeTextWidget() {
+ width = -1;
+ if (textActionHandler != null)
+ textActionHandler.removeText(textEditor);
+
+ if (textEditorParent != null) {
+ textEditorParent.dispose();
+ textEditorParent = null;
+ textEditor = null;
+ treeEditor.setEditor(null, null);
+ }
+ }
+
+ /**
+ * Save the changes and dispose of the text widget.
+ *
+ * @param server the server to rename
+ */
+ protected void saveChangesAndDispose(Object node) {
+ if (saving == true)
+ return;
+ saving = true;
+
+ // Cache the resource to avoid selection loss since a selection of
+ // another item can trigger this method
+ final String newVal = textEditor.getText();
+ XPathResultNode itemToChange = XPathModel.getResultNode(node);
+ // if its unchanged do nothing
+ if( !itemToChange.getText().equals(newVal)) {
+ // set the text and add the document to the list of dirty ones
+ itemToChange.setText(newVal);
+ if( itemToChange.getDocument() != null ) {
+ itemToChange.saveDescriptor();
+ }
+ }
+
+ // Run this in an async to make sure that the operation that triggered
+ // this action is completed. Otherwise this leads to problems when the
+ // icon of the item being renamed is clicked (i.e., which causes the
+ // rename text widget to lose focus and trigger this method)
+ getTree().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ // Dispose the text widget regardless
+ disposeTextWidget();
+ // Ensure the Navigator tree has focus, which it may not if
+ // the text widget previously had focus
+ if (tree != null && !tree.isDisposed()) {
+ tree.setFocus();
+ viewer.refresh(getStructuredSelection().getFirstElement());
+ }
+ } finally {
+ saving = false;
+ }
+ }
+ });
+ }
+
+
+ protected class CustomTreeEditor extends TreeEditor {
+ public CustomTreeEditor(Tree tree) {
+ super(tree);
+ }
+
+ public void setItem (TreeItem item) {
+ super.setItem(item);
+ }
+
+ private boolean hadFocus = false;
+ public void layout () {
+ if (tree == null || tree.isDisposed()) return;
+ if (getItem() == null || getItem().isDisposed()) return;
+ int columnCount = tree.getColumnCount();
+ if (columnCount == 0 && getColumn() != 0) return;
+ if (columnCount > 0 && (getColumn() < 0 || getColumn() >=
columnCount)) return;
+
+ if (getEditor() == null || getEditor().isDisposed()) return;
+ if (getEditor().getVisible ()) {
+ hadFocus = getEditor().isFocusControl();
+ } // this doesn't work because
+ // resizing the column takes the focus away
+ // before we get here
+ getEditor().setBounds (customComputeBounds (superComputeBounds()));
+ if (hadFocus) {
+ if (getEditor() == null || getEditor().isDisposed()) return;
+ getEditor().setFocus ();
+ }
+ }
+
+ Rectangle customComputeBounds (Rectangle rect) {
+ Rectangle r = new Rectangle(rect.x + (width == -1 ? 0 : width), rect.y, rect.width,
rect.height);
+ return r;
+ }
+
+ Rectangle superComputeBounds() {
+ if (getItem() == null || getColumn() == -1 || getItem().isDisposed() ) return new
Rectangle(0, 0, 0, 0);
+ Rectangle cell = getItem().getBounds(getColumn());
+ Rectangle rect = getItem().getImageBounds(getColumn());
+ cell.x = rect.x + rect.width;
+ cell.width -= rect.width;
+ Rectangle area = tree.getClientArea();
+ if (cell.x < area.x + area.width) {
+ if (cell.x + cell.width > area.x + area.width) {
+ cell.width = area.x + area.width - cell.x;
+ }
+ }
+ Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, minimumHeight);
+
+ if (grabHorizontal) {
+ if (tree.getColumnCount() == 0) {
+ // Bounds of tree item only include the text area - stretch out to include
+ // entire client area
+ cell.width = area.x + area.width - cell.x;
+ }
+ editorRect.width = Math.max(cell.width, minimumWidth);
+ }
+
+ if (grabVertical) {
+ editorRect.height = Math.max(cell.height, minimumHeight);
+ }
+
+ if (horizontalAlignment == SWT.RIGHT) {
+ editorRect.x += cell.width - editorRect.width;
+ } else if (horizontalAlignment == SWT.LEFT) {
+ // do nothing - cell.x is the right answer
+ } else { // default is CENTER
+ editorRect.x += (cell.width - editorRect.width)/2;
+ }
+ // don't let the editor overlap with the +/- of the tree
+ editorRect.x = Math.max(cell.x, editorRect.x);
+
+ if (verticalAlignment == SWT.BOTTOM) {
+ editorRect.y += cell.height - editorRect.height;
+ } else if (verticalAlignment == SWT.TOP) {
+ // do nothing - cell.y is the right answer
+ } else { // default is CENTER
+ editorRect.y += (cell.height - editorRect.height)/2;
+ }
+ return editorRect;
+ }
+
+ }
+
+}
\ No newline at end of file
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathDecorator.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathDecorator.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathDecorator.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,38 @@
+package org.jboss.ide.eclipse.as.ui.views.server.extensions;
+
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import
org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
+
+public class XPathDecorator extends LabelProvider implements ILightweightLabelDecorator
{
+ public void decorate(Object element, IDecoration decoration) {
+ String decoration2 = getDecoration(element);
+ if( decoration2 != null ) {
+ decoration.addSuffix(decoration2);
+ }
+ }
+
+ public static String getDecoration(Object element) {
+ if( element instanceof XPathQuery) {
+ XPathResultNode[] nodes = XPathModel.getResultNodes((XPathQuery)element);
+ if(nodes.length == 1 ) {
+ return " " + nodes[0].getText();
+ }
+ }
+
+ if( element instanceof XPathFileResult ) {
+ XPathResultNode[] nodes = ((XPathFileResult)element).getChildren();
+ if( nodes.length == 1 )
+ return " " + nodes[0].getText();
+ }
+
+ if( element instanceof XPathResultNode ) {
+ return ((XPathResultNode)element).getText();
+ }
+ return null;
+ }
+}
\ No newline at end of file
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathTreeContentProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathTreeContentProvider.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathTreeContentProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,135 @@
+package org.jboss.ide.eclipse.as.ui.views.server.extensions;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import
org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
+
+public class XPathTreeContentProvider implements ITreeContentProvider {
+
+ public static class DelayProxy {
+ }
+
+ public static final DelayProxy LOADING = new DelayProxy();
+
+ private Viewer viewer;
+ private ArrayList<XPathCategory> loading = new ArrayList<XPathCategory>();
+
+ public class ServerWrapper {
+ public IServer server;
+
+ public ServerWrapper(IServer server) {
+ this.server = server;
+ }
+
+ public int hashCode() {
+ return server.getId().hashCode();
+ }
+
+ public boolean equals(Object other) {
+ return other instanceof ServerWrapper
+ && ((ServerWrapper) other).server.getId().equals(
+ server.getId());
+ }
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement == null)
+ return new Object[] {};
+ if (parentElement instanceof IServer) {
+ return new Object[] { new ServerWrapper((IServer) parentElement) };
+ }
+
+ if (parentElement instanceof ServerWrapper) {
+ return XPathModel.getDefault().getCategories(
+ ((ServerWrapper) parentElement).server);
+ }
+
+ if (parentElement instanceof XPathCategory) {
+ if (((XPathCategory) parentElement).isLoaded())
+ return ((XPathCategory) parentElement).getQueries();
+
+ if (!loading.contains((XPathCategory) parentElement))
+ launchLoad((XPathCategory) parentElement);
+
+ return new Object[] { LOADING };
+ }
+
+ // we're the named element (JNDI)
+ if (parentElement instanceof XPathQuery) {
+ if (XPathModel.getResultNodes((XPathQuery) parentElement).length == 1) {
+ return new Object[0];
+ } else {
+ return ((XPathQuery) parentElement).getResults();
+ }
+ }
+
+ // we're a file node (blah.xml)
+ if (parentElement instanceof XPathFileResult) {
+ if (((XPathFileResult) parentElement).getChildren().length == 1)
+ return new Object[0];
+ return ((XPathFileResult) parentElement).getChildren();
+ }
+
+ if (parentElement instanceof XPathResultNode) {
+ return new Object[0];
+ }
+
+ return new Object[0];
+ }
+
+ protected void launchLoad(final XPathCategory cat) {
+ new Job("Loading XPaths") {
+ protected IStatus run(IProgressMonitor monitor) {
+ loading.add(cat);
+ XPathQuery[] queries = cat.getQueries();
+ XPathFileResult[] results;
+ for (int i = 0; i < queries.length; i++) {
+ results = queries[i].getResults();
+ for (int j = 0; j < results.length; j++) {
+ results[j].getChildren();
+ }
+ }
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ loading.remove(cat);
+ ((StructuredViewer) viewer).refresh(cat.getServer());
+ }
+ });
+ return Status.OK_STATUS;
+ }
+ }.schedule(200);
+ }
+
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length > 0 ? true : false;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return new Object[0];
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ this.viewer = viewer;
+ }
+}
\ No newline at end of file
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathTreeLabelProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathTreeLabelProvider.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/XPathTreeLabelProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,63 @@
+package org.jboss.ide.eclipse.as.ui.views.server.extensions;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+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.descriptors.XPathCategory;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import
org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
+import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
+import
org.jboss.ide.eclipse.as.ui.views.server.extensions.XPathTreeContentProvider.ServerWrapper;
+
+public class XPathTreeLabelProvider extends LabelProvider {
+ private Image rootImage;
+ public XPathTreeLabelProvider() {
+ super();
+ ImageDescriptor des =
ImageDescriptor.createFromURL(JBossServerUIPlugin.getDefault().getBundle().getEntry("icons/XMLFile.gif"));
+ rootImage = des.createImage();
+ }
+
+ public Image getImage(Object element) {
+ if( element instanceof ServerWrapper )
+ return rootImage;
+
+ if (element instanceof XPathCategory)
+ return PlatformUI.getWorkbench().getSharedImages().getImage(
+ ISharedImages.IMG_OBJ_FOLDER);
+
+ return null;
+ }
+
+ public String getText(Object element) {
+ if( element instanceof ServerWrapper )
+ return "XML Configuration";
+ if( element == XPathTreeContentProvider.LOADING )
+ return "Loading...";
+
+ if (element instanceof XPathCategory)
+ return ((XPathCategory) element).getName();
+
+ if( element instanceof XPathQuery )
+ return ((XPathQuery)element).getName();
+
+ if( element instanceof XPathFileResult )
+ return ((XPathFileResult)element).getFileLocation();
+
+ return "";
+ }
+
+ public XPathResultNode[] getResultNodes(XPathQuery query) {
+ ArrayList<XPathResultNode> l = new ArrayList<XPathResultNode>();
+ XPathFileResult[] files = query.getResults();
+ for( int i = 0; i < files.length; i++ ) {
+ l.addAll(Arrays.asList(files[i].getChildren()));
+ }
+ return l.toArray(new XPathResultNode[l.size()]);
+ }
+}
Modified:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/DescriptorXPathViewProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/DescriptorXPathViewProvider.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/DescriptorXPathViewProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -21,50 +21,14 @@
*/
package org.jboss.ide.eclipse.as.ui.views.server.providers;
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory;
-import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult;
-import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
-import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
-import
org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
-import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
-import org.jboss.ide.eclipse.as.ui.Messages;
-import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs;
-import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs.XPathCategoryDialog;
-import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs.XPathDialog;
-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.providers.descriptors.DescriptorXPathPropertySheetPage;
/**
*
* @author Rob Stryker <rob.stryker(a)redhat.com>
*
*/
-public class DescriptorXPathViewProvider extends JBossServerViewExtension {
+public class DescriptorXPathViewProvider { /*
+extends JBossServerViewExtension {
private XPathTreeContentProvider contentProvider;
private XPathTreeLabelProvider labelProvider;
@@ -323,5 +287,6 @@
}
}
}
+ */
}
Modified:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/EventLogViewProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/EventLogViewProvider.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/EventLogViewProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -21,57 +21,15 @@
*/
package org.jboss.ide.eclipse.as.ui.views.server.providers;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogRoot;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.IEventLogListener;
-import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
-import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
-import org.jboss.ide.eclipse.as.ui.dialogs.ShowStackTraceDialog;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.IEventLogLabelProvider;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.JBossServerViewExtension;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.PropertySheetFactory;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerViewProvider;
-import
org.jboss.ide.eclipse.as.ui.views.server.extensions.PropertySheetFactory.ISimplePropertiesHolder;
-import
org.jboss.tools.as.wst.server.ui.views.server.preferencepages.ViewProviderPreferenceComposite;
-
/**
*
* @author Rob Stryker <rob.stryker(a)redhat.com>
*
*/
-public class EventLogViewProvider extends JBossServerViewExtension implements
IEventLogListener, ISimplePropertiesHolder {
+public class EventLogViewProvider {
+ /*
+ extends JBossServerViewExtension implements IEventLogListener, ISimplePropertiesHolder
{
public static final String SHOW_TIMESTAMP =
"org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.showTimestamp";
public static final String GROUP_BY_CATEGORY =
"org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.groupByCategory";
@@ -323,11 +281,11 @@
return new Properties();
}
- public ViewProviderPreferenceComposite createPreferenceComposite(Composite parent) {
+ public EventLogPreferenceComposite createPreferenceComposite(Composite parent) {
return new EventLogPreferenceComposite(parent);
}
- protected class EventLogPreferenceComposite extends ViewProviderPreferenceComposite {
+ protected class EventLogPreferenceComposite extends Composite {
private Button newestFirst, oldestFirst, showTime, sort;
private Group firstGroup;
public EventLogPreferenceComposite(Composite parent) {
@@ -451,5 +409,5 @@
EventLogModel.disableLogging();
}
-
+*/
}
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/InactiveExtensionViewProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/InactiveExtensionViewProvider.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/InactiveExtensionViewProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -1,157 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.ui.views.server.providers;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
-import org.jboss.ide.eclipse.as.ui.Messages;
-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.tools.as.wst.server.ui.ToolsServerUICore;
-import org.jboss.tools.as.wst.server.ui.views.server.JBossServerView;
-
-/**
- *
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public class InactiveExtensionViewProvider extends JBossServerViewExtension {
-
- private ITreeContentProvider contentProvider;
- private LabelProvider labelProvider;
- public InactiveExtensionViewProvider() {
- contentProvider = new InactiveContentProvider();
- labelProvider = new InactiveLabelProvider();
- }
-
-
- public class InactiveContentProvider implements ITreeContentProvider {
-
- public Object[] getChildren(Object parentElement) {
- if( parentElement == provider ) {
- ServerViewProvider[] allExtensions = ToolsServerUICore.getAllServerViewProviders();
- ArrayList<ServerViewProvider> list = new
ArrayList<ServerViewProvider>();
- for( int i = 0; i < allExtensions.length; i++ ) {
- if( !allExtensions[i].isEnabled()) {
- list.add(allExtensions[i]);
- }
- }
- ServerViewProvider[] retval = new ServerViewProvider[list.size()];
- list.toArray(retval);
- return retval;
- }
- return new Object[0];
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0 ? true : false;
- }
-
- public Object[] getElements(Object inputElement) {
- // Unused
- return null;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // Do nothing... don't care about which server is selected
- }
-
- }
-
- public class InactiveLabelProvider extends LabelProvider {
- public Image getImage(Object element) {
- if( element instanceof ServerViewProvider ) {
- return ((ServerViewProvider)element).getImage();
- }
- return null;
- }
-
- public String getText(Object element) {
- if( element instanceof ServerViewProvider ) {
- return ((ServerViewProvider)element).getName();
- }
- return element == null ? "" : element.toString();
- }
-
- }
-
- public void fillContextMenu(Shell shell, IMenuManager menu, Object[] selection) {
- final Object[] selected = selection;
- boolean allProviders = true;
- for( int i = 0; i < selected.length; i++ )
- allProviders = allProviders && selected[i] instanceof ServerViewProvider
- && selected[i] != this.provider;
-
- if( allProviders) {
- Action act = new Action() {
- public void run() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- for( int i = 0; i < selected.length; i++ ) {
- ((ServerViewProvider)selected[i]).setEnabled(true);
- ((ServerViewProvider)selected[i]).getDelegate().getContentProvider().
- inputChanged(JBossServerView.getDefault().getServerFrame().getViewer(), null,
JBossServerView.getDefault().getSelectedServer());
- }
- JBossServerView.getDefault().getExtensionFrame().getViewer().refresh();
- }
- } );
- }
- };
- act.setText(Messages.InactiveCategoriesReEnable);
- menu.add(act);
- }
- }
-
- public void fillContextMenu(Shell shell, IMenuManager menu, Object selection) {
- fillContextMenu(shell, menu, new Object[] { selection });
- }
-
- public ITreeContentProvider getContentProvider() {
- return contentProvider;
- }
-
- public LabelProvider getLabelProvider() {
- return labelProvider;
- }
-
- public IPropertySheetPage getPropertySheetPage() {
- return null;
- }
-
-}
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -1,295 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.ui.views.server.providers;
-
-import java.util.ArrayList;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.server.core.IModule;
-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.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerEvent;
-import org.eclipse.wst.server.core.ServerUtil;
-import org.eclipse.wst.server.core.internal.PublishServerJob;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.ui.ServerUICore;
-import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
-import org.jboss.ide.eclipse.as.core.server.UnitedServerListener;
-import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
-import org.jboss.ide.eclipse.as.core.util.ModuleUtil;
-import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
-import org.jboss.ide.eclipse.as.ui.Messages;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerViewProvider;
-import
org.jboss.ide.eclipse.as.ui.views.server.extensions.SimplePropertiesViewExtension;
-
-/**
- *
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public class ModuleViewProvider extends SimplePropertiesViewExtension {
-
- private ModuleContentProvider contentProvider;
- private ModuleLabelProvider labelProvider;
- private Action deleteModuleAction, fullPublishModuleAction,
incrementalPublishModuleAction;
- private ModuleServer[] selection;
- private IServerLifecycleListener serverResourceListener;
- private IServerListener serverListener;
-
- public ModuleViewProvider() {
- contentProvider = new ModuleContentProvider();
- labelProvider = new ModuleLabelProvider();
- createActions();
- addListeners();
- }
-
- private void createActions() {
- deleteModuleAction = new Action() {
- public void run() {
- if (MessageDialog.openConfirm(new Shell(), Messages.ServerDialogHeading,
Messages.DeleteModuleConfirm)) {
- Thread t = new Thread() { public void run() {
- try {
- if( selection.length > 0 && selection[0].server != null ) {
- IServer server = selection[0].server;
- ArrayList topModsToRemove = new ArrayList();
- IModule topModTmp;
- for( int i = 0; i < selection.length; i++ ) {
- if( !topModsToRemove.contains(selection[i].module[0]))
- topModsToRemove.add(selection[i].module[0]);
- }
- IServerWorkingCopy serverWC = server.createWorkingCopy();
- IModule[] modsToRemove =
- (IModule[]) topModsToRemove.toArray(new IModule[topModsToRemove.size()]);
- ServerUtil.modifyModules(serverWC, new IModule[0], modsToRemove, new
NullProgressMonitor());
- IServer server2 = serverWC.save(true, null);
- new PublishServerJob(server2, IServer.PUBLISH_INCREMENTAL, true).schedule();
- }
- } catch (CoreException e) {
- // ignore
- }
- }};
- t.start();
- }
- }
- };
- deleteModuleAction.setText(Messages.DeleteModuleText);
- deleteModuleAction.setDescription(Messages.DeleteModuleDescription);
- deleteModuleAction.setImageDescriptor(JBossServerUISharedImages.getImageDescriptor(JBossServerUISharedImages.UNPUBLISH_IMAGE));
-
- fullPublishModuleAction = new Action() {
- public void run() {
- actionPublish(IServer.PUBLISH_STATE_FULL);
- }
- };
- fullPublishModuleAction.setText(Messages.FullPublishModuleText);
- fullPublishModuleAction.setDescription(Messages.PublishModuleDescription);
- fullPublishModuleAction.setImageDescriptor(JBossServerUISharedImages.getImageDescriptor(JBossServerUISharedImages.PUBLISH_IMAGE));
-
-
- incrementalPublishModuleAction = new Action() {
- public void run() {
- actionPublish(IServer.PUBLISH_STATE_INCREMENTAL);
- }
- };
- incrementalPublishModuleAction.setText(Messages.IncrementalPublishModuleText);
- incrementalPublishModuleAction.setDescription(Messages.PublishModuleDescription);
- incrementalPublishModuleAction.setImageDescriptor(JBossServerUISharedImages.getImageDescriptor(JBossServerUISharedImages.PUBLISH_IMAGE));
-}
-
- protected void actionPublish(int type) {
- // Assumption: Anything selected is already on the server, or it wouldnt be in the
view.
- if( selection != null && selection.length > 0 ) {
- Server s = ((Server)selection[0].server);
- for( int i = 0; i < selection.length; i++ ) {
- IModule[] mod = selection[i].module;
- s.setModulePublishState(mod, type);
- ArrayList<IModule[]> allChildren = ModuleUtil.getDeepChildren(s, mod);
- for( int j = 0; j < allChildren.size(); j++ ) {
- s.setModulePublishState((IModule[])allChildren.get(j), type);
- }
- }
- new PublishServerJob(s, IServer.PUBLISH_INCREMENTAL, true).schedule();
- }
- }
-
-
- public void fillContextMenu(Shell shell, IMenuManager menu, Object[] selection) {
- if( allAre(selection, ModuleServer.class)) {
- ModuleServer[] ms = new ModuleServer[selection.length];
- for( int i = 0; i < selection.length; i++ )
- ms[i] = (ModuleServer)selection[i];
- this.selection = ms;
- menu.add(deleteModuleAction);
- menu.add(fullPublishModuleAction);
- menu.add(incrementalPublishModuleAction);
- }
- }
-
- public ITreeContentProvider getContentProvider() {
- return contentProvider;
- }
-
- public LabelProvider getLabelProvider() {
- return labelProvider;
- }
-
- public boolean supports(IServer server) {
- return true;
- }
-
-
- class ModuleContentProvider implements ITreeContentProvider {
-
- private IServer input;
-
- public Object[] getChildren(Object parentElement) {
-
- if (parentElement instanceof ModuleServer) {
- ModuleServer ms = (ModuleServer) parentElement;
- try {
- IModule[] children = ms.server.getChildModules(ms.module, null);
- int size = children.length;
- ModuleServer[] ms2 = new ModuleServer[size];
- for (int i = 0; i < size; i++) {
- int size2 = ms.module.length;
- IModule[] module = new IModule[size2 + 1];
- System.arraycopy(ms.module, 0, module, 0, size2);
- module[size2] = children[i];
- ms2[i] = new ModuleServer(ms.server, module);
- }
- return ms2;
- } catch (Exception e) {
- return new Object[]{};
- }
- }
-
-
-
- if( parentElement instanceof ServerViewProvider && input != null ) {
- IModule[] modules = input.getModules();
- int size = modules.length;
- ModuleServer[] ms = new ModuleServer[size];
- for (int i = 0; i < size; i++) {
- ms[i] = new ModuleServer(input, new IModule[] { modules[i] });
- }
- return ms;
- }
- return new Object[] {};
- }
-
- public Object getParent(Object element) {
- if( element instanceof ModuleServer ) {
- return provider;
- }
-
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0 ? true : false;
- }
-
- // unused
- public Object[] getElements(Object inputElement) {
- return null;
- }
-
- public void dispose() {
- // TODO Auto-generated method stub
-
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- input = (IServer)newInput;
- }
-
- public IServer getServer() {
- return input;
- }
- }
-
- class ModuleLabelProvider extends LabelProvider {
- public String getText(Object obj) {
- if( obj instanceof ModuleServer ) {
- ModuleServer ms = (ModuleServer)obj;
- int size = ms.module.length;
- return ms.module[size - 1].getName();
- }
-
- return "unknown";
- }
- public Image getImage(Object obj) {
- if( obj instanceof ModuleServer ) {
- ModuleServer ms = (ModuleServer)obj;
- int size = ms.module.length;
- return ServerUICore.getLabelProvider().getImage(ms.module[ms.module.length - 1]);
- }
- return null;
- }
-
- }
-
-
- public String[] getPropertyKeys(Object selected) {
- return new String[] { Messages.ModulePropertyType, Messages.ModulePropertyProject,
Messages.ModulePropertyName };
- }
-
- public Properties getProperties(Object selected) {
- Properties props = new Properties();
- if( selected != null && selected instanceof ModuleServer) {
- ModuleServer moduleServer = ((ModuleServer)selected);
- IModule mod = moduleServer.module[moduleServer.module.length-1];
- if( mod != null && mod.getProject() != null ) {
- props.setProperty(Messages.ModulePropertyType, mod.getModuleType().getId());
- props.setProperty(Messages.ModulePropertyProject, mod.getProject().getName());
- props.setProperty(Messages.ModulePropertyProject, mod.getName());
- }
- }
- return props;
- }
-
- private void addListeners() {
- UnitedServerListenerManager.getDefault().addListener(new UnitedServerListener() {
- public void serverChanged(ServerEvent event) {
- int eventKind = event.getKind();
- if ((eventKind & ServerEvent.MODULE_CHANGE) != 0) {
- // module change event
- if ((eventKind & ServerEvent.STATE_CHANGE) != 0 || (eventKind &
ServerEvent.PUBLISH_STATE_CHANGE) != 0) {
- refreshViewer();
- }
- }
- }
- });
- }
-}
Modified:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/descriptors/DescriptorXPathPropertySheetPage.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/descriptors/DescriptorXPathPropertySheetPage.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/descriptors/DescriptorXPathPropertySheetPage.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -38,7 +38,6 @@
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.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
@@ -61,14 +60,13 @@
import
org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
import org.jboss.ide.eclipse.as.ui.Messages;
import org.jboss.ide.eclipse.as.ui.views.server.providers.DescriptorXPathViewProvider;
-import
org.jboss.tools.as.wst.server.ui.views.server.ExtensionTableViewer.ContentWrapper;
/**
*
* @author Rob Stryker <rob.stryker(a)redhat.com>
*
*/
-public class DescriptorXPathPropertySheetPage implements IPropertySheetPage {
+public class DescriptorXPathPropertySheetPage { /*implements IPropertySheetPage {
private TreeViewer xpathTreeViewer;
private TreeColumn column, column2;//, column3;
private Tree xpathTree;
@@ -141,9 +139,6 @@
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
//input = null;
Object element = ((IStructuredSelection)selection).getFirstElement();
- if( element instanceof ContentWrapper ) {
- element = ((ContentWrapper)element).getElement();
- }
if( element != null //)&& element != provider.getActiveCategory()
&& element instanceof XPathCategory) {
// show loading
@@ -426,5 +421,5 @@
}
return null;
}
-
+*/
}
Modified:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/descriptors/XPathPropertyContentProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/descriptors/XPathPropertyContentProvider.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/descriptors/XPathPropertyContentProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -27,7 +27,6 @@
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
import
org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerViewProvider;
/**
*
@@ -57,10 +56,6 @@
return ((XPathQuery)parentElement).getResults();
}
}
-
- // re-creates it from scratch... hrmm
- if( parentElement instanceof ServerViewProvider )
- return new Object[] {"ERROR"}; //XPathModel.getDefault().getCategories()
return new Object[0];
}
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ExtensionManager.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ExtensionManager.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ExtensionManager.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -1,79 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.tools.as.wst.server.ui;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerViewProvider;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class ExtensionManager {
- private static ExtensionManager instance;
- public static ExtensionManager getDefault() {
- if( instance == null )
- instance = new ExtensionManager();
- return instance;
- }
-
- private ServerViewProvider[] serverViewExtensions;
- public ServerViewProvider[] getAllServerViewProviders() {
- if( serverViewExtensions == null )
- loadAllServerViewProviders();
- Arrays.sort(serverViewExtensions, new Comparator() {
- public int compare(Object arg0, Object arg1) {
- if( arg0 instanceof ServerViewProvider && arg1 instanceof ServerViewProvider)
{
- return ((ServerViewProvider)arg0).getWeight() -
((ServerViewProvider)arg1).getWeight();
- }
- return 0;
- }
- });
- return serverViewExtensions;
- }
- private void loadAllServerViewProviders() {
- // Create the extensions from the registry
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] elements =
registry.getConfigurationElementsFor(JBossServerUIPlugin.PLUGIN_ID,
"ServerViewExtension");
- ArrayList list = new ArrayList();
- for( int i = 0; i < elements.length; i++ ) {
- try {
- list.add(new ServerViewProvider(elements[i]));
- } catch(Exception e) {
- String msg = "Server View Provider (" +
elements[i].getAttribute(ServerViewProvider.ID_LABEL) + ") failed to load";
- IStatus status = new Status(IStatus.ERROR, JBossServerUIPlugin.PLUGIN_ID, msg, e);
- JBossServerUIPlugin.getDefault().getLog().log(status);
- }
- }
- serverViewExtensions = (ServerViewProvider[]) list.toArray(new
ServerViewProvider[list.size()]);
- }
-
-}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,297 @@
+package org.jboss.tools.as.wst.server.ui;
+
+import java.util.Iterator;
+
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionManager;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.bindings.TriggerSequence;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.keys.IBindingService;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerPort;
+import org.eclipse.wst.server.core.model.ServerDelegate;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import org.eclipse.wst.server.ui.internal.Trace;
+import org.eclipse.wst.server.ui.internal.actions.NewServerWizardAction;
+import org.eclipse.wst.server.ui.internal.view.servers.CopyAction;
+import org.eclipse.wst.server.ui.internal.view.servers.DeleteAction;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleSloshAction;
+import org.eclipse.wst.server.ui.internal.view.servers.MonitorServerPortAction;
+import org.eclipse.wst.server.ui.internal.view.servers.OpenAction;
+import org.eclipse.wst.server.ui.internal.view.servers.PasteAction;
+import org.eclipse.wst.server.ui.internal.view.servers.PropertiesAction;
+import org.eclipse.wst.server.ui.internal.view.servers.PublishAction;
+import org.eclipse.wst.server.ui.internal.view.servers.PublishCleanAction;
+import org.eclipse.wst.server.ui.internal.view.servers.RemoveModuleAction;
+import org.eclipse.wst.server.ui.internal.view.servers.RenameAction;
+import org.eclipse.wst.server.ui.internal.view.servers.RestartModuleAction;
+import org.eclipse.wst.server.ui.internal.view.servers.ShowInConsoleAction;
+import org.eclipse.wst.server.ui.internal.view.servers.ShowInDebugAction;
+import org.eclipse.wst.server.ui.internal.view.servers.StartAction;
+import org.eclipse.wst.server.ui.internal.view.servers.StartModuleAction;
+import org.eclipse.wst.server.ui.internal.view.servers.StopAction;
+import org.eclipse.wst.server.ui.internal.view.servers.StopModuleAction;
+
+public class ServerActionProvider extends CommonActionProvider {
+ private ICommonActionExtensionSite actionSite;
+ private Clipboard clipboard;
+ public ServerActionProvider() {
+ super();
+ }
+
+ public void init(ICommonActionExtensionSite aSite) {
+ super.init(aSite);
+ this.actionSite = aSite;
+ ICommonViewerSite site = aSite.getViewSite();
+ if( site instanceof ICommonViewerWorkbenchSite ) {
+ StructuredViewer v = aSite.getStructuredViewer();
+ if( v instanceof CommonViewer ) {
+ CommonViewer cv = (CommonViewer)v;
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
+ addListeners(cv);
+ makeServerActions(cv, wsSite.getSelectionProvider());
+ }
+ }
+ }
+
+
+ // actions on a server
+ protected Action[] actions;
+ protected Action actionModifyModules;
+ protected Action openAction, showInConsoleAction, showInDebugAction, propertiesAction,
monitorPropertiesAction;
+ protected Action copyAction, pasteAction, deleteAction, renameAction;
+ protected Action noneAction = new Action(Messages.dialogMonitorNone) {
+ // dummy action
+ };
+
+ private void addListeners(CommonViewer tableViewer) {
+ tableViewer.addOpenListener(new IOpenListener() {
+ public void open(OpenEvent event) {
+ try {
+ IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+ Object data = sel.getFirstElement();
+ if (!(data instanceof IServer))
+ return;
+ IServer server = (IServer) data;
+ ServerUIPlugin.editServer(server);
+ } catch (Exception e) {
+ Trace.trace(Trace.SEVERE, "Could not open server", e);
+ }
+ }
+ });
+ }
+
+ private void makeServerActions(CommonViewer tableViewer, ISelectionProvider provider) {
+ clipboard = new Clipboard(tableViewer.getTree().getDisplay());
+ Shell shell = tableViewer.getTree().getShell();
+
+ actions = new Action[6];
+ // create the start actions
+ actions[0] = new StartAction(shell, provider, ILaunchManager.DEBUG_MODE);
+ actions[1] = new StartAction(shell, provider, ILaunchManager.RUN_MODE);
+ actions[2] = new StartAction(shell, provider, ILaunchManager.PROFILE_MODE);
+
+ // create the stop action
+ actions[3] = new StopAction(shell, provider);
+
+ // create the publish actions
+ actions[4] = new PublishAction(shell, provider);
+ actions[5] = new PublishCleanAction(shell, provider);
+
+ // create the open action
+ openAction = new OpenAction(provider);
+
+// // create copy, paste, and delete actions
+ pasteAction = new PasteAction(shell, provider, clipboard);
+ copyAction = new CopyAction(provider, clipboard, pasteAction);
+ deleteAction = new DeleteAction(shell, provider);
+ renameAction = new RenameAction(shell, tableViewer, provider);
+
+ // create the other actions
+ actionModifyModules = new ModuleSloshAction(shell, provider);
+ showInConsoleAction = new ShowInConsoleAction(provider);
+ showInDebugAction = new ShowInDebugAction(provider);
+
+ // create the properties action
+ propertiesAction = new PropertiesAction(shell, provider);
+ monitorPropertiesAction = new PropertiesAction(shell,
"org.eclipse.wst.server.ui.properties.monitor", provider);
+ }
+
+ public void fillActionBars(IActionBars actionBars) {
+ actionBars.setGlobalActionHandler("org.eclipse.wst.server.debug",
actions[0]);
+ actionBars.setGlobalActionHandler("org.eclipse.wst.server.run", actions[1]);
+ actionBars.setGlobalActionHandler("org.eclipse.wst.server.stop",
actions[3]);
+ actionBars.setGlobalActionHandler("org.eclipse.wst.server.publish",
actions[4]);
+ actionBars.setGlobalActionHandler("org.eclipse.ui.navigator.Open",
openAction);
+ actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), propertiesAction);
+ actionBars.updateActionBars();
+ actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
+ actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
+ actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
+ actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
+
+ IContributionManager cm = actionBars.getToolBarManager();
+ cm.removeAll();
+
+ for (int i = 0; i < actions.length - 1; i++)
+ cm.add(actions[i]);
+ }
+
+ private static void fillNewContextMenu(Shell shell, ISelection selection, IMenuManager
menu) {
+ IAction newServerAction = new NewServerWizardAction();
+ newServerAction.setText(Messages.actionNewServer);
+ menu.add(newServerAction);
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ ICommonViewerSite site = actionSite.getViewSite();
+ IStructuredSelection selection = null;
+ Shell shell = actionSite.getViewSite().getShell();
+ if( site instanceof ICommonViewerWorkbenchSite ) {
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
+ selection = (IStructuredSelection) wsSite.getSelectionProvider().getSelection();
+ }
+
+ IServer server = null;
+ IModule[] module = null;
+ if (selection != null && !selection.isEmpty()) {
+ Iterator iterator = selection.iterator();
+ Object obj = iterator.next();
+ if (obj instanceof IServer)
+ server = (IServer) obj;
+ if (obj instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) obj;
+ server = ms.server;
+ module = ms.module;
+ }
+ if (iterator.hasNext()) {
+ server = null;
+ module = null;
+ }
+ }
+
+ // new action
+ MenuManager newMenu = new MenuManager(Messages.actionNew);
+ fillNewContextMenu(null, selection, newMenu);
+ menu.add(newMenu);
+
+ // open action
+ if (server != null && module == null) {
+ menu.add(openAction);
+
+ String text = Messages.actionShowIn;
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ final IBindingService bindingService = (IBindingService) workbench
+ .getAdapter(IBindingService.class);
+ final TriggerSequence[] activeBindings = bindingService
+ .getActiveBindingsFor("org.eclipse.ui.navigate.showInQuickMenu");
+ if (activeBindings.length > 0) {
+ text += "\t" + activeBindings[0].format();
+ }
+
+ MenuManager showInMenu = new MenuManager(text);
+ showInMenu.add(showInConsoleAction);
+ showInMenu.add(showInDebugAction);
+ //IActionBars actionBars = getViewSite().getActionBars();
+ //actionBars.setGlobalActionHandler("group.show", showInMenu);
+ menu.add(showInMenu);
+ menu.add(new Separator());
+ } else
+ menu.add(new Separator());
+
+ if (server != null) {
+ if (module == null) {
+ menu.add(copyAction);
+ menu.add(pasteAction);
+ menu.add(deleteAction);
+ menu.add(renameAction);
+ } else if (module.length == 1)
+ menu.add(new RemoveModuleAction(shell, server, module[0]));
+ menu.add(new Separator());
+ }
+
+ if (server != null && module == null) {
+ // server actions
+ for (int i = 0; i < actions.length; i++)
+ menu.add(actions[i]);
+
+ menu.add(new Separator());
+ menu.add(actionModifyModules);
+
+ // monitor
+ if (server.getServerType() != null) {
+ final MenuManager menuManager = new MenuManager(Messages.actionMonitor);
+
+ final IServer server2 = server;
+ final Shell shell2 = shell;
+ menuManager.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ menuManager.removeAll();
+ if (server2.getAdapter(ServerDelegate.class) != null) {
+ ServerPort[] ports = server2.getServerPorts(null);
+ if (ports != null) {
+ int size = ports.length;
+ for (int i = 0; i < size; i++) {
+ if (!ports[i].isAdvanced())
+ menuManager.add(new MonitorServerPortAction(shell2, server2, ports[i]));
+ }
+ }
+ }
+
+ if (menuManager.isEmpty())
+ menuManager.add(noneAction);
+
+ menuManager.add(new Separator());
+ menuManager.add(monitorPropertiesAction);
+ }
+ });
+
+ // add an initial menu item so that the menu appears correctly
+ noneAction.setEnabled(false);
+ menuManager.add(noneAction);
+ menu.add(menuManager);
+ }
+ }
+
+ if (server != null && module != null) {
+ menu.add(new Separator());
+ menu.add(new StartModuleAction(server, module));
+ menu.add(new StopModuleAction(server, module));
+ menu.add(new RestartModuleAction(server, module));
+ }
+
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));
+
+ if (server != null) {
+ menu.add(new Separator());
+ menu.add(propertiesAction);
+ }
+ }
+}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerContentProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerContentProvider.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerContentProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,331 @@
+package org.jboss.tools.as.wst.server.ui;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IPublishListener;
+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.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.core.internal.UpdateServerJob;
+import org.eclipse.wst.server.core.util.PublishAdapter;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.Trace;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
+import org.eclipse.wst.server.ui.internal.viewers.BaseContentProvider;
+
+public class ServerContentProvider extends BaseContentProvider implements
ITreeContentProvider {
+ public static Object INITIALIZING = new Object();
+ protected IServerLifecycleListener serverResourceListener;
+ protected IPublishListener publishListener;
+ protected IServerListener serverListener;
+
+ // servers that are currently publishing and starting
+ protected static Set<String> publishing = new HashSet<String>(4);
+ protected static Set<String> starting = new HashSet<String>(4);
+ protected boolean animationActive = false;
+ protected boolean stopAnimation = false;
+ protected boolean initialized = false;
+
+
+ private StructuredViewer viewer;
+
+ public ServerContentProvider() {
+ addListeners();
+ }
+
+ public Object[] getElements(Object element) {
+ if( !initialized ) {
+ deferInitialization();
+ return new Object[] {INITIALIZING};
+ }
+
+ List<IServer> list = new ArrayList<IServer>();
+ IServer[] servers = ServerCore.getServers();
+ if (servers != null) {
+ int size = servers.length;
+ for (int i = 0; i < size; i++) {
+ if (!((Server)servers[i]).isPrivate())
+ list.add(servers[i]);
+ }
+ }
+ return list.toArray();
+ }
+
+ public Object[] getChildren(Object element) {
+ if (element instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) element;
+ try {
+ IModule[] children = ms.server.getChildModules(ms.module, null);
+ int size = children.length;
+ ModuleServer[] ms2 = new ModuleServer[size];
+ for (int i = 0; i < size; i++) {
+ int size2 = ms.module.length;
+ IModule[] module = new IModule[size2 + 1];
+ System.arraycopy(ms.module, 0, module, 0, size2);
+ module[size2] = children[i];
+ ms2[i] = new ModuleServer(ms.server, module);
+ }
+ return ms2;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ IServer server = (IServer) element;
+ IModule[] modules = server.getModules();
+ int size = modules.length;
+ ModuleServer[] ms = new ModuleServer[size];
+ for (int i = 0; i < size; i++) {
+ ms[i] = new ModuleServer(server, new IModule[] { modules[i] });
+ }
+ return ms;
+ }
+
+ public Object getParent(Object element) {
+ if (element instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) element;
+ return ms.server;
+ }
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ if (element instanceof ModuleServer) {
+ // Check if the module server has child modules.
+ ModuleServer curModuleServer = (ModuleServer)element;
+ IServer curServer = curModuleServer.server;
+ IModule[] curModule = curModuleServer.module;
+ if (curServer != null && curModule != null) {
+ IModule[] curChildModule = curServer.getChildModules(curModule, null);
+ if (curChildModule != null && curChildModule.length > 0)
+ return true;
+
+ return false;
+ }
+
+ return false;
+ }
+ if( element instanceof IServer ) {
+ return ((IServer) element).getModules().length > 0;
+ }
+ return false;
+ }
+
+ public void inputChanged(Viewer aViewer, Object oldInput, Object newInput) {
+ viewer = (StructuredViewer) aViewer;
+ }
+
+ public void dispose() {
+ // do nothing
+ }
+
+
+
+ // Listeners and refreshing the viewer
+ protected void addListeners() {
+ serverResourceListener = new IServerLifecycleListener() {
+ public void serverAdded(IServer server) {
+ refreshServer(null);
+ server.addServerListener(serverListener);
+ ((Server) server).addPublishListener(publishListener);
+ }
+ public void serverChanged(IServer server) {
+ refreshServer(server);
+ }
+ public void serverRemoved(IServer server) {
+ refreshServer(null);
+ server.removeServerListener(serverListener);
+ ((Server) server).removePublishListener(publishListener);
+ }
+ };
+ ServerCore.addServerLifecycleListener(serverResourceListener);
+
+ publishListener = new PublishAdapter() {
+ public void publishStarted(IServer server) {
+ handlePublishChange(server, true);
+ }
+
+ public void publishFinished(IServer server, IStatus status) {
+ handlePublishChange(server, false);
+ }
+ };
+
+ serverListener = new IServerListener() {
+ public void serverChanged(ServerEvent event) {
+ if (event == null)
+ return;
+
+ int eventKind = event.getKind();
+ IServer server = event.getServer();
+ if ((eventKind & ServerEvent.SERVER_CHANGE) != 0) {
+ // server change event
+ if ((eventKind & ServerEvent.STATE_CHANGE) != 0) {
+ refreshServer(server, true);
+ int state = event.getState();
+ String id = server.getId();
+ if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING) {
+ boolean startThread = false;
+ synchronized (starting) {
+ if (!starting.contains(id)) {
+ if (starting.isEmpty())
+ startThread = true;
+ starting.add(id);
+ }
+ }
+ if (startThread)
+ startThread();
+ } else {
+ boolean stopThread = false;
+ synchronized (starting) {
+ if (starting.contains(id)) {
+ starting.remove(id);
+ if (starting.isEmpty())
+ stopThread = true;
+ }
+ }
+ if (stopThread)
+ stopThread();
+ }
+ } else
+ refreshServer(server);
+ } else if ((eventKind & ServerEvent.MODULE_CHANGE) != 0) {
+ // module change event
+ if ((eventKind & ServerEvent.STATE_CHANGE) != 0 || (eventKind &
ServerEvent.PUBLISH_STATE_CHANGE) != 0) {
+ refreshServer(server);
+ }
+ }
+ }
+ };
+
+ // add listeners to servers
+ IServer[] servers = ServerCore.getServers();
+ if (servers != null) {
+ int size = servers.length;
+ for (int i = 0; i < size; i++) {
+ servers[i].addServerListener(serverListener);
+ ((Server) servers[i]).addPublishListener(publishListener);
+ }
+ }
+ }
+
+ protected void deferInitialization() {
+ Job job = new Job(Messages.jobInitializingServersView) {
+ public IStatus run(IProgressMonitor monitor) {
+ IServer[] servers = ServerCore.getServers();
+ int size = servers.length;
+ for (int i = 0; i < size; i++) {
+ ((Server)servers[i]).getAllModules().iterator();
+ }
+
+ for (int i = 0; i < size; i++) {
+ IServer server = servers[i];
+ if (server.getServerType() != null && server.getServerState() ==
IServer.STATE_UNKNOWN) {
+ UpdateServerJob job2 = new UpdateServerJob(server);
+ job2.schedule();
+ }
+ }
+ initialized = true;
+ refreshServer(null);
+ return Status.OK_STATUS;
+ }
+ };
+
+ job.setSystem(true);
+ job.setPriority(Job.SHORT);
+ job.schedule();
+ }
+
+ protected void refreshServer(final IServer server) {
+ refreshServer(server, false);
+ }
+ protected void refreshServer(final IServer server, final boolean resetSelection) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ if( viewer != null && !viewer.getControl().isDisposed()) {
+ viewer.refresh(server);
+ if( resetSelection ) {
+ ISelection sel = viewer.getSelection();
+ viewer.setSelection(sel);
+ }
+ ServerDecorator.getDefault().redecorate(server);
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ });
+ }
+
+ protected void handlePublishChange(IServer server, boolean isPublishing) {
+ String serverId = server.getId();
+ if (isPublishing)
+ publishing.add(serverId);
+ else
+ publishing.remove(serverId);
+
+ refreshServer(server);
+ }
+
+
+ protected void startThread() {
+ if (animationActive)
+ return;
+
+ stopAnimation = false;
+
+ final Display display = viewer == null ? Display.getDefault() :
viewer.getControl().getDisplay();
+ final int SLEEP = 200;
+ final Runnable[] animator = new Runnable[1];
+ animator[0] = new Runnable() {
+ public void run() {
+ if (!stopAnimation) {
+ try {
+ int size = 0;
+ String[] servers;
+ synchronized (starting) {
+ size = starting.size();
+ servers = new String[size];
+ starting.toArray(servers);
+ }
+
+ for (int i = 0; i < size; i++) {
+ IServer server = ServerCore.findServer(servers[i]);
+ if (server != null ) {
+ ServerDecorator.animate();
+ refreshServer(server);
+ }
+ }
+ } catch (Exception e) {
+ Trace.trace(Trace.FINEST, "Error in Servers view animation", e);
+ }
+ display.timerExec(SLEEP, animator[0]);
+ }
+ }
+ };
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ display.timerExec(SLEEP, animator[0]);
+ }
+ });
+ }
+
+ protected void stopThread() {
+ stopAnimation = true;
+ }}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerDecorator.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerDecorator.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerDecorator.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,196 @@
+package org.jboss.tools.as.wst.server.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.ui.ServerUICore;
+import org.eclipse.wst.server.ui.internal.ImageResource;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
+
+public class ServerDecorator extends LabelProvider implements ILightweightLabelDecorator
{
+
+ public static final String[] syncState = new String[] {
+ Messages.viewSyncOkay,
+ Messages.viewSyncRestart,
+ Messages.viewSyncPublish,
+ Messages.viewSyncRestartPublish,
+ Messages.viewSyncPublishing};
+
+ public static final String[] syncStateUnmanaged = new String[] {
+ Messages.viewSyncOkay2,
+ Messages.viewSyncRestart2,
+ Messages.viewSyncPublish2,
+ Messages.viewSyncRestartPublish2,
+ Messages.viewSyncPublishing2};
+
+ public static final String[] modulePublishState = new String[] {
+ "",
+ Messages.viewSyncOkay,
+ Messages.viewSyncPublish,
+ Messages.viewSyncPublish};
+
+ private static ServerDecorator instance;
+ public static ServerDecorator getDefault() {
+ return instance;
+ }
+
+ private static int count = 0;
+ public static void animate() {
+ count = (count + 1)%3;
+ }
+ public static int getCount() {
+ return count;
+ }
+
+ public ServerDecorator() {
+ instance = this;
+ }
+
+ public void decorate(Object element, IDecoration decoration) {
+ if( element instanceof IServer ) {
+ String state = getServerStateLabel((IServer)element);
+ String status = getServerStatusLabel((IServer)element);
+ decoration.addSuffix(combine(state, status));
+ } else if( element instanceof ModuleServer ) {
+ String state = getModuleStateText((ModuleServer)element);
+ String status = getModuleStatusText((ModuleServer)element);
+ decoration.addSuffix(combine(state, status));
+ }
+ }
+
+ protected String combine(String state, String status) {
+ if(isEmpty(state) && isEmpty(status))
+ return "";
+ if( isEmpty(state))
+ return " [" + status + "]";
+ if( isEmpty(status))
+ return " [" + state + "]";
+ return " [" + state + ", " + status + "]";
+ }
+
+ protected boolean isEmpty(String s) {
+ return (s == null || "".equals(s));
+ }
+
+ public void redecorate(IServer server) {
+ fireLabelProviderChanged(new LabelProviderChangedEvent(this));
+ }
+
+
+
+ /*
+ * Utility methods
+ */
+ public static Image getServerImage(IServer server) {
+ return server == null ? null :
+ server.getServerType() == null ? null :
+ ImageResource.getImage(server.getServerType().getId());
+ }
+
+ public static String getServerStateLabel(IServer server) {
+ return server == null ? null :
+ server.getServerType() == null ? null :
+ getStateLabel(server.getServerType(), server.getServerState(), server.getMode());
+ }
+
+ public static String getStateLabel(IServerType serverType, int state, String mode) {
+ return serverType == null ? null :
+ UIDecoratorManager.getUIDecorator(serverType).getStateLabel(state, mode, count);
+ }
+
+ public static String getServerStatusLabel(IServer server) {
+ IStatus status = ((Server) server).getServerStatus();
+ if (status != null)
+ return status.getMessage();
+
+ if (server.getServerType() == null)
+ return "";
+
+ if (server.getServerState() == IServer.STATE_UNKNOWN)
+ return "";
+
+ String serverId = server.getId();
+ if (ServerContentProvider.publishing.contains(serverId))
+ return ServerDecorator.syncState[4];
+
+ // republish
+ int i = 0;
+ if (server.shouldPublish()) {
+ if (((Server)server).isPublishUnknown())
+ return "";
+ i += 2;
+ }
+
+ if (server.shouldRestart())
+ i = 1;
+
+ return syncState[i];
+ }
+
+ public static Image getServerStateImage(IServer server) {
+ return server == null ? null :
+ getStateImage(server.getServerType(), server.getServerState(), server.getMode());
+ }
+
+ public static Image getStateImage(IServerType serverType, int state, String mode) {
+ return serverType == null ? null :
+ UIDecoratorManager.getUIDecorator(serverType).getStateImage(state, mode, getCount());
+ }
+
+ public static String getModuleText(ModuleServer ms ) {
+ if (ms == null || ms.module == null)
+ return "";
+ int size = ms.module.length;
+ return ms.module[size - 1].getName();
+ }
+
+ public static Image getModuleImage(ModuleServer ms) {
+ if( ms != null ) {
+ ILabelProvider labelProvider = ServerUICore.getLabelProvider();
+ Image image = labelProvider.getImage(ms.module[ms.module.length - 1]);
+ labelProvider.dispose();
+ return image;
+ }
+ return null;
+ }
+
+ public static String getModuleStateText(ModuleServer ms) {
+ return "";
+ }
+
+ public static String getModuleStatusText(ModuleServer ms) {
+ if( ms != null && ms.server != null && ms.module != null ) {
+ IStatus status = ((Server) ms.server).getModuleStatus(ms.module);
+ if (status != null)
+ return status.getMessage();
+
+ return modulePublishState[ms.server.getModulePublishState(ms.module)];
+ }
+ return "";
+ }
+
+ public static Image getModuleStatusImage(ModuleServer ms) {
+ IStatus status = ((Server) ms.server).getModuleStatus(ms.module);
+ if (status != null) {
+ ISharedImages sharedImages =
ServerUIPlugin.getInstance().getWorkbench().getSharedImages();
+ if (status.getSeverity() == IStatus.ERROR)
+ return sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+ else if (status.getSeverity() == IStatus.WARNING)
+ return sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+ else if (status.getSeverity() == IStatus.INFO)
+ return sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
+ }
+ return null;
+ }
+}
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerLabelProvider.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerLabelProvider.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerLabelProvider.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.as.wst.server.ui;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.ServerUICore;
+import org.eclipse.wst.server.ui.internal.ImageResource;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
+/**
+ * Server table label provider.
+ */
+public class ServerLabelProvider extends LabelProvider {
+
+ /**
+ * ServerTableLabelProvider constructor comment.
+ */
+ public ServerLabelProvider() {
+ super();
+ }
+
+ public String getText(Object element) {
+ if (element instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) element;
+ if (ms.module == null)
+ return "";
+ int size = ms.module.length;
+ String name = ms.module[size - 1].getName();
+ return name;
+ }
+
+ if( element instanceof IServer ) {
+ IServer server = (IServer) element;
+ return notNull(server.getName());
+ }
+
+ if( element == ServerContentProvider.INITIALIZING)
+ return Messages.viewInitializing;
+
+ return "-";
+ }
+ public Image getImage(Object element) {
+ Image image = null;
+ if (element instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) element;
+ ILabelProvider labelProvider = ServerUICore.getLabelProvider();
+ image = labelProvider.getImage(ms.module[ms.module.length - 1]);
+ labelProvider.dispose();
+ } else if( element instanceof IServer ) {
+ IServer server = (IServer) element;
+ if (server.getServerType() != null) {
+ image = ImageResource.getImage(server.getServerType().getId());
+ }
+ }
+ return image;
+ }
+
+ protected String notNull(String s) {
+ if (s == null)
+ return "";
+ return s;
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+}
\ No newline at end of file
Added:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersView.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersView.java
(rev 0)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersView.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.as.wst.server.ui;
+
+import org.eclipse.ui.navigator.CommonNavigator;
+/**
+ * A view of servers, their modules, and status.
+ */
+public class ServersView extends CommonNavigator {
+ /**
+ * ServersView constructor comment.
+ */
+ public ServersView() {
+ super();
+ }
+}
\ No newline at end of file
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ToolsServerUICore.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ToolsServerUICore.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ToolsServerUICore.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -1,24 +0,0 @@
-package org.jboss.tools.as.wst.server.ui;
-
-import java.util.ArrayList;
-
-import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerViewProvider;
-
-public class ToolsServerUICore {
-
- public static ServerViewProvider[] getEnabledViewProviders(IServer server) {
- ServerViewProvider[] serverViewExtensions = getAllServerViewProviders();
- ArrayList<ServerViewProvider> list = new ArrayList<ServerViewProvider>();
- for( int i = 0; i < serverViewExtensions.length; i++ ) {
- if( serverViewExtensions[i].isEnabled() &&
serverViewExtensions[i].supports(server)) {
- list.add(serverViewExtensions[i]);
- }
- }
- return list.toArray(new ServerViewProvider[list.size()]);
- }
-
- public static ServerViewProvider[] getAllServerViewProviders() {
- return ExtensionManager.getDefault().getAllServerViewProviders();
- }
-}
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ExtensionTableViewer.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ExtensionTableViewer.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ExtensionTableViewer.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -1,491 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.tools.as.wst.server.ui.views.server;
-
-import java.util.ArrayList;
-import java.util.Properties;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-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.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.Widget;
-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.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerLifecycleListener;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.ui.ServerUICore;
-import org.jboss.ide.eclipse.as.core.server.UnitedServerListener;
-import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
-import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
-import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
-import org.jboss.ide.eclipse.as.ui.Messages;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.PropertySheetFactory;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerViewProvider;
-import
org.jboss.ide.eclipse.as.ui.views.server.extensions.PropertySheetFactory.ISimplePropertiesHolder;
-import
org.jboss.ide.eclipse.as.ui.views.server.extensions.PropertySheetFactory.SimplePropertiesPropertySheetPage;
-import org.jboss.tools.as.wst.server.ui.ToolsServerUICore;
-
-/**
- *
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public class ExtensionTableViewer extends TreeViewer {
-
- protected TableViewerPropertySheet propertySheet;
- protected Action disableCategoryAction, refreshAction;
- protected boolean suppressingRefresh = false;
- public ExtensionTableViewer(Tree tree) {
- super(tree);
- setContentProvider(new ContentProviderDelegator());
- setLabelProvider(new LabelProviderDelegator());
- propertySheet = new TableViewerPropertySheet();
- createActions();
-
- UnitedServerListenerManager.getDefault().addListener(new UnitedServerListener() {
- public void serverRemoved(IServer server) {
- final IServer server2 = server;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- Object o = getInput();
- if( server2.equals(o)) {
- setInput(null);
- }
- }
- });
- }
- });
- }
-
- protected void createActions() {
- disableCategoryAction = new Action() {
- public void run() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- Object selected = getSelectedElement();
- if( selected instanceof ServerViewProvider) {
- ((ServerViewProvider)selected).setEnabled(false);
- refresh();
- }
- }
- } );
- }
- };
- disableCategoryAction.setText(Messages.DisableCategoryAction);
- refreshAction = new Action() {
- public void run() {
- Object o1 = ((IStructuredSelection)getSelection()).getFirstElement();
- if( o1 != null ) {
- // tell the delegate to refresh its model for the selected item, before we refresh
the viewer
- ServerViewProvider provider = o1 instanceof ServerViewProvider ?
(ServerViewProvider)o1 : ((ContentWrapper)o1).getProvider();
- if( provider != null )
- provider.getDelegate().refreshModel(o1);
- }
- Object el = getSelectedElement();
- if( el instanceof ServerViewProvider )
- refresh(el);
- else
- refresh(((IStructuredSelection)getSelection()).getFirstElement());
- }
- };
- refreshAction.setText("Refresh Item");
- }
-
- public static class ContentWrapper {
- private Object o;
- private ServerViewProvider provider;
-
- public ContentWrapper(Object o, ServerViewProvider provider) {
- this.o = o;
- this.provider = provider;
- }
-
- public Object getElement() {
- return o;
- }
-
- public ServerViewProvider getProvider() {
- return provider;
- }
-
- public boolean equals(Object other) {
- if( other == null ) return false;
-
- if( other instanceof ContentWrapper ) {
- if( ((ContentWrapper)other).getElement() == null )
- return o == null;
- return ((ContentWrapper)other).getElement().equals(o);
- }
- return false;
- }
-
- public int hashCode() {
- if( o == null ) return super.hashCode();
- return o.hashCode();
- }
- }
-
- protected class LabelProviderDelegator extends LabelProvider {
- public String getText(Object obj) {
- if( obj instanceof JBossServer) {
- JBossServer server = (JBossServer)obj;
- String ret = server.getServer().getName();
- return ret;
- }
- if( obj instanceof ServerViewProvider) {
- return ((ServerViewProvider)obj).getName();
- }
-
- if( obj instanceof ContentWrapper ) {
- ContentWrapper wrapper = (ContentWrapper)obj;
- return
wrapper.getProvider().getDelegate().getLabelProvider().getText(wrapper.getElement());
- }
- return obj.toString();
- }
- public Image getImage(Object obj) {
- if( obj instanceof JBossServer ) {
- return ServerUICore.getLabelProvider().getImage(((JBossServer)obj).getServer());
- }
- if( obj instanceof ServerViewProvider ) {
- return ((ServerViewProvider)obj).getImage();
- }
-
- if( obj instanceof ContentWrapper ) {
- Object object2 = ((ContentWrapper)obj).getElement();
- return
((ContentWrapper)obj).getProvider().getDelegate().getLabelProvider().getImage(object2);
- }
-
- return null;
- }
- }
- protected class ContentProviderDelegator implements ITreeContentProvider {
-
- public ContentProviderDelegator() {
- }
-
- public ContentWrapper[] wrap( Object[] elements, ServerViewProvider provider ) {
- if( elements == null ) return new ContentWrapper[0];
-
- ContentWrapper[] wrappers = new ContentWrapper[elements.length];
- for( int i = 0; i < wrappers.length; i++ ) {
- wrappers[i] = new ContentWrapper(elements[i], provider);
- }
- return wrappers;
- }
-
- public Object[] getElements(Object inputElement) {
- if( inputElement == null ) return new Object[0];
- IServer tmp = (IServer)getInput();
- if( tmp == null )
- return new Object[0];
- return ToolsServerUICore.getEnabledViewProviders(tmp);
- }
-
- public Object[] getChildren(Object parentElement) {
- if( parentElement == null ) return new Object[0];
-
- if( parentElement instanceof ServerViewProvider) {
- Object[] ret =
((ServerViewProvider)parentElement).getDelegate().getContentProvider().getChildren(parentElement);
- return wrap(ret, ((ServerViewProvider)parentElement));
- }
-
- if( parentElement instanceof ContentWrapper ) {
- ContentWrapper parentWrapper = (ContentWrapper)parentElement;
- Object[] o = null;
- try {
- o =
parentWrapper.getProvider().getDelegate().getContentProvider().getChildren(parentWrapper.getElement());
- } catch( Exception e) {
- JBossServerUIPlugin.log("Error finding children of " + parentElement, e);
- }
- if( o == null )
- return new Object[0];
- return wrap(o, parentWrapper.getProvider());
- }
- return new Object[0];
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- if( element instanceof ServerViewProvider )
- return
((ServerViewProvider)element).getDelegate().getContentProvider().hasChildren(element);
- if( element instanceof ContentWrapper ) {
- ContentWrapper parentWrapper = (ContentWrapper)element;
- return
parentWrapper.getProvider().getDelegate().getContentProvider().hasChildren(parentWrapper.getElement());
- }
- return getChildren(element).length > 0 ? true : false;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- ServerViewProvider[] providers = ToolsServerUICore.
- getEnabledViewProviders(newInput instanceof IServer ? (IServer)newInput : null);
- for( int i = 0; i < providers.length; i++ ) {
- try {
- providers[i].getDelegate().getContentProvider().inputChanged(viewer, oldInput,
newInput);
- } catch( Exception e) {
- JBossServerUIPlugin.log("Error changing input to " + newInput, e);
- }
- }
- }
-
- }
-
- public Object getRawElement(Object o) {
- if( o instanceof ContentWrapper )
- return ((ContentWrapper)o).getElement();
- return o;
- }
-
- public Object[] getRawElements(IStructuredSelection selection) {
- ArrayList<Object> tmp = new ArrayList<Object>();
- Object[] obj = selection.toArray();
- Object tmp2;
- for( int i = 0; i < obj.length; i++ ) {
- tmp2 = getRawElement(obj[i]);
- if( tmp2 != null ) tmp.add(tmp2);
- }
- return (Object[]) tmp.toArray(new Object[tmp.size()]);
- }
-
- public ServerViewProvider getParentViewProvider(Object o) {
- if( o instanceof ContentWrapper )
- return ((ContentWrapper)o).getProvider();
- return null;
- }
-
- public Object getSelectedElement() {
- ISelection sel = getSelection();
- if( sel instanceof IStructuredSelection ) {
- Object o = ((IStructuredSelection)sel).getFirstElement();
- if( o != null && o instanceof ContentWrapper ) {
- o = ((ContentWrapper)o).getElement();
- }
- return o;
- }
- return null;
- }
-
- protected void fillSelectedContextMenu(Shell shell, IMenuManager mgr) {
- ISelection sel = getSelection();
- if (sel instanceof IStructuredSelection) {
- ServerViewProvider provider = findProvider((IStructuredSelection)sel);
- if (provider != null) {
- Object[] selected = getRawElements((IStructuredSelection)sel);
- provider.getDelegate().fillContextMenu(shell, mgr, selected);
- }
- }
- }
-
- protected ServerViewProvider findProvider(IStructuredSelection sel) {
- Object[] selected = sel.toArray();
- ServerViewProvider provider = null;
- ServerViewProvider tmpProvider;
- for( int i = 0; i < selected.length; i++ ) {
- if( selected[i] instanceof ServerViewProvider ) {
- tmpProvider = (ServerViewProvider)selected[i];
- } else {
- tmpProvider = getParentViewProvider(selected[i]);
- }
- if( provider == null )
- provider = tmpProvider;
- else if( tmpProvider != provider )
- return null;
- }
- return provider;
- }
-
- protected void fillJBContextMenu(Shell shell, IMenuManager menu) {
- Object selected = getSelectedElement();
- menu.add(refreshAction);
- if( selected instanceof ServerViewProvider ) {
- menu.add(disableCategoryAction);
- }
-
- menu.add(new Separator());
- }
-
- public IPropertySheetPage getPropertySheet() {
- return propertySheet;
- }
-
- public class TableViewerPropertySheet implements IPropertySheetPage {
-
- private PageBook book;
- private ArrayList<ServerViewProvider> addedControls = new
ArrayList<ServerViewProvider>();
- private SimplePropertiesPropertySheetPage topLevelPropertiesPage;
-
- public void createControl(Composite parent) {
- topLevelPropertiesPage = PropertySheetFactory.createSimplePropertiesSheet(new
TopLevelProperties());
- book = new PageBook(parent, SWT.NONE);
- addedControls.clear();
- topLevelPropertiesPage.createControl(book);
- book.showPage(topLevelPropertiesPage.getControl());
- }
-
- public void dispose() {
- }
-
- public Control getControl() {
- return book;
- }
-
- public void setActionBars(IActionBars actionBars) {
- }
-
- public void setFocus() {
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection sel) {
- Object selected = getSelectedObject(sel);
- if( selected != null ) {
-
- IPropertySheetPage page = null;
- if( selected instanceof ContentWrapper ) {
- page = getDelegatePage(((ContentWrapper)selected).getProvider());
- } else /*if( selected instanceof ServerViewProvider ) {
- page = getDelegatePage((ServerViewProvider)selected);
- } else if( page == null ) */ {
- page = topLevelPropertiesPage;
- }
- if( page != null ) {
- page.selectionChanged(part, sel);
- book.showPage(page.getControl());
- }
- }
- }
- private IPropertySheetPage getDelegatePage(ServerViewProvider provider) {
- IPropertySheetPage returnSheet = null;
- returnSheet = provider.getDelegate().getPropertySheetPage();
- if( !addedControls.contains(provider) && returnSheet != null) {
- returnSheet.createControl(book);
- addedControls.add(provider);
- }
- return returnSheet;
- }
-
- public Object getSelectedObject(ISelection sel) {
- if( sel instanceof IStructuredSelection ) {
- IStructuredSelection selection = (IStructuredSelection)sel;
- Object selected = selection.getFirstElement();
- return selected;
- }
- return null;
- }
-
- }
- /**
- * Properties for the top level elements
- * (a server or a category / extension point
- * @author rstryker
- *
- */
- class TopLevelProperties implements ISimplePropertiesHolder {
- public Properties getProperties(Object selected) {
- Properties ret = new Properties();
- if( selected instanceof ServerViewProvider ) {
- ServerViewProvider provider = (ServerViewProvider)selected;
- ret.setProperty(Messages.ExtensionID, provider.getId());
- ret.setProperty(Messages.ExtensionName, provider.getName());
- ret.setProperty(Messages.ExtensionDescription, provider.getDescription());
- ret.setProperty(Messages.ExtensionProviderClass, provider.getDelegateName());
- }
- return ret;
- }
-
-
- public String[] getPropertyKeys(Object selected) {
- if( selected instanceof ServerViewProvider) {
- return new String[] {
- Messages.ExtensionName, Messages.ExtensionDescription,
- Messages.ExtensionID, Messages.ExtensionProviderClass
- };
-
- }
- if( selected instanceof JBossServer ) {
- return new String[] {
- Messages.ServerRuntimeVersion, Messages.ServerHome,
- Messages.ServerConfigurationName, Messages.ServerDeployDir,
- };
- }
- return new String[] {};
- }
- }
-
- public void dispose() {
- // The Loner
- propertySheet.dispose();
-
- ServerViewProvider[] providers = ToolsServerUICore.getAllServerViewProviders();
- for( int i = 0; i < providers.length; i++ ) {
- providers[i].dispose();
- }
- }
-
-
- public void suppressingRefresh(Runnable runnable) {
- boolean currentVal = suppressingRefresh;
- suppressingRefresh = true;
- runnable.run();
- suppressingRefresh = currentVal;
- }
-
- public void refresh() {
- refresh(null);
- }
- public void refresh(final Object element) {
- if(!suppressingRefresh) {
- try {
- super.refresh(element);
- } catch( Exception e ) {
- JBossServerUIPlugin.log("Error refreshing view. ", e);
- }
- }
- }
-
- public boolean elementInTree(Object element) {
- Widget[] w = super.findItems(element);
- return w != null && w.length > 0;
- }
-
-
-}
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/JBossServerView.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/JBossServerView.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/JBossServerView.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -1,192 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.tools.as.wst.server.ui.views.server;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
-
-/**
- *
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public class JBossServerView extends ViewPart {
-
- public static final String VIEW_ID =
"org.jboss.ide.eclipse.as.ui.views.JBossServerView";
-
- private static final String TAG_SASHFORM_HEIGHT = "sashformHeight";
-
- public static JBossServerView instance;
- private static ArrayList<ISelectionChangedListener> serverFrameListeners = new
ArrayList<ISelectionChangedListener>();
- private static ArrayList<ISelectionChangedListener> extensionFrameListeners = new
ArrayList<ISelectionChangedListener>();
-
- public static JBossServerView getDefault() {
- return instance;
- }
-
- public static void addServerFrameListener(ISelectionChangedListener listener) {
- if( !serverFrameListeners.contains(listener))
- serverFrameListeners.add(listener);
- if( getDefault() != null )
- getDefault().getServerFrame().getViewer().addSelectionChangedListener(listener);
- }
- public static void addExtensionFrameListener(ISelectionChangedListener listener) {
- if( !extensionFrameListeners.contains(listener))
- extensionFrameListeners.add(listener);
- 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();
- public void refresh();
- }
-
- public JBossServerView() {
- super();
- instance = this;
- }
-
- private SashForm form;
- private int[] sashRows;
- private IMemento memento;
-
- private IServerViewFrame[] frames;
- private ServerFrame serverFrame;
- private ServerExtensionFrame extensionFrame;
-
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- ServerUIPlugin.getPreferences().setShowOnActivity(false);
- this.memento = memento;
- int sum = 0;
- sashRows = new int[2];
- for (int i = 0; i < sashRows.length; i++) {
- sashRows[i] = 50;
- if (memento != null) {
- Integer in = memento.getInteger(TAG_SASHFORM_HEIGHT + i);
- if (in != null && in.intValue() > 5)
- sashRows[i] = in.intValue();
- }
- sum += sashRows[i];
- }
- }
-
- public void saveState(IMemento memento) {
- super.saveState(memento);
- int[] weights = form.getWeights();
- for (int i = 0; i < weights.length; i++) {
- if (weights[i] != 0)
- memento.putInteger(TAG_SASHFORM_HEIGHT + i, weights[i]);
- }
- }
-
- public void createPartControl(Composite parent) {
- form = new SashForm(parent, SWT.VERTICAL);
- form.setBackground(new Color(parent.getDisplay(), 255, 255, 255));
- form.setLayout(new FillLayout());
-
-
- Composite topWrapper = new Composite(form, SWT.NONE);
- topWrapper.setLayout(new FillLayout());
- serverFrame = new ServerFrame(topWrapper, this);
-
- Composite bottomWrapper = new Composite(form, SWT.NONE);
- bottomWrapper.setLayout(new FillLayout());
- extensionFrame = new ServerExtensionFrame(bottomWrapper, this);
-
-
- frames = new IServerViewFrame[] { serverFrame, extensionFrame };
-
- // add toolbar buttons
- IContributionManager cm = getViewSite().getActionBars().getToolBarManager();
- for( int i = 0; i < frames.length; i++ ) {
- IAction[] actions = frames[i].getActionBarActions();
- for (int j = 0; j < actions.length - 1; j++)
- cm.add(actions[j]);
- }
-
- form.setWeights(sashRows);
-
-
- // if the extensions have already been created, add those listeners now.
- Iterator<ISelectionChangedListener> k;
- for(k = serverFrameListeners.iterator(); k.hasNext();)
- serverFrame.getViewer().addSelectionChangedListener(k.next());
- for(k = extensionFrameListeners.iterator(); k.hasNext();)
- extensionFrame.getViewer().addSelectionChangedListener(k.next());
- }
-
- public void refreshAll() {
- for( int i = 0; i < frames.length; i++ ) {
- frames[i].refresh();
- }
- }
-
- public ServerFrame getServerFrame() { return this.serverFrame; }
- public ServerExtensionFrame getExtensionFrame() { return this.extensionFrame; }
-
- public void setFocus() {
- getExtensionFrame().getViewer().getTree().setFocus();
- }
-
- public IServer getSelectedServer() {
- return serverFrame == null ? null : serverFrame.getSelectedServer();
- }
-
- public Object getAdapter(Class adaptor) {
- if( adaptor == IPropertySheetPage.class) {
- return extensionFrame.getViewer().getPropertySheet();
- }
- return super.getAdapter(adaptor);
- }
-}
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ServerExtensionFrame.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ServerExtensionFrame.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ServerExtensionFrame.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -1,122 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.tools.as.wst.server.ui.views.server;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
-import org.jboss.tools.as.wst.server.ui.views.server.JBossServerView.IServerViewFrame;
-
-/**
- *
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public class ServerExtensionFrame extends Composite implements IServerViewFrame {
-
- private Tree jbTreeTable;
- private ExtensionTableViewer jbViewer;
- private JBossServerView view;
- public ServerExtensionFrame(Composite parent, JBossServerView view) {
- super(parent, SWT.NONE);
- this.view = view;
- setLayout(new FillLayout());
- jbTreeTable = new Tree(this, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL |
SWT.V_SCROLL | SWT.BORDER);
- jbViewer = new ExtensionTableViewer(jbTreeTable);
- view.getSite().setSelectionProvider(jbViewer);
- addListeners();
- doMenuStuff(parent);
- }
-
- protected void doMenuStuff(Composite parent) {
- MenuManager menuManager = new MenuManager("#PopupMenu");
- menuManager.setRemoveAllWhenShown(true);
- final Shell shell = jbTreeTable.getShell();
- menuManager.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager mgr) {
- jbViewer.fillSelectedContextMenu(shell, mgr);
- mgr.add(new Separator());
- jbViewer.fillJBContextMenu(shell, mgr);
- }
- });
- Menu menu = menuManager.createContextMenu(parent);
- jbTreeTable.setMenu(menu);
- }
-
- public ExtensionTableViewer getViewer() {
- return jbViewer;
- }
-
- public void refresh() {
- jbViewer.refresh();
- }
-
- public void addListeners() {
-
- /*
- * Handles the selection of the server viewer which is embedded in my sashform
- */
- view.getServerFrame().getViewer().addSelectionChangedListener(new
ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- Object selection = ((TreeSelection)event.getSelection()).getFirstElement();
- Object server = selection;
- if( selection instanceof ModuleServer ) {
- server = ((ModuleServer)selection).server;
- }
-
- if( selection == null ) return;
- if( server != jbViewer.getInput()) {
- // find the newest copy of the server
- IServer tmp = ServerCore.findServer(((IServer)server).getId());
- jbViewer.setInput(tmp);
- } else {
- jbViewer.refresh();
- }
- }
-
- });
- }
-
-
- public IAction[] getActionBarActions() {
- return new IAction[] {}; // none
- }
-
- public int getDefaultSize() {
- return 0;
- }
- }
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ServerFrame.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ServerFrame.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ServerFrame.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -1,345 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.tools.as.wst.server.ui.views.server;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.bindings.TriggerSequence;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.core.internal.Trace;
-import org.eclipse.wst.server.ui.internal.ContextIds;
-import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
-import org.eclipse.wst.server.ui.internal.actions.NewServerWizardAction;
-import org.eclipse.wst.server.ui.internal.view.servers.CopyAction;
-import org.eclipse.wst.server.ui.internal.view.servers.DeleteAction;
-import org.eclipse.wst.server.ui.internal.view.servers.ModuleSloshAction;
-import org.eclipse.wst.server.ui.internal.view.servers.OpenAction;
-import org.eclipse.wst.server.ui.internal.view.servers.PasteAction;
-import org.eclipse.wst.server.ui.internal.view.servers.PropertiesAction;
-import org.eclipse.wst.server.ui.internal.view.servers.PublishAction;
-import org.eclipse.wst.server.ui.internal.view.servers.PublishCleanAction;
-import org.eclipse.wst.server.ui.internal.view.servers.RenameAction;
-import org.eclipse.wst.server.ui.internal.view.servers.ShowInConsoleAction;
-import org.eclipse.wst.server.ui.internal.view.servers.ShowInDebugAction;
-import org.eclipse.wst.server.ui.internal.view.servers.StartAction;
-import org.eclipse.wst.server.ui.internal.view.servers.StopAction;
-import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
-import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
-import org.jboss.ide.eclipse.as.ui.dialogs.TwiddleDialog;
-import org.jboss.tools.as.wst.server.ui.views.server.JBossServerView.IServerViewFrame;
-
-/**
- *
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public class ServerFrame extends Composite implements IServerViewFrame {
-
- protected Action[] actions;
- protected IWorkbenchPartSite site;
- protected IViewSite viewSite;
- protected Tree treeTable;
- protected ServerTableViewer tableViewer;
-
- // custom
- protected Action editLaunchConfigAction, twiddleAction, newServerAction;
-
- // wtp
- protected Action actionModifyModules;
- protected Action openAction, showInConsoleAction, showInDebugAction, propertiesAction;
- protected Action copyAction, pasteAction, deleteAction, renameAction;
-
- public ServerFrame(Composite parent, JBossServerView view) {
- super(parent, SWT.BORDER);
- setLayout(new FillLayout());
- this.site = view.getSite();
- this.viewSite = view.getViewSite();
-
-
- int cols[] = new int[] {150, 100, 50};
-
- treeTable = new Tree(this, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL |
SWT.V_SCROLL | SWT.NONE);
- treeTable.setHeaderVisible(true);
- treeTable.setLinesVisible(false);
- treeTable.setFont(parent.getFont());
- PlatformUI.getWorkbench().getHelpSystem().setHelp(treeTable, ContextIds.VIEW_SERVERS);
-
- // add columns
- TreeColumn column = new TreeColumn(treeTable, SWT.SINGLE);
- column.setText(Messages.viewServer);
- column.setWidth(cols[0]);
-
- TreeColumn column2 = new TreeColumn(treeTable, SWT.SINGLE);
- column2.setText(Messages.viewState);
- column2.setWidth(cols[1]);
-
- TreeColumn column3 = new TreeColumn(treeTable, SWT.SINGLE);
- column3.setText(Messages.viewStatus);
- column3.setWidth(cols[2]);
-
- tableViewer = new ServerTableViewer(viewSite, treeTable);
- initializeActions(tableViewer);
-
- treeTable.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- try {
- } catch (Exception e) {
- viewSite.getActionBars().getStatusLineManager().setMessage(null, "");
- }
- }
- public void widgetDefaultSelected(SelectionEvent event) {
- try {
- TreeItem item = treeTable.getSelection()[0];
- Object data = item.getData();
- if (!(data instanceof IServer))
- return;
- IServer server = (IServer) data;
- ServerUIPlugin.editServer(server);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not open server", e);
- }
- }
- });
-
- MenuManager menuManager = new MenuManager("#PopupMenu");
- menuManager.setRemoveAllWhenShown(true);
- final Shell shell = treeTable.getShell();
- menuManager.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager mgr) {
- fillContextMenu(shell, mgr);
- }
- });
- Menu menu = menuManager.createContextMenu(parent);
- treeTable.setMenu(menu);
- site.registerContextMenu(menuManager, tableViewer);
- site.setSelectionProvider(tableViewer);
- }
-
- protected void fillContextMenu(Shell shell, IMenuManager menu) {
- if( getSelectedServer() != null ) {
- cloneFill(shell, menu);
- } else {
- menu.add(newServerAction);
- }
- }
-
- protected void cloneFill(Shell shell, IMenuManager menu) {
-
- /* Show in ... */
- String text = Messages.actionShowIn;
- final IWorkbench workbench = PlatformUI.getWorkbench();
- final IBindingService bindingService = (IBindingService) workbench
- .getAdapter(IBindingService.class);
- final TriggerSequence[] activeBindings = bindingService
- .getActiveBindingsFor("org.eclipse.ui.navigate.showInQuickMenu");
- if (activeBindings.length > 0) {
- text += "\t" + activeBindings[0].format();
- }
-
- menu.add(newServerAction);
- menu.add(openAction);
-
- MenuManager showInMenu = new MenuManager(text);
- showInMenu.add(showInConsoleAction);
- showInMenu.add(showInDebugAction);
- menu.add(showInMenu);
- menu.add(new Separator());
-
- menu.add(copyAction);
- menu.add(pasteAction);
- menu.add(deleteAction);
- menu.add(renameAction);
-
- menu.add(new Separator());
-
- // server actions
- for (int i = 0; i < actions.length; i++)
- menu.add(actions[i]);
-
- menu.add(new Separator());
-// menu.add(actionModifyModules);
-
- menu.add(twiddleAction);
- menu.add(editLaunchConfigAction);
- menu.add(actionModifyModules);
- twiddleAction.setEnabled(true);
- editLaunchConfigAction.setEnabled(true);
-
- }
-
- public IServer getSelectedServer() {
- Object o = ((IStructuredSelection)tableViewer.getSelection()).getFirstElement();
- return (IServer)o;
- }
-
- public void initializeActions(ISelectionProvider provider) {
- createWTPActions(provider);
- createCustomActions();
- }
-
- protected void createWTPActions(ISelectionProvider provider) {
- Shell shell = viewSite.getShell();
- IActionBars actionBars = viewSite.getActionBars();
-
- actions = new Action[6];
- // create the start actions
- actions[0] = new StartAction(shell, provider, ILaunchManager.DEBUG_MODE);
- actionBars.setGlobalActionHandler("org.eclipse.wst.server.debug",
actions[0]);
- actions[1] = new StartAction(shell, provider, ILaunchManager.RUN_MODE);
- actionBars.setGlobalActionHandler("org.eclipse.wst.server.run", actions[1]);
- actions[2] = new StartAction(shell, provider, ILaunchManager.PROFILE_MODE);
-
- // create the stop action
- actions[3] = new StopAction(shell, provider);
- actionBars.setGlobalActionHandler("org.eclipse.wst.server.stop",
actions[3]);
-
- // create the publish actions
- actions[4] = new PublishAction(shell, provider);
- actionBars.setGlobalActionHandler("org.eclipse.wst.server.publish",
actions[4]);
- actions[5] = new PublishCleanAction(shell, provider);
-
- // create the open action
- openAction = new OpenAction(provider);
- actionBars.setGlobalActionHandler("org.eclipse.ui.navigator.Open",
openAction);
-
- // create copy, paste, and delete actions
- pasteAction = new PasteAction(shell, provider, tableViewer.clipboard);
- copyAction = new CopyAction(provider, tableViewer.clipboard, pasteAction);
- deleteAction = new DeleteAction(shell, provider);
- renameAction = new RenameAction(shell, tableViewer, provider);
- actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
- actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
- actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
- actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
-
- // create the other actions
- actionModifyModules = new ModuleSloshAction(shell, provider);
- showInConsoleAction = new ShowInConsoleAction(provider);
- showInDebugAction = new ShowInDebugAction(provider);
-
- // create the properties action
- propertiesAction = new PropertiesAction(shell, provider);
- actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), propertiesAction);
- }
-
- protected void createCustomActions() {
- newServerAction = new Action() {
- public void run() {
- IAction newServerAction = new NewServerWizardAction();
- newServerAction.run();
- }
- };
- newServerAction.setText("New Server");
- newServerAction.setImageDescriptor(JBossServerUISharedImages.getImageDescriptor(JBossServerUISharedImages.GENERIC_SERVER_IMAGE));
-
- editLaunchConfigAction = new Action() {
- public void run() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- final Object selected = getSelectedServer();
- IServer s = null;
- if( selected instanceof JBossServer ) {
- s = ((JBossServer)selected).getServer();
- } else if( selected instanceof IServer ) {
- s = (IServer)selected;
- }
-
- if( s != null ) {
- ILaunchConfiguration launchConfig = ((Server) s).getLaunchConfiguration(true,
null);
- // TODO: use correct launch group
- DebugUITools.openLaunchConfigurationPropertiesDialog(new Shell(), launchConfig,
"org.eclipse.debug.ui.launchGroup.run");
- }
- } catch (CoreException ce) {
- }
- }
- });
- }
- };
- editLaunchConfigAction.setText(org.jboss.ide.eclipse.as.ui.Messages.EditLaunchConfigurationAction);
- editLaunchConfigAction.setImageDescriptor(JBossServerUISharedImages.getImageDescriptor(JBossServerUISharedImages.IMG_JBOSS_CONFIGURATION));
-
- twiddleAction = new Action() {
- public void run() {
- final IStructuredSelection selected =
((IStructuredSelection)tableViewer.getSelection());
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- TwiddleDialog dialog = new TwiddleDialog(tableViewer.getTree().getShell(),
selected.getFirstElement());
- dialog.open();
- }
- } );
-
- }
- };
- twiddleAction.setText( org.jboss.ide.eclipse.as.ui.Messages.TwiddleServerAction);
- twiddleAction.setImageDescriptor(JBossServerUISharedImages.getImageDescriptor(JBossServerUISharedImages.TWIDDLE_IMAGE));
-
- }
-
- public ServerTableViewer getViewer() {
- return tableViewer;
- }
-
- public void refresh() {
- tableViewer.refresh();
- }
-
- public IAction[] getActionBarActions() {
- return actions;
- }
-
- public int getDefaultSize() {
- return 0;
- }
-}
Deleted:
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ServerTableViewer.java
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ServerTableViewer.java 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/views/server/ServerTableViewer.java 2008-10-30
02:21:00 UTC (rev 11315)
@@ -1,389 +0,0 @@
-package org.jboss.tools.as.wst.server.ui.views.server;
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.wst.server.core.IPublishListener;
-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.IServerType;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.ServerEvent;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.core.util.PublishAdapter;
-import org.eclipse.wst.server.ui.internal.Trace;
-import org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager;
-import org.eclipse.wst.server.ui.internal.view.servers.ServerTableLabelProvider;
-/**
- * Tree view showing servers and their associations.
- * This is for the TOP window
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public class ServerTableViewer extends TreeViewer {
- protected static final String ROOT = "root";
-
- protected IServerLifecycleListener serverResourceListener;
- protected IPublishListener publishListener;
- protected IServerListener serverListener;
-
- protected static Object deletedElement = null;
-
- // servers that are currently publishing and starting
- protected static List publishing = new ArrayList();
- protected static List starting = new ArrayList();
-
- protected ServerTableLabelProvider2 labelProvider;
- protected Clipboard clipboard;
-
- protected IViewSite viewSite;
-
- protected class ServerTableLabelProvider2 extends ServerTableLabelProvider {
- private int myCount = 0;
- protected Image getStateImage(IServerType serverType, int state, String mode) {
- return UIDecoratorManager.getUIDecorator(serverType).getStateImage(state, mode,
myCount);
- }
- protected String getStateLabel(IServerType serverType, int state, String mode) {
- return UIDecoratorManager.getUIDecorator(serverType).getStateLabel(state, mode,
myCount);
- }
- protected void animate2() {
- myCount ++;
- if (myCount > 2)
- myCount = 0;
- }
-
- }
-
- public class TrimmedServerContentProvider implements IStructuredContentProvider,
ITreeContentProvider {
- public Object[] getElements(Object element) {
- return ServerCore.getServers();
- }
-
- public void inputChanged(Viewer theViewer, Object oldInput, Object newInput) {
- // do nothing
- }
-
- public void dispose() {
- // do nothing
- }
-
- public Object[] getChildren(Object element) {
- return new Object[0];
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return false;
- }
- }
-
- protected Thread thread = null;
- protected boolean stopThread = false;
-
- protected void startThread() {
- stopThread = false;
- if (thread != null)
- return;
-
- thread = new Thread("Servers View Animator") {
- public void run() {
- while (!stopThread) {
- try {
- labelProvider.animate2();
- final Object[] rootElements =
((ITreeContentProvider)getContentProvider()).getElements(null);
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (getTree() != null && !getTree().isDisposed())
- update(rootElements, null);
- }
- });
- Thread.sleep(250);
- } catch (Exception e) {
- Trace.trace(Trace.FINEST, "Error in animated server view", e);
- }
- thread = null;
- }
- }
- };
- thread.setDaemon(true);
- thread.start();
- }
-
- protected void stopThread() {
- stopThread = true;
- }
-
- /**
- * ServerTableViewer constructor comment.
- *
- * @param view the view
- * @param tree the tree
- */
- public ServerTableViewer(final IViewSite site, final Tree tree) {
- super(tree);
- this.viewSite = site;
- clipboard = new Clipboard(tree.getDisplay());
-
- setContentProvider(new TrimmedServerContentProvider());
- labelProvider = new ServerTableLabelProvider2();
- labelProvider.addListener(new ILabelProviderListener() {
- public void labelProviderChanged(LabelProviderChangedEvent event) {
- Object[] obj = event.getElements();
- if (obj == null)
- refresh(true);
- else {
- int size = obj.length;
- for (int i = 0; i < size; i++)
- refresh(obj[i], true);
- }
- }
- });
- setLabelProvider(labelProvider);
- setSorter(new ViewerSorter() {
- // empty
- });
-
- setInput(ROOT);
- addListeners();
- }
-
- protected void addListeners() {
- serverResourceListener = new IServerLifecycleListener() {
- public void serverAdded(IServer server) {
- addServer(server);
- server.addServerListener(serverListener);
- ((Server) server).addPublishListener(publishListener);
- }
- public void serverChanged(IServer server) {
- refreshServer(server);
- }
- public void serverRemoved(IServer server) {
- removeServer(server);
- server.removeServerListener(serverListener);
- ((Server) server).removePublishListener(publishListener);
- }
- };
- ServerCore.addServerLifecycleListener(serverResourceListener);
-
- publishListener = new PublishAdapter() {
- public void publishStarted(IServer server) {
- handlePublishChange(server, true);
- }
-
- public void publishFinished(IServer server, IStatus status) {
- handlePublishChange(server, false);
- }
- };
-
- serverListener = new IServerListener() {
- public void serverChanged(ServerEvent event) {
- if (event == null) {
- return;
- }
- int eventKind = event.getKind();
- IServer server = event.getServer();
- if ((eventKind & ServerEvent.SERVER_CHANGE) != 0) {
- // server change event
- if ((eventKind & ServerEvent.STATE_CHANGE) != 0) {
- refreshServer(server);
- int state = event.getState();
- String id = server.getId();
- if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING) {
- if (!starting.contains(id)) {
- if (starting.isEmpty())
- startThread();
- starting.add(id);
- }
- } else {
- if (starting.contains(id)) {
- starting.remove(id);
- if (starting.isEmpty())
- stopThread();
- }
- }
- } else
- refreshServer(server);
- } else if ((eventKind & ServerEvent.MODULE_CHANGE) != 0) {
- // module change event
- if ((eventKind & ServerEvent.STATE_CHANGE) != 0 || (eventKind &
ServerEvent.PUBLISH_STATE_CHANGE) != 0) {
- refreshServer(server);
- }
- }
- }
- };
-
- // add listeners to servers
- IServer[] servers = ServerCore.getServers();
- if (servers != null) {
- int size = servers.length;
- for (int i = 0; i < size; i++) {
- servers[i].addServerListener(serverListener);
- ((Server) servers[i]).addPublishListener(publishListener);
- }
- }
- }
-
- protected void refreshServer(final IServer server) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- refresh(server);
-
- // This ensures the icons are updated in case of a publish or state change
- ISelection sel = ServerTableViewer.this.getSelection();
- ServerTableViewer.this.setSelection(sel);
- } catch (Exception e) {
- // ignore
- }
- }
- });
- }
-
- protected void handleDispose(DisposeEvent event) {
- stopThread();
- //if (dsListener != null)
- // view.getViewSite().getPage().removeSelectionListener(dsListener);
-
- ServerCore.removeServerLifecycleListener(serverResourceListener);
-
- // remove listeners from server
- IServer[] servers = ServerCore.getServers();
- if (servers != null) {
- int size = servers.length;
- for (int i = 0; i < size; i++) {
- servers[i].removeServerListener(serverListener);
- ((Server) servers[i]).removePublishListener(publishListener);
- }
- }
-
- clipboard.dispose();
- super.handleDispose(event);
- }
-
- /**
- * Called when the publish state changes.
- * @param server org.eclipse.wst.server.core.IServer
- */
- protected void handlePublishChange(IServer server, boolean isPublishing) {
- String serverId = server.getId();
- if (isPublishing)
- publishing.add(serverId);
- else
- publishing.remove(serverId);
-
- refreshServer(server);
- }
-
- /**
- *
- */
- protected void handleServerModulesChanged(IServer server2) {
- if (server2 == null)
- return;
-
- IServer[] servers = ServerCore.getServers();
- if (servers != null) {
- int size = servers.length;
- for (int i = 0; i < size; i++) {
- if (server2.equals(servers[i]))
- refresh(servers[i]);
- }
- }
- }
-
- /**
- * Called when an element is added.
- * @param server org.eclipse.wst.server.core.IServer
- */
- protected void handleServerResourceAdded(IServer server) {
- add(null, server);
- }
-
- /**
- * Called when an element is changed.
- * @param server org.eclipse.wst.server.core.IServer
- */
- protected void handleServerResourceChanged(IServer server) {
- refresh(server);
- }
-
- /**
- * Called when an element is removed.
- * @param server org.eclipse.wst.server.core.IServer
- */
- protected void handleServerResourceRemoved(IServer server) {
- remove(server);
-
- String serverId = server.getId();
- publishing.remove(serverId);
-
- viewSite.getActionBars().getStatusLineManager().setMessage(null, null);
- }
-
- protected void addServer(final IServer server) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- add(ROOT, server);
- }
- });
- }
-
- protected void removeServer(final IServer server) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- remove(server);
- }
- });
- }
-}
\ No newline at end of file
Modified: workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
---
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-10-30
00:31:00 UTC (rev 11314)
+++
workspace/rstryker/viewRefactor/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-10-30
02:21:00 UTC (rev 11315)
@@ -112,6 +112,7 @@
</adapter>
</extension>
+<!--
<extension
point="org.eclipse.ui.views">
<view
@@ -122,10 +123,10 @@
id="org.jboss.ide.eclipse.as.ui.views.JBossServerView"
name="JBoss Server View"/>
</extension>
+-->
-
<extension
point="org.jboss.ide.eclipse.as.ui.ServerViewExtension">
<ViewProvider
@@ -301,15 +302,15 @@
<extension point="org.eclipse.ui.actionSets">
<actionSet description="%actionSets.serverActions.description"
id="org.jboss.tools.jst.web.ui.server.actionSet"
label="%actionSets.serverActions.label" visible="true">
- <action
class="org.jboss.tools.as.wst.server.ui.action.SelectServerActionDelegate"
icon="icons/actions/xpl/server.gif"
id="org.jboss.tools.jst.web.ui.action.server.SelectServerActionDelegate"
label="label1" style="pulldown"
toolbarPath="Normal/SelectServer"
tooltip="%actionSets.serverActions.selectServer.label">
+ <action
class="org.jboss.ide.eclipse.as.ui.actions.SelectServerActionDelegate"
icon="icons/actions/xpl/server.gif"
id="org.jboss.tools.jst.web.ui.action.server.SelectServerActionDelegate"
label="label1" style="pulldown"
toolbarPath="Normal/SelectServer"
tooltip="%actionSets.serverActions.selectServer.label">
</action>
- <action
class="org.jboss.tools.as.wst.server.ui.action.ChangeTimeStampActionDelegate"
icon="icons/actions/webxml.gif"
id="org.jboss.tools.jst.web.ui.action.server.ChangeTimeStampActionDelegate"
label="label2" toolbarPath="Normal/server"
tooltip="%actionSets.serverActions.changeWebXmlTimeStamp.label">
+ <action
class="org.jboss.ide.eclipse.as.ui.actions.ChangeTimeStampActionDelegate"
icon="icons/actions/webxml.gif"
id="org.jboss.tools.jst.web.ui.action.server.ChangeTimeStampActionDelegate"
label="label2" toolbarPath="Normal/server"
tooltip="%actionSets.serverActions.changeWebXmlTimeStamp.label">
</action>
- <action
class="org.jboss.tools.as.wst.server.ui.action.StopServerActionDelegate"
icon="icons/actions/stop.gif"
id="org.jboss.tools.jst.web.ui.action.server.StopServerActionDelegate"
label="label4" toolbarPath="Normal/server"
tooltip="%actionSets.serverActions.stopServer.label">
+ <action
class="org.jboss.ide.eclipse.as.ui.actions.StopServerActionDelegate"
icon="icons/actions/stop.gif"
id="org.jboss.tools.jst.web.ui.action.server.StopServerActionDelegate"
label="label4" toolbarPath="Normal/server"
tooltip="%actionSets.serverActions.stopServer.label">
</action>
- <action
class="org.jboss.tools.as.wst.server.ui.action.DebugServerActionDelegate"
icon="icons/actions/xpl/debug.gif"
id="org.jboss.tools.jst.web.ui.action.server.DebugServerActionDelegate"
label="label6" toolbarPath="Normal/server"
tooltip="%actionSets.serverActions.startServer.label">
+ <action
class="org.jboss.ide.eclipse.as.ui.actions.DebugServerActionDelegate"
icon="icons/actions/xpl/debug.gif"
id="org.jboss.tools.jst.web.ui.action.server.DebugServerActionDelegate"
label="label6" toolbarPath="Normal/server"
tooltip="%actionSets.serverActions.startServer.label">
</action>
- <action
class="org.jboss.tools.as.wst.server.ui.action.RunServerActionDelegate"
icon="icons/actions/start.gif"
id="org.jboss.tools.jst.web.ui.action.server.RunServerActionDelegate"
label="label7" toolbarPath="Normal/server"
tooltip="%actionSets.serverActions.startServer.label">
+ <action
class="org.jboss.ide.eclipse.as.ui.actions.RunServerActionDelegate"
icon="icons/actions/start.gif"
id="org.jboss.tools.jst.web.ui.action.server.RunServerActionDelegate"
label="label7" toolbarPath="Normal/server"
tooltip="%actionSets.serverActions.startServer.label">
</action>
</actionSet>
</extension>
@@ -329,18 +330,18 @@
<extension point="org.eclipse.ui.views">
<view
- id="org.eclipse.wst.server.ui.ServersViewProvisional"
- name="JBoss Servers View 2 (beta)"
+ id="org.jboss.tools.as.wst.server.ui.ServersView"
+ name="JBoss Server View"
category="org.eclipse.wst.server.ui"
-
class="org.eclipse.wst.server.ui.internal.view.servers.provisional.ServersView"
+ class="org.jboss.tools.as.wst.server.ui.ServersView"
icon="icons/jboss.gif"/>
</extension>
<extension point="org.eclipse.ui.decorators">
<decorator
-
class="org.eclipse.wst.server.ui.internal.view.servers.provisional.ServerDecorator"
- icon="icons/obj16/server.gif"
- id="org.eclipse.wst.server.ui.navigatorDecorator"
+ class="org.jboss.tools.as.wst.server.ui.ServerDecorator"
+ icon="icons/cview16/servers_view.gif"
+ id="org.jboss.tools.as.wst.server.ui.navigatorDecorator"
label="Server State Decorator"
lightweight="true"
location="BOTTOM_RIGHT">
@@ -361,10 +362,10 @@
point="org.eclipse.ui.navigator.navigatorContent">
<navigatorContent
activeByDefault="true"
-
contentProvider="org.eclipse.wst.server.ui.internal.view.servers.provisional.ServerContentProvider"
+
contentProvider="org.jboss.tools.as.wst.server.ui.ServerContentProvider"
icon="icons/cview16/servers_view.gif"
- id="org.eclipse.wst.server.ui.ServersView.content.root"
-
labelProvider="org.eclipse.wst.server.ui.internal.view.servers.provisional.ServerLabelProvider"
+ id="org.jboss.tools.as.wst.server.ui.ServersView.content.root"
+ labelProvider="org.jboss.tools.as.wst.server.ui.ServerLabelProvider"
name="Servers View Default Content"
priority="highest">
<triggerPoints>
@@ -382,8 +383,8 @@
</instanceof>
</or></possibleChildren>
<actionProvider
-
class="org.eclipse.wst.server.ui.internal.view.servers.provisional.ServerActionProvider"
-
id="org.eclipse.wst.server.ui.internal.view.servers.provisional.ServerActionProvider"
+ class="org.jboss.tools.as.wst.server.ui.ServerActionProvider"
+
id="org.jboss.tools.as.wst.server.ui.ServersView.ServerActionProvider"
priority="highest">
</actionProvider>
</navigatorContent>
@@ -391,11 +392,11 @@
<extension
point="org.eclipse.ui.navigator.viewer">
<viewerContentBinding
- viewerId="org.eclipse.wst.server.ui.ServersViewProvisional">
+ viewerId="org.jboss.tools.as.wst.server.ui.ServersView">
<includes>
<contentExtension
isRoot="true"
-
pattern="org.eclipse.wst.server.ui.ServersView.content.root">
+
pattern="org.jboss.tools.as.wst.server.ui.ServersView.content.root">
</contentExtension>
</includes>
</viewerContentBinding>
@@ -411,8 +412,8 @@
id="org.jboss.ide.eclipse.as.ui.extensions.eventLog"
activeByDefault="true"
icon="icons/info_obj.gif"
-
contentProvider="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.EventLogContentProvider"
-
labelProvider="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.EventLogLabelProvider"
+
contentProvider="org.jboss.ide.eclipse.as.ui.views.server.extensions.EventLogContentProvider"
+
labelProvider="org.jboss.ide.eclipse.as.ui.views.server.extensions.EventLogLabelProvider"
name="JBoss Server Event Log"
priority="normal">
<triggerPoints>
@@ -430,17 +431,17 @@
</instanceof>
</or></possibleChildren>
<actionProvider
-
class="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.EventLogActionProvider"
+
class="org.jboss.ide.eclipse.as.ui.views.server.extensions.EventLogActionProvider"
id="org.jboss.ide.eclipse.as.ui.extensions.eventLog.actions"
priority="highest">
</actionProvider>
</navigatorContent>
<navigatorContent
activeByDefault="true"
-
contentProvider="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathTreeContentProvider"
+
contentProvider="org.jboss.ide.eclipse.as.ui.views.server.extensions.XPathTreeContentProvider"
icon="icons/XMLFile.gif"
id="org.jboss.ide.eclipse.as.ui.extensions.xml"
-
labelProvider="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathTreeLabelProvider"
+
labelProvider="org.jboss.ide.eclipse.as.ui.views.server.extensions.XPathTreeLabelProvider"
name="XML Configuration"
priority="normal">
<triggerPoints>
@@ -451,10 +452,10 @@
<possibleChildren>
<or>
<instanceof
-
value="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathProvider$XPathTreeContentProvider$ServerWrapper">
+
value="org.jboss.ide.eclipse.as.ui.views.server.extensions.XPathTreeContentProvider$ServerWrapper">
</instanceof>
<instanceof
-
value="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathProvider$XPathTreeContentProvider$DelayProxy">
+
value="org.jboss.ide.eclipse.as.ui.views.server.extensions.XPathTreeContentProvider$DelayProxy">
</instanceof>
<instanceof
value="org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory">
@@ -470,8 +471,8 @@
</instanceof></or>
</possibleChildren>
<actionProvider
-
class="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathActionProvider"
- id="org.jboss.ide.eclipse.as.ui.extensions.eventLog.actions"
+
class="org.jboss.ide.eclipse.as.ui.views.server.extensions.XPathActionProvider"
+ id="org.jboss.ide.eclipse.as.ui.extensions.xml.actions"
priority="highest">
</actionProvider>
</navigatorContent>
@@ -479,7 +480,7 @@
<extension
point="org.eclipse.ui.navigator.viewer">
<viewerContentBinding
- viewerId="org.eclipse.wst.server.ui.ServersViewProvisional">
+ viewerId="org.jboss.tools.as.wst.server.ui.ServersView">
<includes>
<contentExtension
isRoot="false"
@@ -498,7 +499,7 @@
<!-- Decorator for xpaths / xml-->
<extension point="org.eclipse.ui.decorators">
<decorator
-
class="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathDecorator"
+
class="org.jboss.ide.eclipse.as.ui.views.server.extensions.XPathDecorator"
id="org.jboss.ide.eclipse.as.ui.extensions.xml.decorator"
label="JBoss Server XML Configuration Decorator"
lightweight="true"