Skip to main content
summaryrefslogtreecommitdiffstats
blob: b8f185e249d8f3ea23de4440da6ec2cffcf9204e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.ats.editor.help;

import java.io.File;
import java.io.IOException;
import org.eclipse.help.IHelpResource;
import org.eclipse.osee.ats.internal.AtsPlugin;
import org.eclipse.osee.framework.jdk.core.util.AHTML;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.plugin.core.PluginUtil;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.DynamicXWidgetLayoutData;

/**
 * @author Donald G. Dunne
 */
public class WorkAttrHelpResource implements IHelpResource {

   private final DynamicXWidgetLayoutData layoutData;

   public WorkAttrHelpResource(DynamicXWidgetLayoutData layoutData) {
      this.layoutData = layoutData;
   }

   @Override
   public String getHref() {
      if (layoutData != null) {
         File file = (new PluginUtil(AtsPlugin.PLUGIN_ID)).getPluginStoreFile(layoutData.getStoreName() + ".html");
         String absFile = "file:\\/\\/" + file.getAbsolutePath();
         StringBuffer sb = new StringBuffer();
         sb.append(AHTML.heading(1, layoutData.getName()));
         if (layoutData.getToolTip() != null) {
            sb.append(AHTML.para(layoutData.getToolTip()));
         } else {
            sb.append(AHTML.para("Enter the " + layoutData.getName()));
         }
         String html = AHTML.simplePage(sb.toString());

         try {
            Lib.writeStringToFile(html, file);
         } catch (IOException ex) {
            OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
         }

         return absFile;
      }
      return null;
   }

   @Override
   public String getLabel() {
      if (layoutData != null) {
         return layoutData.getName();
      }
      return "";
   }

}

Back to the top