public LoginAdvancedControl(Composite parent, int style, AuthenticationRunner authenticator) {
    super(parent, style);
    this.authenticator = authenticator;

    Grid12 grid = new Grid12(this, 40, 20);

    grid.createLabel(4, Labels.getString("SettingsPage.username"));
    userName =
        grid.createText(
            6, SWT.BORDER | SWT.FILL, authenticator.getConfig().getString(Config.USERNAME));
    grid.createPadding(2);

    grid.createLabel(4, Labels.getString("SettingsPage.sessionId"));
    sessionId =
        grid.createText(
            6, SWT.BORDER, authenticator.getConfig().getString(Config.SFDC_INTERNAL_SESSION_ID));
    grid.createPadding(2);

    grid.createLabel(4, Labels.getString("SettingsPage.instServerUrl"));
    loginUrl = grid.createText(6, SWT.BORDER, authenticator.getConfig().getString(Config.ENDPOINT));
    grid.createPadding(2);

    loginLabel = grid.createLabel(8, "");
    loginButton = grid.createButton(2, SWT.PUSH | SWT.FILL, Labels.getString("SettingsPage.login"));
    loginButton.addListener(SWT.Selection, this::loginButton_Clicked);
    grid.createPadding(2);
  }
예제 #2
0
 @Test
 public void testInitialize() {
   Labels.initialize(new Locale("en"));
   Object oldInternalInstance = Labels.getInstance();
   Labels.initialize(new Locale("ee"));
   assertFalse(oldInternalInstance == Labels.getInstance());
 }
예제 #3
0
 @Override
 public void run() {
   HyperlinkDialog dlg = new HyperlinkDialog(LoaderWindow.getApp().getShell(), controller);
   dlg.setText(Labels.getString("HelpUIAction.dlgTitle")); // $NON-NLS-1$
   dlg.setMessage(Labels.getString("HelpUIAction.dlgMsg")); // $NON-NLS-1$
   dlg.setLinkText(Labels.getString("HelpUIAction.dlgLinkText")); // $NON-NLS-1$
   dlg.setLinkURL(Labels.getString("HelpUIAction.dlgURL")); // $NON-NLS-1$
   dlg.setBoldMessage(Labels.getString("HelpUIAction.msgHeader")); // $NON-NLS-1$
   dlg.open();
 }
예제 #4
0
 // Methods
 public WeigthsNetworkWindow(
     String title,
     NetworkPainter networkPainter,
     Map<Tuple<Id<TransitStopFacility>, Id<ActivityFacility>>, Tuple<Boolean, Double>> ids,
     SortedMap<Id<ActivityFacility>, MPAreaData> dataMPAreas,
     SortedMap<String, Coord> stopsBase) {
   setTitle(title);
   setDefaultCloseOperation(HIDE_ON_CLOSE);
   this.setLocation(0, 0);
   this.setLayout(new BorderLayout());
   layersPanels.put(
       PanelIds.ONE, new WeigthsNetworkPanel(this, networkPainter, ids, dataMPAreas, stopsBase));
   this.add(layersPanels.get(PanelIds.ONE), BorderLayout.CENTER);
   option = Option.ZOOM;
   JPanel buttonsPanel = new JPanel();
   buttonsPanel.setLayout(new GridLayout(Option.values().length, 1));
   for (Option option : Option.values()) {
     JButton optionButton = new JButton(option.getCaption());
     optionButton.setActionCommand(option.getCaption());
     optionButton.addActionListener(this);
     buttonsPanel.add(optionButton);
   }
   this.add(buttonsPanel, BorderLayout.EAST);
   JPanel infoPanel = new JPanel();
   infoPanel.setLayout(new BorderLayout());
   readyButton = new JButton("Ready to exit");
   readyButton.addActionListener(this);
   readyButton.setActionCommand(READY_TO_EXIT);
   infoPanel.add(readyButton, BorderLayout.WEST);
   JPanel labelsPanel = new JPanel();
   labelsPanel.setLayout(new GridLayout(1, Labels.values().length));
   labelsPanel.setBorder(new TitledBorder("Information"));
   labels = new JTextField[Labels.values().length];
   for (int i = 0; i < Labels.values().length; i++) {
     labels[i] = new JTextField("");
     labels[i].setEditable(false);
     labels[i].setBackground(null);
     labels[i].setBorder(null);
     labelsPanel.add(labels[i]);
   }
   infoPanel.add(labelsPanel, BorderLayout.CENTER);
   JPanel coordsPanel = new JPanel();
   coordsPanel.setLayout(new GridLayout(1, 2));
   coordsPanel.setBorder(new TitledBorder("Coordinates"));
   coordsPanel.add(lblCoords[0]);
   coordsPanel.add(lblCoords[1]);
   infoPanel.add(coordsPanel, BorderLayout.EAST);
   this.add(infoPanel, BorderLayout.SOUTH);
   setSize(
       Toolkit.getDefaultToolkit().getScreenSize().width,
       Toolkit.getDefaultToolkit().getScreenSize().height);
 }
예제 #5
0
 public static String getTitleI18n(Locale locale, String modelName, String tabName)
     throws XavaException {
   String id = null;
   if (Is.emptyString(tabName)) {
     id = modelName + ".tab.title";
   } else {
     id = modelName + ".tabs." + tabName + ".title";
   }
   if (Labels.existsExact(id, locale)) {
     return Labels.get(id, locale);
   } else {
     return null;
   }
 }
예제 #6
0
 public static int warningConfMessageBox(Shell shell, String message) {
   return messageBox(
       shell,
       Labels.getString("UI.warning"),
       SWT.ICON_WARNING | SWT.YES | SWT.NO,
       String.valueOf(message)); // $NON-NLS-1$
 }
예제 #7
0
 public static int errorMessageBox(Shell shell, String message) {
   return messageBox(
       shell,
       Labels.getString("UI.error"),
       SWT.OK | SWT.ICON_ERROR,
       String.valueOf(message)); // $NON-NLS-1$
 }
예제 #8
0
  /**
   * Creates an ArrayList with JLabels containing an order.
   *
   * @return ArrayList with JLabels
   */
  private ArrayList<javax.swing.JLabel> createOrderLabels() {

    ArrayList<javax.swing.JLabel> orders = new ArrayList<javax.swing.JLabel>();
    ArrayList<Order> allOrders = Order.getAllOrders();
    for (int i = 0; i < allOrders.size(); i++) {
      String orderText = "";
      final Order order = allOrders.get(i);

      // Set text for the JLabel
      orderText =
          order.getDateAndTime()
              + ": "
              + order.getCustomer().getName()
              + ", "
              + order.getCustomer().getAddress();
      orderText = orderText.substring(0, orderText.length());

      // Create a JLabel and define dimensions and other variables
      javax.swing.JLabel label = Labels.createOneLineLabel(orderText, "blue");
      label.addMouseListener(
          new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
              orderLabelMouseClicked(order);
            }
          });

      // Add JLabel to the arrayList of orders
      orders.add(label);
    }
    return orders;
  }
  /**
   * InputDialog constructor
   *
   * @param parent the parent
   */
  public AdvancedSettingsDialog(Shell parent, Controller controller) {
    super(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
    setText(Labels.getString("AdvancedSettingsDialog.title")); // $NON-NLS-1$
    setMessage(Labels.getString("AdvancedSettingsDialog.message")); // $NON-NLS-1$
    this.controller = controller;

    URI uri;
    String server = "";
    try {
      uri = new URI(Connector.END_POINT);
      server = uri.getScheme() + "://" + uri.getHost(); // $NON-NLS-1$
    } catch (URISyntaxException e) {
      logger.error(e);
    }
    defaultServer = server;
  }
예제 #10
0
 public List namesToMetaProperties(Collection names) throws XavaException {
   List metaProperties = new ArrayList();
   Iterator it = names.iterator();
   int i = -1;
   while (it.hasNext()) {
     i++;
     String name = (String) it.next();
     MetaProperty metaPropertyTab = null;
     try {
       MetaProperty metaProperty = getMetaModel().getMetaProperty(name).cloneMetaProperty();
       metaProperty.setQualifiedName(name);
       String labelId = null;
       if (representCollection()) {
         labelId = getId() + "." + name;
         // If there is no specific translation for the collection,
         // we take the translation from the default tab.
         if (!Labels.existsExact(labelId)) {
           labelId = getIdForDefaultTab() + ".properties." + name;
         }
       } else {
         labelId = getId() + ".properties." + name;
       }
       if (Labels.exists(labelId)) {
         metaProperty.setLabelId(labelId);
       } else if (metaPropertiesTab != null) {
         // By now only the label overwritten from the property of tab
         metaPropertyTab = (MetaProperty) metaPropertiesTab.get(name);
         if (metaPropertyTab != null) {
           metaProperty = metaProperty.cloneMetaProperty();
           metaProperty.setLabel(metaPropertyTab.getLabel());
         }
       }
       metaProperties.add(metaProperty);
     } catch (ElementNotFoundException ex) {
       MetaProperty notInEntity = new MetaProperty();
       notInEntity.setName(name);
       notInEntity.setTypeName("java.lang.Object");
       if (metaPropertyTab != null) {
         notInEntity.setLabel(metaPropertyTab.getLabel());
       }
       metaProperties.add(notInEntity);
     }
   }
   return metaProperties;
 }
예제 #11
0
  @Override
  public boolean performFinish() {
    // validate the status output
    String outputDirName = getFinishPage().getOutputDir();
    File statusDir = new File(outputDirName);
    if (!statusDir.exists() || !statusDir.isDirectory()) {
      UIUtils.errorMessageBox(
          getShell(), Labels.getString("LoadWizard.errorValidDirectory")); // $NON-NLS-1$
      return false;
    }
    // set the files for status output
    try {
      getController().setStatusFiles(outputDirName, false, true);
      getController().saveConfig();
    } catch (ProcessInitializationException e) {
      UIUtils.errorMessageBox(getShell(), e);
      return false;
    }

    int val = UIUtils.warningConfMessageBox(getShell(), getConfirmationText());

    if (val != SWT.YES) {
      return false;
    }

    if (!wizardhook_validateFinish()) {
      return false;
    }

    try {
      ProgressMonitorDialog dlg = new ProgressMonitorDialog(getShell());
      dlg.run(true, true, new SWTLoadRunable(getController()));

    } catch (InvocationTargetException e) {
      logger.error(Labels.getString("LoadWizard.errorAction"), e); // $NON-NLS-1$
      UIUtils.errorMessageBox(getShell(), e.getCause() != null ? e.getCause() : e);
      return false;
    } catch (InterruptedException e) {
      logger.error(Labels.getString("LoadWizard.errorAction"), e); // $NON-NLS-1$
      UIUtils.errorMessageBox(getShell(), e.getCause() != null ? e.getCause() : e);
      return false;
    }

    return true;
  }
예제 #12
0
 @Test
 public void testInexistentLabel() {
   try {
     Labels.getLabel("abra-cadabra");
     fail();
   } catch (Exception e) {
     // exception is good
   }
 }
예제 #13
0
 @Test
 public void testImageAsStream() throws IOException {
   InputStream stream = Labels.getInstance().getImageAsStream("button.start.img");
   // Now check the first bytes of GIF image header
   stream.read();
   assertEquals((int) 'P', stream.read());
   assertEquals((int) 'N', stream.read());
   assertEquals((int) 'G', stream.read());
   stream.close();
 }
예제 #14
0
  private void findAndTestLabels(File file) throws IOException {
    // TODO: tune these regexps
    final Pattern LABELS_REGEX =
        Pattern.compile("Label.get{1,60}\"([a-z]\\w+?\\.[a-z][\\w.]+?\\w)\"");
    final Pattern EXCEPTION_REGEX = Pattern.compile("new\\s+?(\\w+?Exception)\\(\"([\\w.]+?\\w)\"");

    BufferedReader fileReader = new BufferedReader(new FileReader(file));
    StringBuffer sb = new StringBuffer();
    String fileLine;
    while ((fileLine = fileReader.readLine()) != null) {
      sb.append(fileLine);
    }
    fileReader.close();
    String fileContent = sb.toString();

    String key = null;
    //		String value = null;
    try {
      //			System.out.println(file.getPath());

      Matcher matcher = LABELS_REGEX.matcher(fileContent);
      while (matcher.find()) {
        // try to load the label
        key = matcher.group(1);
        //				value =
        Labels.getLabel(key);
        //				System.out.println(key + "=" + value);
      }

      matcher = EXCEPTION_REGEX.matcher(fileContent);
      while (matcher.find()) {
        // try to load the label
        key = "exception." + matcher.group(1) + "." + matcher.group(2);
        //				value =
        Labels.getLabel(key);
        //				System.out.println(key + "=" + value);
      }
    } catch (MissingResourceException e) {
      throw new AssertionFailedError("Label not found: " + key + ", in file: " + file.getPath());
    }
  }
  @Override
  protected Component getChart() {
    Chart chart = new Chart(ChartType.PIE);

    Configuration conf = chart.getConfiguration();

    conf.setTitle("Browser market shares at a specific website, 2010");

    PlotOptionsPie plotOptions = new PlotOptionsPie();
    plotOptions.setStartAngle(45);
    plotOptions.setEndAngle(180);
    plotOptions.setCursor(Cursor.POINTER);
    Labels dataLabels = new Labels(true);
    dataLabels.setFormatter("'<b>'+ this.point.name +'</b>: '+ this.percentage +' %'");
    plotOptions.setDataLabels(dataLabels);
    conf.setPlotOptions(plotOptions);

    conf.setSeries(getBrowserMarketShareSeries());

    chart.drawChart();
    return chart;
  }
예제 #16
0
  @Test
  public void testIncrementCounters() {
    Labels labels = new Labels();

    LabelCounters lc = new LabelCounters();
    lc.setTotalMessages(120L);
    lc.setTotalBytes(1024000L);
    lc.setUnreadMessages(32L);

    LabelCounters diff = new LabelCounters();
    diff.setTotalMessages(19L);
    diff.setTotalBytes(24000L);
    diff.setUnreadMessages(5L);

    // increment initialized label
    labels.add(1, ReservedLabels.INBOX.getName());
    labels.setCounters(1, lc);
    labels.incrementCounters(1, diff);

    assertEquals(labels.getLabelCounters(1).getTotalMessages().intValue(), 120 + 19);
    assertEquals(labels.getLabelCounters(1).getTotalBytes().intValue(), 1024000 + 24000);
    assertEquals(labels.getLabelCounters(1).getUnreadMessages().intValue(), 32 + 5);
  }
  /**
   * Creates the dialog's contents
   *
   * @param shell the dialog window
   */
  private void createContents(final Shell shell) {

    final Config config = controller.getConfig();

    // Create the ScrolledComposite to scroll horizontally and vertically
    ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);

    // Create the parent Composite container for the three child containers
    Composite container = new Composite(sc, SWT.NONE);
    GridLayout containerLayout = new GridLayout(1, false);
    container.setLayout(containerLayout);
    shell.setLayout(new FillLayout());

    GridData data;
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 50;
    data.widthHint = 400;

    // START TOP COMPONENT

    Composite topComp = new Composite(container, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    topComp.setLayout(layout);
    topComp.setLayoutData(data);

    Label blank = new Label(topComp, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 10;
    blank.setLayoutData(data);
    blank.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    // Show the message
    Label label = new Label(topComp, SWT.NONE);
    label.setText(message);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 30;
    data.widthHint = 370;

    Font f = label.getFont();
    FontData[] farr = f.getFontData();
    FontData fd = farr[0];
    fd.setStyle(SWT.BOLD);
    label.setFont(new Font(Display.getCurrent(), fd));

    label.setLayoutData(data);
    label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    Label labelSeparator = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    labelSeparator.setLayoutData(data);

    // END TOP COMPONENT

    // START MIDDLE COMPONENT

    Composite restComp = new Composite(container, SWT.NONE);
    data = new GridData(GridData.FILL_BOTH);
    restComp.setLayoutData(data);
    layout = new GridLayout(2, false);
    layout.verticalSpacing = 10;
    restComp.setLayout(layout);

    // Hide welecome screen
    Label labelHideWelcomeScreen = new Label(restComp, SWT.RIGHT);
    labelHideWelcomeScreen.setText(
        Labels.getString("AdvancedSettingsDialog.hideWelcomeScreen")); // $NON-NLS-1$
    labelHideWelcomeScreen.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonHideWelcomeScreen = new Button(restComp, SWT.CHECK);
    buttonHideWelcomeScreen.setSelection(config.getBoolean(Config.HIDE_WELCOME_SCREEN));

    // batch size
    Label labelBatch = new Label(restComp, SWT.RIGHT);
    labelBatch.setText(Labels.getString("AdvancedSettingsDialog.batchSize")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelBatch.setLayoutData(data);

    textBatch = new Text(restComp, SWT.BORDER);
    textBatch.setText(config.getString(Config.LOAD_BATCH_SIZE));
    textBatch.setTextLimit(8);
    textBatch.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 50;
    textBatch.setLayoutData(data);

    // insert Nulls
    Label labelNulls = new Label(restComp, SWT.RIGHT);
    labelNulls.setText(Labels.getString("AdvancedSettingsDialog.insertNulls")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelNulls.setLayoutData(data);
    buttonNulls = new Button(restComp, SWT.CHECK);
    buttonNulls.setSelection(config.getBoolean(Config.INSERT_NULLS));

    // assignment rules
    Label labelRule = new Label(restComp, SWT.RIGHT);
    labelRule.setText(Labels.getString("AdvancedSettingsDialog.assignmentRule")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelRule.setLayoutData(data);

    textRule = new Text(restComp, SWT.BORDER);
    textRule.setTextLimit(18);
    data = new GridData();
    data.widthHint = 115;
    textRule.setLayoutData(data);
    textRule.setText(config.getString(Config.ASSIGNMENT_RULE));

    // endpoint
    Label labelEndpoint = new Label(restComp, SWT.RIGHT);
    labelEndpoint.setText(Labels.getString("AdvancedSettingsDialog.serverURL")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelEndpoint.setLayoutData(data);

    textEndpoint = new Text(restComp, SWT.BORDER);
    data = new GridData();
    data.widthHint = 250;
    textEndpoint.setLayoutData(data);
    String endpoint = config.getString(Config.ENDPOINT);
    if ("".equals(endpoint)) { // $NON-NLS-1$
      endpoint = defaultServer;
    }

    textEndpoint.setText(endpoint);

    // reset url on login
    Label labelResetUrl = new Label(restComp, SWT.RIGHT);
    labelResetUrl.setText(
        Labels.getString("AdvancedSettingsDialog.resetUrlOnLogin")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelResetUrl.setLayoutData(data);
    buttonResetUrl = new Button(restComp, SWT.CHECK);
    buttonResetUrl.setSelection(config.getBoolean(Config.RESET_URL_ON_LOGIN));

    // insert compression
    Label labelCompression = new Label(restComp, SWT.RIGHT);
    labelCompression.setText(Labels.getString("AdvancedSettingsDialog.compression")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelCompression.setLayoutData(data);
    buttonCompression = new Button(restComp, SWT.CHECK);
    buttonCompression.setSelection(config.getBoolean(Config.NO_COMPRESSION));

    // timeout size
    Label labelTimeout = new Label(restComp, SWT.RIGHT);
    labelTimeout.setText(Labels.getString("AdvancedSettingsDialog.timeout")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTimeout.setLayoutData(data);

    textTimeout = new Text(restComp, SWT.BORDER);
    textTimeout.setTextLimit(4);
    textTimeout.setText(config.getString(Config.TIMEOUT_SECS));
    textTimeout.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 30;
    textTimeout.setLayoutData(data);

    // extraction batch size
    Label labelQueryBatch = new Label(restComp, SWT.RIGHT);
    labelQueryBatch.setText(Labels.getString("ExtractionInputDialog.querySize")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelQueryBatch.setLayoutData(data);

    textQueryBatch = new Text(restComp, SWT.BORDER);
    textQueryBatch.setText(config.getString(Config.EXTRACT_REQUEST_SIZE));
    textQueryBatch.setTextLimit(4);
    textQueryBatch.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 30;
    textQueryBatch.setLayoutData(data);

    // enable/disable output of success file for extracts
    Label labelOutputExtractStatus = new Label(restComp, SWT.RIGHT);
    labelOutputExtractStatus.setText(
        Labels.getString("AdvancedSettingsDialog.outputExtractStatus")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOutputExtractStatus.setLayoutData(data);

    buttonOutputExtractStatus = new Button(restComp, SWT.CHECK);
    buttonOutputExtractStatus.setSelection(config.getBoolean(Config.ENABLE_EXTRACT_STATUS_OUTPUT));

    // utf-8 for loading
    Label labelReadUTF8 = new Label(restComp, SWT.RIGHT);
    labelReadUTF8.setText(Labels.getString("AdvancedSettingsDialog.readUTF8")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelReadUTF8.setLayoutData(data);

    buttonReadUtf8 = new Button(restComp, SWT.CHECK);
    buttonReadUtf8.setSelection(config.getBoolean(Config.READ_UTF8));

    // utf-8 for extraction
    Label labelWriteUTF8 = new Label(restComp, SWT.RIGHT);
    labelWriteUTF8.setText(Labels.getString("AdvancedSettingsDialog.writeUTF8")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelWriteUTF8.setLayoutData(data);

    buttonWriteUtf8 = new Button(restComp, SWT.CHECK);
    buttonWriteUtf8.setSelection(config.getBoolean(Config.WRITE_UTF8));

    // European Dates
    Label labelEuropeanDates = new Label(restComp, SWT.RIGHT);
    labelEuropeanDates.setText(
        Labels.getString("AdvancedSettingsDialog.useEuropeanDateFormat")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelEuropeanDates.setLayoutData(data);

    buttonEuroDates = new Button(restComp, SWT.CHECK);
    buttonEuroDates.setSelection(config.getBoolean(Config.EURO_DATES));

    // Field truncation
    Label labelTruncateFields = new Label(restComp, SWT.RIGHT);
    labelTruncateFields.setText(Labels.getString("AdvancedSettingsDialog.allowFieldTruncation"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTruncateFields.setLayoutData(data);

    buttonTruncateFields = new Button(restComp, SWT.CHECK);
    buttonTruncateFields.setSelection(config.getBoolean(Config.TRUNCATE_FIELDS));

    Label labelCsvCommand = new Label(restComp, SWT.RIGHT);
    labelCsvCommand.setText(Labels.getString("AdvancedSettingsDialog.useCommaAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelCsvCommand.setLayoutData(data);
    buttonCsvComma = new Button(restComp, SWT.CHECK);
    buttonCsvComma.setSelection(config.getBoolean(Config.CSV_DELIMETER_COMMA));

    Label labelTabCommand = new Label(restComp, SWT.RIGHT);
    labelTabCommand.setText(Labels.getString("AdvancedSettingsDialog.useTabAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTabCommand.setLayoutData(data);
    buttonCsvTab = new Button(restComp, SWT.CHECK);
    buttonCsvTab.setSelection(config.getBoolean(Config.CSV_DELIMETER_TAB));

    Label labelOtherCommand = new Label(restComp, SWT.RIGHT);
    labelOtherCommand.setText(Labels.getString("AdvancedSettingsDialog.useOtherAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOtherCommand.setLayoutData(data);
    buttonCsvOther = new Button(restComp, SWT.CHECK);
    buttonCsvOther.setSelection(config.getBoolean(Config.CSV_DELIMETER_OTHER));

    Label labelOtherDelimiterValue = new Label(restComp, SWT.RIGHT);
    labelOtherDelimiterValue.setText(
        Labels.getString("AdvancedSettingsDialog.csvOtherDelimiterValue"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOtherDelimiterValue.setLayoutData(data);
    textSplitterValue = new Text(restComp, SWT.BORDER);
    textSplitterValue.setText(config.getString(Config.CSV_DELIMETER_OTHER_VALUE));
    data = new GridData();
    data.widthHint = 25;
    textSplitterValue.setLayoutData(data);

    // Enable Bulk API Setting
    Label labelUseBulkApi = new Label(restComp, SWT.RIGHT);
    labelUseBulkApi.setText(Labels.getString("AdvancedSettingsDialog.useBulkApi")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelUseBulkApi.setLayoutData(data);

    boolean useBulkAPI = config.getBoolean(Config.BULK_API_ENABLED);
    buttonUseBulkApi = new Button(restComp, SWT.CHECK);
    buttonUseBulkApi.setSelection(useBulkAPI);
    buttonUseBulkApi.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            boolean enabled = buttonUseBulkApi.getSelection();
            // update batch size when this setting changes
            int newDefaultBatchSize = controller.getConfig().getDefaultBatchSize(enabled);
            logger.info("Setting batch size to " + newDefaultBatchSize);
            textBatch.setText(String.valueOf(newDefaultBatchSize));
            // make sure the appropriate check boxes are enabled or disabled
            initBulkApiSetting(enabled);
          }
        });

    // Bulk API serial concurrency mode setting
    Label labelBulkApiSerialMode = new Label(restComp, SWT.RIGHT);
    labelBulkApiSerialMode.setText(
        Labels.getString("AdvancedSettingsDialog.bulkApiSerialMode")); // $NON-NLS-1$
    labelBulkApiSerialMode.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonBulkApiSerialMode = new Button(restComp, SWT.CHECK);
    buttonBulkApiSerialMode.setSelection(config.getBoolean(Config.BULK_API_SERIAL_MODE));
    buttonBulkApiSerialMode.setEnabled(useBulkAPI);

    // Bulk API serial concurrency mode setting
    Label labelBulkApiZipContent = new Label(restComp, SWT.RIGHT);
    labelBulkApiZipContent.setText(
        Labels.getString("AdvancedSettingsDialog.bulkApiZipContent")); // $NON-NLS-1$
    labelBulkApiZipContent.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonBulkApiZipContent = new Button(restComp, SWT.CHECK);
    buttonBulkApiZipContent.setSelection(config.getBoolean(Config.BULK_API_SERIAL_MODE));
    buttonBulkApiZipContent.setEnabled(useBulkAPI);
    // timezone
    textTimezone =
        createTextInput(
            restComp,
            "AdvancedSettingsDialog.timezone",
            Config.TIMEZONE,
            TimeZone.getDefault().getID(),
            200);

    // proxy Host
    Label labelProxyHost = new Label(restComp, SWT.RIGHT);
    labelProxyHost.setText(Labels.getString("AdvancedSettingsDialog.proxyHost")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyHost.setLayoutData(data);

    textProxyHost = new Text(restComp, SWT.BORDER);
    textProxyHost.setText(config.getString(Config.PROXY_HOST));
    data = new GridData();
    data.widthHint = 250;
    textProxyHost.setLayoutData(data);

    // Proxy Port
    Label labelProxyPort = new Label(restComp, SWT.RIGHT);
    labelProxyPort.setText(Labels.getString("AdvancedSettingsDialog.proxyPort")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyPort.setLayoutData(data);

    textProxyPort = new Text(restComp, SWT.BORDER);
    textProxyPort.setText(config.getString(Config.PROXY_PORT));
    textProxyPort.setTextLimit(4);
    textProxyPort.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 25;
    textProxyPort.setLayoutData(data);

    // Proxy Username
    Label labelProxyUsername = new Label(restComp, SWT.RIGHT);
    labelProxyUsername.setText(Labels.getString("AdvancedSettingsDialog.proxyUser")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyUsername.setLayoutData(data);

    textProxyUsername = new Text(restComp, SWT.BORDER);
    textProxyUsername.setText(config.getString(Config.PROXY_USERNAME));
    data = new GridData();
    data.widthHint = 120;
    textProxyUsername.setLayoutData(data);

    // Proxy Password
    Label labelProxyPassword = new Label(restComp, SWT.RIGHT);
    labelProxyPassword.setText(
        Labels.getString("AdvancedSettingsDialog.proxyPassword")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyPassword.setLayoutData(data);

    textProxyPassword = new Text(restComp, SWT.BORDER | SWT.PASSWORD);
    textProxyPassword.setText(config.getString(Config.PROXY_PASSWORD));
    data = new GridData();
    data.widthHint = 120;
    textProxyPassword.setLayoutData(data);

    // proxy NTLM domain
    Label labelProxyNtlmDomain = new Label(restComp, SWT.RIGHT);
    labelProxyNtlmDomain.setText(
        Labels.getString("AdvancedSettingsDialog.proxyNtlmDomain")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyNtlmDomain.setLayoutData(data);

    textProxyNtlmDomain = new Text(restComp, SWT.BORDER);
    textProxyNtlmDomain.setText(config.getString(Config.PROXY_NTLM_DOMAIN));
    data = new GridData();
    data.widthHint = 250;
    textProxyNtlmDomain.setLayoutData(data);

    //////////////////////////////////////////////////
    // Row to start At

    Label blankAgain = new Label(restComp, SWT.NONE);
    data = new GridData();
    data.horizontalSpan = 2;
    blankAgain.setLayoutData(data);

    // Row to start AT
    Label labelLastRow = new Label(restComp, SWT.NONE);

    String lastBatch = controller.getConfig().getString(LastRun.LAST_LOAD_BATCH_ROW);
    if (lastBatch.equals("")) { // $NON-NLS-1$
      lastBatch = "0"; // $NON-NLS-1$
    }

    labelLastRow.setText(
        Labels.getFormattedString("AdvancedSettingsDialog.lastBatch", lastBatch)); // $NON-NLS-1$
    data = new GridData();
    data.horizontalSpan = 2;
    labelLastRow.setLayoutData(data);

    Label labelRowToStart = new Label(restComp, SWT.RIGHT);
    labelRowToStart.setText(Labels.getString("AdvancedSettingsDialog.startRow")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelRowToStart.setLayoutData(data);

    textRowToStart = new Text(restComp, SWT.BORDER);
    textRowToStart.setText(config.getString(Config.LOAD_ROW_TO_START_AT));
    data = new GridData();
    data.widthHint = 75;
    textRowToStart.setLayoutData(data);
    textRowToStart.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });

    // now that we've created all the buttons, make sure that buttons dependent on the bulk api
    // setting are enabled or disabled appropriately
    initBulkApiSetting(useBulkAPI);

    // the bottow separator
    Label labelSeparatorBottom = new Label(restComp, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    labelSeparatorBottom.setLayoutData(data);

    // ok cancel buttons
    new Label(restComp, SWT.NONE);

    // END MIDDLE COMPONENT

    // START BOTTOM COMPONENT

    Composite buttonComp = new Composite(restComp, SWT.NONE);
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    buttonComp.setLayoutData(data);
    buttonComp.setLayout(new GridLayout(2, false));

    // Create the OK button and add a handler
    // so that pressing it will set input
    // to the entered value
    Button ok = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
    ok.setText(Labels.getString("UI.ok")); // $NON-NLS-1$
    ok.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            Config config = controller.getConfig();

            // set the configValues
            config.setValue(Config.HIDE_WELCOME_SCREEN, buttonHideWelcomeScreen.getSelection());
            config.setValue(Config.INSERT_NULLS, buttonNulls.getSelection());
            config.setValue(Config.LOAD_BATCH_SIZE, textBatch.getText());
            if (!buttonCsvComma.getSelection()
                && !buttonCsvTab.getSelection()
                && (!buttonCsvOther.getSelection()
                    || textSplitterValue.getText() == null
                    || textSplitterValue.getText().length() == 0)) {
              return;
            }
            config.setValue(Config.CSV_DELIMETER_OTHER_VALUE, textSplitterValue.getText());
            config.setValue(Config.CSV_DELIMETER_COMMA, buttonCsvComma.getSelection());
            config.setValue(Config.CSV_DELIMETER_TAB, buttonCsvTab.getSelection());
            config.setValue(Config.CSV_DELIMETER_OTHER, buttonCsvOther.getSelection());

            config.setValue(Config.EXTRACT_REQUEST_SIZE, textQueryBatch.getText());
            config.setValue(Config.ENDPOINT, textEndpoint.getText());
            config.setValue(Config.ASSIGNMENT_RULE, textRule.getText());
            config.setValue(Config.LOAD_ROW_TO_START_AT, textRowToStart.getText());
            config.setValue(Config.RESET_URL_ON_LOGIN, buttonResetUrl.getSelection());
            config.setValue(Config.NO_COMPRESSION, buttonCompression.getSelection());
            config.setValue(Config.TRUNCATE_FIELDS, buttonTruncateFields.getSelection());
            config.setValue(Config.TIMEOUT_SECS, textTimeout.getText());
            config.setValue(
                Config.ENABLE_EXTRACT_STATUS_OUTPUT, buttonOutputExtractStatus.getSelection());
            config.setValue(Config.READ_UTF8, buttonReadUtf8.getSelection());
            config.setValue(Config.WRITE_UTF8, buttonWriteUtf8.getSelection());
            config.setValue(Config.EURO_DATES, buttonEuroDates.getSelection());
            config.setValue(Config.TIMEZONE, textTimezone.getText());
            config.setValue(Config.PROXY_HOST, textProxyHost.getText());
            config.setValue(Config.PROXY_PASSWORD, textProxyPassword.getText());
            config.setValue(Config.PROXY_PORT, textProxyPort.getText());
            config.setValue(Config.PROXY_USERNAME, textProxyUsername.getText());
            config.setValue(Config.PROXY_NTLM_DOMAIN, textProxyNtlmDomain.getText());
            config.setValue(Config.BULK_API_ENABLED, buttonUseBulkApi.getSelection());
            config.setValue(Config.BULK_API_SERIAL_MODE, buttonBulkApiSerialMode.getSelection());
            config.setValue(Config.BULK_API_ZIP_CONTENT, buttonBulkApiZipContent.getSelection());

            controller.saveConfig();
            controller.logout();

            input = Labels.getString("UI.ok"); // $NON-NLS-1$
            shell.close();
          }
        });
    data = new GridData();
    data.widthHint = 75;
    ok.setLayoutData(data);

    // Create the cancel button and add a handler
    // so that pressing it will set input to null
    Button cancel = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
    cancel.setText(Labels.getString("UI.cancel")); // $NON-NLS-1$
    cancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            input = null;
            shell.close();
          }
        });

    // END BOTTOM COMPONENT

    data = new GridData();
    data.widthHint = 75;
    cancel.setLayoutData(data);

    // Set the OK button as the default, so
    // user can type input and press Enter
    // to dismiss
    shell.setDefaultButton(ok);

    // Set the child as the scrolled content of the ScrolledComposite
    sc.setContent(container);

    // Set the minimum size
    sc.setMinSize(768, 1024);

    // Expand both horizontally and vertically
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
  }
 private void createLabel(Composite parent, String labelKey) {
   Label l = new Label(parent, SWT.RIGHT);
   l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
   l.setText(Labels.getString(labelKey));
 }
예제 #19
0
 @Test
 public void testSimpleLabel() {
   assertEquals("&Scan", Labels.getLabel("menu.scan"));
 }
예제 #20
0
  public HelpUIAction(Controller controller) {
    super(Labels.getString("HelpUIAction.menuText"), null); // $NON-NLS-1$
    setToolTipText(Labels.getString("HelpUIAction.tooltip")); // $NON-NLS-1$

    this.controller = controller;
  }
예제 #21
0
  ColonyScreen(
      final Empire empire, final Colony colony, final int category, final Building building) {

    // Screen XXX
    this.setBounds(0, 0, resolutionX, resolutionY);
    this.add(GraphicFU.bgPanel, 0, 0);
    this.addMouseListener(getBack(empire, colony, category, building));
    this.topNavi = new TopNavi(empire);
    this.add(this.topNavi, 1, 0);

    JPanel colonyPanel = new JPanel();
    colonyPanel.setBounds(
        0, TopNavi.height, resolutionX, resolutionY - TopNavi.height - bottomPanelHeight);
    colonyPanel.setBorder(GUIBorder);
    colonyPanel.setLayout(new GridLayout(0, 3));
    colonyPanel.setOpaque(false);

    JPanel sliderPanel = new JPanel();
    sliderPanel.setOpaque(false);
    sliderPanel.setVisible(true);
    sliderPanel.setLayout(new GridLayout(0, 1));

    double maxAllocation = 0;

    for (int i = 0; i < 7; i++) {
      allocationSlider[i] = new AllocationSlider(allocationBarColor[i]);
      allocationSlider[i].setOpaque(false);
      allocationSlider[i].setVisible(true);
      allocationSlider[i].setLayout(new GridLayout());
      //	allocationSlider[i].setLayout(null);
      allocationSlider[i].addMouseListener(getSliderListener(empire, colony, category, building));
      allocationSlider[i].allocation = colony.allocation[i];
      allocationSlider[i].add(
          Labels.string((int) (allocationSlider[i].allocation * 1000) / 10.0 + "%"));
      sliderPanel.add(allocationSlider[i]);

      //	maxAllocation = Math.max(maxAllocation, allocationSlider[i].allocation);

    }

    allocationSlider[0].add(Labels.labourForceFood(colony));
    allocationSlider[1].add(Labels.labourForceResources(colony));
    allocationSlider[2].add(Labels.labourForceGoods(colony));
    allocationSlider[3].add(Labels.labourForceResearch(colony));
    allocationSlider[4].add(Labels.labourForceServices(colony));
    allocationSlider[5].add(Labels.labourForcePublicServices(colony));
    allocationSlider[6].add(
        Labels.label(
            (int) (colony.goods.stock * 10) / 10.0 + " " + language.abbrMegatons,
            GraphicFU.goodsIcon));

    // int distance = (int)((resolutionX -32) / 3 / (maxAllocation * 40.0 + 0.2));
    // System.out.print("Distance : " + distance);

    // for (int i = 0; i <7 ; i++){
    //		int pops = (int) (allocationSlider[i].allocation * 40.0 + 0.2);
    //		for (int j = 0; j < pops; j++ ){
    //	JLabel popIcon = Labels.icon(Species.rachni.speciesIcon);
    //			JLabel popIcon = Labels.icon(Species.humans.speciesIcon);
    //			popIcon.setToolTipText("Nr." + j);

    //	if (distance < 16){
    //		if ((j & 1) == 0){
    //			popIcon.setBounds(j * distance, 25, 40, 40);
    //			}
    //		else{
    //			popIcon.setBounds(j * distance, 0, 40, 40);
    //			}
    //		}
    //	else {
    //				popIcon.setBounds(j * distance, 10, 40, 40);
    //		}

    //		allocationSlider[i].add(popIcon);
    //		}
    //	}

    colonyPanel.add(sliderPanel);

    // LABELS XXX
    if (category >= 0 && category <= 7 && colony.getAvailableBuildings(category).size() > 0) {
      JScrollPane sp = ScrollPanes.buildingsAvailable(empire, colony, category, null);
      sp.addMouseListener(getBack(empire, colony, category, building));
      colonyPanel.add(sp);
    } else if (building != null) {
      JScrollPane sp = ScrollPanes.buildingDescription(empire, building);
      sp.addMouseListener(getBack(empire, colony, category, building));
      colonyPanel.add(sp);
    } else {
      JPanel dataPanel = new JPanel();
      dataPanel.setOpaque(false);
      dataPanel.setVisible(true);
      dataPanel.setLayout(new GridLayout(0, 1));

      for (int i = 0; i < 7; i++) {
        allocationPanel[i] = new JPanel();
        allocationPanel[i].setOpaque(false);
        allocationPanel[i].setLayout(new GridLayout());
        allocationPanel[i].addMouseListener(getBack(empire, colony, category, building));
        dataPanel.add(allocationPanel[i]);
      }

      //	allocationPanel[0].add(Labels.labourForceFood(colony),c);
      //	allocationPanel[1].add(Labels.labourForceResources(colony),c);
      //	allocationPanel[2].add(Labels.labourForceGoods(colony),c);
      //	allocationPanel[3].add(Labels.labourForceResearch(colony),c);
      //	allocationPanel[4].add(Labels.labourForceServices(colony),c);
      //	allocationPanel[5].add(Labels.labourForcePublicServices(colony),c);
      //	allocationPanel[6].add(Labels.labourForce(colony),c);

      //	allocationPanel[0].add(Labels.string((int)(colony.bProductivityFood * 1000) / 10.0 + "
      // %"),c);
      //	allocationPanel[1].add(Labels.string((int)(colony.bProductivityResources * 1000) / 10.0 + "
      // %"),c);
      //	allocationPanel[2].add(Labels.string((int)(colony.bProductivityGoods * 1000) / 10.0 + "
      // %"),c);
      //	allocationPanel[3].add(Labels.string((int)(colony.bProductivityResearch * 1000) / 10.0 + "
      // %"),c);
      //	allocationPanel[4].add(Labels.string((int)(colony.bWorkersServices	 * 1000) / 10.0 + "
      // %"),c);
      //	allocationPanel[5].add(Labels.string((int)(colony.bWorkersPublic * 1000) / 10.0 + " %"),c);

      allocationPanel[0].add(Labels.commodity(colony.commodity[0]));
      allocationPanel[1].add(Labels.commodity(colony.resources));
      allocationPanel[2].add(Labels.commodity(colony.goods));
      allocationPanel[3].add(
          Labels.label(
              (int) (colony.research.output * 10) / 10.0 + " " + language.abbrResearchUnits,
              GraphicFU.researchIcon));
      allocationPanel[4].add(
          Labels.label(
              (int) (colony.services.output * 10) / 10.0 + " " + language.abbrBillionCredits,
              GraphicFU.servicesIcon));
      allocationPanel[5].add(Labels.commodity(colony.money));
      allocationPanel[6].add(
          Labels.string((int) (colony.getGDP() * 10) / 10.0 + " " + language.abbrBillionCredits));

      if (colony.getBalanceFood() > 0) {
        allocationPanel[0].add(
            Labels.label(
                "+" + (int) (colony.getBalanceFood() * 10) / 10.0 + " " + language.abbrMegatons,
                GraphicFU.arrowUp2));
      } else if (colony.getBalanceFood() < 0) {
        allocationPanel[0].add(
            Labels.label(
                (int) (colony.getBalanceFood() * 10) / 10.0 + " " + language.abbrMegatons,
                GraphicFU.arrowDown2));
      } else {
        allocationPanel[0].add(
            Labels.label(
                (int) (colony.getBalanceFood() * 10) / 10.0 + " " + language.abbrMegatons,
                GraphicFU.arrowNeutral));
      }

      if (colony.getBalanceResources() > 0) {
        allocationPanel[1].add(
            Labels.label(
                "+"
                    + (int) (colony.getBalanceResources() * 10) / 10.0
                    + " "
                    + language.abbrMegatons,
                GraphicFU.arrowUp2));
      } else if (colony.getBalanceResources() < 0) {
        allocationPanel[1].add(
            Labels.label(
                (int) (colony.getBalanceResources() * 10) / 10.0 + " " + language.abbrMegatons,
                GraphicFU.arrowDown2));
      } else {
        allocationPanel[1].add(
            Labels.label(
                (int) (colony.getBalanceResources() * 10) / 10.0 + " " + language.abbrMegatons,
                GraphicFU.arrowNeutral));
      }

      if (colony.getBalanceGoods() > 0) {
        allocationPanel[2].add(
            Labels.label(
                "+" + (int) (colony.getBalanceGoods() * 10) / 10.0 + " " + language.abbrMegatons,
                GraphicFU.arrowUp2));
      } else if (colony.getBalanceGoods() < 0) {
        allocationPanel[2].add(
            Labels.label(
                (int) (colony.getBalanceGoods() * 10) / 10.0 + " " + language.abbrMegatons,
                GraphicFU.arrowDown2));
      } else {
        allocationPanel[2].add(
            Labels.label(
                (int) (colony.getBalanceGoods() * 10) / 10.0 + " " + language.abbrMegatons,
                GraphicFU.arrowNeutral));
      }

      allocationPanel[3].add(
          Labels.label(
              (int) (colony.innovation.output * 10) / 10.0 + " " + language.abbrResearchUnits,
              GraphicFU.innovationIcon));
      allocationPanel[4].add(
          Labels.label(
              (int) (colony.incomeAverage * 10000) / 10.0 + " " + "Cr./p", GraphicFU.moneyIcon));

      if (colony.getTax() - colony.getPublicExpenses() > 0) {
        allocationPanel[5].add(
            Labels.label(
                "+"
                    + (int) ((colony.getTax() - colony.getPublicExpenses()) * 10) / 10.0
                    + " "
                    + language.abbrBillionCredits,
                GraphicFU.arrowUp2));
      } else if (colony.getTax() - colony.getPublicExpenses() < 0) {
        allocationPanel[5].add(
            Labels.label(
                (int) ((colony.getTax() - colony.getPublicExpenses()) * 10) / 10.0
                    + " "
                    + language.abbrBillionCredits,
                GraphicFU.arrowDown2));
      } else {
        allocationPanel[5].add(
            Labels.label(
                (int) ((colony.getTax() - colony.getPublicExpenses()) * 10) / 10.0
                    + " "
                    + language.abbrBillionCredits,
                GraphicFU.arrowUp2));
      }

      allocationPanel[6].add(Labels.string((int) (colony.administration * 1000) / 10.0 + " %"));

      //	allocationPanel[0].add(Labels.string((int)(colony.getIncomeFood() * 10) / 10.0 + " " +
      // language.abbrBillionCredits),c);
      //	allocationPanel[1].add(Labels.string((int)(colony.getIncomeResources() * 10) / 10.0 + " " +
      // language.abbrBillionCredits),c);
      //	allocationPanel[2].add(Labels.string((int)(colony.getIncomeGoods() * 10) / 10.0 + " " +
      // language.abbrBillionCredits),c);
      //	allocationPanel[3].add(Labels.string((int)(colony.getIncomeResearch() * 10) / 10.0 + " " +
      // language.abbrBillionCredits),c);
      //	allocationPanel[4].add(Labels.string((int)(colony.getIncomeServices() * 10) / 10.0 + " " +
      // language.abbrBillionCredits),c);
      //	allocationPanel[5].add(Labels.string((int)(colony.getIncomePublicServices() * 10) / 10.0 +
      // " "  + language.abbrBillionCredits),c);
      //	allocationPanel[6].add(Labels.string((int)(colony.getGDP() * 10) / 10.0 + " " +
      // language.abbrBillionCredits),c);

      colonyPanel.add(dataPanel);
    }

    // BUILDINGS XXX

    JPanel buildingPanel = new JPanel();
    buildingPanel.setOpaque(false);
    buildingPanel.setVisible(true);
    buildingPanel.setLayout(new GridLayout(0, 1));

    JLabel buildOption[] = new JLabel[7];

    for (int i = 0; i < 7; i++) {
      buildingsPanel[i] = new JPanel();
      buildingsPanel[i].setOpaque(false);
      buildingsPanel[i].setLayout(new FlowLayout());
      buildingsPanel[i].addMouseListener(getBack(empire, colony, category, building));

      buildingsScroll[i] =
          new JScrollPane(
              buildingsPanel[i],
              ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
              ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      buildingsScroll[i].setOpaque(false);
      buildingsScroll[i].getViewport().setOpaque(false);
      buildingsScroll[i].setWheelScrollingEnabled(true);
      buildingsScroll[i].getHorizontalScrollBar().setPreferredSize(new Dimension(0, 5));

      if (colony.getAvailableBuildings(i).size() > 0) {
        buildOption[i] = Labels.icon(GraphicFU.addIcon);
        buildOption[i].setBorder(new EmptyBorder(0, 0, 10, 0));
        buildOption[i].addMouseListener(getBuildOptionsML(empire, colony, i));
        buildingsPanel[i].add(buildOption[i]);
      }

      buildingPanel.add(buildingsScroll[i]);
    }

    for (int i = 0; i < 7; i++) {
      for (Building buildingX : colony.buildings) {
        if (buildingX.buildingType.classification == i) {
          BuildingButton bb = new BuildingButton(empire, buildingX);
          bb.setBorder(new EmptyBorder(0, 0, 15, 0));
          buildingsPanel[i].add(bb);
        }
      }
    }

    colonyPanel.add(buildingPanel);

    this.add(colonyPanel, 1, 0);

    // LABEL PANEL XXX

    this.add(new AODescriptionPanel(empire), 1, 0);

    this.topNavi.turnButton.addMouseListener(
        new MouseListener() {

          public void mouseClicked(MouseEvent e) {}

          public void mousePressed(MouseEvent e) {
            FUMain.mainFrame.openColonyScreen(empire, colony, category, building);
          }

          @Override
          public void mouseEntered(MouseEvent e) {}

          @Override
          public void mouseExited(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}
        });
  }
예제 #22
0
 // Methods
 public BusLaneAdderWindow(
     String title,
     Network network,
     File imageFile,
     double[] upLeft,
     double[] downRight,
     String finalNetworkFile,
     CoordinateTransformation coordinateTransformation)
     throws IOException {
   setTitle(title);
   this.finalNetworkFile = finalNetworkFile;
   this.network = network;
   NetworkTwoNodesPainter networkPainter = new NetworkTwoNodesPainter(network, Color.BLACK);
   setDefaultCloseOperation(EXIT_ON_CLOSE);
   this.setLocation(0, 0);
   this.setLayout(new BorderLayout());
   layersPanels.put(
       PanelIds.ONE,
       new BusLaneAdderPanel(
           this, networkPainter, imageFile, upLeft, downRight, coordinateTransformation));
   this.add(layersPanels.get(PanelIds.ONE), BorderLayout.CENTER);
   option = Options.ZOOM;
   JPanel toolsPanel = new JPanel();
   toolsPanel.setLayout(new GridBagLayout());
   for (Tool tool : Tool.values()) {
     JButton toolButton = new JButton(tool.caption);
     toolButton.setActionCommand(tool.name());
     toolButton.addActionListener(this);
     GridBagConstraints gbc = new GridBagConstraints();
     gbc.gridx = tool.gx;
     gbc.gridy = tool.gy;
     gbc.gridwidth = tool.sx;
     gbc.gridheight = tool.sy;
     toolsPanel.add(toolButton, gbc);
   }
   this.add(toolsPanel, BorderLayout.NORTH);
   JPanel buttonsPanel = new JPanel();
   buttonsPanel.setLayout(new GridLayout(Options.values().length, 1));
   for (Options option : Options.values()) {
     JButton optionButton = new JButton(option.getCaption());
     optionButton.setActionCommand(option.getCaption());
     optionButton.addActionListener(this);
     buttonsPanel.add(optionButton);
   }
   this.add(buttonsPanel, BorderLayout.EAST);
   JPanel infoPanel = new JPanel();
   infoPanel.setLayout(new BorderLayout());
   readyButton = new JButton("Ready to exit");
   readyButton.addActionListener(this);
   readyButton.setActionCommand(READY_TO_EXIT);
   infoPanel.add(readyButton, BorderLayout.WEST);
   JPanel labelsPanel = new JPanel();
   labelsPanel.setLayout(new GridLayout(1, Labels.values().length));
   labelsPanel.setBorder(new TitledBorder("Information"));
   labels = new JTextField[Labels.values().length];
   for (int i = 0; i < Labels.values().length; i++) {
     labels[i] = new JTextField("");
     labels[i].setEditable(false);
     labels[i].setBackground(null);
     labels[i].setBorder(null);
     labelsPanel.add(labels[i]);
   }
   infoPanel.add(labelsPanel, BorderLayout.CENTER);
   JPanel coordsPanel = new JPanel();
   coordsPanel.setLayout(new GridLayout(1, 2));
   coordsPanel.setBorder(new TitledBorder("Coordinates"));
   coordsPanel.add(lblCoords[0]);
   coordsPanel.add(lblCoords[1]);
   infoPanel.add(coordsPanel, BorderLayout.EAST);
   this.add(infoPanel, BorderLayout.SOUTH);
   super.setSize(
       Toolkit.getDefaultToolkit().getScreenSize().width,
       Toolkit.getDefaultToolkit().getScreenSize().height);
 }