diff --git a/com.aptana.portal.ui.extended/.classpath b/com.aptana.portal.ui.extended/.classpath new file mode 100644 index 0000000000..eca7bdba8f --- /dev/null +++ b/com.aptana.portal.ui.extended/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/com.aptana.portal.ui.extended/.project b/com.aptana.portal.ui.extended/.project new file mode 100644 index 0000000000..a730ee2859 --- /dev/null +++ b/com.aptana.portal.ui.extended/.project @@ -0,0 +1,28 @@ + + + com.aptana.portal.ui.extended + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/com.aptana.portal.ui.extended/.settings/org.eclipse.jdt.core.prefs b/com.aptana.portal.ui.extended/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..0c68a61dca --- /dev/null +++ b/com.aptana.portal.ui.extended/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/com.aptana.portal.ui.extended/META-INF/MANIFEST.MF b/com.aptana.portal.ui.extended/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..ad576a1444 --- /dev/null +++ b/com.aptana.portal.ui.extended/META-INF/MANIFEST.MF @@ -0,0 +1,26 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Core +Bundle-SymbolicName: com.aptana.portal.ui.extended +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: com.aptana.portal.ui.extended.PortaUIExtended +Bundle-Vendor: APTANA +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.aptana.portal.ui;visibility:=reexport, + org.eclipse.core.resources, + com.aptana.jetty.util.epl, + org.eclipse.e4.core.contexts, + org.eclipse.e4.ui.css.swt.theme, + org.eclipse.e4.ui.model.workbench, + com.aptana.core, + com.aptana.configurations, + com.aptana.theme, + com.aptana.projects, + com.aptana.core.io, + com.aptana.ui, + com.aptana.explorer +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Export-Package: com.aptana.portal.ui.dispatch.configurationProcessors, + com.aptana.portal.ui.dispatch.configurationProcessors.installer diff --git a/com.aptana.portal.ui.extended/build.properties b/com.aptana.portal.ui.extended/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/com.aptana.portal.ui.extended/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/actionControllers/TemplateActionController.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/actionControllers/TemplateActionController.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/actionControllers/TemplateActionController.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/actionControllers/TemplateActionController.java diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/actionControllers/ThemeActionController.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/actionControllers/ThemeActionController.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/actionControllers/ThemeActionController.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/actionControllers/ThemeActionController.java diff --git a/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/actionControllers/messages.properties b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/actionControllers/messages.properties new file mode 100644 index 0000000000..726a98b69a --- /dev/null +++ b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/actionControllers/messages.properties @@ -0,0 +1,8 @@ +AbstractActionController_invocationError=An error occurred while trying to +GemsActionController_computingGemsJobName=Computing installed gems +ActionController_internalError=Internal Error +ConsoleController_devToolboxConsoleName=Dev Toolbox Console +PluginsActionController_computingInstalledPlugins=Computing installed plug-ins... +PluginsActionController_installNewSoftware=Install New Software... +InstallActionController_installing=Installing... +LaunchActionController_launchingJob=Launcing... diff --git a/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/AbstractBrowserNotification.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/AbstractBrowserNotification.java new file mode 100644 index 0000000000..5f10d10100 --- /dev/null +++ b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/AbstractBrowserNotification.java @@ -0,0 +1,128 @@ +/** + * Aptana Studio + * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. + * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). + * Please see the license.html included with this distribution for details. + * Any modifications to this file must keep this entire header intact. + */ +package com.aptana.portal.ui.dispatch.browserNotifications; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import com.aptana.portal.ui.dispatch.BrowserNotifier; +import com.aptana.portal.ui.dispatch.IBrowserNotificationConstants; + +/** + * A base class for all browser notification classed. The BrowserNotification register itself as a listener to some + * eclipse event and then notify the target browser editors about any event that is occurring. The notification is done + * through the {@link BrowserNotifier} class. + * + * @author Shalom Gibly + */ +public abstract class AbstractBrowserNotification +{ + protected List notificationTargets; + protected boolean isListening; + + /** + * Constructor + */ + public AbstractBrowserNotification() + { + notificationTargets = new ArrayList(); + } + + /** + * Set the notification targets for this browser notification class. An asterisk (*) sign signals to notify all the + * opened registered browser-editors. + * + * @param targets + * A list of comma separated target ids. + */ + public void setNotificationTargets(String targets) + { + notificationTargets.clear(); + if (targets != null) + { + String[] ids = targets.split(", *"); //$NON-NLS-1$ + for (String id : ids) + { + id = id.trim(); + if (id.equals("*")) { //$NON-NLS-1$ + // in case we have an asterisk, the notification will go to all + // of the registered browser-editors. + notificationTargets.clear(); + break; + } + if (id.length() > 0) + { + notificationTargets.add(id); + } + } + } + } + + /** + * Returns a list of notification targets. An empty list signals that we need to notify any available registered + * browser editor. + * + * @return An unmodifiable notification targets list. + */ + public List getNotificationTargets() + { + return Collections.unmodifiableList(notificationTargets); + } + + /** + * Start this browser notifier. + */ + public abstract void start(); + + /** + * Stop this browser notifier. + */ + public abstract void stop(); + + /** + * Fire a notification for the registered notification targets with the eventId, type and data. + * + * @param eventId + * See {@link IBrowserNotificationConstants} + * @param eventType + * See {@link IBrowserNotificationConstants} + * @param data + * A JSON data (can be null) + * @see IBrowserNotificationConstants + */ + protected void notifyTargets(String eventId, String eventType, String data) + { + notifyTargets(eventId, eventType, data, false); + } + + /** + * Fire a notification for the registered notification targets with the eventId, type and data. + * + * @param eventId + * See {@link IBrowserNotificationConstants} + * @param eventType + * See {@link IBrowserNotificationConstants} + * @param data + * A JSON data (can be null) + * @param notifyInUIThread + * Indicate that the notification should be wrapped in a UI thread. + * @see IBrowserNotificationConstants + */ + protected void notifyTargets(String eventId, String eventType, String data, boolean notifyInUIThread) + { + if (notifyInUIThread) + { + BrowserNotifier.getInstance().notifyBrowserInUIThread(getNotificationTargets(), eventId, eventType, data); + } + else + { + BrowserNotifier.getInstance().notifyBrowser(getNotificationTargets(), eventId, eventType, data); + } + } +} diff --git a/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/BrowserNotificationProxy.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/BrowserNotificationProxy.java new file mode 100644 index 0000000000..bbd9bee3e6 --- /dev/null +++ b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/BrowserNotificationProxy.java @@ -0,0 +1,135 @@ +/** + * Appcelerator Titanium Studio + * Copyright (c) 2013 by Appcelerator, Inc. All Rights Reserved. + * Proprietary and Confidential - This source code is not for redistribution + */ + +package com.aptana.portal.ui.dispatch.browserNotifications; + +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; + +import com.aptana.core.logging.IdeLog; +import com.aptana.portal.ui.PortalUIPlugin; + +/** + * Proxy class to the contributors of Browser notifications. + * + * @author pinnamuri + */ +public class BrowserNotificationProxy extends AbstractBrowserNotification +{ + + private IConfigurationElement element; + private AbstractBrowserNotification contributorClass; + private static final String ATT_CLASS = "class"; //$NON-NLS-1$ + private static final String ATT_NOTIFICATION_TARGET = "notificationTarget"; //$NON-NLS-1$ + + public BrowserNotificationProxy(IConfigurationElement element) + { + this.element = element; + } + + @Override + public void start() + { + try + { + loadElement(); + contributorClass.start(); + + } + catch (CoreException e) + { + IdeLog.logError(PortalUIPlugin.getDefault(), e); + } + } + + @Override + public List getNotificationTargets() + { + try + { + loadElement(); + return contributorClass.getNotificationTargets(); + + } + catch (CoreException e) + { + IdeLog.logError(PortalUIPlugin.getDefault(), e); + } + return Collections.emptyList(); + } + + @Override + public void setNotificationTargets(String targets) + { + try + { + loadElement(); + contributorClass.setNotificationTargets(targets); + } + catch (CoreException e) + { + IdeLog.logError(PortalUIPlugin.getDefault(), e); + } + + } + + private synchronized void loadElement() throws CoreException + { + if (contributorClass == null) + { + contributorClass = (AbstractBrowserNotification) element.createExecutableExtension(ATT_CLASS); + contributorClass.setNotificationTargets(element.getAttribute(ATT_NOTIFICATION_TARGET)); + } + } + + @Override + protected void notifyTargets(String eventId, String eventType, String data) + { + try + { + loadElement(); + contributorClass.notifyTargets(eventId, eventType, data); + } + catch (CoreException e) + { + IdeLog.logError(PortalUIPlugin.getDefault(), e); + } + } + + @Override + protected void notifyTargets(String eventId, String eventType, String data, boolean notifyInUIThread) + { + try + { + loadElement(); + contributorClass.notifyTargets(eventId, eventType, data, notifyInUIThread); + } + catch (CoreException e) + { + IdeLog.logError(PortalUIPlugin.getDefault(), e); + } + + } + + @Override + public void stop() + { + try + { + loadElement(); + contributorClass.stop(); + + } + catch (CoreException e) + { + IdeLog.logError(PortalUIPlugin.getDefault(), e); + } + } + +} diff --git a/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/ProjectCreationBrowserNotification.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/ProjectCreationBrowserNotification.java new file mode 100644 index 0000000000..5814839c6c --- /dev/null +++ b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/ProjectCreationBrowserNotification.java @@ -0,0 +1,67 @@ +/** + * Aptana Studio + * Copyright (c) 2012 by Appcelerator, Inc. All Rights Reserved. + * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). + * Please see the license.html included with this distribution for details. + * Any modifications to this file must keep this entire header intact. + */ + +package com.aptana.portal.ui.dispatch.browserNotifications; + +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.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.ui.progress.UIJob; + +import com.aptana.core.util.EclipseUtil; +import com.aptana.portal.ui.IPortalPreferences; +import com.aptana.portal.ui.PortalUIPlugin; +import com.aptana.portal.ui.dispatch.IBrowserNotificationConstants; + +/** + * A browser notification class that listens to the project creation events and notify those changes. + * + * @author pinnamuri + */ +public class ProjectCreationBrowserNotification extends AbstractBrowserNotification +{ + + private IPropertyChangeListener propertyListener = new IPropertyChangeListener() + { + public void propertyChange(PropertyChangeEvent event) + { + if (event.getProperty().equals(IPortalPreferences.RECENTLY_CREATED_PROJECT)) + { + Job job = new UIJob("Notifying project create event") //$NON-NLS-1$ + { + @Override + public IStatus runInUIThread(IProgressMonitor monitor) + { + // Notify the Portal's observers + notifyTargets(IBrowserNotificationConstants.EVENT_ID_PROJECT_CREATE, + IBrowserNotificationConstants.EVENT_TYPE_CHANGED, (String) null); + return Status.OK_STATUS; + } + }; + EclipseUtil.setSystemForJob(job); + job.schedule(); + } + } + }; + + @Override + public void start() + { + PortalUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(propertyListener); + } + + @Override + public void stop() + { + PortalUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(propertyListener); + } + +} diff --git a/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/RecentFilesBrowserNotification.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/RecentFilesBrowserNotification.java new file mode 100644 index 0000000000..67c7b307de --- /dev/null +++ b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/RecentFilesBrowserNotification.java @@ -0,0 +1,144 @@ +/** + * Aptana Studio + * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. + * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). + * Please see the license.html included with this distribution for details. + * Any modifications to this file must keep this entire header intact. + */ +package com.aptana.portal.ui.dispatch.browserNotifications; + +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.ui.IPartListener; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.progress.UIJob; + +import com.aptana.core.util.EclipseUtil; +import com.aptana.portal.ui.PortalUIPlugin; +import com.aptana.portal.ui.dispatch.IBrowserNotificationConstants; + +/** + * A browser notification class that listens to the eclipse editors and notify about changes in the recently opened + * files history. + * + * @author Shalom Gibly + */ +public class RecentFilesBrowserNotification extends AbstractBrowserNotification +{ + private IPartListener partListener; + + /** + * Constructor. + */ + public RecentFilesBrowserNotification() + { + partListener = new PartListener(); + } + + /* + * (non-Javadoc) + * @see com.aptana.portal.dispatch.AbstractBrowserNotification#start() + */ + @Override + public void start() + { + isListening = true; + Job job = new UIJob("register RecentlyOpenedFilesFunction workspace listener") //$NON-NLS-1$ + { + @Override + public IStatus runInUIThread(IProgressMonitor monitor) + { + IWorkbenchWindow window = PortalUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); + if (window != null) + { + IWorkbenchPage activePage = window.getActivePage(); + if (activePage != null) + { + activePage.addPartListener(partListener); + } + } + return Status.OK_STATUS; + } + }; + EclipseUtil.setSystemForJob(job); + job.schedule(); + } + + /* + * (non-Javadoc) + * @see com.aptana.portal.dispatch.AbstractBrowserNotification#stop() + */ + @Override + public void stop() + { + isListening = false; + Job job = new UIJob("unregister RecentlyOpenedFilesFunction workspace listener") //$NON-NLS-1$ + { + @Override + public IStatus runInUIThread(IProgressMonitor monitor) + { + + IWorkbench workbench = PortalUIPlugin.getDefault().getWorkbench(); + if (!workbench.isClosing()) + { + IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + if (window != null) + { + IWorkbenchPage activePage = window.getActivePage(); + if (activePage != null) + { + activePage.removePartListener(partListener); + } + } + } + return Status.OK_STATUS; + } + }; + EclipseUtil.setSystemForJob(job); + job.schedule(); + } + + /** + * Listen to the workbench part to trigger a browser update every time a new file is being opened. + */ + private class PartListener implements IPartListener + { + public void partActivated(IWorkbenchPart part) + { + } + + public void partBroughtToTop(IWorkbenchPart part) + { + } + + public void partClosed(IWorkbenchPart part) + { + } + + public void partDeactivated(IWorkbenchPart part) + { + } + + public void partOpened(IWorkbenchPart part) + { + if (!isListening) + { + IWorkbenchPage activePage = PortalUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow() + .getActivePage(); + if (activePage != null) + { + activePage.removePartListener(this); + } + return; + } + // Notify the Portal's observers + notifyTargets(IBrowserNotificationConstants.EVENT_ID_RECENT_FILES, + IBrowserNotificationConstants.EVENT_TYPE_CHANGED, (String) null); + } + } +} diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/browserNotifications/TemplatesNotification.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/TemplatesNotification.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/browserNotifications/TemplatesNotification.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/browserNotifications/TemplatesNotification.java diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/InstallerConfigurationProcessor.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/InstallerConfigurationProcessor.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/InstallerConfigurationProcessor.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/InstallerConfigurationProcessor.java diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/JavaScriptLibraryInstallProcessor.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/JavaScriptLibraryInstallProcessor.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/JavaScriptLibraryInstallProcessor.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/JavaScriptLibraryInstallProcessor.java diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/Messages.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/Messages.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/Messages.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/Messages.java diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/PythonInstallProcessor.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/PythonInstallProcessor.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/PythonInstallProcessor.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/PythonInstallProcessor.java diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/RubyInstallProcessor.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/RubyInstallProcessor.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/RubyInstallProcessor.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/RubyInstallProcessor.java diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/VersionsConfigurationProcessor.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/VersionsConfigurationProcessor.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/VersionsConfigurationProcessor.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/VersionsConfigurationProcessor.java diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/XAMPPInstallProcessor.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/XAMPPInstallProcessor.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/XAMPPInstallProcessor.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/XAMPPInstallProcessor.java diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/installer/InstallerOptionsDialog.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/installer/InstallerOptionsDialog.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/installer/InstallerOptionsDialog.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/installer/InstallerOptionsDialog.java diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/installer/JavaScriptImporterOptionsDialog.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/installer/JavaScriptImporterOptionsDialog.java similarity index 98% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/installer/JavaScriptImporterOptionsDialog.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/installer/JavaScriptImporterOptionsDialog.java index 9a6f1f89c4..dedb76078f 100644 --- a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/installer/JavaScriptImporterOptionsDialog.java +++ b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/installer/JavaScriptImporterOptionsDialog.java @@ -42,6 +42,7 @@ import com.aptana.core.util.StringUtil; import com.aptana.portal.ui.PortalUIPlugin; import com.aptana.portal.ui.dispatch.configurationProcessors.Messages; +import com.aptana.portal.ui.extended.PortaUIExtended; /** * An import dialog that appears right after we download a JavaScript library through the developer-toolbox.
@@ -93,7 +94,7 @@ protected void configureShell(Shell newShell) @Override protected void setAttributes() { - attributes.put(ACTIVE_PROJECT_ATTR, PortalUIPlugin.getActiveProject()); + attributes.put(ACTIVE_PROJECT_ATTR, PortaUIExtended.getActiveProject()); } /** @@ -211,7 +212,7 @@ private void initProjectsCombo(final Combo combo) { return; } - IProject activeProject = PortalUIPlugin.getActiveProject(); + IProject activeProject = PortaUIExtended.getActiveProject(); String activeProjectName = (activeProject != null) ? activeProject.getName() : null; if (activeProject != null && activeProject.isAccessible()) { diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/messages.properties b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/messages.properties similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/configurationProcessors/messages.properties rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/configurationProcessors/messages.properties diff --git a/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/processorDelegates/BaseVersionProcessor.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/processorDelegates/BaseVersionProcessor.java new file mode 100644 index 0000000000..0999724520 --- /dev/null +++ b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/processorDelegates/BaseVersionProcessor.java @@ -0,0 +1,29 @@ +/** + * Aptana Studio + * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. + * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). + * Please see the license.html included with this distribution for details. + * Any modifications to this file must keep this entire header intact. + */ +package com.aptana.portal.ui.dispatch.processorDelegates; + +import com.aptana.configurations.processor.AbstractProcessorDelegate; + +/** + * A base application version retrieval delegate for applications that use '--version' in order to get their version. + * + * @author Shalom Gibly + */ +public abstract class BaseVersionProcessor extends AbstractProcessorDelegate +{ + private static final String VERSION_COMMAND_SYNTAX = "--version"; //$NON-NLS-1$ + + /** + * Constructs a new BaseVersionProcessor + */ + public BaseVersionProcessor() + { + // Make sure we add the supported commands + supportedCommands.put(VERSION_COMMAND, VERSION_COMMAND_SYNTAX); + } +} diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/processorDelegates/CachedVersionProcessorDelegate.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/processorDelegates/CachedVersionProcessorDelegate.java similarity index 97% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/processorDelegates/CachedVersionProcessorDelegate.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/processorDelegates/CachedVersionProcessorDelegate.java index dd8d2cf470..df1c8dec42 100644 --- a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/processorDelegates/CachedVersionProcessorDelegate.java +++ b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/processorDelegates/CachedVersionProcessorDelegate.java @@ -26,6 +26,7 @@ import com.aptana.jetty.util.epl.ajax.JSON; import com.aptana.portal.ui.IPortalPreferences; import com.aptana.portal.ui.PortalUIPlugin; +import com.aptana.portal.ui.extended.PortaUIExtended; /** * A configuration processor delegate that use the preferences as a cache mechanism for the installed apps versions. @@ -76,7 +77,7 @@ public Object runCommand(String commandType, IPath workingDir) IPreferencesService service = Platform.getPreferencesService(); IScopeContext[] contexts; - IProject project = PortalUIPlugin.getActiveProject(); + IProject project = PortaUIExtended.getActiveProject(); if (project != null) { contexts = new IScopeContext[] { new ProjectScope(project), DefaultScope.INSTANCE }; diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/processorDelegates/RailsVersionProcessor.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/processorDelegates/RailsVersionProcessor.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/processorDelegates/RailsVersionProcessor.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/processorDelegates/RailsVersionProcessor.java diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/processorDelegates/RubyVersionProcessor.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/processorDelegates/RubyVersionProcessor.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/processorDelegates/RubyVersionProcessor.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/processorDelegates/RubyVersionProcessor.java diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/processorDelegates/SQLiteVersionProcessor.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/processorDelegates/SQLiteVersionProcessor.java similarity index 100% rename from plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/processorDelegates/SQLiteVersionProcessor.java rename to com.aptana.portal.ui.extended/src/com/aptana/portal/ui/dispatch/processorDelegates/SQLiteVersionProcessor.java diff --git a/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/extended/PortaUIExtended.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/extended/PortaUIExtended.java new file mode 100644 index 0000000000..ec2eb839cc --- /dev/null +++ b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/extended/PortaUIExtended.java @@ -0,0 +1,172 @@ +package com.aptana.portal.ui.extended; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.IPreferencesService; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import com.aptana.core.resources.IProjectContext; +import com.aptana.explorer.ExplorerPlugin; +import com.aptana.explorer.IExplorerUIConstants; +import com.aptana.explorer.IPreferenceConstants; + +/** + * The activator class controls the plug-in life cycle + */ +public class PortaUIExtended extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.aptana.portal.ui.extended"; //$NON-NLS-1$ + + // The shared instance + private static PortaUIExtended plugin; + + /** + * The constructor + */ + public PortaUIExtended() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static PortaUIExtended getDefault() { + return plugin; + } + + + /** + * Try to resolve and return the last active project in the App Explorer. + * + * @return The active IProject. Can be null if not resolved. + */ + public static IProject getActiveProject() + { + // FIXME: Shalom - This is a modified of a code taken from the com.aptana.explorer plugin. Change this code to + // use a more generic solution for the active project problem once it's implemented. + + // First try and get the active project for the instance of the App Explorer open in the active window + final IProject[] projects = new IProject[1]; + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() + { + public void run() + { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + { + return; + } + IWorkbenchPage page = window.getActivePage(); + if (page == null) + { + return; + } + // First, check the view references. + IViewReference[] refs = page.getViewReferences(); + if (refs == null) + { + return; + } + for (IViewReference ref : refs) + { + if (ref == null || !ref.getId().equals(IExplorerUIConstants.VIEW_ID)) + { + continue; + } + IProjectContext view = (IProjectContext) ref.getPart(false); + if (view == null) + { + continue; + } + IProject activeProject = view.getActiveProject(); + if (activeProject != null) + { + projects[0] = activeProject; + return; + } + } + // If we got to this point, we could not find the SingleProjectView and its active project. + // Try to find the a project by the active editor. + IEditorPart activeEditor = page.getActiveEditor(); + if (activeEditor != null) + { + IResource resource = null; + if (activeEditor.getEditorInput().getPersistable() != null) + { + // it's probably a non-browser editor. + resource = (IResource) activeEditor.getEditorInput().getAdapter(IResource.class); + } + else + { + // look for the first persistable editor input we can find. + IEditorReference[] editorReferences = page.getEditorReferences(); + for (IEditorReference reference : editorReferences) + { + IEditorPart editor = reference.getEditor(false); + if (editor != null) + { + resource = (IResource) editor.getEditorInput().getAdapter(IResource.class); + if (resource != null) + { + break; + } + } + } + } + if (resource != null) + { + projects[0] = ((IResource) resource).getProject(); + return; + } + } + } + }); + if (projects[0] != null) + { + return projects[0]; + } + + // Fall back to using project stored in prefs. + IPreferencesService preferencesService = Platform.getPreferencesService(); + String activeProjectName = preferencesService.getString(ExplorerPlugin.PLUGIN_ID, + IPreferenceConstants.ACTIVE_PROJECT, null, null); + IProject result = null; + + if (activeProjectName != null) + { + result = ResourcesPlugin.getWorkspace().getRoot().getProject(activeProjectName); + } + + return result; + } + +} diff --git a/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/internal/command/NewProjectFromTemplateCommandHandler.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/internal/command/NewProjectFromTemplateCommandHandler.java new file mode 100644 index 0000000000..6dc1dbea22 --- /dev/null +++ b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/internal/command/NewProjectFromTemplateCommandHandler.java @@ -0,0 +1,98 @@ +/** + * Aptana Studio + * Copyright (c) 2011 by Appcelerator, Inc. All Rights Reserved. + * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). + * Please see the license.html included with this distribution for details. + * Any modifications to this file must keep this entire header intact. + */ +package com.aptana.portal.ui.internal.command; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWizard; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.wizards.IWizardDescriptor; +import org.eclipse.ui.wizards.IWizardRegistry; + +import com.aptana.projects.wizards.AbstractNewProjectWizard; +import com.aptana.projects.wizards.ProjectTemplateSelectionPage; +import com.aptana.ui.util.UIUtils; + +/** + * Command handler for "com.aptana.portal.ui.command.newProjectFromTemplate". Opens an Aptana/Titanium wizard and + * initializes the project template + * + * @author nle + */ +public class NewProjectFromTemplateCommandHandler extends AbstractHandler +{ + + /** + * Execute the new project command. The command returns the created {@link IProject} name when it's done, in case a + * project was created. + * + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent event) throws ExecutionException + { + String wizardId = event.getParameter(ProjectTemplateSelectionPage.COMMAND_PROJECT_FROM_TEMPLATE_NEW_WIZARD_ID); + String templateName = event + .getParameter(ProjectTemplateSelectionPage.COMMAND_PROJECT_FROM_TEMPLATE_PROJECT_TEMPLATE_NAME); + + IWizardRegistry wizardRegistry = PlatformUI.getWorkbench().getNewWizardRegistry(); + IWizardDescriptor wizardDescriptor = wizardRegistry.findWizard(wizardId); + if (wizardDescriptor == null) + { + throw new ExecutionException("unknown wizard: " + wizardId); //$NON-NLS-1$ + } + + try + { + IWorkbenchWizard wizard = wizardDescriptor.createWizard(); + wizard.init(PlatformUI.getWorkbench(), null); + + if (wizard instanceof IExecutableExtension) + { + ((IExecutableExtension) wizard).setInitializationData(null, + ProjectTemplateSelectionPage.COMMAND_PROJECT_FROM_TEMPLATE_PROJECT_TEMPLATE_NAME, templateName); + } + + if (wizardDescriptor.canFinishEarly() && !wizardDescriptor.hasPages()) + { + wizard.performFinish(); + return getProject(wizard); + } + + Shell parent = UIUtils.getActiveShell(); + WizardDialog dialog = new WizardDialog(parent, wizard); + dialog.create(); + dialog.open(); + return getProject(wizard); + } + catch (CoreException ex) + { + throw new ExecutionException("error creating wizard", ex); //$NON-NLS-1$ + } + } + + /** + * Returns the created project. + * + * @param wizard + * @return An {@link IProject}, or null. + */ + private IProject getProject(IWorkbenchWizard wizard) + { + if (wizard instanceof AbstractNewProjectWizard) + { + return ((AbstractNewProjectWizard) wizard).getCreatedProject(); + } + return null; + } +} diff --git a/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/internal/command/ShowStartPageCommandHandler.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/internal/command/ShowStartPageCommandHandler.java new file mode 100644 index 0000000000..21d88b0a96 --- /dev/null +++ b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/internal/command/ShowStartPageCommandHandler.java @@ -0,0 +1,33 @@ +/** + * Aptana Studio + * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. + * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). + * Please see the license.html included with this distribution for details. + * Any modifications to this file must keep this entire header intact. + */ +package com.aptana.portal.ui.internal.command; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.aptana.portal.ui.internal.startpage.StartPageUtil; + +/** + * A command handler for showing the Studio's start-page. + * + * @author Shalom Gibly + */ +public class ShowStartPageCommandHandler extends AbstractHandler +{ + + /* + * (non-Javadoc) + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent event) throws ExecutionException + { + StartPageUtil.showStartPage(true, null); + return null; + } +} diff --git a/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/internal/command/ShowToolboxCommandHandler.java b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/internal/command/ShowToolboxCommandHandler.java new file mode 100644 index 0000000000..872b75d0ee --- /dev/null +++ b/com.aptana.portal.ui.extended/src/com/aptana/portal/ui/internal/command/ShowToolboxCommandHandler.java @@ -0,0 +1,34 @@ +/** + * Aptana Studio + * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. + * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). + * Please see the license.html included with this distribution for details. + * Any modifications to this file must keep this entire header intact. + */ +package com.aptana.portal.ui.internal.command; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.aptana.portal.ui.browser.PortalBrowserEditor; +import com.aptana.portal.ui.internal.Portal; + +/** + * A command handler for showing the developer-toolbox from the Help menu. + * + * @author Shalom Gibly + */ +public class ShowToolboxCommandHandler extends AbstractHandler +{ + + /* + * (non-Javadoc) + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent event) throws ExecutionException + { + Portal.getInstance().openPortal(null, PortalBrowserEditor.WEB_BROWSER_EDITOR_ID); + return null; + } +} diff --git a/plugins/com.aptana.portal.ui/META-INF/MANIFEST.MF b/plugins/com.aptana.portal.ui/META-INF/MANIFEST.MF index d123f7f7ed..24afa9c752 100644 --- a/plugins/com.aptana.portal.ui/META-INF/MANIFEST.MF +++ b/plugins/com.aptana.portal.ui/META-INF/MANIFEST.MF @@ -6,19 +6,16 @@ Bundle-Version: 3.0.0.qualifier Bundle-Activator: com.aptana.portal.ui.PortalUIPlugin Bundle-Vendor: %providerName Require-Bundle: com.aptana.jetty.util.epl, - com.aptana.core, - com.aptana.core.io, org.eclipse.ui.browser, org.eclipse.ui.console, org.eclipse.debug.ui, - com.aptana.ui, com.aptana.configurations, - com.aptana.usage;bundle-version="4.0.0", - com.aptana.theme, - com.aptana.explorer, com.aptana.browser;visibility:=reexport, - com.aptana.projects, - org.eclipse.e4.ui.workbench;resolution:=optional + org.eclipse.e4.ui.workbench;resolution:=optional, + org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.core.expressions, + com.aptana.core Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy Export-Package: com.aptana.portal.ui, @@ -27,8 +24,6 @@ Export-Package: com.aptana.portal.ui, com.aptana.portal.ui.dispatch.actionControllers, com.aptana.portal.ui.dispatch.browserFunctions, com.aptana.portal.ui.dispatch.browserNotifications, - com.aptana.portal.ui.dispatch.configurationProcessors, - com.aptana.portal.ui.dispatch.configurationProcessors.installer, com.aptana.portal.ui.dispatch.processorDelegates, com.aptana.portal.ui.internal;x-internal:=true, com.aptana.portal.ui.internal.command;x-internal:=true, diff --git a/plugins/com.aptana.portal.ui/plugin.xml b/plugins/com.aptana.portal.ui/plugin.xml index 14ee2e207e..6867bf0a7d 100644 --- a/plugins/com.aptana.portal.ui/plugin.xml +++ b/plugins/com.aptana.portal.ui/plugin.xml @@ -18,57 +18,6 @@ class="com.aptana.portal.ui.internal.startup.PortalStartup"> - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/PortalUIPlugin.java b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/PortalUIPlugin.java index 8324ecc25c..c997f17649 100644 --- a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/PortalUIPlugin.java +++ b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/PortalUIPlugin.java @@ -7,28 +7,12 @@ */ package com.aptana.portal.ui; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.preferences.IPreferencesService; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.aptana.core.resources.IProjectContext; -import com.aptana.explorer.ExplorerPlugin; -import com.aptana.explorer.IExplorerUIConstants; -import com.aptana.explorer.IPreferenceConstants; - /** * The activator class controls the plug-in life cycle */ @@ -87,110 +71,6 @@ public static PortalUIPlugin getDefault() return plugin; } - /** - * Try to resolve and return the last active project in the App Explorer. - * - * @return The active IProject. Can be null if not resolved. - */ - public static IProject getActiveProject() - { - // FIXME: Shalom - This is a modified of a code taken from the com.aptana.explorer plugin. Change this code to - // use a more generic solution for the active project problem once it's implemented. - - // First try and get the active project for the instance of the App Explorer open in the active window - final IProject[] projects = new IProject[1]; - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() - { - public void run() - { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - { - return; - } - IWorkbenchPage page = window.getActivePage(); - if (page == null) - { - return; - } - // First, check the view references. - IViewReference[] refs = page.getViewReferences(); - if (refs == null) - { - return; - } - for (IViewReference ref : refs) - { - if (ref == null || !ref.getId().equals(IExplorerUIConstants.VIEW_ID)) - { - continue; - } - IProjectContext view = (IProjectContext) ref.getPart(false); - if (view == null) - { - continue; - } - IProject activeProject = view.getActiveProject(); - if (activeProject != null) - { - projects[0] = activeProject; - return; - } - } - // If we got to this point, we could not find the SingleProjectView and its active project. - // Try to find the a project by the active editor. - IEditorPart activeEditor = page.getActiveEditor(); - if (activeEditor != null) - { - IResource resource = null; - if (activeEditor.getEditorInput().getPersistable() != null) - { - // it's probably a non-browser editor. - resource = (IResource) activeEditor.getEditorInput().getAdapter(IResource.class); - } - else - { - // look for the first persistable editor input we can find. - IEditorReference[] editorReferences = page.getEditorReferences(); - for (IEditorReference reference : editorReferences) - { - IEditorPart editor = reference.getEditor(false); - if (editor != null) - { - resource = (IResource) editor.getEditorInput().getAdapter(IResource.class); - if (resource != null) - { - break; - } - } - } - } - if (resource != null) - { - projects[0] = ((IResource) resource).getProject(); - return; - } - } - } - }); - if (projects[0] != null) - { - return projects[0]; - } - - // Fall back to using project stored in prefs. - IPreferencesService preferencesService = Platform.getPreferencesService(); - String activeProjectName = preferencesService.getString(ExplorerPlugin.PLUGIN_ID, - IPreferenceConstants.ACTIVE_PROJECT, null, null); - IProject result = null; - - if (activeProjectName != null) - { - result = ResourcesPlugin.getWorkspace().getRoot().getProject(activeProjectName); - } - - return result; - } public static Image getImage(String string) { diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/AbstractPortalBrowserEditor.java b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/AbstractPortalBrowserEditor.java index e392b98a14..21038f2239 100644 --- a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/AbstractPortalBrowserEditor.java +++ b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/AbstractPortalBrowserEditor.java @@ -45,9 +45,6 @@ import com.aptana.portal.ui.internal.BrowserViewerWrapper; import com.aptana.portal.ui.internal.BrowserWrapper; import com.aptana.portal.ui.internal.startpage.IStartPageUISystemProperties; -import com.aptana.ui.dialogs.HyperlinkMessageDialog; -import com.aptana.ui.util.UIUtils; -import com.aptana.ui.util.WorkbenchBrowserUtil; /** * A portal browser editor. diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/HyperlinkMessageDialog.java b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/HyperlinkMessageDialog.java new file mode 100644 index 0000000000..575be5d354 --- /dev/null +++ b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/HyperlinkMessageDialog.java @@ -0,0 +1,158 @@ +/** + * Aptana Studio + * Copyright (c) 2005-2012 by Appcelerator, Inc. All Rights Reserved. + * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). + * Please see the license.html included with this distribution for details. + * Any modifications to this file must keep this entire header intact. + */ +package com.aptana.portal.ui.browser; + +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.Shell; + +import com.aptana.core.util.StringUtil; + +/** + * @author Max Stepanov + */ +public class HyperlinkMessageDialog extends MessageDialog +{ + + private Link messageLink; + + private String toggleMessage; + private boolean toggleState; + + /** + * @param parentShell + * @param dialogTitle + * @param dialogTitleImage + * @param dialogMessage + * @param dialogImageType + * @param dialogButtonLabels + * @param defaultIndex + */ + public HyperlinkMessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, + int dialogImageType, String[] dialogButtonLabels, int defaultIndex, String toggleMessage) + { + super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, + defaultIndex); + this.toggleMessage = toggleMessage; + } + + public boolean getToggleState() + { + return toggleState; + } + + @Override + protected Control createDialogArea(Composite parent) + { + Composite dialogAreaComposite = (Composite) super.createDialogArea(parent); + if (!StringUtil.isEmpty(toggleMessage)) + { + createToggleButton(dialogAreaComposite); + } + return dialogAreaComposite; + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.dialogs.IconAndMessageDialog#createMessageArea(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createMessageArea(Composite composite) + { + String message = this.message; + this.message = null; + Composite messageArea = (Composite) super.createMessageArea(composite); + messageLink = new Link(messageArea, getMessageLabelStyle() | SWT.NO_FOCUS); + messageLink.setText("" + message); //$NON-NLS-1$ + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false) + .hint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH), SWT.DEFAULT) + .applyTo(messageLink); + messageLink.addSelectionListener(new SelectionAdapter() + { + public void widgetSelected(SelectionEvent e) + { + openLink(e); + } + }); + return messageArea; + } + + protected Button createToggleButton(Composite parent) + { + final Button button = new Button(parent, SWT.CHECK | SWT.LEFT); + button.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create()); + button.setFont(parent.getFont()); + button.setText(toggleMessage); + button.addSelectionListener(new SelectionAdapter() + { + + public void widgetSelected(SelectionEvent e) + { + toggleState = button.getSelection(); + } + }); + + return button; + } + + protected void openLink(SelectionEvent e) + { + WorkbenchBrowserUtil.launchExternalBrowser(e.text); + } + + public static boolean open(int kind, Shell parent, String title, String message, int style) + { + return open(kind, parent, title, message, null, style); + } + + public static boolean open(int kind, Shell parent, String title, String message, String toggleMessage, int style) + { + HyperlinkMessageDialog dialog = new HyperlinkMessageDialog(parent, title, null, message, kind, + getButtonLabels(kind), 0, toggleMessage); + return dialog.open() == 0; + } + + public static void openInformation(Shell parent, String title, String message) + { + open(INFORMATION, parent, title, message, null, SWT.NONE); + } + + public static void openError(Shell parent, String title, String message) + { + open(ERROR, parent, title, message, SWT.NONE); + } + + public static String[] getButtonLabels(int kind) + { + switch (kind) + { + case ERROR: + case INFORMATION: + case WARNING: + return new String[] { IDialogConstants.OK_LABEL }; + case CONFIRM: + return new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }; + case QUESTION: + return new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; + case QUESTION_WITH_CANCEL: + return new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, + IDialogConstants.CANCEL_LABEL }; + default: + throw new IllegalArgumentException("Illegal value for kind in HyperlinkMessageDialog.open()"); //$NON-NLS-1$ + } + } +} diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/UIUtils.java b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/UIUtils.java new file mode 100644 index 0000000000..86b47d9dc9 --- /dev/null +++ b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/UIUtils.java @@ -0,0 +1,64 @@ +package com.aptana.portal.ui.browser; + +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +public class UIUtils +{ + + /** + * Gets the active shell for the workbench + * + * @return the active shell + */ + public static Shell getActiveShell() + { + Shell shell = getDisplay().getActiveShell(); + if (shell == null) + { + IWorkbenchWindow window = getActiveWorkbenchWindow(); + if (window != null) + { + shell = window.getShell(); + } + } + return shell; + } + + /** + * Gets the display for the workbench + * + * @return the display + */ + public static Display getDisplay() + { + return PlatformUI.getWorkbench().getDisplay(); + } + + public static IWorkbenchWindow getActiveWorkbenchWindow() + { + try + { + return PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + } + catch (IllegalStateException e) + { + // Workbench has not been created yet + return null; + } + } + + public static IWorkbenchPage getActivePage() + { + IWorkbenchWindow workbench = getActiveWorkbenchWindow(); + if (workbench == null) + { + return null; + } + return workbench.getActivePage(); + } + +} diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/WorkbenchBrowserUtil.java b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/WorkbenchBrowserUtil.java new file mode 100644 index 0000000000..a3cee606df --- /dev/null +++ b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/browser/WorkbenchBrowserUtil.java @@ -0,0 +1,235 @@ +/** + * Aptana Studio + * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. + * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). + * Please see the license.html included with this distribution for details. + * Any modifications to this file must keep this entire header intact. + */ + +package com.aptana.portal.ui.browser; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.swt.program.Program; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.browser.IWebBrowser; +import org.eclipse.ui.browser.IWorkbenchBrowserSupport; + +import com.aptana.core.logging.IdeLog; +import com.aptana.core.util.IProcessRunner; +import com.aptana.core.util.PlatformUtil; +import com.aptana.core.util.ProcessRunner; +import com.aptana.core.util.StringUtil; +import com.aptana.portal.ui.PortalUIPlugin; + +/** + * @author Max Stepanov + */ +public class WorkbenchBrowserUtil +{ + + private static final Pattern ARG_SPLITTER = Pattern.compile("([^\"]\\S*|\".+?\")\\s*"); //$NON-NLS-1$ + + private IProcessRunner runner; + private IWorkbenchBrowserSupport support; + + /** + * + */ + private WorkbenchBrowserUtil() + { + this(new ProcessRunner(), PlatformUI.getWorkbench().getBrowserSupport()); + } + + protected WorkbenchBrowserUtil(IProcessRunner runner, IWorkbenchBrowserSupport support) + { + this.runner = runner; + this.support = support; + } + + public static void launchExternalBrowser(String url) + { + try + { + launchExternalBrowser(new URL(url)); + } + catch (MalformedURLException e) + { + IdeLog.logError(PortalUIPlugin.getDefault(), e); + } + } + + public static void launchExternalBrowser(URL url) + { + launchExternalBrowser(url, null); + } + + public static IWebBrowser launchExternalBrowser(String url, String browserId) + { + try + { + return launchExternalBrowser(new URL(url), browserId); + } + catch (MalformedURLException e) + { + IdeLog.logError(PortalUIPlugin.getDefault(), e); + } + return null; + } + + public static IWebBrowser launchExternalBrowser(URL url, String browserId) + { + return new WorkbenchBrowserUtil().doLaunchExternalBrowser(url, browserId); + } + + IWebBrowser doLaunchExternalBrowser(URL url, String browserId) + { + if (browserId != null) + { + try + { + IWebBrowser webBrowser = support.createBrowser(IWorkbenchBrowserSupport.AS_EXTERNAL, browserId, null, + null); + if (webBrowser != null) + { + webBrowser.openURL(url); + return webBrowser; + } + } + catch (PartInitException e) + { + IdeLog.logError(PortalUIPlugin.getDefault(), e); + } + } + try + { + IWebBrowser webBrowser = support.getExternalBrowser(); + webBrowser.openURL(url); + return webBrowser; + } + catch (Exception e) + { + IdeLog.logError(PortalUIPlugin.getDefault(), e); + launchBrowserByCommand(url); + } + return null; + } + + /** + * If we try to open URLs in the splash (before the platform loads), we typically fail and need a fallback mechanism + * to open URLs externally. + * + * @param url + */ + public static void launchBrowserByCommand(URL url) + { + new WorkbenchBrowserUtil().doLaunchBrowserByCommand(url); + } + + @SuppressWarnings("nls") + void doLaunchBrowserByCommand(URL url) + { + if (launchProgram(url)) + { + return; + } + + // Can we fall back to running a command to load the URL? + if (isMac()) + { + runner.runInBackground("open", url.toString()); + } + else if (isWindows()) + { + List args = new ArrayList(); + IStatus result = runner.runInBackground("reg", "query", "HKEY_CLASSES_ROOT\\http\\shell\\open\\command"); + if (result.isOK()) + { + String output = result.getMessage(); + int index = output.indexOf("REG_SZ"); + if (index != -1) + { + output = output.substring(index + 6); + // Split by lines, take first line, remove leading and trailing whitespace + String firstLine = StringUtil.LINE_SPLITTER.split(output)[0].trim(); + // Now grab all the args which are delimited by spaces, unless quoted. + Matcher m = ARG_SPLITTER.matcher(firstLine); + while (m.find()) + { + // Replace %1 with the url we want to hit + args.add(StringUtil.stripQuotes(m.group(1)).replace("%1", url.toString())); + } + } + } + // We failed to grab the location of the default browser from the registry! + if (args.isEmpty()) + { + args.add("iexplore.exe"); + args.add(url.toString()); + } + runner.runInBackground(args.toArray(new String[args.size()])); + } + else + { + runner.runInBackground("xdg-open", url.toString()); + } + } + + /** + * Attempts to use {@link Program#launch(String)} to open a URL. + * + * @param url + * @return + */ + protected boolean launchProgram(URL url) + { + return Program.launch(url.toString()); + } + + protected boolean isWindows() + { + return PlatformUtil.isWindows(); + } + + protected boolean isMac() + { + return PlatformUtil.isMac(); + } + + /** + * Opens an URL with the default settings (which will typically open in an internal browser with no toolbar/url + * bar/etc). + * + * @param url + * @return + */ + public static IWebBrowser openURL(String url) + { + return new WorkbenchBrowserUtil().doOpenURL(url); + } + + IWebBrowser doOpenURL(String url) + { + try + { + IWebBrowser webBrowser = support.createBrowser(null); + if (webBrowser != null) + { + webBrowser.openURL(new URL(url)); + } + return webBrowser; + } + catch (Exception e) + { + IdeLog.logError(PortalUIPlugin.getDefault(), e); + } + return null; + } +} diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/actionControllers/WorkbenchActionController.java b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/actionControllers/WorkbenchActionController.java deleted file mode 100644 index 799daf9ec9..0000000000 --- a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/actionControllers/WorkbenchActionController.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Aptana Studio - * Copyright (c) 2005-2012 by Appcelerator, Inc. All Rights Reserved. - * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). - * Please see the license.html included with this distribution for details. - * Any modifications to this file must keep this entire header intact. - */ -package com.aptana.portal.ui.dispatch.actionControllers; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.eclipse.ui.IPerspectiveDescriptor; - -import com.aptana.configurations.processor.ConfigurationStatus; -import com.aptana.core.util.ArrayUtil; -import com.aptana.jetty.util.epl.ajax.JSON; -import com.aptana.ui.util.UIUtils; - -/** - * A action controller for workbench related actions. - * - * @author Shalom Gibly - */ -public class WorkbenchActionController extends AbstractActionController -{ - private static final String ID = "id"; //$NON-NLS-1$ - private static final String DESCRIPTION = "description"; //$NON-NLS-1$ - private static final String LABEL = "label"; //$NON-NLS-1$ - - // ############## Actions ############### - /** - * Returns a JSON map representation for the active perspective. - * - *
-	 *   Sample JS code:
-	 *   result = dispatch($H({controller:'portal.workbench', action:"getActivePerspective"}).toJSON());
-	 * 
- * - * @return A JSON map with label, description and id key-value pairs. - */ - @ControllerAction - public Object getActivePerspective() - { - IPerspectiveDescriptor descriptor = UIUtils.getActivePerspectiveDescriptor(); - Map result = new HashMap(); - if (descriptor == null) - { - return JSON.toString(ArrayUtil.NO_STRINGS); - } - result.put(LABEL, descriptor.getLabel()); - result.put(DESCRIPTION, descriptor.getDescription()); - result.put(ID, descriptor.getId()); - return JSON.toString(result); - } - - /* - * (non-Javadoc) - * @see com.aptana.configurations.processor.IConfigurationProcessorListener#configurationStateChanged(com.aptana. - * configurations.processor.ConfigurationStatus, java.util.Set) - */ - public void configurationStateChanged(ConfigurationStatus status, Set attributesChanged) - { - // Nothing to do here - } -} diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/browserFunctions/DispatcherBrowserFunction.java b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/browserFunctions/DispatcherBrowserFunction.java index 62afbc0ff8..3dcda2157d 100644 --- a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/browserFunctions/DispatcherBrowserFunction.java +++ b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/dispatch/browserFunctions/DispatcherBrowserFunction.java @@ -7,7 +7,6 @@ */ package com.aptana.portal.ui.dispatch.browserFunctions; -import java.text.MessageFormat; import java.util.Map; import com.aptana.core.logging.IdeLog; @@ -18,9 +17,6 @@ import com.aptana.portal.ui.dispatch.IActionController; import com.aptana.portal.ui.dispatch.IBrowserNotificationConstants; import com.aptana.portal.ui.internal.IBrowserFunctionHandler; -import com.aptana.usage.FeatureEvent; -import com.aptana.usage.IStudioAnalytics; -import com.aptana.usage.UsagePlugin; /** * This class is the main functions dispatcher for all the registered IActionControllers. @@ -120,27 +116,10 @@ public Object function(Object[] arguments) return BrowserNotifier.toJSONErrorNotification(IBrowserNotificationConstants.JSON_ERROR_WRONG_ARGUMENTS, e.getMessage()); } - // Send an Analytics ping - sendEvent(new FeatureEvent(MessageFormat.format("{0}.{1}", controllerID, action), null)); //$NON-NLS-1$ // OK... Done with the checks. Now dispatch. return dispatch(controller, action, args); } - private void sendEvent(FeatureEvent featureEvent) - { - UsagePlugin plugin = UsagePlugin.getDefault(); - if (plugin == null) - { - return; - } - IStudioAnalytics analytics = plugin.getStudioAnalytics(); - if (analytics == null) - { - return; - } - analytics.sendEvent(featureEvent); - } - /** * Dispatch the action controller function in a synchronous way.
* The action that is being dispatched can still create a Job that will run asynchronously and report back when diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/internal/Portal.java b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/internal/Portal.java index ad3ae4be51..a95e3cf57e 100644 --- a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/internal/Portal.java +++ b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/internal/Portal.java @@ -26,10 +26,8 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; @@ -51,10 +49,7 @@ import com.aptana.portal.ui.IPortalPreferences; import com.aptana.portal.ui.PortalUIPlugin; import com.aptana.portal.ui.browser.AbstractPortalBrowserEditor; -import com.aptana.theme.IThemeManager; -import com.aptana.theme.ThemePlugin; -import com.aptana.ui.util.UIUtils; -import com.aptana.usage.UsagePlugin; +import com.aptana.portal.ui.browser.UIUtils; /** * The portal class is a singleton that controls the portal browser and allows interacting with it. @@ -160,12 +155,12 @@ else if (!isConnected(url)) URL localURL = FileLocator.toFileURL(Portal.class.getResource(BASE_LOCAL_URL)); url = URLUtil.appendParameters(localURL, new String[] { "url", url.toString() }); //$NON-NLS-1$ } - Map parameters = getURLParametersForProject(PortalUIPlugin.getActiveProject()); - if (additionalParameters != null) - { - parameters.putAll(additionalParameters); - } - url = URLUtil.appendParameters(url, parameters, false); +// Map parameters = getURLParametersForProject(PortalUIPlugin.getActiveProject()); +// if (additionalParameters != null) +// { +// parameters.putAll(additionalParameters); +// } + url = URLUtil.appendParameters(url, new HashMap(), false); } catch (IOException e) { @@ -287,6 +282,7 @@ protected URL getDefaultURL() throws IOException return getDefaultURL(new URL(BASE_REMOTE_URL), Portal.class.getResource(BASE_LOCAL_URL)); } + /** * Returns the default URL for the portal.
* In case we have a live Internet connection, return the remote content. Otherwise, return the local content. @@ -359,56 +355,56 @@ protected HttpsURLConnection getConnection(URL httpsURL) throws Exception return con; } - /** - * Build the URL GET parameters that will be appended to the original portal path. - * - * @param activeProject - * @return The GET parameters string - */ - @SuppressWarnings("nls") - protected Map getURLParametersForProject(final IProject activeProject) - { - final Map builder = new HashMap(); - builder.putAll(URLUtil.getDefaultParameters()); - - builder.put("bg", toHex(getThemeManager().getCurrentTheme().getBackground())); - builder.put("fg", toHex(getThemeManager().getCurrentTheme().getForeground())); - - // "chrome" - UIUtils.getDisplay().syncExec(new Runnable() - { - public void run() - { - Color color = PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); - builder.put("ch", toHex(color.getRGB()));// FIXME Grab one of the actual parent widgets and grab it's - // bg? - } - }); - - // project type - builder.put("p", String.valueOf(getProjectType(activeProject))); - - // version control - // builder.append("&vc="); - // builder.append(getVersionControl()); - - // github - // builder.append("&gh="); - // builder.append(hasGithubRemote() ? '1' : '0'); - - // timestamp to force updates to server (bypass browser cache) - builder.put("ts", String.valueOf(System.currentTimeMillis())); - - // guid that relates to a single install of the IDE - builder.put("id", getGUID()); - - // deploy info - builder.putAll(getDeployParam(activeProject)); - - // for debugging output - // builder.append("&debug=1"); - return builder; - } +// /** +// * Build the URL GET parameters that will be appended to the original portal path. +// * +// * @param activeProject +// * @return The GET parameters string +// */ +// @SuppressWarnings("nls") +// protected Map getURLParametersForProject(final IProject activeProject) +// { +// final Map builder = new HashMap(); +// builder.putAll(URLUtil.getDefaultParameters()); +// +// builder.put("bg", toHex(getThemeManager().getCurrentTheme().getBackground())); +// builder.put("fg", toHex(getThemeManager().getCurrentTheme().getForeground())); +// +// // "chrome" +// UIUtils.getDisplay().syncExec(new Runnable() +// { +// public void run() +// { +// Color color = PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); +// builder.put("ch", toHex(color.getRGB()));// FIXME Grab one of the actual parent widgets and grab it's +// // bg? +// } +// }); +// +// // project type +// builder.put("p", String.valueOf(getProjectType(activeProject))); +// +// // version control +// // builder.append("&vc="); +// // builder.append(getVersionControl()); +// +// // github +// // builder.append("&gh="); +// // builder.append(hasGithubRemote() ? '1' : '0'); +// +// // timestamp to force updates to server (bypass browser cache) +// builder.put("ts", String.valueOf(System.currentTimeMillis())); +// +// // guid that relates to a single install of the IDE +//// builder.put("id", getGUID()); +// +// // deploy info +// builder.putAll(getDeployParam(activeProject)); +// +// // for debugging output +// // builder.append("&debug=1"); +// return builder; +// } @SuppressWarnings("nls") protected Map getDeployParam(IProject selectedProject) @@ -440,21 +436,6 @@ protected Map getDeployParam(IProject selectedProject) return builder; } - /** - * Get the theme manager. - * - * @return - */ - protected IThemeManager getThemeManager() - { - return ThemePlugin.getDefault().getThemeManager(); - } - - protected String getGUID() - { - return UsagePlugin.getApplicationId(); - } - protected char getProjectType(IProject selectedProject) { if (selectedProject != null && selectedProject.isAccessible()) diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/internal/command/NewProjectFromTemplateCommandHandler.java b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/internal/command/NewProjectFromTemplateCommandHandler.java index 6dc1dbea22..2dd9fa4bc9 100644 --- a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/internal/command/NewProjectFromTemplateCommandHandler.java +++ b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/internal/command/NewProjectFromTemplateCommandHandler.java @@ -1,98 +1,47 @@ -/** - * Aptana Studio - * Copyright (c) 2011 by Appcelerator, Inc. All Rights Reserved. - * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). - * Please see the license.html included with this distribution for details. - * Any modifications to this file must keep this entire header intact. - */ package com.aptana.portal.ui.internal.command; -import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IExecutableExtension; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWizard; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.wizards.IWizardDescriptor; -import org.eclipse.ui.wizards.IWizardRegistry; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.commands.IHandlerListener; -import com.aptana.projects.wizards.AbstractNewProjectWizard; -import com.aptana.projects.wizards.ProjectTemplateSelectionPage; -import com.aptana.ui.util.UIUtils; - -/** - * Command handler for "com.aptana.portal.ui.command.newProjectFromTemplate". Opens an Aptana/Titanium wizard and - * initializes the project template - * - * @author nle - */ -public class NewProjectFromTemplateCommandHandler extends AbstractHandler +public class NewProjectFromTemplateCommandHandler implements IHandler { - /** - * Execute the new project command. The command returns the created {@link IProject} name when it's done, in case a - * project was created. - * - * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) - */ - public Object execute(ExecutionEvent event) throws ExecutionException + public void addHandlerListener(IHandlerListener handlerListener) { - String wizardId = event.getParameter(ProjectTemplateSelectionPage.COMMAND_PROJECT_FROM_TEMPLATE_NEW_WIZARD_ID); - String templateName = event - .getParameter(ProjectTemplateSelectionPage.COMMAND_PROJECT_FROM_TEMPLATE_PROJECT_TEMPLATE_NAME); + // TODO Auto-generated method stub + + } - IWizardRegistry wizardRegistry = PlatformUI.getWorkbench().getNewWizardRegistry(); - IWizardDescriptor wizardDescriptor = wizardRegistry.findWizard(wizardId); - if (wizardDescriptor == null) - { - throw new ExecutionException("unknown wizard: " + wizardId); //$NON-NLS-1$ - } + public void dispose() + { + // TODO Auto-generated method stub - try - { - IWorkbenchWizard wizard = wizardDescriptor.createWizard(); - wizard.init(PlatformUI.getWorkbench(), null); + } - if (wizard instanceof IExecutableExtension) - { - ((IExecutableExtension) wizard).setInitializationData(null, - ProjectTemplateSelectionPage.COMMAND_PROJECT_FROM_TEMPLATE_PROJECT_TEMPLATE_NAME, templateName); - } + public Object execute(ExecutionEvent event) throws ExecutionException + { + // TODO Auto-generated method stub + return null; + } - if (wizardDescriptor.canFinishEarly() && !wizardDescriptor.hasPages()) - { - wizard.performFinish(); - return getProject(wizard); - } + public boolean isEnabled() + { + // TODO Auto-generated method stub + return false; + } - Shell parent = UIUtils.getActiveShell(); - WizardDialog dialog = new WizardDialog(parent, wizard); - dialog.create(); - dialog.open(); - return getProject(wizard); - } - catch (CoreException ex) - { - throw new ExecutionException("error creating wizard", ex); //$NON-NLS-1$ - } + public boolean isHandled() + { + // TODO Auto-generated method stub + return false; } - /** - * Returns the created project. - * - * @param wizard - * @return An {@link IProject}, or null. - */ - private IProject getProject(IWorkbenchWizard wizard) + public void removeHandlerListener(IHandlerListener handlerListener) { - if (wizard instanceof AbstractNewProjectWizard) - { - return ((AbstractNewProjectWizard) wizard).getCreatedProject(); - } - return null; + // TODO Auto-generated method stub + } + } diff --git a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/internal/startpage/StartPageBrowserEditor.java b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/internal/startpage/StartPageBrowserEditor.java index 12079df7d3..364cb12519 100644 --- a/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/internal/startpage/StartPageBrowserEditor.java +++ b/plugins/com.aptana.portal.ui/src/com/aptana/portal/ui/internal/startpage/StartPageBrowserEditor.java @@ -24,7 +24,7 @@ public class StartPageBrowserEditor extends AbstractPortalBrowserEditor { public static final String WEB_BROWSER_EDITOR_ID = "com.aptana.portal.ui.browser.startPage"; //$NON-NLS-1$ - public static final String STUDIO_START_PAGE_URL = "http://content.aptana.com/aptana/my_aptana/?content=start"; //$NON-NLS-1$ + public static final String STUDIO_START_PAGE_URL = "https://appc-studio.appcelerator.com/"; //$NON-NLS-1$ private static final String TITLE_IMAGE = "icons/obj16/radrails16.png"; //$NON-NLS-1$ diff --git a/plugins/com.aptana.projects/plugin.xml b/plugins/com.aptana.projects/plugin.xml index 2dd91dc526..4f69a7b3f0 100644 --- a/plugins/com.aptana.projects/plugin.xml +++ b/plugins/com.aptana.projects/plugin.xml @@ -191,14 +191,6 @@
- - - -