Search in sources :

Example 11 with ServerSettings

use of com.centurylink.mdw.plugin.project.model.ServerSettings in project mdw-designer by CenturyLinkCloud.

the class ProjectSection method elementChanged.

@Override
public void elementChanged(ElementChangeEvent ece) {
    if (ece.getChangeType().equals(ChangeType.SETTINGS_CHANGE)) {
        if (ece.getNewValue() instanceof JdbcDataSource && jdbcUrlEditor != null) {
            JdbcDataSource dataSource = (JdbcDataSource) ece.getNewValue();
            if (!"projectSection".equals(dataSource.getEntrySource())) {
                // avoid overwriting
                String newJdbcUrl = dataSource.getJdbcUrlWithMaskedCredentials();
                jdbcUrlEditor.setValue(newJdbcUrl);
            }
        } else if (ece.getNewValue() instanceof ServerSettings) {
            ServerSettings serverSettings = (ServerSettings) ece.getNewValue();
            if (!hostEditor.getValue().equals(serverSettings.getHost()))
                hostEditor.setValue(serverSettings.getHost());
            if (!portEditor.getValue().equals(String.valueOf(serverSettings.getPort())))
                portEditor.setValue(serverSettings.getPort());
        } else if (ece.getNewValue() instanceof String) {
            if (!webContextRootEditor.getValue().equals(ece.getNewValue()))
                webContextRootEditor.setValue(ece.getNewValue().toString());
        } else if (ece.getNewValue() instanceof Boolean && !updateServerCacheEditor.getValue().equalsIgnoreCase(ece.getNewValue().toString()))
            updateServerCacheEditor.setValue(ece.getNewValue().toString());
    } else if (ece.getChangeType().equals(ChangeType.VERSION_CHANGE) && project.equals(ece.getElement()) && !mdwVersionEditor.getValue().equals(ece.getNewValue()))
        mdwVersionEditor.setValue(ece.getNewValue().toString());
}
Also used : ServerSettings(com.centurylink.mdw.plugin.project.model.ServerSettings) JdbcDataSource(com.centurylink.mdw.plugin.project.model.JdbcDataSource)

Example 12 with ServerSettings

use of com.centurylink.mdw.plugin.project.model.ServerSettings in project mdw-designer by CenturyLinkCloud.

the class ServerConsole method addToMenuAndToolbar.

public void addToMenuAndToolbar() {
    // start action
    startAction = new Action("Start") {

        public void run() {
            WorkflowElementActionHandler actionHandler = new WorkflowElementActionHandler();
            actionHandler.run(getRunnableObject());
        }
    };
    startAction.setImageDescriptor(MdwPlugin.getImageDescriptor("icons/run.gif"));
    Object runnableObj = getRunnableObject();
    String startText = "Start";
    if (runnableObj instanceof WorkflowProject)
        startText += " " + ((WorkflowProject) runnableObj).getName();
    else if (runnableObj instanceof ServerSettings)
        startText += " " + ((ServerSettings) runnableObj).getServerName();
    startAction.setToolTipText(startText);
    startAction.setEnabled(runnableObj != null);
    // client shell action
    clientShellAction = new Action("Client Shell") {

        public void run() {
            WorkflowElementActionHandler actionHandler = new WorkflowElementActionHandler();
            actionHandler.clientShell(getRunnableObject());
        }
    };
    clientShellAction.setImageDescriptor(MdwPlugin.getImageDescriptor("icons/client_shell.gif"));
    clientShellAction.setToolTipText("Client Shell");
    clientShellAction.setEnabled(false);
    // deploy action
    deployAction = new Action("Deploy") {

        public void run() {
            WorkflowElementActionHandler actionHandler = new WorkflowElementActionHandler();
            actionHandler.deploy(getRunnableObject());
        }
    };
    deployAction.setImageDescriptor(MdwPlugin.getImageDescriptor("icons/deploy.gif"));
    deployAction.setToolTipText("Deploy");
    deployAction.setEnabled(false);
    // stop action
    stopAction = new Action("Stop") {

        public void run() {
            WorkflowElementActionHandler actionHandler = new WorkflowElementActionHandler();
            actionHandler.stop(getRunnableObject());
        }
    };
    stopAction.setImageDescriptor(MdwPlugin.getImageDescriptor("icons/stop.gif"));
    stopAction.setToolTipText("Stop");
    stopAction.setEnabled(false);
    // create menu
    getViewSite().getActionBars().getMenuManager().add(startAction);
    // getViewSite().getActionBars().getMenuManager().add(clientShellAction);
    getViewSite().getActionBars().getMenuManager().add(deployAction);
    getViewSite().getActionBars().getMenuManager().add(stopAction);
    getViewSite().getActionBars().getMenuManager().add(new Separator());
    // create toolbar
    getViewSite().getActionBars().getToolBarManager().add(startAction);
    getViewSite().getActionBars().getToolBarManager().add(clientShellAction);
    getViewSite().getActionBars().getToolBarManager().add(deployAction);
    getViewSite().getActionBars().getToolBarManager().add(stopAction);
    getViewSite().getActionBars().getToolBarManager().add(new Separator());
}
Also used : WorkflowElementActionHandler(com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler) Action(org.eclipse.jface.action.Action) ServerSettings(com.centurylink.mdw.plugin.project.model.ServerSettings) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) Separator(org.eclipse.jface.action.Separator)

Example 13 with ServerSettings

use of com.centurylink.mdw.plugin.project.model.ServerSettings in project mdw-designer by CenturyLinkCloud.

the class ServiceMixServerBehavior method getServerSettings.

ServerSettings getServerSettings() {
    serverSettings = null;
    String serverLoc = getServer().getAttribute(ServiceMixServer.LOCATION, "");
    ServiceMixRuntime runtime = (ServiceMixRuntime) getServer().getRuntime().loadAdapter(RuntimeDelegate.class, null);
    if (!serverLoc.isEmpty() && runtime != null && runtime.getLocation() != null && !runtime.getLocation().isEmpty()) {
        serverSettings = new ServerSettings(getProject());
        serverSettings.setContainerType(ContainerType.ServiceMix);
        serverSettings.setHome(runtime.getLocation().toString());
        serverSettings.setJdkHome(runtime.getJavaHome());
        serverSettings.setServerName(getServer().getName());
        serverSettings.setServerLoc(serverLoc);
        serverSettings.setHost(getServer().getHost());
        serverSettings.setPort(getServer().getAttribute(ServiceMixServer.SERVER_PORT, 0));
        serverSettings.setCommandPort(getServer().getAttribute(ServiceMixServer.SSH_PORT, 0));
        serverSettings.setUser(getServer().getAttribute(ServiceMixServer.USER, ""));
        serverSettings.setPassword(getServer().getAttribute(ServiceMixServer.PASSWORD, ""));
        serverSettings.setJavaOptions(getServer().getAttribute(JAVA_OPTIONS, DEFAULT_JAVA_OPTS));
        serverSettings.setDebug(getServer().getAttribute(DEBUG_MODE, DEFAULT_DEBUG_MODE));
        serverSettings.setDebugPort(getServer().getAttribute(DEBUG_PORT, DEFAULT_DEBUG_PORT));
        serverSettings.setSuspend(getServer().getAttribute(DEBUG_SUSPEND, DEFAULT_DEBUG_SUSPEND));
    }
    if (serverSettings == null) {
        // compatibility for old servers
        WorkflowProject workflowProject = getProject();
        if (workflowProject == null)
            return null;
        serverSettings = workflowProject.getServerSettings();
        serverSettings.setServerName(getServer().getName());
    }
    return serverSettings;
}
Also used : ServerSettings(com.centurylink.mdw.plugin.project.model.ServerSettings) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) RuntimeDelegate(org.eclipse.wst.server.core.model.RuntimeDelegate)

Example 14 with ServerSettings

use of com.centurylink.mdw.plugin.project.model.ServerSettings in project mdw-designer by CenturyLinkCloud.

the class WorkflowElementActionHandler method clientShell.

public void clientShell(Object element) {
    ServerSettings serverSettings;
    if (element instanceof WorkflowProject || element instanceof ServerSettings) {
        if (element instanceof WorkflowProject) {
            WorkflowProject workflowProject = (WorkflowProject) element;
            serverSettings = workflowProject.getServerSettings();
            MdwPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.PREFS_SERVER_WF_PROJECT, workflowProject.getName());
        } else {
            serverSettings = (ServerSettings) element;
            MdwPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.PREFS_RUNNING_SERVER, serverSettings.getServerName());
        }
        ServerConfigurator configurator = ServerConfigurator.Factory.create(serverSettings);
        configurator.doClientShell(getShell());
    }
}
Also used : ServerSettings(com.centurylink.mdw.plugin.project.model.ServerSettings) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) ServerConfigurator(com.centurylink.mdw.plugin.server.ServerConfigurator)

Example 15 with ServerSettings

use of com.centurylink.mdw.plugin.project.model.ServerSettings in project mdw-designer by CenturyLinkCloud.

the class WorkflowElementActionHandler method run.

public void run(Object element) {
    if (element instanceof WorkflowProcess) {
        WorkflowProcess processVersion = (WorkflowProcess) element;
        IEditorPart editorPart = findOpenEditor(processVersion);
        if (editorPart != null && editorPart.isDirty()) {
            if (MessageDialog.openQuestion(getShell(), "Process Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
                editorPart.doSave(new NullProgressMonitor());
        }
        if (MdwPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREFS_WEB_BASED_PROCESS_LAUNCH)) {
            // web-based process launch
            try {
                IViewPart viewPart = getPage().showView("mdw.views.designer.process.launch");
                if (viewPart != null) {
                    ProcessLaunchView launchView = (ProcessLaunchView) viewPart;
                    launchView.setProcess(processVersion);
                }
            } catch (PartInitException ex) {
                PluginMessages.log(ex);
            }
        } else {
            if (editorPart == null) {
                // process must be open
                open((WorkflowElement) element);
            }
            ProcessLaunchShortcut launchShortcut = new ProcessLaunchShortcut();
            launchShortcut.launch(new StructuredSelection(processVersion), ILaunchManager.RUN_MODE);
        }
    } else if (element instanceof Activity) {
        Activity activity = (Activity) element;
        WorkflowProcess processVersion = activity.getProcess();
        IEditorPart editorPart = findOpenEditor(processVersion);
        if (editorPart != null && editorPart.isDirty()) {
            if (MessageDialog.openQuestion(getShell(), "Activity Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
                editorPart.doSave(new NullProgressMonitor());
        }
        ActivityLaunchShortcut launchShortcut = new ActivityLaunchShortcut();
        launchShortcut.launch(new StructuredSelection(activity), ILaunchManager.RUN_MODE);
    } else if (element instanceof ExternalEvent) {
        ExternalEvent externalEvent = (ExternalEvent) element;
        ExternalEventLaunchShortcut launchShortcut = new ExternalEventLaunchShortcut();
        launchShortcut.launch(new StructuredSelection(externalEvent), ILaunchManager.RUN_MODE);
    } else if (element instanceof Template) {
        Template template = (Template) element;
        IEditorPart editorPart = template.getFileEditor();
        if (editorPart != null && editorPart.isDirty()) {
            if (MessageDialog.openQuestion(getShell(), "Run Template", "Save template '" + template.getName() + "' before running?"))
                editorPart.doSave(new NullProgressMonitor());
        }
        template.openFile(new NullProgressMonitor());
        new TemplateRunDialog(getShell(), template).open();
    } else if (element instanceof Page) {
        Page page = (Page) element;
        IEditorPart editorPart = page.getFileEditor();
        if (editorPart != null) {
            if (editorPart.isDirty()) {
                if (MessageDialog.openQuestion(getShell(), "Run Page", "Save page '" + page.getName() + "' before running?"))
                    editorPart.doSave(new NullProgressMonitor());
            }
        }
        page.run();
    } else if (element instanceof WorkflowProject || element instanceof ServerSettings) {
        ServerSettings serverSettings;
        if (element instanceof WorkflowProject) {
            WorkflowProject workflowProject = (WorkflowProject) element;
            if (workflowProject.isRemote())
                throw new IllegalArgumentException("Cannot run server for remote projects.");
            serverSettings = workflowProject.getServerSettings();
        } else {
            serverSettings = (ServerSettings) element;
        }
        if (ServerRunner.isServerRunning()) {
            String question = "A server may be running already.  Shut down the currently-running server?";
            MessageDialog dlg = new MessageDialog(getShell(), "Server Running", null, question, MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Shutdown", "Ignore", "Cancel" }, 0);
            int res = dlg.open();
            if (res == 0)
                new ServerRunner(serverSettings, getShell().getDisplay()).stop();
            else if (res == 2)
                return;
        }
        if (serverSettings.getHome() == null && element instanceof WorkflowProject) {
            final IProject project = serverSettings.getProject().isCloudProject() ? serverSettings.getProject().getSourceProject() : serverSettings.getProject().getEarProject();
            @SuppressWarnings("restriction") org.eclipse.ui.internal.dialogs.PropertyDialog dialog = org.eclipse.ui.internal.dialogs.PropertyDialog.createDialogOn(getShell(), "mdw.workflow.mdwServerConnectionsPropertyPage", project);
            if (dialog != null)
                dialog.open();
        } else {
            IPreferenceStore prefStore = MdwPlugin.getDefault().getPreferenceStore();
            if (element instanceof WorkflowProject)
                prefStore.setValue(PreferenceConstants.PREFS_SERVER_WF_PROJECT, ((WorkflowProject) element).getName());
            else
                prefStore.setValue(PreferenceConstants.PREFS_RUNNING_SERVER, serverSettings.getServerName());
            ServerRunner runner = new ServerRunner(serverSettings, getShell().getDisplay());
            if (serverSettings.getProject() != null)
                runner.setJavaProject(serverSettings.getProject().getJavaProject());
            runner.start();
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IViewPart(org.eclipse.ui.IViewPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExternalEventLaunchShortcut(com.centurylink.mdw.plugin.launch.ExternalEventLaunchShortcut) AdapterActivity(com.centurylink.mdw.plugin.designer.model.Activity.AdapterActivity) EvaluatorActivity(com.centurylink.mdw.plugin.designer.model.Activity.EvaluatorActivity) StartActivity(com.centurylink.mdw.plugin.designer.model.Activity.StartActivity) Activity(com.centurylink.mdw.plugin.designer.model.Activity) ActivityLaunchShortcut(com.centurylink.mdw.plugin.launch.ActivityLaunchShortcut) TemplateRunDialog(com.centurylink.mdw.plugin.designer.dialogs.TemplateRunDialog) SearchResultsPage(com.centurylink.mdw.plugin.search.SearchResultsPage) Page(com.centurylink.mdw.plugin.designer.model.Page) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Template(com.centurylink.mdw.plugin.designer.model.Template) TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) ProcessLaunchShortcut(com.centurylink.mdw.plugin.launch.ProcessLaunchShortcut) ServerSettings(com.centurylink.mdw.plugin.project.model.ServerSettings) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) PartInitException(org.eclipse.ui.PartInitException) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) IProject(org.eclipse.core.resources.IProject) ServerRunner(com.centurylink.mdw.plugin.server.ServerRunner) ProcessLaunchView(com.centurylink.mdw.plugin.designer.views.ProcessLaunchView) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

ServerSettings (com.centurylink.mdw.plugin.project.model.ServerSettings)19 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)7 JdbcDataSource (com.centurylink.mdw.plugin.project.model.JdbcDataSource)3 Activity (com.centurylink.mdw.plugin.designer.model.Activity)2 AdapterActivity (com.centurylink.mdw.plugin.designer.model.Activity.AdapterActivity)2 EvaluatorActivity (com.centurylink.mdw.plugin.designer.model.Activity.EvaluatorActivity)2 StartActivity (com.centurylink.mdw.plugin.designer.model.Activity.StartActivity)2 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)2 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)2 ActivityLaunchShortcut (com.centurylink.mdw.plugin.launch.ActivityLaunchShortcut)2 ExternalEventLaunchShortcut (com.centurylink.mdw.plugin.launch.ExternalEventLaunchShortcut)2 ProcessLaunchShortcut (com.centurylink.mdw.plugin.launch.ProcessLaunchShortcut)2 VcsRepository (com.centurylink.mdw.plugin.project.model.VcsRepository)2 ServerConfigurator (com.centurylink.mdw.plugin.server.ServerConfigurator)2 ServerRunner (com.centurylink.mdw.plugin.server.ServerRunner)2 GeneralSecurityException (java.security.GeneralSecurityException)2 IStatus (org.eclipse.core.runtime.IStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Status (org.eclipse.core.runtime.Status)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2